VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
intra_data.h 文件参考

Zero-serialisation in-process message container for intra:// transport. 更多...

#include <memory>
#include <string>
#include "../serializer.h"
#include "./types.h"
intra_data.h 的引用(Include)关系图:
此图展示该文件被哪些文件直接或间接地引用了:

浏览该文件的源代码.

 Polymorphic base for all typed in-process message containers. 更多...

命名空间

宏定义

#define VLINK_INTRA_DATA_DECLARE(target_type, declare_name)
 Generates a typed in-process message container pair.

类型定义

using vlink::IntraData = std::shared_ptr<IntraDataType>
 Shared-ownership handle for an IntraDataType payload.

详细描述

Zero-serialisation in-process message container for intra:// transport.

IntraData is the zero-copy message type used exclusively on the intra:// transport, where publisher and subscriber reside in the same process. Instead of serialising a message to Bytes and immediately deserialising it on the other side, a shared_ptr to the payload object is passed directly.

Usage Pattern
The VLINK_INTRA_DATA_DECLARE(target_type, declare_name) macro generates two types for a given VLink message type T:
  • declare_nameType – concrete IntraDataType subclass holding a T value plus serialisation/deserialisation helpers.
  • declare_name – a std::shared_ptr<declare_nameType> wrapper with a static create() factory and implicit conversions from the base shared_ptr.
Example
// Declare once (typically in a generated or per-type header):
VLINK_INTRA_DATA_DECLARE(MyProtoMsg, MyProtoIntra)
// In Publisher:
auto data = MyProtoIntra::create();
data->value.set_field(42);
pub.publish_intra(data); // zero-copy path
// In Subscriber:
sub.listen([](const MyProtoIntra& intra) {
// use typed->value directly
});
#define VLINK_INTRA_DATA_DECLARE(target_type, declare_name)
Generates a typed in-process message container pair.
定义 intra_data.h:123
注解
IntraData messages are only supported on intra:// topics. Attempting to call write(IntraData) on a non-intra PublisherImpl logs a warning and returns false.

宏定义说明

◆ VLINK_INTRA_DATA_DECLARE

#define VLINK_INTRA_DATA_DECLARE ( target_type,
declare_name )

Generates a typed in-process message container pair.

Expands to two declarations:

  1. declare_nameType – a concrete IntraDataType subclass with:
    • target_type value – the message payload.
    • static constexpr Serializer::Type kValueType – compile-time type tag.
    • bool operator<<(const Bytes&) – deserialise Bytes into value.
    • bool operator>>(Bytes&) const – serialise value into Bytes.
    • size_t get_serialized_size() const – byte count needed for serialisation.
    • static std::string get_serialized_type() – type name string.
    • A static_assert ensuring target_type is a supported serialiser type.
  2. declare_name – a std::shared_ptr<declare_nameType> subclass with:
    • Constructors and conversions from the base shared_ptr.
    • static declare_name create() – factory returning a heap-allocated instance.
参数
target_typeThe VLink message type (must be a supported Serializer::Type).
declare_nameThe name to give the generated container types.