|
VLink
2.1.0
A high-performance communication middleware
|
Read-side primitive of the VLink event communication model. 更多...
#include <memory>#include <string>#include <type_traits>#include "./base/functional.h"#include "./impl/subscriber_impl.h"#include "./node.h"#include "./internal/subscriber-inl.h"类 | |
| class | vlink::Subscriber< MsgT, SecT > |
| Type-safe topic listener for the VLink event communication model. 更多... | |
| class | vlink::SecuritySubscriber< MsgT > |
Convenience alias of Subscriber with per-message decryption enabled. 更多... | |
命名空间 | |
| vlink | |
Read-side primitive of the VLink event communication model.
Subscriber<MsgT, SecT> attaches a callback to a VLink topic. Each frame delivered by the transport back-end is deserialised into a MsgT instance and forwarded to the user callback registered via listen(). Unlike Getter, the subscriber retains no value history – it simply forwards every event in delivery order.
The class is a thin, header-only template wrapper around SubscriberImpl. Codec dispatch is fully resolved at compile time using the type detected by Serializer::get_type_of<MsgT>().
* Transport Back-end Subscriber<MsgT> * ------------------ ----------------- * | inbound frame | * |--------------------------------------> | * | | Serializer::deserialize * | | (per-delivery local value) * | | * | | optional MessageLoop hop * | | * | v * | user callback(const MsgT&) *
| Category | Example C++ Type | Serializer::Type | Notes |
|---|---|---|---|
| Raw bytes | Bytes | kBytesType | Pass-through to callback. |
| Protobuf value | MyProto | kProtoType | ParseFromArray path. |
| Protobuf pointer | MyProto* | kProtoPtrType | Needs bind_proto_arena. |
| FlatBuffers obj | MyTableT (NativeTable) | kFlatTableType | Object API. |
| FlatBuffers ptr | MyTable* | kFlatPtrType | Zero-copy view of buffer. |
| DDS CDR | FastDDS IDL or ROS2 message type | kCdrType | Encapsulated CDR bytes. |
| POD struct | trivial standard-layout type | kStandardType | sizeof(T) byte copy. |
| String | std::string | kStringType | Payload-sized byte string. |
| Custom | type with operator>>/<< | kCustomType | User-supplied codec. |
Raw Protobuf pointer receivers allocate a distinct message in the bound Arena for each delivery; that storage remains until the Arena is reset or destroyed.
MsgT is a shared pointer whose element_type derives from IntraDataType (generated via VLINK_INTRA_DATA_DECLARE) and the URL scheme is intra://, the shared pointer is forwarded zero-copy to the callback without serialisation: Bytes creates owned storage, and copying an IntraData shared pointer extends that object's lifetime.listen() more than once is a fatal error. The subscriber must be initialised (either by InitType::kWithInit or by explicit init()) before listen() is called.