Rerun C++ SDK
Loading...
Searching...
No Matches
view_contents.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/blueprint/archetypes/view_contents.def.rs".
3
4#pragma once
5
6#include "../../archetype_utils.hpp"
7#include "../../blueprint/components/query_expression.hpp"
8#include "../../collection.hpp"
9#include "../../component_batch.hpp"
10#include "../../component_column.hpp"
11#include "../../result.hpp"
12
13#include <cstdint>
14#include <optional>
15#include <utility>
16#include <vector>
17
18namespace rerun::blueprint::archetypes {
19 /// **Archetype**: The contents of a `View`.
20 ///
21 /// The contents are found by combining a collection of `QueryExpression`s.
22 ///
23 /// ```diff
24 /// + /world/** # add everything…
25 /// - /world/roads/** # …but remove all roads…
26 /// + /world/roads/main # …but show main road
27 /// ```
28 ///
29 /// If there is multiple matching rules, the most specific rule wins.
30 /// If there are multiple rules of the same specificity, the last one wins.
31 /// If no rules match, the path is excluded.
32 ///
33 /// Specifying a path without a `+` or `-` prefix is equivalent to `+`:
34 /// ```diff
35 /// /world/** # add everything…
36 /// - /world/roads/** # …but remove all roads…
37 /// /world/roads/main # …but show main road
38 /// ```
39 ///
40 /// The `/**` suffix matches the whole subtree, i.e. self and any child, recursively
41 /// (`/world/**` matches both `/world` and `/world/car/driver`).
42 /// Other uses of `*` are not (yet) supported.
43 ///
44 /// Internally, `EntityPathFilter` sorts the rule by entity path, with recursive coming before non-recursive.
45 /// This means the last matching rule is also the most specific one. For instance:
46 /// ```diff
47 /// + /world/**
48 /// - /world
49 /// - /world/car/**
50 /// + /world/car/driver
51 /// ```
52 ///
53 /// The last rule matching `/world/car/driver` is `+ /world/car/driver`, so it is included.
54 /// The last rule matching `/world/car/hood` is `- /world/car/**`, so it is excluded.
55 /// The last rule matching `/world` is `- /world`, so it is excluded.
56 /// The last rule matching `/world/house` is `+ /world/**`, so it is included.
57 ///
58 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
59 ///
60 struct ViewContents {
61 /// The `QueryExpression` that populates the contents for the view.
62 ///
63 /// They determine which entities are part of the view.
64 std::optional<ComponentBatch> query;
65
66 public:
67 /// The name of the archetype as used in `ComponentDescriptor`s.
68 static constexpr const char ArchetypeName[] = "rerun.blueprint.archetypes.ViewContents";
69
70 /// `ComponentDescriptor` for the `query` field.
71 static constexpr auto Descriptor_query = ComponentDescriptor(
72 ArchetypeName, "ViewContents:query",
74 );
75
76 public:
77 ViewContents() = default;
78 ViewContents(ViewContents&& other) = default;
79 ViewContents(const ViewContents& other) = default;
80 ViewContents& operator=(const ViewContents& other) = default;
81 ViewContents& operator=(ViewContents&& other) = default;
82
84 : query(ComponentBatch::from_loggable(std::move(_query), Descriptor_query)
85 .value_or_throw()) {}
86
87 /// Update only some specific fields of a `ViewContents`.
89 return ViewContents();
90 }
91
92 /// Clear all the fields of a `ViewContents`.
94
95 /// The `QueryExpression` that populates the contents for the view.
96 ///
97 /// They determine which entities are part of the view.
100 ) && {
101 query = ComponentBatch::from_loggable(_query, Descriptor_query).value_or_throw();
102 return std::move(*this);
103 }
104
105 /// Partitions the component data into multiple sub-batches.
106 ///
107 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
108 /// instead, via `ComponentBatch::partitioned`.
109 ///
110 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
111 ///
112 /// The specified `lengths` must sum to the total length of the component batch.
114 return detail::partition_batches({&query}, lengths_).value_or_throw();
115 }
116
117 /// Partitions the component data into unit-length sub-batches.
118 ///
119 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
120 /// where `n` is automatically guessed.
122 return detail::partition_batches_of_unit_length({&query}).value_or_throw();
123 }
124 };
125
126} // namespace rerun::blueprint::archetypes
127
128namespace rerun {
129 /// \private
130 template <typename T>
131 struct AsComponents;
132
133 /// \private
134 template <>
135 struct AsComponents<blueprint::archetypes::ViewContents> {
136 /// Serialize all set component batches.
137 static Result<Collection<ComponentBatch>> as_batches(
139 ) {
140 return detail::collect_batches({&archetype.query});
141 }
142 };
143} // 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 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: The contents of a View.
Definition view_contents.hpp:60
std::optional< ComponentBatch > query
The QueryExpression that populates the contents for the view.
Definition view_contents.hpp:64
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition view_contents.hpp:121
ViewContents with_query(const Collection< rerun::blueprint::components::QueryExpression > &_query) &&
The QueryExpression that populates the contents for the view.
Definition view_contents.hpp:98
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition view_contents.hpp:68
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition view_contents.hpp:113
static ViewContents update_fields()
Update only some specific fields of a ViewContents.
Definition view_contents.hpp:88
static constexpr auto Descriptor_query
ComponentDescriptor for the query field.
Definition view_contents.hpp:71
static ViewContents clear_fields()
Clear all the fields of a ViewContents.