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/build/re_type_definitions/rerun/archetypes/mcap_channel.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/channel_id.hpp"
11#include "../components/key_value_pairs.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 channel within an MCAP file that defines how messages are structured and encoded.
22 ///
23 /// Channels in MCAP files group messages by topic and define their encoding format.
24 /// Each channel has a unique identifier and specifies the message schema and encoding used
25 /// for all messages published to that topic.
26 ///
27 /// See also `archetypes::McapMessage` for individual messages within a channel,
28 /// `archetypes::McapSchema` for the data structure definitions, 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 McapChannel {
34 /// Unique identifier for this channel within the MCAP file.
35 ///
36 /// Channel IDs must be unique within a single MCAP file and are used to associate
37 /// messages with their corresponding channel definition.
38 std::optional<ComponentBatch> id;
39
40 /// The topic name that this channel publishes to.
41 ///
42 /// Topics are hierarchical paths from the original robotics system (e.g., "/sensors/camera/image")
43 /// that categorize and organize different data streams.
44 /// Topics are separate from Rerun's entity paths, but they often can be mapped to them.
45 std::optional<ComponentBatch> topic;
46
47 /// The encoding format used for messages in this channel.
48 ///
49 /// Common encodings include:
50 /// * `ros1` - ROS1 message format
51 /// * `cdr` - Common Data Representation (CDR) message format, used by ROS2
52 /// * `protobuf` - Protocol Buffers
53 /// * `json` - JSON encoding
54 std::optional<ComponentBatch> message_encoding;
55
56 /// Additional metadata for this channel stored as key-value pairs.
57 ///
58 /// This can include channel-specific configuration, description, units, coordinate frames,
59 /// or any other contextual information that helps interpret the data in this channel.
60 std::optional<ComponentBatch> metadata;
61
62 public:
63 /// The name of the archetype as used in `ComponentDescriptor`s.
64 static constexpr const char ArchetypeName[] = "rerun.archetypes.McapChannel";
65
66 /// `ComponentDescriptor` for the `id` field.
67 static constexpr auto Descriptor_id = ComponentDescriptor(
69 );
70 /// `ComponentDescriptor` for the `topic` field.
71 static constexpr auto Descriptor_topic = ComponentDescriptor(
73 );
74 /// `ComponentDescriptor` for the `message_encoding` field.
76 ArchetypeName, "McapChannel:message_encoding",
78 );
79 /// `ComponentDescriptor` for the `metadata` field.
81 ArchetypeName, "McapChannel:metadata",
83 );
84
85 public:
86 McapChannel() = default;
87 McapChannel(McapChannel&& other) = default;
88 McapChannel(const McapChannel& other) = default;
89 McapChannel& operator=(const McapChannel& other) = default;
90 McapChannel& operator=(McapChannel&& other) = default;
91
92 explicit McapChannel(
94 rerun::components::Text _message_encoding
95 )
96 : id(ComponentBatch::from_loggable(std::move(_id), Descriptor_id).value_or_throw()),
97 topic(ComponentBatch::from_loggable(std::move(_topic), Descriptor_topic)
98 .value_or_throw()),
99 message_encoding(ComponentBatch::from_loggable(
100 std::move(_message_encoding), Descriptor_message_encoding
101 )
102 .value_or_throw()) {}
103
104 /// Update only some specific fields of a `McapChannel`.
106 return McapChannel();
107 }
108
109 /// Clear all the fields of a `McapChannel`.
111
112 /// Unique identifier for this channel within the MCAP file.
113 ///
114 /// Channel IDs must be unique within a single MCAP file and are used to associate
115 /// messages with their corresponding channel definition.
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 /// The topic name that this channel publishes to.
131 ///
132 /// Topics are hierarchical paths from the original robotics system (e.g., "/sensors/camera/image")
133 /// that categorize and organize different data streams.
134 /// Topics are separate from Rerun's entity paths, but they often can be mapped to them.
136 topic = ComponentBatch::from_loggable(_topic, Descriptor_topic).value_or_throw();
137 return std::move(*this);
138 }
139
140 /// This method makes it possible to pack multiple `topic` in a single component batch.
141 ///
142 /// This only makes sense when used in conjunction with `columns`. `with_topic` should
143 /// be used when logging a single row's worth of data.
145 topic = ComponentBatch::from_loggable(_topic, Descriptor_topic).value_or_throw();
146 return std::move(*this);
147 }
148
149 /// The encoding format used for messages in this channel.
150 ///
151 /// Common encodings include:
152 /// * `ros1` - ROS1 message format
153 /// * `cdr` - Common Data Representation (CDR) message format, used by ROS2
154 /// * `protobuf` - Protocol Buffers
155 /// * `json` - JSON encoding
159 .value_or_throw();
160 return std::move(*this);
161 }
162
163 /// This method makes it possible to pack multiple `message_encoding` in a single component batch.
164 ///
165 /// This only makes sense when used in conjunction with `columns`. `with_message_encoding` should
166 /// be used when logging a single row's worth of data.
168 const Collection<rerun::components::Text>& _message_encoding
169 ) && {
172 .value_or_throw();
173 return std::move(*this);
174 }
175
176 /// Additional metadata for this channel stored as key-value pairs.
177 ///
178 /// This can include channel-specific configuration, description, units, coordinate frames,
179 /// or any other contextual information that helps interpret the data in this channel.
181 metadata =
182 ComponentBatch::from_loggable(_metadata, Descriptor_metadata).value_or_throw();
183 return std::move(*this);
184 }
185
186 /// This method makes it possible to pack multiple `metadata` in a single component batch.
187 ///
188 /// This only makes sense when used in conjunction with `columns`. `with_metadata` should
189 /// be used when logging a single row's worth of data.
191 ) && {
192 metadata =
193 ComponentBatch::from_loggable(_metadata, Descriptor_metadata).value_or_throw();
194 return std::move(*this);
195 }
196
197 /// Partitions the component data into multiple sub-batches.
198 ///
199 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
200 /// instead, via `ComponentBatch::partitioned`.
201 ///
202 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
203 ///
204 /// The specified `lengths` must sum to the total length of the component batch.
206 return detail::partition_batches({&id, &topic, &message_encoding, &metadata}, lengths_)
207 .value_or_throw();
208 }
209
210 /// Partitions the component data into unit-length sub-batches.
211 ///
212 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
213 /// where `n` is automatically guessed.
215 return detail::partition_batches_of_unit_length(
217 )
218 .value_or_throw();
219 }
220 };
221
222} // namespace rerun::archetypes
223
224namespace rerun {
225 /// \private
226 template <typename T>
227 struct AsComponents;
228
229 /// \private
230 template <>
231 struct AsComponents<archetypes::McapChannel> {
232 /// Serialize all set component batches.
233 static Result<Collection<ComponentBatch>> as_batches(
234 const archetypes::McapChannel& archetype
235 ) {
236 return detail::collect_batches(
237 {&archetype.id, &archetype.topic, &archetype.message_encoding, &archetype.metadata}
238 );
239 }
240 };
241} // 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 channel within an MCAP file that defines how messages are structured and encoded.
Definition mcap_channel.hpp:33
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:125
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:190
McapChannel with_topic(const rerun::components::Text &_topic) &&
The topic name that this channel publishes to.
Definition mcap_channel.hpp:135
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:167
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:156
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition mcap_channel.hpp:64
McapChannel with_metadata(const rerun::components::KeyValuePairs &_metadata) &&
Additional metadata for this channel stored as key-value pairs.
Definition mcap_channel.hpp:180
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:144
std::optional< ComponentBatch > metadata
Additional metadata for this channel stored as key-value pairs.
Definition mcap_channel.hpp:60
static McapChannel update_fields()
Update only some specific fields of a McapChannel.
Definition mcap_channel.hpp:105
static constexpr auto Descriptor_message_encoding
ComponentDescriptor for the message_encoding field.
Definition mcap_channel.hpp:75
std::optional< ComponentBatch > id
Unique identifier for this channel within the MCAP file.
Definition mcap_channel.hpp:38
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition mcap_channel.hpp:214
static constexpr auto Descriptor_topic
ComponentDescriptor for the topic field.
Definition mcap_channel.hpp:71
static constexpr auto Descriptor_id
ComponentDescriptor for the id field.
Definition mcap_channel.hpp:67
std::optional< ComponentBatch > message_encoding
The encoding format used for messages in this channel.
Definition mcap_channel.hpp:54
static constexpr auto Descriptor_metadata
ComponentDescriptor for the metadata field.
Definition mcap_channel.hpp:80
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition mcap_channel.hpp:205
McapChannel with_id(const rerun::components::ChannelId &_id) &&
Unique identifier for this channel within the MCAP file.
Definition mcap_channel.hpp:116
std::optional< ComponentBatch > topic
The topic name that this channel publishes to.
Definition mcap_channel.hpp:45
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