3#include "collection.hpp"
4#include "data_cell.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<DataCell>> serialize(
const Collection<TComponent>& components) {
44 auto cell_result = DataCell::from_loggable<TComponent>(components);
45 RR_RETURN_NOT_OK(cell_result.error);
47 return Result<std::vector<DataCell>>({std::move(cell_result.value)});
52 template <
typename TComponent>
53 struct AsComponents<std::vector<TComponent>> {
54 static Result<std::vector<DataCell>> serialize(
const std::vector<TComponent>& components) {
55 return AsComponents<Collection<TComponent>>::serialize(components);
60 template <
typename TComponent>
61 struct AsComponents<std::initializer_list<TComponent>> {
62 static Result<std::vector<DataCell>> serialize(std::initializer_list<TComponent> components
64 return AsComponents<Collection<TComponent>>::serialize(components);
69 template <
typename TComponent,
size_t NumInstances>
70 struct AsComponents<std::array<TComponent, NumInstances>> {
71 static Result<std::vector<DataCell>> serialize(
72 const std::array<TComponent, NumInstances>& components
74 return AsComponents<Collection<TComponent>>::serialize(components);
79 template <
typename TComponent,
size_t NumInstances>
80 struct AsComponents<TComponent[NumInstances]> {
81 static Result<std::vector<DataCell>> serialize(
const TComponent (&components)[NumInstances]
83 return AsComponents<Collection<TComponent>>::serialize(components);
88 template <const
char Name[]>
89 struct AsComponents<components::IndicatorComponent<Name>> {
90 static Result<std::vector<DataCell>> serialize(
91 const components::IndicatorComponent<Name>& indicator
93 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:20