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