109 template <u
int8_t SizeT,
typename T>
123 template <
typename T>
136 template <
typename T>
137 [[nodiscard]] T
as()
const;
155 [[nodiscard]]
const std::string_view&
get_type()
const;
198 [[nodiscard]]
static constexpr uint8_t
get_offset();
217 static constexpr uint8_t kOffset{20};
219 std::string_view type_;
226template <u
int8_t SizeT,
typename T>
228 static_assert(SizeT <
get_offset(),
"DynamicData name out of size.");
229 static_assert(!std::is_same_v<DynamicData, T>,
"DynamicData can not serialize self.");
235 VLOG_F(
"DynamicData serialize failed.");
238 if constexpr (SizeT > 0) {
239 std::memcpy(data_.real_data(), type, SizeT);
240 type_ = std::string_view(
reinterpret_cast<const char*
>(data_.real_data()), SizeT);
242 type_ = std::string_view();
250 static_assert(!std::is_same_v<DynamicData, T>,
"DynamicData can not deserialize self.");
265 t = std::make_shared<typename T::element_type>();
269 VLOG_F(
"DynamicData deserialize failed.");
Versatile 128-byte byte buffer with SBO, five ownership modes and compression helpers.
Definition bytes.h:113
bool operator>>(Bytes &bytes) const noexcept
Serializes this DynamicData to a wire-format Bytes blob.
const std::string_view & get_type() const
Returns the type name string embedded in the buffer.
bool operator==(const DynamicData &target) const
Returns true if both DynamicData objects have identical buffers.
static constexpr uint8_t get_offset()
Returns the byte offset where the serialized payload begins.
Definition dynamic_data.h:278
const Bytes & get_data() const
Returns a const reference to the raw serialized bytes (including type tag).
bool operator!=(const DynamicData &target) const
Returns true if the objects differ.
T as() const
Deserializes the internal buffer and returns the result by value.
Definition dynamic_data.h:261
bool is_empty() const
Returns true if no payload has been loaded.
DynamicData & load(const char(&type)[SizeT], const T &t)
Serializes t with a type-name tag into the internal buffer.
Definition dynamic_data.h:227
bool convert(T &t) const
Deserializes the internal buffer into t.
Definition dynamic_data.h:249
DynamicData()
Constructs an empty DynamicData with no payload.
bool operator<<(const Bytes &bytes) noexcept
Deserializes a wire-format Bytes blob into this DynamicData.
static constexpr bool is_vlink_dynamic_data()
Compile-time trait marker – returns true to identify this as a DynamicData type.
Definition dynamic_data.h:276
#define VLOG_F(...)
Definition logger.h:856
#define VUNLIKELY(...)
Shorthand alias for VLINK_UNLIKELY. Hints that the expression is unlikely true.
Definition macros.h:302
#define VLINK_EXPORT
Definition macros.h:85
bool deserialize(const Bytes &src, T &des, TransportType transport)
Deserializes src bytes into des with explicit type and transport hints.
Definition serializer-inl.h:488
constexpr bool is_cdr_type() noexcept
Returns true if T is a FastDDS CDR-serialisable type.
Definition serializer-inl.h:648
bool serialize(const T &src, Bytes &des, TransportType transport, uint8_t offset)
Serializes src into des with explicit type and transport hints.
Definition serializer-inl.h:355
@ kUnknown
Unknown or unsupported transport.
Definition types.h:108
Compile-time type-detection and serialisation utilities for VLink messages.
Detects whether type T is a std::shared_ptr specialization.
Definition traits.h:224