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/build/re_type_definitions/rerun/archetypes/clear.def.rs".
3
4#pragma once
5
6#include "../archetype_utils.hpp"
7#include "../collection.hpp"
8#include "../component_batch.hpp"
9#include "../component_column.hpp"
10#include "../components/clear_is_recursive.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(int argc, char* argv[]) {
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 /// The name of the archetype as used in `ComponentDescriptor`s.
91 static constexpr const char ArchetypeName[] = "rerun.archetypes.Clear";
92
93 /// `ComponentDescriptor` for the `is_recursive` field.
95 ArchetypeName, "Clear:is_recursive",
97 );
98
99 public: // START of extensions from clear_ext.cpp:
100 RERUN_SDK_EXPORT static const Clear FLAT;
101
102 RERUN_SDK_EXPORT static const Clear RECURSIVE;
103
104 Clear(bool _is_recursive = false) : Clear(components::ClearIsRecursive(_is_recursive)) {}
105
106 // END of extensions from clear_ext.cpp, start of generated code:
107
108 public:
109 Clear(Clear&& other) = default;
110 Clear(const Clear& other) = default;
111 Clear& operator=(const Clear& other) = default;
112 Clear& operator=(Clear&& other) = default;
113
114 explicit Clear(rerun::components::ClearIsRecursive _is_recursive)
115 : is_recursive(
116 ComponentBatch::from_loggable(std::move(_is_recursive), Descriptor_is_recursive)
117 .value_or_throw()
118 ) {}
119
120 /// Update only some specific fields of a `Clear`.
122 return Clear();
123 }
124
125 /// Clear all the fields of a `Clear`.
127
128 Clear with_is_recursive(const rerun::components::ClearIsRecursive& _is_recursive) && {
129 is_recursive = ComponentBatch::from_loggable(_is_recursive, Descriptor_is_recursive)
130 .value_or_throw();
131 return std::move(*this);
132 }
133
134 /// This method makes it possible to pack multiple `is_recursive` in a single component batch.
135 ///
136 /// This only makes sense when used in conjunction with `columns`. `with_is_recursive` should
137 /// be used when logging a single row's worth of data.
140 ) && {
141 is_recursive = ComponentBatch::from_loggable(_is_recursive, Descriptor_is_recursive)
142 .value_or_throw();
143 return std::move(*this);
144 }
145
146 /// Partitions the component data into multiple sub-batches.
147 ///
148 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
149 /// instead, via `ComponentBatch::partitioned`.
150 ///
151 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
152 ///
153 /// The specified `lengths` must sum to the total length of the component batch.
155 return detail::partition_batches({&is_recursive}, lengths_).value_or_throw();
156 }
157
158 /// Partitions the component data into unit-length sub-batches.
159 ///
160 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
161 /// where `n` is automatically guessed.
163 return detail::partition_batches_of_unit_length({&is_recursive}).value_or_throw();
164 }
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 return detail::collect_batches({&archetype.is_recursive});
180 }
181 };
182} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:90
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:26
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)
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:16
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:138
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition clear.hpp:91
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition clear.hpp:162
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition clear.hpp:154
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:121
static constexpr auto Descriptor_is_recursive
ComponentDescriptor for the is_recursive field.
Definition clear.hpp:94
Component: Configures how a clear operation should behave - recursive or not.
Definition clear_is_recursive.hpp:14