6#include "../result.hpp"
17 class DenseUnionBuilder;
23 enum class AngleTag : uint8_t {
37 std::memset(
reinterpret_cast<void*
>(
this), 0,
sizeof(AngleData));
42 void swap(AngleData& other)
noexcept {
44 char temp[
sizeof(AngleData)];
45 void* otherbytes =
reinterpret_cast<void*
>(&other);
46 void* thisbytes =
reinterpret_cast<void*
>(
this);
47 std::memcpy(temp, thisbytes,
sizeof(AngleData));
48 std::memcpy(thisbytes, otherbytes,
sizeof(AngleData));
49 std::memcpy(otherbytes, temp,
sizeof(AngleData));
56 Angle() : _tag(detail::AngleTag::None) {}
60 const void* otherbytes =
reinterpret_cast<const void*
>(&other._data);
61 void* thisbytes =
reinterpret_cast<void*
>(&this->_data);
62 std::memcpy(thisbytes, otherbytes,
sizeof(detail::AngleData));
65 Angle& operator=(
const Angle& other)
noexcept {
75 Angle& operator=(Angle&& other)
noexcept {
80 void swap(Angle& other)
noexcept {
81 std::swap(this->_tag, other._tag);
82 this->_data.swap(other._data);
85 static Angle radians(
float radians) {
87 self._tag = detail::AngleTag::Radians;
88 new (&self._data.radians)
float(std::move(radians));
92 static Angle degrees(
float degrees) {
94 self._tag = detail::AngleTag::Degrees;
95 new (&self._data.degrees)
float(std::move(degrees));
101 if (_tag == detail::AngleTag::Radians) {
102 return &_data.radians;
110 if (_tag == detail::AngleTag::Degrees) {
111 return &_data.degrees;
118 const detail::AngleData& get_union_data()
const {
123 detail::AngleTag get_union_tag()
const {
128 detail::AngleTag _tag;
129 detail::AngleData _data;
134 template <
typename T>
139 struct Loggable<datatypes::Angle> {
140 static constexpr const char Name[] =
"rerun.datatypes.Angle";
143 static const std::shared_ptr<arrow::DataType>& arrow_datatype();
147 arrow::DenseUnionBuilder* builder,
const datatypes::Angle* elements,
size_t num_elements
151 static Result<std::shared_ptr<arrow::Array>> to_arrow(
152 const datatypes::Angle* instances,
size_t num_instances
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:87
All built-in datatypes. See Types in the Rerun manual.
Definition rerun.hpp:72
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:20
Datatype: Angle in either radians or degrees.
Definition angle.hpp:55
Angle(const Angle &other)
Copy constructor.
Definition angle.hpp:59
const float * get_radians() const
Return a pointer to radians if the union is in that state, otherwise nullptr.
Definition angle.hpp:100
const float * get_degrees() const
Return a pointer to degrees if the union is in that state, otherwise nullptr.
Definition angle.hpp:109