20struct Topic::PackedDataHeader
23 uint8_t data_len_raw[3];
25 uint32_t topic_name_crc32;
27 uint8_t timestamp_us_raw[6];
30 uint8_t pack_header_crc8;
36 void SetDataLen(uint32_t len);
42 uint32_t GetDataLen()
const;
48 void SetTimestamp(MicrosecondTimestamp timestamp);
54 MicrosecondTimestamp GetTimestamp()
const;
57static_assert(
sizeof(Topic::PackedDataHeader) == 16);
58static_assert(offsetof(Topic::PackedDataHeader, prefix) == 0);
59static_assert(offsetof(Topic::PackedDataHeader, data_len_raw) == 1);
60static_assert(offsetof(Topic::PackedDataHeader, topic_name_crc32) == 4);
61static_assert(offsetof(Topic::PackedDataHeader, timestamp_us_raw) == 8);
62static_assert(offsetof(Topic::PackedDataHeader, version) == 14);
63static_assert(offsetof(Topic::PackedDataHeader, pack_header_crc8) == 15);
74template <
typename Data>
75class Topic::PackedData
77 static_assert(TopicPayload<Data>);
86 PackedDataHeader header_;
87 uint8_t data_[
sizeof(Data)];
97 MicrosecondTimestamp GetTimestamp()
const {
return raw.header_.GetTimestamp(); }
111template <
typename Data>
116 ASSERT(block_ !=
nullptr);
118 ASSERT(block_->
data_.payload_size ==
sizeof(Data));
只读原始数据视图 / Immutable raw data view
微秒时间戳 / Microsecond timestamp
Data data_
存储的数据 / Stored data.
可写原始数据视图 / Mutable raw data view
ErrorCode PackData(const Data &data, PackedData< Data > &packet)
将一个精确类型消息打包成 packet / Pack one exact-typed message into one packet using the topic's runtime contract...
static ID GetID()
获取类型的唯一标识符 / Get a unique identifier for type T
LibXR 命名空间 / LibXR namespace.
ErrorCode
定义错误码枚举 / Defines an enumeration for error codes
@ OK
操作成功 / Operation successful
constexpr void CheckTopicPayload()
在模板上下文里断言 payload 类型满足 topic 契约 / Assert in template context that one payload type satisfies the topi...