3#include "collection.hpp"
4#include "component_batch.hpp"
5#include "indicator_component.hpp"
18 template <
typename T2>
19 struct NoAsComponentsFor : std::false_type {};
23 NoAsComponentsFor<T>::value,
24 "AsComponents is not implemented for this type. "
25 "It is implemented for all built-in archetypes as well as std::vector, std::array, and "
26 "c-arrays of components. "
27 "You can add your own implementation by specializing AsComponents<T> for your type T."
37 template <
typename TComponent>
38 struct AsComponents<Collection<TComponent>> {
40 is_loggable<TComponent>,
"The given type does not implement the rerun::Loggable trait."
43 static Result<std::vector<ComponentBatch>> serialize(
44 const Collection<TComponent>& components
46 auto batch_result = ComponentBatch::from_loggable<TComponent>(components);
47 RR_RETURN_NOT_OK(batch_result.error);
49 return Result<std::vector<ComponentBatch>>({std::move(batch_result.value)});
54 template <
typename TComponent>
55 struct AsComponents<std::vector<TComponent>> {
56 static Result<std::vector<ComponentBatch>> serialize(
57 const std::vector<TComponent>& components
59 return AsComponents<Collection<TComponent>>::serialize(components);
64 template <
typename TComponent>
65 struct AsComponents<std::initializer_list<TComponent>> {
66 static Result<std::vector<ComponentBatch>> serialize(
67 std::initializer_list<TComponent> components
69 return AsComponents<Collection<TComponent>>::serialize(components);
74 template <
typename TComponent,
size_t NumInstances>
75 struct AsComponents<std::array<TComponent, NumInstances>> {
76 static Result<std::vector<ComponentBatch>> serialize(
77 const std::array<TComponent, NumInstances>& components
79 return AsComponents<Collection<TComponent>>::serialize(components);
84 template <
typename TComponent,
size_t NumInstances>
85 struct AsComponents<TComponent[NumInstances]> {
86 static Result<std::vector<ComponentBatch>> serialize(
const TComponent (&components
88 return AsComponents<Collection<TComponent>>::serialize(components);
93 template <const
char Name[]>
94 struct AsComponents<components::IndicatorComponent<Name>> {
95 static Result<std::vector<ComponentBatch>> serialize(
96 const components::IndicatorComponent<Name>& indicator
98 return AsComponents<Collection<components::IndicatorComponent<Name>>>::serialize(
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:22