Rerun C++ SDK
Loading...
Searching...
No Matches
clear.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/store/re_types/definitions/rerun/archetypes/clear.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/clear_is_recursive.hpp"
10#include "../indicator_component.hpp"
11#include "../rerun_sdk_export.hpp"
12#include "../result.hpp"
13
14#include <cstdint>
15#include <optional>
16#include <utility>
17#include <vector>
18
19namespace rerun::archetypes {
20 /// **Archetype**: Empties all the components of an entity.
21 ///
22 /// The presence of a clear means that a latest-at query of components at a given path(s)
23 /// will not return any components that were logged at those paths before the clear.
24 /// Any logged components after the clear are unaffected by the clear.
25 ///
26 /// This implies that a range query that includes time points that are before the clear,
27 /// still returns all components at the given path(s).
28 /// Meaning that in practice clears are ineffective when making use of visible time ranges.
29 /// Scalar plots are an exception: they track clears and use them to represent holes in the
30 /// data (i.e. discontinuous lines).
31 ///
32 /// ## Example
33 ///
34 /// ### Flat
35 /// ![image](https://static.rerun.io/clear_simple/2f5df95fcc53e9f0552f65670aef7f94830c5c1a/full.png)
36 ///
37 /// ```cpp
38 /// #include <rerun.hpp>
39 ///
40 /// #include <cmath>
41 /// #include <numeric>
42 /// #include <string> // to_string
43 /// #include <vector>
44 ///
45 /// int main() {
46 /// const auto rec = rerun::RecordingStream("rerun_example_clear");
47 /// rec.spawn().exit_on_failure();
48 ///
49 /// std::vector<rerun::Vector3D> vectors = {
50 /// {1.0, 0.0, 0.0},
51 /// {0.0, -1.0, 0.0},
52 /// {-1.0, 0.0, 0.0},
53 /// {0.0, 1.0, 0.0},
54 /// };
55 /// std::vector<rerun::Position3D> origins = {
56 /// {-0.5, 0.5, 0.0},
57 /// {0.5, 0.5, 0.0},
58 /// {0.5, -0.5, 0.0},
59 /// {-0.5, -0.5, 0.0},
60 /// };
61 /// std::vector<rerun::Color> colors = {
62 /// {200, 0, 0},
63 /// {0, 200, 0},
64 /// {0, 0, 200},
65 /// {200, 0, 200},
66 /// };
67 ///
68 /// // Log a handful of arrows.
69 /// for (size_t i = 0; i <vectors.size(); ++i) {
70 /// auto entity_path = "arrows/" + std::to_string(i);
71 /// rec.log(
72 /// entity_path,
73 /// rerun::Arrows3D::from_vectors(vectors[i])
74 /// .with_origins(origins[i])
75 /// .with_colors(colors[i])
76 /// );
77 /// }
78 ///
79 /// // Now clear them, one by one on each tick.
80 /// for (size_t i = 0; i <vectors.size(); ++i) {
81 /// auto entity_path = "arrows/" + std::to_string(i);
82 /// rec.log(entity_path, rerun::Clear::FLAT);
83 /// }
84 /// }
85 /// ```
86 struct Clear {
87 std::optional<ComponentBatch> is_recursive;
88
89 public:
90 static constexpr const char IndicatorComponentName[] = "rerun.components.ClearIndicator";
91
92 /// Indicator component, used to identify the archetype when converting to a list of components.
94 /// The name of the archetype as used in `ComponentDescriptor`s.
95 static constexpr const char ArchetypeName[] = "rerun.archetypes.Clear";
96
97 /// `ComponentDescriptor` for the `is_recursive` field.
99 ArchetypeName, "is_recursive",
101 );
102
103 public: // START of extensions from clear_ext.cpp:
104 RERUN_SDK_EXPORT static const Clear FLAT;
105
106 RERUN_SDK_EXPORT static const Clear RECURSIVE;
107
108 Clear(bool _is_recursive = false) : Clear(components::ClearIsRecursive(_is_recursive)) {}
109
110 // END of extensions from clear_ext.cpp, start of generated code:
111
112 public:
113 Clear(Clear&& other) = default;
114 Clear(const Clear& other) = default;
115 Clear& operator=(const Clear& other) = default;
116 Clear& operator=(Clear&& other) = default;
117
118 explicit Clear(rerun::components::ClearIsRecursive _is_recursive)
119 : is_recursive(
120 ComponentBatch::from_loggable(std::move(_is_recursive), Descriptor_is_recursive)
121 .value_or_throw()
122 ) {}
123
124 /// Update only some specific fields of a `Clear`.
126 return Clear();
127 }
128
129 /// Clear all the fields of a `Clear`.
131
132 Clear with_is_recursive(const rerun::components::ClearIsRecursive& _is_recursive) && {
133 is_recursive = ComponentBatch::from_loggable(_is_recursive, Descriptor_is_recursive)
134 .value_or_throw();
135 return std::move(*this);
136 }
137
138 /// This method makes it possible to pack multiple `is_recursive` in a single component batch.
139 ///
140 /// This only makes sense when used in conjunction with `columns`. `with_is_recursive` should
141 /// be used when logging a single row's worth of data.
144 ) && {
145 is_recursive = ComponentBatch::from_loggable(_is_recursive, Descriptor_is_recursive)
146 .value_or_throw();
147 return std::move(*this);
148 }
149
150 /// Partitions the component data into multiple sub-batches.
151 ///
152 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
153 /// instead, via `ComponentBatch::partitioned`.
154 ///
155 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
156 ///
157 /// The specified `lengths` must sum to the total length of the component batch.
159
160 /// Partitions the component data into unit-length sub-batches.
161 ///
162 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
163 /// where `n` is automatically guessed.
165 };
166
167} // namespace rerun::archetypes
168
169namespace rerun {
170 /// \private
171 template <typename T>
172 struct AsComponents;
173
174 /// \private
175 template <>
176 struct AsComponents<archetypes::Clear> {
177 /// Serialize all set component batches.
178 static Result<Collection<ComponentBatch>> as_batches(const archetypes::Clear& archetype);
179 };
180} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
A class for representing either a usable value, or an error.
Definition result.hpp:14
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:76
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Arrow-encoded data of a single batch of components together with a component descriptor.
Definition component_batch.hpp:28
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor=rerun::Loggable< T >::Descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:46
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:14
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Archetype: Empties all the components of an entity.
Definition clear.hpp:86
Clear with_many_is_recursive(const Collection< rerun::components::ClearIsRecursive > &_is_recursive) &&
This method makes it possible to pack multiple is_recursive in a single component batch.
Definition clear.hpp:142
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition clear.hpp:95
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
static Clear clear_fields()
Clear all the fields of a Clear.
static Clear update_fields()
Update only some specific fields of a Clear.
Definition clear.hpp:125
static constexpr auto Descriptor_is_recursive
ComponentDescriptor for the is_recursive field.
Definition clear.hpp:98
Component: Configures how a clear operation should behave - recursive or not.
Definition clear_is_recursive.hpp:15
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:32