Rerun C++ SDK
Loading...
Searching...
No Matches
table_column.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/table_column.def.rs".
3
4#pragma once
5
6#include "../../archetype_utils.hpp"
7#include "../../blueprint/components/column_type.hpp"
8#include "../../blueprint/components/editable.hpp"
9#include "../../collection.hpp"
10#include "../../component_batch.hpp"
11#include "../../component_column.hpp"
12#include "../../components/name.hpp"
13#include "../../components/visible.hpp"
14#include "../../result.hpp"
15
16#include <cstdint>
17#include <optional>
18#include <utility>
19#include <vector>
20
21namespace rerun::blueprint::archetypes {
22 /// **Archetype**: Blueprint for a column used by a table or card layout.
23 ///
24 /// This archetype is stored at the layout-specific path for its source column.
25 /// The source is the final `components::ColumnName` part of that path.
26 ///
27 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
28 ///
29 struct TableColumn {
30 /// The name shown for the column.
31 ///
32 /// If unset, the name is inferred from the source column.
33 std::optional<ComponentBatch> name;
34
35 /// Whether the column's values can be edited.
36 ///
37 /// If unset, the column is editable if its field in the table schema has `rerun:is_editable` metadata.
38 /// Edits require a remote table with a column marked by `rerun:is_table_index` metadata and write permission.
39 /// A column can only be edited when its component type has an editor in the Viewer.
40 std::optional<ComponentBatch> editable;
41
42 /// Whether the column is visible in this layout.
43 ///
44 /// If unset, the enclosing layout determines visibility.
45 /// Columns listed in the enclosing layout's `column_order` or `field_order` are shown.
46 /// Unlisted columns use the viewer default for table layouts and are hidden in card layouts.
47 std::optional<ComponentBatch> visible;
48
49 /// Overrides the component the column's values are shown as.
50 ///
51 /// This picks the component UI for every value of the column.
52 /// The column's Arrow datatype must match the datatype of the component type.
53 /// If unset, the component of the source column is used, or the Viewer infers one from the column's datatype.
54 std::optional<ComponentBatch> column_type;
55
56 public:
57 /// The name of the archetype as used in `ComponentDescriptor`s.
58 static constexpr const char ArchetypeName[] = "rerun.blueprint.archetypes.TableColumn";
59
60 /// `ComponentDescriptor` for the `name` field.
61 static constexpr auto Descriptor_name = ComponentDescriptor(
63 );
64 /// `ComponentDescriptor` for the `editable` field.
66 ArchetypeName, "TableColumn:editable",
68 );
69 /// `ComponentDescriptor` for the `visible` field.
70 static constexpr auto Descriptor_visible = ComponentDescriptor(
71 ArchetypeName, "TableColumn:visible",
73 );
74 /// `ComponentDescriptor` for the `column_type` field.
76 ArchetypeName, "TableColumn:column_type",
78 );
79
80 public:
81 TableColumn() = default;
82 TableColumn(TableColumn&& other) = default;
83 TableColumn(const TableColumn& other) = default;
84 TableColumn& operator=(const TableColumn& other) = default;
85 TableColumn& operator=(TableColumn&& other) = default;
86
87 /// Update only some specific fields of a `TableColumn`.
89 return TableColumn();
90 }
91
92 /// Clear all the fields of a `TableColumn`.
94
95 /// The name shown for the column.
96 ///
97 /// If unset, the name is inferred from the source column.
99 name = ComponentBatch::from_loggable(_name, Descriptor_name).value_or_throw();
100 return std::move(*this);
101 }
102
103 /// Whether the column's values can be edited.
104 ///
105 /// If unset, the column is editable if its field in the table schema has `rerun:is_editable` metadata.
106 /// Edits require a remote table with a column marked by `rerun:is_table_index` metadata and write permission.
107 /// A column can only be edited when its component type has an editor in the Viewer.
109 editable =
110 ComponentBatch::from_loggable(_editable, Descriptor_editable).value_or_throw();
111 return std::move(*this);
112 }
113
114 /// Whether the column is visible in this layout.
115 ///
116 /// If unset, the enclosing layout determines visibility.
117 /// Columns listed in the enclosing layout's `column_order` or `field_order` are shown.
118 /// Unlisted columns use the viewer default for table layouts and are hidden in card layouts.
120 visible = ComponentBatch::from_loggable(_visible, Descriptor_visible).value_or_throw();
121 return std::move(*this);
122 }
123
124 /// Overrides the component the column's values are shown as.
125 ///
126 /// This picks the component UI for every value of the column.
127 /// The column's Arrow datatype must match the datatype of the component type.
128 /// If unset, the component of the source column is used, or the Viewer infers one from the column's datatype.
130 ) && {
132 .value_or_throw();
133 return std::move(*this);
134 }
135
136 /// Partitions the component data into multiple sub-batches.
137 ///
138 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
139 /// instead, via `ComponentBatch::partitioned`.
140 ///
141 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
142 ///
143 /// The specified `lengths` must sum to the total length of the component batch.
145 return detail::partition_batches({&name, &editable, &visible, &column_type}, lengths_)
146 .value_or_throw();
147 }
148
149 /// Partitions the component data into unit-length sub-batches.
150 ///
151 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
152 /// where `n` is automatically guessed.
154 return detail::partition_batches_of_unit_length(
156 )
157 .value_or_throw();
158 }
159 };
160
161} // namespace rerun::blueprint::archetypes
162
163namespace rerun {
164 /// \private
165 template <typename T>
166 struct AsComponents;
167
168 /// \private
169 template <>
170 struct AsComponents<blueprint::archetypes::TableColumn> {
171 /// Serialize all set component batches.
172 static Result<Collection<ComponentBatch>> as_batches(
174 ) {
175 return detail::collect_batches(
176 {&archetype.name, &archetype.editable, &archetype.visible, &archetype.column_type}
177 );
178 }
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 Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:26
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: Blueprint for a column used by a table or card layout.
Definition table_column.hpp:29
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition table_column.hpp:144
std::optional< ComponentBatch > visible
Whether the column is visible in this layout.
Definition table_column.hpp:47
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition table_column.hpp:58
TableColumn with_visible(const rerun::components::Visible &_visible) &&
Whether the column is visible in this layout.
Definition table_column.hpp:119
static TableColumn clear_fields()
Clear all the fields of a TableColumn.
std::optional< ComponentBatch > editable
Whether the column's values can be edited.
Definition table_column.hpp:40
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition table_column.hpp:153
std::optional< ComponentBatch > column_type
Overrides the component the column's values are shown as.
Definition table_column.hpp:54
static constexpr auto Descriptor_column_type
ComponentDescriptor for the column_type field.
Definition table_column.hpp:75
static constexpr auto Descriptor_editable
ComponentDescriptor for the editable field.
Definition table_column.hpp:65
TableColumn with_editable(const rerun::blueprint::components::Editable &_editable) &&
Whether the column's values can be edited.
Definition table_column.hpp:108
static TableColumn update_fields()
Update only some specific fields of a TableColumn.
Definition table_column.hpp:88
std::optional< ComponentBatch > name
The name shown for the column.
Definition table_column.hpp:33
TableColumn with_name(const rerun::components::Name &_name) &&
The name shown for the column.
Definition table_column.hpp:98
static constexpr auto Descriptor_name
ComponentDescriptor for the name field.
Definition table_column.hpp:61
TableColumn with_column_type(const rerun::blueprint::components::ColumnType &_column_type) &&
Overrides the component the column's values are shown as.
Definition table_column.hpp:129
static constexpr auto Descriptor_visible
ComponentDescriptor for the visible field.
Definition table_column.hpp:70
Component: Overrides the component a table column's values are shown as.
Definition column_type.hpp:18
Component: Whether a table column's values can be edited.
Definition editable.hpp:17
Component: A display name, typically for an entity or a item like a plot series.
Definition name.hpp:19
Component: Whether the container, view, entity or instance is currently visible.
Definition visible.hpp:14