VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
intra_data.h File Reference

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

#include <memory>
#include <string>
#include "../serializer.h"
#include "./types.h"
Include dependency graph for intra_data.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

 Polymorphic base for all typed in-process message containers. More...

Namespaces

Macros

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

Typedefs

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

Detailed Description

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.
Definition intra_data.h:123
Note
IntraData messages are only supported on intra:// topics. Attempting to call write(IntraData) on a non-intra PublisherImpl logs a warning and returns false.

Macro Definition Documentation

◆ 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.
Parameters
target_typeThe VLink message type (must be a supported Serializer::Type).
declare_nameThe name to give the generated container types.