Rerun C++ SDK
Loading...
Searching...
No Matches
mcap_message.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_message.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 "../result.hpp"
12
13#include <cstdint>
14#include <optional>
15#include <utility>
16#include <vector>
17
18namespace rerun::archetypes {
19 /// **Archetype**: The binary payload of a single MCAP message, without metadata.
20 ///
21 /// This archetype represents only the raw message data from an MCAP file. It does not include
22 /// MCAP message metadata such as timestamps, channel IDs, sequence numbers, or publication times.
23 /// The binary payload represents sensor data, commands, or other information encoded according
24 /// to the format specified by the associated channel.
25 ///
26 /// See `archetypes::McapChannel` for channel definitions that specify message encoding,
27 /// `archetypes::McapSchema` for 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 McapMessage {
33 /// The raw message payload as a binary blob.
34 ///
35 /// This contains the actual message data encoded according to the format specified
36 /// by the associated channel's `message_encoding` field. The structure and interpretation
37 /// of this binary data depends on the encoding format (e.g., ros1, cdr, protobuf)
38 /// and the message schema defined for the channel.
39 std::optional<ComponentBatch> data;
40
41 public:
42 /// The name of the archetype as used in `ComponentDescriptor`s.
43 static constexpr const char ArchetypeName[] = "rerun.archetypes.McapMessage";
44
45 /// `ComponentDescriptor` for the `data` field.
46 static constexpr auto Descriptor_data = ComponentDescriptor(
48 );
49
50 public:
51 McapMessage() = default;
52 McapMessage(McapMessage&& other) = default;
53 McapMessage(const McapMessage& other) = default;
54 McapMessage& operator=(const McapMessage& other) = default;
55 McapMessage& operator=(McapMessage&& other) = default;
56
58 : data(ComponentBatch::from_loggable(std::move(_data), Descriptor_data).value_or_throw()
59 ) {}
60
61 /// Update only some specific fields of a `McapMessage`.
63 return McapMessage();
64 }
65
66 /// Clear all the fields of a `McapMessage`.
68
69 /// The raw message payload as a binary blob.
70 ///
71 /// This contains the actual message data encoded according to the format specified
72 /// by the associated channel's `message_encoding` field. The structure and interpretation
73 /// of this binary data depends on the encoding format (e.g., ros1, cdr, protobuf)
74 /// and the message schema defined for the channel.
76 data = ComponentBatch::from_loggable(_data, Descriptor_data).value_or_throw();
77 return std::move(*this);
78 }
79
80 /// This method makes it possible to pack multiple `data` in a single component batch.
81 ///
82 /// This only makes sense when used in conjunction with `columns`. `with_data` should
83 /// be used when logging a single row's worth of data.
85 data = ComponentBatch::from_loggable(_data, Descriptor_data).value_or_throw();
86 return std::move(*this);
87 }
88
89 /// Partitions the component data into multiple sub-batches.
90 ///
91 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
92 /// instead, via `ComponentBatch::partitioned`.
93 ///
94 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
95 ///
96 /// The specified `lengths` must sum to the total length of the component batch.
98 return detail::partition_batches({&data}, lengths_).value_or_throw();
99 }
100
101 /// Partitions the component data into unit-length sub-batches.
102 ///
103 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
104 /// where `n` is automatically guessed.
106 return detail::partition_batches_of_unit_length({&data}).value_or_throw();
107 }
108 };
109
110} // namespace rerun::archetypes
111
112namespace rerun {
113 /// \private
114 template <typename T>
115 struct AsComponents;
116
117 /// \private
118 template <>
119 struct AsComponents<archetypes::McapMessage> {
120 /// Serialize all set component batches.
121 static Result<Collection<ComponentBatch>> as_batches(
122 const archetypes::McapMessage& archetype
123 ) {
124 return detail::collect_batches({&archetype.data});
125 }
126 };
127} // 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: The binary payload of a single MCAP message, without metadata.
Definition mcap_message.hpp:32
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition mcap_message.hpp:43
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition mcap_message.hpp:97
McapMessage 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_message.hpp:84
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition mcap_message.hpp:105
McapMessage with_data(const rerun::components::Blob &_data) &&
The raw message payload as a binary blob.
Definition mcap_message.hpp:75
std::optional< ComponentBatch > data
The raw message payload as a binary blob.
Definition mcap_message.hpp:39
static McapMessage clear_fields()
Clear all the fields of a McapMessage.
static McapMessage update_fields()
Update only some specific fields of a McapMessage.
Definition mcap_message.hpp:62
static constexpr auto Descriptor_data
ComponentDescriptor for the data field.
Definition mcap_message.hpp:46
Component: A binary blob of data.
Definition blob.hpp:16