Rerun C++ SDK
Loading...
Searching...
No Matches
indicator_component.hpp
1#pragma once
2
3#include <memory> // std::shared_ptr
4#include "loggable.hpp"
5#include "result.hpp"
6
7namespace arrow {
8 class DataType;
9 class Array;
10} // namespace arrow
11
12namespace rerun::components {
13 /// Arrow data type shared by all instances of IndicatorComponent.
14 const std::shared_ptr<arrow::DataType>& indicator_arrow_datatype();
15
16 /// Returns an arrow array for a single indicator component.
17 ///
18 /// This allocates a shared pointer only on the first call and returns references to the static object afterwards.
19 const std::shared_ptr<arrow::Array>& indicator_arrow_array();
20
21 /// Returns an arrow array for a several indicator component.
22 ///
23 /// Unlike the parameterless version this allocates a new data type on every call.
24 std::shared_ptr<arrow::Array> indicator_arrow_array(size_t num_instances);
25
26 /// Indicator component used by archetypes when converting them to component lists.
27 ///
28 /// This is done in order to track how a collection of component was logged.
29 template <const char Name[]>
31} // namespace rerun::components
32
33namespace rerun {
34 /// \private
35 template <const char Name_[]>
36 struct Loggable<components::IndicatorComponent<Name_>> {
37 /// Returns the name of this type.
38 static constexpr const char* Name = Name_;
39
40 /// Returns the arrow data type this type corresponds to.
41 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
43 }
44
45 /// Creates an arrow ComponentBatch from an array of IndicatorComponent components.
46 static Result<std::shared_ptr<arrow::Array>> to_arrow(
47 const components::IndicatorComponent<Name_>*, size_t num_instances
48 ) {
49 // If possible, use the statically allocated shared pointer returned by the parameterless version.
50 if (num_instances == 1) {
52 } else {
53 return components::indicator_arrow_array(num_instances);
54 }
55 }
56 };
57} // namespace rerun
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:75
const std::shared_ptr< arrow::DataType > & indicator_arrow_datatype()
Arrow data type shared by all instances of IndicatorComponent.
const std::shared_ptr< arrow::Array > & indicator_arrow_array()
Returns an arrow array for a single indicator component.
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:22
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:30