Rerun C++ SDK
Loading...
Searching...
No Matches
mcap_channel.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_channel.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/channel_id.hpp"
10#include "../components/key_value_pairs.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 channel within an MCAP file that defines how messages are structured and encoded.
21 ///
22 /// Channels in MCAP files group messages by topic and define their encoding format.
23 /// Each channel has a unique identifier and specifies the message schema and encoding used
24 /// for all messages published to that topic.
25 ///
26 /// See also `archetypes::McapMessage` for individual messages within a channel,
27 /// `archetypes::McapSchema` for the data structure definitions, and the
28 /// [MCAP specification](https://mcap.dev/) for complete format details.
29 ///
30 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
31 ///
32 struct McapChannel {
33 /// Unique identifier for this channel within the MCAP file.
34 ///
35 /// Channel IDs must be unique within a single MCAP file and are used to associate
36 /// messages with their corresponding channel definition.
37 std::optional<ComponentBatch> id;
38
39 /// The topic name that this channel publishes to.
40 ///
41 /// Topics are hierarchical paths from the original robotics system (e.g., "/sensors/camera/image")
42 /// that categorize and organize different data streams.
43 /// Topics are separate from Rerun's entity paths, but they often can be mapped to them.
44 std::optional<ComponentBatch> topic;
45
46 /// The encoding format used for messages in this channel.
47 ///
48 /// Common encodings include:
49 /// * `ros1` - ROS1 message format
50 /// * `cdr` - Common Data Representation (CDR) message format, used by ROS2
51 /// * `protobuf` - Protocol Buffers
52 /// * `json` - JSON encoding
53 std::optional<ComponentBatch> message_encoding;
54
55 /// Additional metadata for this channel stored as key-value pairs.
56 ///
57 /// This can include channel-specific configuration, description, units, coordinate frames,
58 /// or any other contextual information that helps interpret the data in this channel.
59 std::optional<ComponentBatch> metadata;
60
61 public:
62 /// The name of the archetype as used in `ComponentDescriptor`s.
63 static constexpr const char ArchetypeName[] = "rerun.archetypes.McapChannel";
64
65 /// `ComponentDescriptor` for the `id` field.
66 static constexpr auto Descriptor_id = ComponentDescriptor(
68 );
69 /// `ComponentDescriptor` for the `topic` field.
70 static constexpr auto Descriptor_topic = ComponentDescriptor(
72 );
73 /// `ComponentDescriptor` for the `message_encoding` field.
75 ArchetypeName, "McapChannel:message_encoding",
77 );
78 /// `ComponentDescriptor` for the `metadata` field.
80 ArchetypeName, "McapChannel:metadata",
82 );
83
84 public:
85 McapChannel() = default;
86 McapChannel(McapChannel&& other) = default;
87 McapChannel(const McapChannel& other) = default;
88 McapChannel& operator=(const McapChannel& other) = default;
89 McapChannel& operator=(McapChannel&& other) = default;
90
91 explicit McapChannel(
93 rerun::components::Text _message_encoding
94 )
95 : id(ComponentBatch::from_loggable(std::move(_id), Descriptor_id).value_or_throw()),
96 topic(ComponentBatch::from_loggable(std::move(_topic), Descriptor_topic)
97 .value_or_throw()),
98 message_encoding(ComponentBatch::from_loggable(
99 std::move(_message_encoding), Descriptor_message_encoding
100 )
101 .value_or_throw()) {}
102
103 /// Update only some specific fields of a `McapChannel`.
105 return McapChannel();
106 }
107
108 /// Clear all the fields of a `McapChannel`.
110
111 /// Unique identifier for this channel within the MCAP file.
112 ///
113 /// Channel IDs must be unique within a single MCAP file and are used to associate
114 /// messages with their corresponding channel definition.
116 id = ComponentBatch::from_loggable(_id, Descriptor_id).value_or_throw();
117 return std::move(*this);
118 }
119
120 /// This method makes it possible to pack multiple `id` in a single component batch.
121 ///
122 /// This only makes sense when used in conjunction with `columns`. `with_id` should
123 /// be used when logging a single row's worth of data.
125 id = ComponentBatch::from_loggable(_id, Descriptor_id).value_or_throw();
126 return std::move(*this);
127 }
128
129 /// The topic name that this channel publishes to.
130 ///
131 /// Topics are hierarchical paths from the original robotics system (e.g., "/sensors/camera/image")
132 /// that categorize and organize different data streams.
133 /// Topics are separate from Rerun's entity paths, but they often can be mapped to them.
135 topic = ComponentBatch::from_loggable(_topic, Descriptor_topic).value_or_throw();
136 return std::move(*this);
137 }
138
139 /// This method makes it possible to pack multiple `topic` in a single component batch.
140 ///
141 /// This only makes sense when used in conjunction with `columns`. `with_topic` should
142 /// be used when logging a single row's worth of data.
144 topic = ComponentBatch::from_loggable(_topic, Descriptor_topic).value_or_throw();
145 return std::move(*this);
146 }
147
148 /// The encoding format used for messages in this channel.
149 ///
150 /// Common encodings include:
151 /// * `ros1` - ROS1 message format
152 /// * `cdr` - Common Data Representation (CDR) message format, used by ROS2
153 /// * `protobuf` - Protocol Buffers
154 /// * `json` - JSON encoding
158 .value_or_throw();
159 return std::move(*this);
160 }
161
162 /// This method makes it possible to pack multiple `message_encoding` in a single component batch.
163 ///
164 /// This only makes sense when used in conjunction with `columns`. `with_message_encoding` should
165 /// be used when logging a single row's worth of data.
167 const Collection<rerun::components::Text>& _message_encoding
168 ) && {
171 .value_or_throw();
172 return std::move(*this);
173 }
174
175 /// Additional metadata for this channel stored as key-value pairs.
176 ///
177 /// This can include channel-specific configuration, description, units, coordinate frames,
178 /// or any other contextual information that helps interpret the data in this channel.
180 metadata =
181 ComponentBatch::from_loggable(_metadata, Descriptor_metadata).value_or_throw();
182 return std::move(*this);
183 }
184
185 /// This method makes it possible to pack multiple `metadata` in a single component batch.
186 ///
187 /// This only makes sense when used in conjunction with `columns`. `with_metadata` should
188 /// be used when logging a single row's worth of data.
190 ) && {
191 metadata =
192 ComponentBatch::from_loggable(_metadata, Descriptor_metadata).value_or_throw();
193 return std::move(*this);
194 }
195
196 /// Partitions the component data into multiple sub-batches.
197 ///
198 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
199 /// instead, via `ComponentBatch::partitioned`.
200 ///
201 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
202 ///
203 /// The specified `lengths` must sum to the total length of the component batch.
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 };
212
213} // namespace rerun::archetypes
214
215namespace rerun {
216 /// \private
217 template <typename T>
218 struct AsComponents;
219
220 /// \private
221 template <>
222 struct AsComponents<archetypes::McapChannel> {
223 /// Serialize all set component batches.
224 static Result<Collection<ComponentBatch>> as_batches(
225 const archetypes::McapChannel& archetype
226 );
227 };
228} // 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 channel within an MCAP file that defines how messages are structured and encoded.
Definition mcap_channel.hpp:32
McapChannel with_many_id(const Collection< rerun::components::ChannelId > &_id) &&
This method makes it possible to pack multiple id in a single component batch.
Definition mcap_channel.hpp:124
McapChannel with_many_metadata(const Collection< rerun::components::KeyValuePairs > &_metadata) &&
This method makes it possible to pack multiple metadata in a single component batch.
Definition mcap_channel.hpp:189
McapChannel with_topic(const rerun::components::Text &_topic) &&
The topic name that this channel publishes to.
Definition mcap_channel.hpp:134
McapChannel with_many_message_encoding(const Collection< rerun::components::Text > &_message_encoding) &&
This method makes it possible to pack multiple message_encoding in a single component batch.
Definition mcap_channel.hpp:166
static McapChannel clear_fields()
Clear all the fields of a McapChannel.
McapChannel with_message_encoding(const rerun::components::Text &_message_encoding) &&
The encoding format used for messages in this channel.
Definition mcap_channel.hpp:155
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition mcap_channel.hpp:63
McapChannel with_metadata(const rerun::components::KeyValuePairs &_metadata) &&
Additional metadata for this channel stored as key-value pairs.
Definition mcap_channel.hpp:179
McapChannel with_many_topic(const Collection< rerun::components::Text > &_topic) &&
This method makes it possible to pack multiple topic in a single component batch.
Definition mcap_channel.hpp:143
std::optional< ComponentBatch > metadata
Additional metadata for this channel stored as key-value pairs.
Definition mcap_channel.hpp:59
static McapChannel update_fields()
Update only some specific fields of a McapChannel.
Definition mcap_channel.hpp:104
static constexpr auto Descriptor_message_encoding
ComponentDescriptor for the message_encoding field.
Definition mcap_channel.hpp:74
std::optional< ComponentBatch > id
Unique identifier for this channel within the MCAP file.
Definition mcap_channel.hpp:37
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
static constexpr auto Descriptor_topic
ComponentDescriptor for the topic field.
Definition mcap_channel.hpp:70
static constexpr auto Descriptor_id
ComponentDescriptor for the id field.
Definition mcap_channel.hpp:66
std::optional< ComponentBatch > message_encoding
The encoding format used for messages in this channel.
Definition mcap_channel.hpp:53
static constexpr auto Descriptor_metadata
ComponentDescriptor for the metadata field.
Definition mcap_channel.hpp:79
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
McapChannel with_id(const rerun::components::ChannelId &_id) &&
Unique identifier for this channel within the MCAP file.
Definition mcap_channel.hpp:115
std::optional< ComponentBatch > topic
The topic name that this channel publishes to.
Definition mcap_channel.hpp:44
Component: A 16-bit ID representing an MCAP channel.
Definition channel_id.hpp:16
Component: A map of string keys to string values.
Definition key_value_pairs.hpp:28
Component: A string of text, e.g. for labels and text documents.
Definition text.hpp:16