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

Base CRTP template for all VLink communication nodes. 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

 Transport-agnostic CRTP base for all VLink communication nodes. More...

Namespaces

Detailed Description

Base CRTP template for all VLink communication nodes.

Node<ImplT, SecT> is the common base class inherited by Publisher, Subscriber, Server, Client, Setter, and Getter. It owns the transport-specific implementation pointer (impl_), drives the node lifecycle, and provides the shared services described below.

Architecture Overview
+---------------------------------------------------+
| User Application |
| Publisher<T> Subscriber<T> Client<Req,Resp> |
| Server<Req,Resp> Getter<T> Setter<T> |
+-------------------+-------------------------------+
| inherits
+-------------------v-------------------------------+
| Node<ImplT, SecT> |
| lifecycle loans security properties profiler |
+-------------------+-------------------------------+
| owns (unique_ptr)
+-------------------v-------------------------------+
| ImplT (PublisherImpl / SubscriberImpl / ...) |
+-------------------+-------------------------------+
| creates / calls
+-------------------v-------------------------------+
| Transport Back-end |
| intra shm shm2 dds ddsc zenoh ... |
+---------------------------------------------------+
Lifecycle
Step Method Notes
Construction constructor Parses URL, creates impl via Conf factory.
Initialisation init() Calls impl init + init_ext, sets loan flag.
Use publish/listen/invoke Normal operation.
Interrupt interrupt() Unblocks any blocking wait immediately.
De-initialisation deinit() Calls interrupt(), then impl deinit.
Destruction destructor Calls deinit() automatically.
Deferred Initialisation
Publisher<MyMsg> pub("dds://topic", InitType::kWithoutInit);
pub.set_ser_type("my.custom.Type"); // configure before init
pub.init();
Security
Enable per-message encryption by using SecurityType::kWithSecurity:
SecurityPublisher<MyMsg> pub("shm://topic");
pub.set_security_key("my-secret");
Note
intra:// and dds:// with CDR serialisation do NOT support security.
Zero-copy Loans
On shm:// (Iceoryx) and shm2:// (Iceoryx2) transports, a loaned buffer avoids extra copies:
if (pub.is_support_loan()) {
Bytes buf = pub.loan(sizeof(MyStruct));
// fill buf ...
pub.publish(buf); // loan is returned automatically
}
Template Parameters
ImplTConcrete transport implementation (must inherit NodeImpl).
SecTSecurity mode: kWithoutSecurity (default) or kWithSecurity.