|
VLink 2.0.0
A high-performance communication middleware
|
Abstract base for all VLink transport backend node implementations. 更多...
#include <node_impl.h>
Public 类型 | |
| using | ConnectCallback = std::function<void(bool)> |
| Callback invoked when the peer connection state changes. | |
| using | StatusCallback = std::function<void(const Status::BasePtr& ptr)> |
| Callback invoked on DDS status events (e.g. deadline missed). | |
| using | SyncCallback = std::function<void()> |
Callback invoked when a SetterImpl sync completes. | |
| using | ReqRespCallback = std::function<void(uint64_t, const Bytes&, Bytes*)> |
Callback for ServerImpl request/response processing. | |
| using | MsgCallback = std::function<void(const Bytes&)> |
Callback delivering a raw serialised message to a SubscriberImpl or GetterImpl. | |
| using | IntraMsgCallback = std::function<void(const IntraData&)> |
Callback delivering an in-process IntraData message. | |
Public 成员函数 | |
| virtual void | init ()=0 |
| Initialises the underlying transport channel. | |
| virtual void | deinit ()=0 |
| Tears down the underlying transport channel. | |
| virtual bool | suspend () |
| Temporarily suspends message delivery without tearing down the channel. | |
| virtual bool | resume () |
Resumes message delivery after a suspend() call. | |
| virtual bool | is_suspend () const |
Returns true when the node is currently suspended. | |
| virtual void | interrupt () |
| Signals any blocking operations to unblock and return immediately. | |
| virtual bool | is_support_loan () const |
Returns true if the transport supports zero-copy loaning. | |
| virtual Bytes | loan (int64_t size) |
Borrows a write buffer of size bytes from the transport. | |
| virtual bool | return_loan (const Bytes &bytes) |
| Returns a previously loaned buffer to the transport. | |
| virtual void | set_manual_unloan (bool manual_unloan) |
| Configures manual unloan mode for zero-copy transports. | |
| virtual const struct Conf * | get_conf () const |
Returns a pointer to the associated Conf configuration object. | |
| virtual const AbstractNode * | get_abstract_node () const |
Returns a pointer to the AbstractNode peer (if any). | |
| virtual Status::BasePtr | get_status (Status::Type type) const |
| Retrieves a transport-specific status object. | |
| virtual bool | check_version (const Version &version) |
Checks whether version matches the runtime VLink library version. | |
| virtual bool | attach (class MessageLoop *message_loop) |
Attaches the node to a MessageLoop for callback dispatch. | |
| virtual bool | detach () |
Detaches the node from its MessageLoop. | |
| class MessageLoop * | get_message_loop () const |
Returns the MessageLoop this node is attached to. | |
| template<typename T> | |
| const T * | get_target_conf () const |
Returns a typed pointer to the conf by downcasting to T. | |
| void | register_status_handler (StatusCallback &&callback) |
| Registers a callback for DDS status events. | |
| bool | has_register_status () const |
Returns true if a status handler has been registered. | |
| void | call_status (Status::BasePtr ptr) |
| Dispatches a status event to the registered status handler. | |
| void | set_property (const std::string &prop, const std::string &value) |
| Sets a named transport property on this node. | |
| std::string | get_property (const std::string &prop) const |
| Retrieves a named transport property. | |
| Conf::PropertiesMap | get_all_properties () const |
| Returns a snapshot of all properties set on this node. | |
| void | set_discovery_enabled (bool enable) |
| Enables or disables discovery reporting for this node. | |
| bool | get_discovery_enabled () const |
Returns true if discovery reporting is enabled for this node. | |
| void | set_record_path (const std::string &path) |
| Sets the file path for per-node message recording. | |
| void | set_ssl_options (const SslOptions &options) |
| Merges SSL/TLS options into the node property map. | |
| void | try_record (ActionType action_type, const Bytes &data) |
| Records a message to the global and/or per-node bag writers. | |
| void | reset_interrupted () |
Clears the interrupted flag set by interrupt(). | |
| bool | is_interrupted () const |
Returns true if interrupt() has been called and not yet reset. | |
| void | init_ext () |
Registers the node with the global DiscoveryReporter. | |
| void | deinit_ext () |
Deregisters the node from the global DiscoveryReporter. | |
静态 Public 成员函数 | |
| static void | global_init () |
| Initialises process-wide VLink singletons. | |
Public 属性 | |
| std::atomic_bool | has_suspend {false} |
| Atomic suspend state flag (currently unused by default impls). | |
| std::string | url |
Full URL string of this node (e.g. "dds://my/topic"). | |
| std::string | ser_type |
Serialisation type string (e.g. "demo.proto.PointCloud"). | |
| ImplType | impl_type {kUnknownImplType} |
| Role of this implementation node. | |
| SchemaType | schema_type {SchemaType::kUnknown} |
| Coarse schema family reported to discovery and bag/proxy paths. | |
| TransportType | transport_type {TransportType::kUnknown} |
| Transport backend of this implementation node. | |
| bool | is_cdr_type {false} |
true when using DDS native CDR serialisation. | |
| bool | is_security_type {false} |
true when security-authenticated transport is enabled. | |
| bool | is_discovery_enabled {true} |
| Whether this node is reported to the discovery layer. | |
| std::unique_ptr< class CpuProfiler > | profiler |
| Optional per-node CPU profiler (only when global profiling is on). | |
Protected 成员函数 | |
| NodeImpl (ImplType type) | |
| virtual | ~NodeImpl () |
Abstract base for all VLink transport backend node implementations.
Every concrete transport backend (e.g. DdsPublisherImpl, ShmSubscriberImpl) ultimately derives from NodeImpl. The class provides:
init() / deinit() lifecycle interface.Conf layer and the node.MessageLoop attachment for callback dispatch.interrupt() mechanism to unblock blocking operations.try_record) and discovery reporting (init_ext / deinit_ext).global_init() that must be called before any node is created (invoked automatically by the constructor, but safe to call multiple times).suspend() and resume() are optional – the default implementations log a warning and return false if not overridden.register_status_handler() and call_status() are only supported on DDS-family transports (kDds, kDdsc, kDdsr, kDdst). Calling them on other transport types logs a warning and is a no-op. | using vlink::NodeImpl::ConnectCallback = std::function<void(bool)> |
Callback invoked when the peer connection state changes.
| bool | true when connected; false when disconnected. |
| using vlink::NodeImpl::IntraMsgCallback = std::function<void(const IntraData&)> |
| using vlink::NodeImpl::MsgCallback = std::function<void(const Bytes&)> |
Callback delivering a raw serialised message to a SubscriberImpl or GetterImpl.
| bytes | Received payload; lifetime is scoped to the callback. |
| using vlink::NodeImpl::ReqRespCallback = std::function<void(uint64_t, const Bytes&, Bytes*)> |
Callback for ServerImpl request/response processing.
Parameters: (req_id, request_bytes, response_bytes_ptr). The handler writes its response into *response_bytes_ptr; if response_bytes_ptr is nullptr the server is in fire-and-forget mode.
| using vlink::NodeImpl::StatusCallback = std::function<void(const Status::BasePtr& ptr)> |
Callback invoked on DDS status events (e.g. deadline missed).
| ptr | Polymorphic status object; downcast to the concrete type. |
| using vlink::NodeImpl::SyncCallback = std::function<void()> |
Callback invoked when a SetterImpl sync completes.
|
explicitprotected |
|
protectedvirtual |
|
virtual |
Attaches the node to a MessageLoop for callback dispatch.
Once attached, call_status() posts callbacks onto the loop thread. Returns false if a loop is already attached.
| message_loop | Loop to attach to; must not be nullptr. |
true on success; false if already attached. | void vlink::NodeImpl::call_status | ( | Status::BasePtr | ptr | ) |
Dispatches a status event to the registered status handler.
If a MessageLoop is attached the callback is posted onto the loop thread; otherwise it is called directly. Only effective on DDS-family transports.
| ptr | Status object to deliver. |
|
virtual |
Checks whether version matches the runtime VLink library version.
Compares version against VLINK_VERSION_MAJOR/MINOR/PATCH. On the first mismatch a warning is logged (once per process). Version checks are advisory; mismatches do not prevent node creation.
| version | Compile-time version embedded by the application. |
true if versions match; false otherwise.
|
pure virtual |
Tears down the underlying transport channel.
Called by the Node<> template destructor. Releases all transport resources (e.g. DDS entities, SHM segments).
| void vlink::NodeImpl::deinit_ext | ( | ) |
Deregisters the node from the global DiscoveryReporter.
Called at the start of deinit() by all Node<> template specialisations. Restarts the CpuProfiler if global profiling was running.
|
virtual |
Detaches the node from its MessageLoop.
Waits for the loop to become idle (if the call is from a different thread) before clearing the pointer, ensuring no callbacks are in-flight after this call returns.
true on success; false if no loop was attached.
|
nodiscardvirtual |
Returns a pointer to the AbstractNode peer (if any).
Used to access the native handle when the impl is split from the node. The base returns nullptr.
AbstractNode, or nullptr.
|
nodiscard |
Returns a snapshot of all properties set on this node.
PropertiesMap.
|
virtual |
|
nodiscard |
Returns true if discovery reporting is enabled for this node.
|
nodiscard |
Returns the MessageLoop this node is attached to.
nullptr if not attached.
|
nodiscard |
Retrieves a named transport property.
| prop | Property name. |
|
nodiscardvirtual |
Retrieves a transport-specific status object.
Only supported on DDS-family transports. The base logs a warning and returns Status::Unknown.
| type | The type of status to retrieve (e.g. deadline missed). |
nullptr.
|
inlinenodiscard |
Returns a typed pointer to the conf by downcasting to T.
Details
Convenience wrapper around get_conf() for transport backends that need to access their own Conf subclass.
| T | Concrete Conf subclass to cast to. |
const T* pointer, or nullptr if get_conf() returns null.
|
static |
Initialises process-wide VLink singletons.
Ensures the Logger, memory pool, global BagWriter, and global DiscoveryReporter are initialised. Safe to call multiple times; only the first call has an effect. The constructor calls this automatically.
|
nodiscard |
Returns true if a status handler has been registered.
Only effective on DDS-family transports; logs a warning and returns false for other transport types.
true if a non-null status callback is registered.
|
pure virtual |
Initialises the underlying transport channel.
Called by the Node<> template after all properties have been set. Concrete implementations create DDS entities, SHM channels, etc.
| void vlink::NodeImpl::init_ext | ( | ) |
Registers the node with the global DiscoveryReporter.
Called at the end of init() by all Node<> template specialisations. Optionally starts the CpuProfiler if global profiling is enabled. Skips registration for CDR, security, and (by default) intra nodes.
|
virtual |
Signals any blocking operations to unblock and return immediately.
Sets the internal interrupted flag and, in derived classes (e.g. PublisherImpl, ClientImpl), also notifies waiting condition variables to release threads blocked in wait_for_*. Call reset_interrupted() before resuming normal operations.
被 vlink::ClientImpl , 以及 vlink::PublisherImpl 重载.
|
nodiscard |
Returns true if interrupt() has been called and not yet reset.
true when the interrupted flag is set.
|
nodiscardvirtual |
Returns true if the transport supports zero-copy loaning.
Zero-copy loan is a DDS / SHM feature that lets the publisher write directly into pre-allocated shared memory. The base returns false.
true if loan() / return_loan() are supported.
|
nodiscardvirtual |
Returns true when the node is currently suspended.
The base implementation logs a warning and returns false.
true if the node is suspended; false otherwise or if unsupported.
|
nodiscardvirtual |
| void vlink::NodeImpl::register_status_handler | ( | StatusCallback && | callback | ) |
Registers a callback for DDS status events.
Only effective on DDS-family transports (kDds, kDdsc, kDdsr, kDdst). A warning is logged if called on other transport types. If a MessageLoop is attached, the callback is dispatched on that thread.
| callback | Handler invoked with each status change. |
| void vlink::NodeImpl::reset_interrupted | ( | ) |
Clears the interrupted flag set by interrupt().
Must be called before re-using a blocking operation after it has been interrupted, e.g. before calling wait_for_subscribers() again.
|
virtual |
Resumes message delivery after a suspend() call.
The base implementation logs a warning and returns false.
true if resumed successfully; false if unsupported.
|
virtual |
| void vlink::NodeImpl::set_discovery_enabled | ( | bool | enable | ) |
Enables or disables discovery reporting for this node.
When false the node is hidden from DiscoveryReporter / DiscoveryViewer. Proxy-internal channels use this to suppress themselves from topology views. Must be called before init_ext().
| enable | true to report to discovery (default); false to suppress. |
|
virtual |
Configures manual unloan mode for zero-copy transports.
When manual_unloan is true the transport does not automatically release the loaned buffer after publish; the caller must call return_loan() explicitly. The base is a no-op.
| manual_unloan | true to enable manual release; false for automatic. |
| void vlink::NodeImpl::set_property | ( | const std::string & | prop, |
| const std::string & | value ) |
Sets a named transport property on this node.
Properties are key/value strings (e.g. "dds.ip" = "192.168.1.1"). Must be called before init() to take effect. The property map is protected by a shared mutex for thread safety.
| prop | Property name. |
| value | Property value. |
| void vlink::NodeImpl::set_record_path | ( | const std::string & | path | ) |
Sets the file path for per-node message recording.
When non-empty a BagWriter instance is obtained (or shared with other nodes writing to the same path) and try_record() will capture messages. Pass an empty string to disable per-node recording.
| path | File path for the bag; empty disables recording. |
| void vlink::NodeImpl::set_ssl_options | ( | const SslOptions & | options | ) |
Merges SSL/TLS options into the node property map.
Acquires the helper mutex and calls SslOptions::parse_to() to write the non-default fields of options as ssl.* entries in helper_->property_map. The transport factory reads these entries during connection setup to configure TLS.
| options | The SSL/TLS configuration to merge. |
|
virtual |
Temporarily suspends message delivery without tearing down the channel.
The base implementation logs a warning and returns false. Only a subset of transport backends support this operation.
true if suspended successfully; false if unsupported. | void vlink::NodeImpl::try_record | ( | ActionType | action_type, |
| const Bytes & | data ) |
Records a message to the global and/or per-node bag writers.
Queries the global BagWriter (if one is active) and the per-node writer set by set_record_path(). CDR DDS messages and intra messages are excluded by default.
| action_type | The role this message is being recorded for. |
| data | Raw serialised message bytes. |
| std::atomic_bool vlink::NodeImpl::has_suspend {false} |
Atomic suspend state flag (currently unused by default impls).
| ImplType vlink::NodeImpl::impl_type {kUnknownImplType} |
Role of this implementation node.
| bool vlink::NodeImpl::is_cdr_type {false} |
true when using DDS native CDR serialisation.
| bool vlink::NodeImpl::is_discovery_enabled {true} |
Whether this node is reported to the discovery layer.
| bool vlink::NodeImpl::is_security_type {false} |
true when security-authenticated transport is enabled.
| std::unique_ptr<class CpuProfiler> vlink::NodeImpl::profiler |
Optional per-node CPU profiler (only when global profiling is on).
| SchemaType vlink::NodeImpl::schema_type {SchemaType::kUnknown} |
Coarse schema family reported to discovery and bag/proxy paths.
| std::string vlink::NodeImpl::ser_type |
Serialisation type string (e.g. "demo.proto.PointCloud").
| TransportType vlink::NodeImpl::transport_type {TransportType::kUnknown} |
Transport backend of this implementation node.
| std::string vlink::NodeImpl::url |
Full URL string of this node (e.g. "dds://my/topic").