|
VLink
2.1.0
A high-performance communication middleware
|
Compile-time codec dispatch for VLink message payloads. 更多...
#include <string>#include "./base/bytes.h"#include "./impl/types.h"#include "./internal/serializer-inl.h"命名空间 | |
| vlink | |
| Serializer | |
| Compile-time codec detection and dispatch for VLink message payloads. | |
| vlink::Serializer | |
枚举 | |
| enum | vlink::Serializer::Type : uint8_t { vlink::Serializer::kUnknownType = 0 , vlink::Serializer::kBytesType = 1 , vlink::Serializer::kDynamicType = 2 , vlink::Serializer::kCustomType = 3 , vlink::Serializer::kCdrType = 4 , vlink::Serializer::kProtoType = 5 , vlink::Serializer::kProtoPtrType = 6 , vlink::Serializer::kFlatTableType = 7 , vlink::Serializer::kFlatPtrType = 8 , vlink::Serializer::kFlatBuilderType = 9 , vlink::Serializer::kStringType = 10 , vlink::Serializer::kCharsType = 11 , vlink::Serializer::kStreamType = 12 , vlink::Serializer::kStandardType = 13 , vlink::Serializer::kStandardPtrType = 14 } |
| Identifies the codec to use for a given C++ message type. 更多... | |
函数 | |
| constexpr bool | vlink::Serializer::is_supported (Type type) noexcept |
Reports whether type identifies a usable codec. 更多... | |
Compile-time codec dispatch for VLink message payloads.
The Serializer namespace is the codec router used by every VLink primitive. Given a C++ type T it determines, at compile time, which encoding family applies (raw bytes, Protobuf, FlatBuffers, FastDDS CDR, standard-layout POD, etc.) and dispatches serialize() / deserialize() to the appropriate code path with zero runtime cost.
Application code rarely calls these helpers directly; Publisher, Subscriber, Client, Server, Setter, and Getter call them internally as part of their publish() / listen() / invoke() / set() / get() implementations.
Serializer::Type Enum| Constant | C++ criterion | Trait | Notes |
|---|---|---|---|
kBytesType | T is Bytes | is_bytes_type | Pass-through. |
kDynamicType | Has is_vlink_dynamic_data() | is_dynamic_type | Dynamic data. |
kCdrType | FastDDS IDL or ROS 2 type | is_cdr_type | CDR bytes. |
kProtoType | Protobuf-like value | is_proto_type | Protobuf value. |
kProtoPtrType | Protobuf-like pointer | is_proto_ptr_type | Caller-owned. |
kFlatTableType | FlatBuffers NativeTable | is_flat_table_type | Object API. |
kFlatPtrType | Pointer to flatbuffers::Table | is_flat_ptr_type | Zero-copy view. |
kFlatBuilderType | Has fbb_ and Finish() | is_flat_builder_type | Builder. |
kCustomType | Has operator>>/<<(Bytes&) | is_custom_type | Custom codec. |
kStringType | T is std::string | is_string_type | Byte string. |
kCharsType | Character pointer or array | is_chars_type | Serialise only. |
kStreamType | Supports std::stringstream | is_stream_type | Fallback. |
kStandardType | Trivial standard-layout value | is_standard_type | Byte copy. |
kStandardPtrType | Pointer to trivial standard type | is_standard_ptr_type | Zero-copy pointer. |
Most value-like detectors unwrap std::shared_ptr<T> before matching (e.g. Protobuf values, CDR values, FlatBuffers native tables, custom codecs, strings, stream types, and standard-layout values).
* get_type_of<T>() probes traits in this fixed order; first match wins: * * Bytes --(no)--> Dynamic --(no)--> CDR --(no)--> Proto * | * v (no) * FlatPtr <--(no)-- FlatTable <--(no)-- ProtoPtr <--(no)--+ * | * v (no) * FlatBuilder --(no)--> Custom --(no)--> String --(no)--> Chars * | * v (no) * Stream <--(no)-- StandardPtr <--(no)-- Standard <--(no)----+ * | * v (no) * kUnknownType *
T: static or inline where appropriate.