6#include "../result.hpp"
18 class DenseUnionBuilder;
24 enum class TimeRangeBoundaryTag : uint8_t {
33 union TimeRangeBoundaryData {
40 TimeRangeBoundaryData() {
41 std::memset(
reinterpret_cast<void*
>(
this), 0,
sizeof(TimeRangeBoundaryData));
44 ~TimeRangeBoundaryData() {}
46 void swap(TimeRangeBoundaryData& other)
noexcept {
48 char temp[
sizeof(TimeRangeBoundaryData)];
49 void* otherbytes =
reinterpret_cast<void*
>(&other);
50 void* thisbytes =
reinterpret_cast<void*
>(
this);
51 std::memcpy(temp, thisbytes,
sizeof(TimeRangeBoundaryData));
52 std::memcpy(thisbytes, otherbytes,
sizeof(TimeRangeBoundaryData));
53 std::memcpy(otherbytes, temp,
sizeof(TimeRangeBoundaryData));
64 const void* otherbytes =
reinterpret_cast<const void*
>(&other._data);
65 void* thisbytes =
reinterpret_cast<void*
>(&this->_data);
66 std::memcpy(thisbytes, otherbytes,
sizeof(detail::TimeRangeBoundaryData));
75 TimeRangeBoundary(TimeRangeBoundary&& other) noexcept : TimeRangeBoundary() {
79 TimeRangeBoundary& operator=(TimeRangeBoundary&& other)
noexcept {
84 void swap(TimeRangeBoundary& other)
noexcept {
85 std::swap(this->_tag, other._tag);
86 this->_data.swap(other._data);
92 self._tag = detail::TimeRangeBoundaryTag::CursorRelative;
100 self._tag = detail::TimeRangeBoundaryTag::Absolute;
108 self._tag = detail::TimeRangeBoundaryTag::Infinite;
114 if (_tag == detail::TimeRangeBoundaryTag::CursorRelative) {
115 return &_data.cursor_relative;
123 if (_tag == detail::TimeRangeBoundaryTag::Absolute) {
124 return &_data.absolute;
132 return _tag == detail::TimeRangeBoundaryTag::Infinite;
136 const detail::TimeRangeBoundaryData& get_union_data()
const {
141 detail::TimeRangeBoundaryTag get_union_tag()
const {
146 detail::TimeRangeBoundaryTag _tag;
147 detail::TimeRangeBoundaryData _data;
152 template <
typename T>
157 struct Loggable<datatypes::TimeRangeBoundary> {
158 static constexpr const char Name[] =
"rerun.datatypes.TimeRangeBoundary";
161 static const std::shared_ptr<arrow::DataType>& arrow_datatype();
164 static Result<std::shared_ptr<arrow::Array>> to_arrow(
165 const datatypes::TimeRangeBoundary* instances,
size_t num_instances
170 arrow::DenseUnionBuilder* builder,
const datatypes::TimeRangeBoundary* elements,
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:95
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:22
Datatype: A 64-bit number describing either nanoseconds OR sequence numbers.
Definition time_int.hpp:24
Datatype: Left or right boundary of a time range.
Definition time_range_boundary.hpp:59
static TimeRangeBoundary cursor_relative(rerun::datatypes::TimeInt cursor_relative)
Boundary is a value relative to the time cursor.
Definition time_range_boundary.hpp:90
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:122
TimeRangeBoundary(const TimeRangeBoundary &other)
Copy constructor.
Definition time_range_boundary.hpp:63
static TimeRangeBoundary infinite()
The boundary extends to infinity.
Definition time_range_boundary.hpp:106
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:113
static TimeRangeBoundary absolute(rerun::datatypes::TimeInt absolute)
Boundary is an absolute value.
Definition time_range_boundary.hpp:98
bool is_infinite() const
Returns true if the union is in the infinite state.
Definition time_range_boundary.hpp:131