5#include <unordered_map>
7#include "collection.hpp"
8#include "component_descriptor.hpp"
9#include "component_type.hpp"
11#include "loggable.hpp"
18struct rr_component_batch;
26 std::shared_ptr<arrow::Array>
array;
48 rerun::is_loggable<T>,
49 "The given type does not implement the rerun::Loggable trait."
55 static std::unordered_map<ComponentDescriptorHash, ComponentTypeHandle>
60 auto descr_hash = descriptor.hashed();
62 auto search = comp_types_per_descr.find(descr_hash);
63 if (search != comp_types_per_descr.end()) {
64 comp_type_handle = search->second;
69 comp_type.register_component();
70 RR_RETURN_NOT_OK(comp_type_handle_result.error);
72 comp_type_handle = comp_type_handle_result.value;
73 comp_types_per_descr.insert({descr_hash, comp_type_handle});
78 RR_RETURN_NOT_OK(
array.error);
81 component_batch.
array = std::move(
array.value);
83 return component_batch;
113 template <
typename T>
115 if (component.has_value()) {
127 template <
typename T>
131 if (component.has_value()) {
143 template <
typename T>
147 if (components.has_value()) {
159 template <
typename T>
164 if (components.has_value()) {
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
static Collection< TElement > borrow(const T *data, size_t num_instances=1)
Borrows binary compatible data into the collection from a typed pointer.
Definition collection.hpp:154
size_t size() const
Returns the number of instances in this collection.
Definition collection.hpp:291
const TElement * data() const
Returns a raw pointer to the underlying data.
Definition collection.hpp:327
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:95
A class for representing either a usable value, or an error.
Definition result.hpp:14
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
uint32_t ComponentTypeHandle
Handle to a registered component types.
Definition component_type.hpp:14
Arrow-encoded data of a single batch components for a single entity.
Definition component_batch.hpp:24
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:36
static Result< ComponentBatch > from_loggable(const T &component)
Creates a new component batch from a single component instance.
Definition component_batch.hpp:90
static Result< ComponentBatch > from_loggable(const T &component, const ComponentDescriptor &descriptor)
Creates a new component batch from a single component instance.
Definition component_batch.hpp:100
static Result< ComponentBatch > from_loggable(const std::optional< rerun::Collection< T > > &components)
Creates a new data cell from an optional collection of component instances.
Definition component_batch.hpp:144
Error to_c_ffi_struct(rr_component_batch &out_component_batch) const
To rerun C API component batch.
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:44
static Result< ComponentBatch > from_loggable(const std::optional< rerun::Collection< T > > &components, const ComponentDescriptor &descriptor)
Creates a new data cell from an optional collection of component instances.
Definition component_batch.hpp:160
ComponentTypeHandle component_type
The type of the component instances in array.
Definition component_batch.hpp:29
static Result< ComponentBatch > from_loggable(const std::optional< T > &component, const ComponentDescriptor &descriptor)
Creates a new data cell from a single optional component instance.
Definition component_batch.hpp:128
std::shared_ptr< arrow::Array > array
Arrow-encoded data of the component instances.
Definition component_batch.hpp:26
static Result< ComponentBatch > from_loggable(const std::optional< T > &component)
Creates a new data cell from a single optional component instance.
Definition component_batch.hpp:114
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:13
A type of component that can be registered.
Definition component_type.hpp:19
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11