Rerun C++ SDK
Loading...
Searching...
No Matches
card_layout.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/card_layout.def.rs".
3
4#pragma once
5
6#include "../../archetype_utils.hpp"
7#include "../../blueprint/components/column_name.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**: Blueprint for displaying table records as cards.
20 ///
21 /// This archetype is stored at the entity `/table/layouts/cards`.
22 ///
23 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
24 ///
25 struct CardLayout {
26 /// The source column used for card titles.
27 ///
28 /// If unset, the first visible string column is used as the title.
29 std::optional<ComponentBatch> title;
30
31 /// The source column containing the target opened when a card is activated.
32 ///
33 /// If unset, the first configured preview field is used, then the first inferred URL column.
34 std::optional<ComponentBatch> link;
35
36 /// Source columns visible by default in each card, in display order.
37 ///
38 /// Unlisted fields are hidden unless their `archetypes::TableColumn` visibility overrides the default.
39 /// Each source column may appear at most once.
40 ///
41 /// The first visible field of component type `components::Flag` is shown in the card header
42 /// instead of the labeled-field list.
43 std::optional<ComponentBatch> field_order;
44
45 public:
46 /// The name of the archetype as used in `ComponentDescriptor`s.
47 static constexpr const char ArchetypeName[] = "rerun.blueprint.archetypes.CardLayout";
48
49 /// `ComponentDescriptor` for the `title` field.
50 static constexpr auto Descriptor_title = ComponentDescriptor(
51 ArchetypeName, "CardLayout:title",
53 );
54 /// `ComponentDescriptor` for the `link` field.
55 static constexpr auto Descriptor_link = ComponentDescriptor(
56 ArchetypeName, "CardLayout:link",
58 );
59 /// `ComponentDescriptor` for the `field_order` field.
61 ArchetypeName, "CardLayout:field_order",
63 );
64
65 public:
66 CardLayout() = default;
67 CardLayout(CardLayout&& other) = default;
68 CardLayout(const CardLayout& other) = default;
69 CardLayout& operator=(const CardLayout& other) = default;
70 CardLayout& operator=(CardLayout&& other) = default;
71
74 ComponentBatch::from_loggable(std::move(_field_order), Descriptor_field_order)
75 .value_or_throw()
76 ) {}
77
78 /// Update only some specific fields of a `CardLayout`.
80 return CardLayout();
81 }
82
83 /// Clear all the fields of a `CardLayout`.
85
86 /// The source column used for card titles.
87 ///
88 /// If unset, the first visible string column is used as the title.
90 title = ComponentBatch::from_loggable(_title, Descriptor_title).value_or_throw();
91 return std::move(*this);
92 }
93
94 /// The source column containing the target opened when a card is activated.
95 ///
96 /// If unset, the first configured preview field is used, then the first inferred URL column.
98 link = ComponentBatch::from_loggable(_link, Descriptor_link).value_or_throw();
99 return std::move(*this);
100 }
101
102 /// Source columns visible by default in each card, in display order.
103 ///
104 /// Unlisted fields are hidden unless their `archetypes::TableColumn` visibility overrides the default.
105 /// Each source column may appear at most once.
106 ///
107 /// The first visible field of component type `components::Flag` is shown in the card header
108 /// instead of the labeled-field list.
111 ) && {
113 .value_or_throw();
114 return std::move(*this);
115 }
116
117 /// Partitions the component data into multiple sub-batches.
118 ///
119 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
120 /// instead, via `ComponentBatch::partitioned`.
121 ///
122 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
123 ///
124 /// The specified `lengths` must sum to the total length of the component batch.
126 return detail::partition_batches({&title, &link, &field_order}, lengths_)
127 .value_or_throw();
128 }
129
130 /// Partitions the component data into unit-length sub-batches.
131 ///
132 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
133 /// where `n` is automatically guessed.
135 return detail::partition_batches_of_unit_length({&title, &link, &field_order})
136 .value_or_throw();
137 }
138 };
139
140} // namespace rerun::blueprint::archetypes
141
142namespace rerun {
143 /// \private
144 template <typename T>
145 struct AsComponents;
146
147 /// \private
148 template <>
149 struct AsComponents<blueprint::archetypes::CardLayout> {
150 /// Serialize all set component batches.
151 static Result<Collection<ComponentBatch>> as_batches(
152 const blueprint::archetypes::CardLayout& archetype
153 ) {
154 return detail::collect_batches(
155 {&archetype.title, &archetype.link, &archetype.field_order}
156 );
157 }
158 };
159} // 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: Blueprint for displaying table records as cards.
Definition card_layout.hpp:25
CardLayout with_link(const rerun::blueprint::components::ColumnName &_link) &&
The source column containing the target opened when a card is activated.
Definition card_layout.hpp:97
std::optional< ComponentBatch > field_order
Source columns visible by default in each card, in display order.
Definition card_layout.hpp:43
static CardLayout clear_fields()
Clear all the fields of a CardLayout.
static constexpr auto Descriptor_field_order
ComponentDescriptor for the field_order field.
Definition card_layout.hpp:60
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition card_layout.hpp:134
std::optional< ComponentBatch > link
The source column containing the target opened when a card is activated.
Definition card_layout.hpp:34
static constexpr auto Descriptor_title
ComponentDescriptor for the title field.
Definition card_layout.hpp:50
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition card_layout.hpp:47
static constexpr auto Descriptor_link
ComponentDescriptor for the link field.
Definition card_layout.hpp:55
std::optional< ComponentBatch > title
The source column used for card titles.
Definition card_layout.hpp:29
CardLayout with_title(const rerun::blueprint::components::ColumnName &_title) &&
The source column used for card titles.
Definition card_layout.hpp:89
static CardLayout update_fields()
Update only some specific fields of a CardLayout.
Definition card_layout.hpp:79
CardLayout with_field_order(const Collection< rerun::blueprint::components::ColumnName > &_field_order) &&
Source columns visible by default in each card, in display order.
Definition card_layout.hpp:109
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition card_layout.hpp:125
Component: The name of a column in a table.
Definition column_name.hpp:22