VLink  2.0.0
A high-performance communication middleware
intra_data.h 文件参考

Reference-counted in-process payload type used by the intra:// backend. 更多...

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

浏览源代码.

struct  vlink::IntraDataType
 Polymorphic base of every in-process payload container. 更多...
 

命名空间

 

宏定义

#define VLINK_INTRA_DATA_DECLARE(target_type, declare_name)
 Emits a typed in-process container pair around an arbitrary message type. 更多...
 

类型定义

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

详细描述

Reference-counted in-process payload type used by the intra:// backend.

This is an internal implementation header used by the public publisher and subscriber templates when they target the intra:// transport; it should not be included directly by application code. IntraData is the shared-ownership vehicle that lets a co-located publisher and subscriber exchange a message by pointer instead of going through a full serialise / deserialise round trip.

In-process hand-off
Publisher thread Subscriber thread
---------------- ------------------
data = MyMsgIntra::create() shared_ptr -> queue
data->value = ... ^
pub.publish(data) ---------------------+
v
sub.listen()
|
v
use data->value directly
IntraDataType contract
Concrete subtypes emitted by VLINK_INTRA_DATA_DECLARE add:
  • A typed value member carrying the user payload.
  • operator<< and operator>> for on-demand serialisation when the message has to be replicated across a non-intra boundary (e.g. recording).
  • get_serialized_size(), get_serialized_type() and get_schema_type() helpers shared with the public Serializer API.
Example
// 1. Declare the generated container pair next to the message type:
VLINK_INTRA_DATA_DECLARE(MyProtoMsg, MyProtoIntra)
// 2. Publish (zero-copy path):
auto data = MyProtoIntra::create();
data->value.set_field(42);
pub.publish(data);
// 3. Subscribe (zero-copy path):
sub.listen([](const MyProtoIntra& intra) {
process(intra->value);
});
#define VLINK_INTRA_DATA_DECLARE(target_type, declare_name)
Emits a typed in-process container pair around an arbitrary message type.
Definition: intra_data.h:143
注解
Only the intra:// transport understands IntraData; calling write(IntraData) on any other publisher backend logs a warning and returns false.

宏定义说明

◆ VLINK_INTRA_DATA_DECLARE

#define VLINK_INTRA_DATA_DECLARE (   target_type,
  declare_name 
)

Emits a typed in-process container pair around an arbitrary message type.

Expansion produces:

  1. declare_name##Type – a concrete IntraDataType subclass with:
    • target_type value member.
    • static constexpr kValueType matching Serializer::get_type_of<>.
    • operator<<(const Bytes&) deserialising into value.
    • operator>>(Bytes&) serialising from value.
    • get_serialized_size(), get_serialized_type() and get_schema_type() helpers consistent with the public serializer API.
    • A static_assert ensuring target_type is a supported serializer type.
  2. declare_name – a std::shared_ptr<declare_name##Type> wrapper with constructors that accept the underlying shared_ptr and a static create() factory that allocates a fresh instance.

The static get_serialized_type() returns an empty string for raw Bytes instantiations by design; this matches the contract documented in serializer.h.

参数
target_typeUser message type, must satisfy Serializer::is_supported.
declare_nameIdentifier prefix for the generated container types.