VLink  2.0.0
A high-performance communication middleware
node.h File Reference

Common CRTP base for every VLink communication primitive. More...

#include <atomic>
#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include "./extension/security.h"
#include "./impl/node_impl.h"
#include "./internal/node-inl.h"
Include dependency graph for node.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  vlink::Node< ImplT, SecT >
 Transport-agnostic CRTP base for all VLink communication primitives. More...
 

Namespaces

 

Detailed Description

Common CRTP base for every VLink communication primitive.

Node<ImplT, SecT> is the polymorphic base class shared by all six VLink communication primitives. It owns the transport-specific implementation pointer (impl_), drives the node lifecycle, and exposes the cross-cutting services that every primitive needs: zero-copy loans, peer-discovery toggling, message-loop attachment, recording, security installation, profiling, and SSL/TLS configuration.

Class Hierarchy
*   +--------------------------------------------------------------+
*   |                  User-facing primitives                      |
*   |  Publisher<T>   Subscriber<T>   Setter<T>    Getter<T>       |
*   |  Client<Req,Resp>               Server<Req,Resp>             |
*   +-----------------------------+--------------------------------+
*                                 | inherits
*   +-----------------------------v--------------------------------+
*   |                  Node<ImplT, SecT>                           |
*   |  lifecycle | loans | properties | profiler | ssl | security  |
*   +-----------------------------+--------------------------------+
*                                 | owns std::unique_ptr<ImplT>
*   +-----------------------------v--------------------------------+
*   |     ImplT  (PublisherImpl, SubscriberImpl, SetterImpl, ...)  |
*   +-----------------------------+--------------------------------+
*                                 | dispatches to transport
*   +-----------------------------v--------------------------------+
*   |    Transport back-ends                                       |
*   |    intra | shm | shm2 | dds | ddsc | zenoh | someip | ...    |
*   +--------------------------------------------------------------+
* 
Lifecycle State Diagram
*      +------------+    constructor    +------------+    init()    +------------+
*      | (uninited) |------------------>|  parsed    |------------->|   active   |
*      |            |  parse URL / Conf |  (impl_)   |  init_ext    | (using API)|
*      +------------+                   +------------+              +------------+
*                                              ^                          |
*                                              |  init()                  | interrupt()
*                                              |                          v
*                                       +------+------+            +-------------+
*                                       |  deinited   |<-----------|  blocking   |
*                                       |             |  deinit()  |  wait aborts|
*                                       +-------------+            +-------------+
*                                              |
*                                              | destructor (calls deinit if active)
*                                              v
*                                         destroyed
* 
Step Method Notes
Construction constructor Parses URL, creates impl via Conf factory.
Initialisation init() Runs impl init + init_ext, samples loans.
Active publish / listen / ... Normal operation.
Interrupt interrupt() Aborts blocking waits immediately.
Deinitialisation deinit() interrupt() then impl deinit + deinit_ext.
Destruction destructor Auto-deinits if still active.
ImplType Roles
ImplType Primitive that uses it Direction
kPublisher Publisher<T> Event write
kSubscriber Subscriber<T> Event read
kClient Client<Req,Resp> RPC caller
kServer Server<Req,Resp> RPC handler
kSetter Setter<T> Field write
kGetter Getter<T> Field read
Deferred Initialisation
pub.set_ser_type("my.custom.Type");
pub.set_discovery_enabled(false);
pub.init();
Security
Use the Security* primitive aliases to enable per-message encryption. The Security::Config aggregate is passed as the second constructor argument; omitting it (or passing an empty aggregate) uses the built-in default symmetric slot:
cfg.key = "my-secret";
vlink::SecurityPublisher<MyMsg> pub("shm://topic", cfg);
Note
intra:// and dds:// CDR payloads do not support per-message security; constructing a Security* primitive there is a fatal.
Zero-copy Loans
On loan-capable transports the loan API avoids extra copies:
vlink::Publisher<vlink::Bytes> pub("shm://topic");
if (pub.is_support_loan()) {
vlink::Bytes buf = pub.loan(payload_size);
write_into(buf);
pub.publish(buf); // loan is returned automatically
}
Template Parameters
ImplTConcrete transport implementation derived from NodeImpl.
SecTSecurity mode: kWithoutSecurity (default) or kWithSecurity.
See also
publisher.h, subscriber.h, client.h, server.h, getter.h, setter.h, extension/security.h, extension/ssl_options.h