6#include "../result.hpp"
17 class DenseUnionBuilder;
23 enum class AngleTag : uint8_t {
39 std::memset(
reinterpret_cast<void*
>(
this), 0,
sizeof(AngleData));
44 void swap(AngleData& other)
noexcept {
46 char temp[
sizeof(AngleData)];
47 void* otherbytes =
reinterpret_cast<void*
>(&other);
48 void* thisbytes =
reinterpret_cast<void*
>(
this);
49 std::memcpy(temp, thisbytes,
sizeof(AngleData));
50 std::memcpy(thisbytes, otherbytes,
sizeof(AngleData));
51 std::memcpy(otherbytes, temp,
sizeof(AngleData));
58 Angle() : _tag(detail::AngleTag::None) {}
62 const void* otherbytes =
reinterpret_cast<const void*
>(&other._data);
63 void* thisbytes =
reinterpret_cast<void*
>(&this->_data);
64 std::memcpy(thisbytes, otherbytes,
sizeof(detail::AngleData));
67 Angle& operator=(
const Angle& other)
noexcept {
77 Angle& operator=(Angle&& other)
noexcept {
82 void swap(Angle& other)
noexcept {
83 std::swap(this->_tag, other._tag);
84 this->_data.swap(other._data);
90 self._tag = detail::AngleTag::Radians;
91 new (&self._data.radians)
float(std::move(
radians));
98 self._tag = detail::AngleTag::Degrees;
99 new (&self._data.degrees)
float(std::move(
degrees));
105 if (_tag == detail::AngleTag::Radians) {
106 return &_data.radians;
114 if (_tag == detail::AngleTag::Degrees) {
115 return &_data.degrees;
122 const detail::AngleData& get_union_data()
const {
127 detail::AngleTag get_union_tag()
const {
132 detail::AngleTag _tag;
133 detail::AngleData _data;
138 template <
typename T>
143 struct Loggable<datatypes::Angle> {
144 static constexpr const char Name[] =
"rerun.datatypes.Angle";
147 static const std::shared_ptr<arrow::DataType>& arrow_datatype();
150 static Result<std::shared_ptr<arrow::Array>> to_arrow(
151 const datatypes::Angle* instances,
size_t num_instances
156 arrow::DenseUnionBuilder* builder,
const datatypes::Angle* elements,
size_t num_elements
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:88
All built-in datatypes. See Types in the Rerun manual.
Definition rerun.hpp:78
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:21
Datatype: Angle in either radians or degrees.
Definition angle.hpp:57
Angle(const Angle &other)
Copy constructor.
Definition angle.hpp:61
static Angle radians(float radians)
Angle in radians. One turn is equal to 2π (or τ) radians.
Definition angle.hpp:88
static Angle degrees(float degrees)
Angle in degrees. One turn is equal to 360 degrees.
Definition angle.hpp:96
const float * get_radians() const
Return a pointer to radians if the union is in that state, otherwise nullptr.
Definition angle.hpp:104
const float * get_degrees() const
Return a pointer to degrees if the union is in that state, otherwise nullptr.
Definition angle.hpp:113