Rerun C++ SDK
Loading...
Searching...
No Matches
mcap_schema.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/mcap_schema.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/blob.hpp"
11#include "../components/schema_id.hpp"
12#include "../components/text.hpp"
13#include "../result.hpp"
14
15#include <cstdint>
16#include <optional>
17#include <utility>
18#include <vector>
19
20namespace rerun::archetypes {
21 /// **Archetype**: A schema definition that describes the structure of messages in an MCAP file.
22 ///
23 /// Schemas define the data types and field structures used by messages in MCAP channels.
24 /// They provide the blueprint for interpreting message payloads, specifying field names,
25 /// types, and organization. Each schema is referenced by channels to indicate how their
26 /// messages should be decoded and understood.
27 ///
28 /// See also `archetypes::McapChannel` for channels that reference these schemas,
29 /// `archetypes::McapMessage` for the messages that conform to these schemas, and the
30 /// [MCAP specification](https://mcap.dev/) for complete format details.
31 ///
32 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
33 ///
34 struct McapSchema {
35 /// Unique identifier for this schema within the MCAP file.
36 ///
37 /// Schema IDs must be unique within an MCAP file and are referenced by channels
38 /// to specify their message structure. A single schema can be shared across multiple channels.
39 std::optional<ComponentBatch> id;
40
41 /// Human-readable name identifying this schema.
42 ///
43 /// Schema names typically describe the message type or data structure
44 /// (e.g., `"geometry_msgs/msg/Twist"`, `"sensor_msgs/msg/Image"`, `"MyCustomMessage"`).
45 std::optional<ComponentBatch> name;
46
47 /// The schema definition format used to describe the message structure.
48 ///
49 /// Common schema encodings include:
50 /// * `protobuf` - [Protocol Buffers](https://mcap.dev/spec/registry#protobuf-1) schema definition
51 /// * `ros1msg` - [ROS1](https://mcap.dev/spec/registry#ros1msg) message definition format
52 /// * `ros2msg` - [ROS2](https://mcap.dev/spec/registry#ros2msg) message definition format
53 /// * `jsonschema` - [JSON Schema](https://mcap.dev/spec/registry#jsonschema) specification
54 /// * `flatbuffer` - [FlatBuffers](https://mcap.dev/spec/registry#flatbuffer) schema definition
55 std::optional<ComponentBatch> encoding;
56
57 /// The schema definition content as binary data.
58 ///
59 /// This contains the actual schema specification in the format indicated by the
60 /// `encoding` field. For text-based schemas (like ROS message definitions or JSON Schema),
61 /// this is typically UTF-8 encoded text. For binary schema formats, this contains
62 /// the serialized schema data.
63 std::optional<ComponentBatch> data;
64
65 public:
66 /// The name of the archetype as used in `ComponentDescriptor`s.
67 static constexpr const char ArchetypeName[] = "rerun.archetypes.McapSchema";
68
69 /// `ComponentDescriptor` for the `id` field.
70 static constexpr auto Descriptor_id = ComponentDescriptor(
72 );
73 /// `ComponentDescriptor` for the `name` field.
74 static constexpr auto Descriptor_name = ComponentDescriptor(
76 );
77 /// `ComponentDescriptor` for the `encoding` field.
80 );
81 /// `ComponentDescriptor` for the `data` field.
82 static constexpr auto Descriptor_data = ComponentDescriptor(
84 );
85
86 public:
87 McapSchema() = default;
88 McapSchema(McapSchema&& other) = default;
89 McapSchema(const McapSchema& other) = default;
90 McapSchema& operator=(const McapSchema& other) = default;
91 McapSchema& operator=(McapSchema&& other) = default;
92
93 explicit McapSchema(
96 )
97 : id(ComponentBatch::from_loggable(std::move(_id), Descriptor_id).value_or_throw()),
98 name(ComponentBatch::from_loggable(std::move(_name), Descriptor_name).value_or_throw()
99 ),
100 encoding(ComponentBatch::from_loggable(std::move(_encoding), Descriptor_encoding)
101 .value_or_throw()),
102 data(ComponentBatch::from_loggable(std::move(_data), Descriptor_data).value_or_throw()
103 ) {}
104
105 /// Update only some specific fields of a `McapSchema`.
107 return McapSchema();
108 }
109
110 /// Clear all the fields of a `McapSchema`.
112
113 /// Unique identifier for this schema within the MCAP file.
114 ///
115 /// Schema IDs must be unique within an MCAP file and are referenced by channels
116 /// to specify their message structure. A single schema can be shared across multiple channels.
118 id = ComponentBatch::from_loggable(_id, Descriptor_id).value_or_throw();
119 return std::move(*this);
120 }
121
122 /// This method makes it possible to pack multiple `id` in a single component batch.
123 ///
124 /// This only makes sense when used in conjunction with `columns`. `with_id` should
125 /// be used when logging a single row's worth of data.
127 id = ComponentBatch::from_loggable(_id, Descriptor_id).value_or_throw();
128 return std::move(*this);
129 }
130
131 /// Human-readable name identifying this schema.
132 ///
133 /// Schema names typically describe the message type or data structure
134 /// (e.g., `"geometry_msgs/msg/Twist"`, `"sensor_msgs/msg/Image"`, `"MyCustomMessage"`).
136 name = ComponentBatch::from_loggable(_name, Descriptor_name).value_or_throw();
137 return std::move(*this);
138 }
139
140 /// This method makes it possible to pack multiple `name` in a single component batch.
141 ///
142 /// This only makes sense when used in conjunction with `columns`. `with_name` should
143 /// be used when logging a single row's worth of data.
145 name = ComponentBatch::from_loggable(_name, Descriptor_name).value_or_throw();
146 return std::move(*this);
147 }
148
149 /// The schema definition format used to describe the message structure.
150 ///
151 /// Common schema encodings include:
152 /// * `protobuf` - [Protocol Buffers](https://mcap.dev/spec/registry#protobuf-1) schema definition
153 /// * `ros1msg` - [ROS1](https://mcap.dev/spec/registry#ros1msg) message definition format
154 /// * `ros2msg` - [ROS2](https://mcap.dev/spec/registry#ros2msg) message definition format
155 /// * `jsonschema` - [JSON Schema](https://mcap.dev/spec/registry#jsonschema) specification
156 /// * `flatbuffer` - [FlatBuffers](https://mcap.dev/spec/registry#flatbuffer) schema definition
158 encoding =
159 ComponentBatch::from_loggable(_encoding, Descriptor_encoding).value_or_throw();
160 return std::move(*this);
161 }
162
163 /// This method makes it possible to pack multiple `encoding` in a single component batch.
164 ///
165 /// This only makes sense when used in conjunction with `columns`. `with_encoding` should
166 /// be used when logging a single row's worth of data.
168 encoding =
169 ComponentBatch::from_loggable(_encoding, Descriptor_encoding).value_or_throw();
170 return std::move(*this);
171 }
172
173 /// The schema definition content as binary data.
174 ///
175 /// This contains the actual schema specification in the format indicated by the
176 /// `encoding` field. For text-based schemas (like ROS message definitions or JSON Schema),
177 /// this is typically UTF-8 encoded text. For binary schema formats, this contains
178 /// the serialized schema data.
180 data = ComponentBatch::from_loggable(_data, Descriptor_data).value_or_throw();
181 return std::move(*this);
182 }
183
184 /// This method makes it possible to pack multiple `data` in a single component batch.
185 ///
186 /// This only makes sense when used in conjunction with `columns`. `with_data` should
187 /// be used when logging a single row's worth of data.
189 data = ComponentBatch::from_loggable(_data, Descriptor_data).value_or_throw();
190 return std::move(*this);
191 }
192
193 /// Partitions the component data into multiple sub-batches.
194 ///
195 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
196 /// instead, via `ComponentBatch::partitioned`.
197 ///
198 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
199 ///
200 /// The specified `lengths` must sum to the total length of the component batch.
202 return detail::partition_batches({&id, &name, &encoding, &data}, lengths_)
203 .value_or_throw();
204 }
205
206 /// Partitions the component data into unit-length sub-batches.
207 ///
208 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
209 /// where `n` is automatically guessed.
211 return detail::partition_batches_of_unit_length({&id, &name, &encoding, &data})
212 .value_or_throw();
213 }
214 };
215
216} // namespace rerun::archetypes
217
218namespace rerun {
219 /// \private
220 template <typename T>
221 struct AsComponents;
222
223 /// \private
224 template <>
225 struct AsComponents<archetypes::McapSchema> {
226 /// Serialize all set component batches.
227 static Result<Collection<ComponentBatch>> as_batches(const archetypes::McapSchema& archetype
228 ) {
229 return detail::collect_batches(
230 {&archetype.id, &archetype.name, &archetype.encoding, &archetype.data}
231 );
232 }
233 };
234} // 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: A schema definition that describes the structure of messages in an MCAP file.
Definition mcap_schema.hpp:34
static constexpr auto Descriptor_encoding
ComponentDescriptor for the encoding field.
Definition mcap_schema.hpp:78
static constexpr auto Descriptor_name
ComponentDescriptor for the name field.
Definition mcap_schema.hpp:74
McapSchema with_many_name(const Collection< rerun::components::Text > &_name) &&
This method makes it possible to pack multiple name in a single component batch.
Definition mcap_schema.hpp:144
static constexpr auto Descriptor_data
ComponentDescriptor for the data field.
Definition mcap_schema.hpp:82
McapSchema with_encoding(const rerun::components::Text &_encoding) &&
The schema definition format used to describe the message structure.
Definition mcap_schema.hpp:157
static constexpr auto Descriptor_id
ComponentDescriptor for the id field.
Definition mcap_schema.hpp:70
std::optional< ComponentBatch > data
The schema definition content as binary data.
Definition mcap_schema.hpp:63
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition mcap_schema.hpp:210
McapSchema with_id(const rerun::components::SchemaId &_id) &&
Unique identifier for this schema within the MCAP file.
Definition mcap_schema.hpp:117
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition mcap_schema.hpp:67
static McapSchema update_fields()
Update only some specific fields of a McapSchema.
Definition mcap_schema.hpp:106
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition mcap_schema.hpp:201
std::optional< ComponentBatch > name
Human-readable name identifying this schema.
Definition mcap_schema.hpp:45
McapSchema with_data(const rerun::components::Blob &_data) &&
The schema definition content as binary data.
Definition mcap_schema.hpp:179
McapSchema with_name(const rerun::components::Text &_name) &&
Human-readable name identifying this schema.
Definition mcap_schema.hpp:135
McapSchema with_many_encoding(const Collection< rerun::components::Text > &_encoding) &&
This method makes it possible to pack multiple encoding in a single component batch.
Definition mcap_schema.hpp:167
static McapSchema clear_fields()
Clear all the fields of a McapSchema.
McapSchema with_many_id(const Collection< rerun::components::SchemaId > &_id) &&
This method makes it possible to pack multiple id in a single component batch.
Definition mcap_schema.hpp:126
McapSchema with_many_data(const Collection< rerun::components::Blob > &_data) &&
This method makes it possible to pack multiple data in a single component batch.
Definition mcap_schema.hpp:188
std::optional< ComponentBatch > encoding
The schema definition format used to describe the message structure.
Definition mcap_schema.hpp:55
std::optional< ComponentBatch > id
Unique identifier for this schema within the MCAP file.
Definition mcap_schema.hpp:39
Component: A binary blob of data.
Definition blob.hpp:16
Component: A 16-bit unique identifier for a schema within the MCAP file.
Definition schema_id.hpp:14
Component: A string of text, e.g. for labels and text documents.
Definition text.hpp:16