6#include "../component_descriptor.hpp"
7#include "../result.hpp"
19 class DenseUnionBuilder;
25 enum class TimeRangeBoundaryTag : uint8_t {
34 union TimeRangeBoundaryData {
41 TimeRangeBoundaryData() {
42 std::memset(
reinterpret_cast<void*
>(
this), 0,
sizeof(TimeRangeBoundaryData));
45 ~TimeRangeBoundaryData() {}
47 void swap(TimeRangeBoundaryData& other)
noexcept {
49 char temp[
sizeof(TimeRangeBoundaryData)];
50 void* otherbytes =
reinterpret_cast<void*
>(&other);
51 void* thisbytes =
reinterpret_cast<void*
>(
this);
52 std::memcpy(temp, thisbytes,
sizeof(TimeRangeBoundaryData));
53 std::memcpy(thisbytes, otherbytes,
sizeof(TimeRangeBoundaryData));
54 std::memcpy(otherbytes, temp,
sizeof(TimeRangeBoundaryData));
65 const void* otherbytes =
reinterpret_cast<const void*
>(&other._data);
66 void* thisbytes =
reinterpret_cast<void*
>(&this->_data);
67 std::memcpy(thisbytes, otherbytes,
sizeof(detail::TimeRangeBoundaryData));
76 TimeRangeBoundary(TimeRangeBoundary&& other) noexcept : TimeRangeBoundary() {
80 TimeRangeBoundary& operator=(TimeRangeBoundary&& other)
noexcept {
85 void swap(TimeRangeBoundary& other)
noexcept {
86 std::swap(this->_tag, other._tag);
87 this->_data.swap(other._data);
93 self._tag = detail::TimeRangeBoundaryTag::CursorRelative;
101 self._tag = detail::TimeRangeBoundaryTag::Absolute;
109 self._tag = detail::TimeRangeBoundaryTag::Infinite;
115 if (_tag == detail::TimeRangeBoundaryTag::CursorRelative) {
116 return &_data.cursor_relative;
124 if (_tag == detail::TimeRangeBoundaryTag::Absolute) {
125 return &_data.absolute;
133 return _tag == detail::TimeRangeBoundaryTag::Infinite;
137 const detail::TimeRangeBoundaryData& get_union_data()
const {
142 detail::TimeRangeBoundaryTag get_union_tag()
const {
147 detail::TimeRangeBoundaryTag _tag;
148 detail::TimeRangeBoundaryData _data;
153 template <
typename T>
158 struct Loggable<datatypes::TimeRangeBoundary> {
159 static constexpr ComponentDescriptor Descriptor =
"rerun.datatypes.TimeRangeBoundary";
162 static const std::shared_ptr<arrow::DataType>& arrow_datatype();
165 static Result<std::shared_ptr<arrow::Array>> to_arrow(
166 const datatypes::TimeRangeBoundary* instances,
size_t num_instances
171 arrow::DenseUnionBuilder* builder,
const datatypes::TimeRangeBoundary* elements,
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:96
All built-in datatypes. See Types in the Rerun manual.
Definition rerun.hpp:82
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Datatype: A 64-bit number describing either nanoseconds OR sequence numbers.
Definition time_int.hpp:25
Datatype: Left or right boundary of a time range.
Definition time_range_boundary.hpp:60
static TimeRangeBoundary cursor_relative(rerun::datatypes::TimeInt cursor_relative)
Boundary is a value relative to the time cursor.
Definition time_range_boundary.hpp:91
const rerun::datatypes::TimeInt * get_absolute() const
Return a pointer to absolute if the union is in that state, otherwise nullptr.
Definition time_range_boundary.hpp:123
TimeRangeBoundary(const TimeRangeBoundary &other)
Copy constructor.
Definition time_range_boundary.hpp:64
static TimeRangeBoundary infinite()
The boundary extends to infinity.
Definition time_range_boundary.hpp:107
const rerun::datatypes::TimeInt * get_cursor_relative() const
Return a pointer to cursor_relative if the union is in that state, otherwise nullptr.
Definition time_range_boundary.hpp:114
static TimeRangeBoundary absolute(rerun::datatypes::TimeInt absolute)
Boundary is an absolute value.
Definition time_range_boundary.hpp:99
bool is_infinite() const
Returns true if the union is in the infinite state.
Definition time_range_boundary.hpp:132