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 "../rerun_sdk_export.hpp"
11#include "../result.hpp"
12
13#include <cstdint>
14#include <optional>
15#include <utility>
16#include <vector>
17
18namespace rerun::archetypes {
19 /// **Archetype**: Empties all the components of an entity.
20 ///
21 /// The presence of a clear means that a latest-at query of components at a given path(s)
22 /// will not return any components that were logged at those paths before the clear.
23 /// Any logged components after the clear are unaffected by the clear.
24 ///
25 /// This implies that a range query that includes time points that are before the clear,
26 /// still returns all components at the given path(s).
27 /// Meaning that in practice clears are ineffective when making use of visible time ranges.
28 /// Scalar plots are an exception: they track clears and use them to represent holes in the
29 /// data (i.e. discontinuous lines).
30 ///
31 /// ## Example
32 ///
33 /// ### Flat
34 /// ![image](https://static.rerun.io/clear_simple/2f5df95fcc53e9f0552f65670aef7f94830c5c1a/full.png)
35 ///
36 /// ```cpp
37 /// #include <rerun.hpp>
38 ///
39 /// #include <cmath>
40 /// #include <numeric>
41 /// #include <string> // to_string
42 /// #include <vector>
43 ///
44 /// int main() {
45 /// const auto rec = rerun::RecordingStream("rerun_example_clear");
46 /// rec.spawn().exit_on_failure();
47 ///
48 /// std::vector<rerun::Vector3D> vectors = {
49 /// {1.0, 0.0, 0.0},
50 /// {0.0, -1.0, 0.0},
51 /// {-1.0, 0.0, 0.0},
52 /// {0.0, 1.0, 0.0},
53 /// };
54 /// std::vector<rerun::Position3D> origins = {
55 /// {-0.5, 0.5, 0.0},
56 /// {0.5, 0.5, 0.0},
57 /// {0.5, -0.5, 0.0},
58 /// {-0.5, -0.5, 0.0},
59 /// };
60 /// std::vector<rerun::Color> colors = {
61 /// {200, 0, 0},
62 /// {0, 200, 0},
63 /// {0, 0, 200},
64 /// {200, 0, 200},
65 /// };
66 ///
67 /// // Log a handful of arrows.
68 /// for (size_t i = 0; i <vectors.size(); ++i) {
69 /// auto entity_path = "arrows/" + std::to_string(i);
70 /// rec.log(
71 /// entity_path,
72 /// rerun::Arrows3D::from_vectors(vectors[i])
73 /// .with_origins(origins[i])
74 /// .with_colors(colors[i])
75 /// );
76 /// }
77 ///
78 /// // Now clear them, one by one on each tick.
79 /// for (size_t i = 0; i <vectors.size(); ++i) {
80 /// auto entity_path = "arrows/" + std::to_string(i);
81 /// rec.log(entity_path, rerun::Clear::FLAT);
82 /// }
83 /// }
84 /// ```
85 struct Clear {
86 std::optional<ComponentBatch> is_recursive;
87
88 public:
89 /// The name of the archetype as used in `ComponentDescriptor`s.
90 static constexpr const char ArchetypeName[] = "rerun.archetypes.Clear";
91
92 /// `ComponentDescriptor` for the `is_recursive` field.
94 ArchetypeName, "Clear:is_recursive",
96 );
97
98 public: // START of extensions from clear_ext.cpp:
99 RERUN_SDK_EXPORT static const Clear FLAT;
100
101 RERUN_SDK_EXPORT static const Clear RECURSIVE;
102
103 Clear(bool _is_recursive = false) : Clear(components::ClearIsRecursive(_is_recursive)) {}
104
105 // END of extensions from clear_ext.cpp, start of generated code:
106
107 public:
108 Clear(Clear&& other) = default;
109 Clear(const Clear& other) = default;
110 Clear& operator=(const Clear& other) = default;
111 Clear& operator=(Clear&& other) = default;
112
113 explicit Clear(rerun::components::ClearIsRecursive _is_recursive)
114 : is_recursive(
115 ComponentBatch::from_loggable(std::move(_is_recursive), Descriptor_is_recursive)
116 .value_or_throw()
117 ) {}
118
119 /// Update only some specific fields of a `Clear`.
121 return Clear();
122 }
123
124 /// Clear all the fields of a `Clear`.
126
127 Clear with_is_recursive(const rerun::components::ClearIsRecursive& _is_recursive) && {
128 is_recursive = ComponentBatch::from_loggable(_is_recursive, Descriptor_is_recursive)
129 .value_or_throw();
130 return std::move(*this);
131 }
132
133 /// This method makes it possible to pack multiple `is_recursive` in a single component batch.
134 ///
135 /// This only makes sense when used in conjunction with `columns`. `with_is_recursive` should
136 /// be used when logging a single row's worth of data.
139 ) && {
140 is_recursive = ComponentBatch::from_loggable(_is_recursive, Descriptor_is_recursive)
141 .value_or_throw();
142 return std::move(*this);
143 }
144
145 /// Partitions the component data into multiple sub-batches.
146 ///
147 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
148 /// instead, via `ComponentBatch::partitioned`.
149 ///
150 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
151 ///
152 /// The specified `lengths` must sum to the total length of the component batch.
154
155 /// Partitions the component data into unit-length sub-batches.
156 ///
157 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
158 /// where `n` is automatically guessed.
160 };
161
162} // namespace rerun::archetypes
163
164namespace rerun {
165 /// \private
166 template <typename T>
167 struct AsComponents;
168
169 /// \private
170 template <>
171 struct AsComponents<archetypes::Clear> {
172 /// Serialize all set component batches.
173 static Result<Collection<ComponentBatch>> as_batches(const archetypes::Clear& archetype);
174 };
175} // 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)
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:85
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:137
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition clear.hpp:90
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:120
static constexpr auto Descriptor_is_recursive
ComponentDescriptor for the is_recursive field.
Definition clear.hpp:93
Component: Configures how a clear operation should behave - recursive or not.
Definition clear_is_recursive.hpp:14