VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
vlink::NodeImpl类 参考abstract

Abstract base for all VLink transport backend node implementations. 更多...

#include <node_impl.h>

类 vlink::NodeImpl 继承关系图:
vlink::NodeImpl 的协作图:

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 Confget_conf () const
 Returns a pointer to the associated Conf configuration object.
virtual const AbstractNodeget_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 MessageLoopget_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 CpuProfilerprofiler
 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:

  • The pure-virtual init() / deinit() lifecycle interface.
  • Common property storage shared between the Conf layer and the node.
  • An optional MessageLoop attachment for callback dispatch.
  • An interrupt() mechanism to unblock blocking operations.
  • Hooks for data recording (try_record) and discovery reporting (init_ext / deinit_ext).
  • A static 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.

成员类型定义说明

◆ ConnectCallback

using vlink::NodeImpl::ConnectCallback = std::function<void(bool)>

Callback invoked when the peer connection state changes.

参数
booltrue when connected; false when disconnected.

◆ IntraMsgCallback

using vlink::NodeImpl::IntraMsgCallback = std::function<void(const IntraData&)>

Callback delivering an in-process IntraData message.

Only used on intra:// transport. The IntraData is a shared_ptr to the payload type, so no copy occurs.

◆ MsgCallback

using vlink::NodeImpl::MsgCallback = std::function<void(const Bytes&)>

Callback delivering a raw serialised message to a SubscriberImpl or GetterImpl.

参数
bytesReceived payload; lifetime is scoped to the callback.

◆ ReqRespCallback

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.

◆ StatusCallback

using vlink::NodeImpl::StatusCallback = std::function<void(const Status::BasePtr& ptr)>

Callback invoked on DDS status events (e.g. deadline missed).

参数
ptrPolymorphic status object; downcast to the concrete type.

◆ SyncCallback

using vlink::NodeImpl::SyncCallback = std::function<void()>

Callback invoked when a SetterImpl sync completes.

构造及析构函数说明

◆ NodeImpl()

vlink::NodeImpl::NodeImpl ( ImplType type)
explicitprotected
这是这个函数的调用关系图:

◆ ~NodeImpl()

virtual vlink::NodeImpl::~NodeImpl ( )
protectedvirtual
函数调用图:

成员函数说明

◆ attach()

virtual bool vlink::NodeImpl::attach ( class MessageLoop * message_loop)
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_loopLoop to attach to; must not be nullptr.
返回
true on success; false if already attached.

◆ call_status()

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.

参数
ptrStatus object to deliver.

◆ check_version()

virtual bool vlink::NodeImpl::check_version ( const Version & version)
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.

参数
versionCompile-time version embedded by the application.
返回
true if versions match; false otherwise.

◆ deinit()

virtual void vlink::NodeImpl::deinit ( )
pure virtual

Tears down the underlying transport channel.

Called by the Node<> template destructor. Releases all transport resources (e.g. DDS entities, SHM segments).

◆ deinit_ext()

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.

◆ detach()

virtual bool vlink::NodeImpl::detach ( )
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.

◆ get_abstract_node()

virtual const AbstractNode * vlink::NodeImpl::get_abstract_node ( ) const
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.

返回
Pointer to the AbstractNode, or nullptr.

◆ get_all_properties()

Conf::PropertiesMap vlink::NodeImpl::get_all_properties ( ) const
nodiscard

Returns a snapshot of all properties set on this node.

返回
A copy of the internal PropertiesMap.

◆ get_conf()

virtual const struct Conf * vlink::NodeImpl::get_conf ( ) const
virtual

Returns a pointer to the associated Conf configuration object.

Concrete backends override this to return their typed Conf subclass (e.g. DdsConf). The base returns nullptr.

返回
Pointer to the owning Conf, or nullptr in the base.
这是这个函数的调用关系图:

◆ get_discovery_enabled()

bool vlink::NodeImpl::get_discovery_enabled ( ) const
nodiscard

Returns true if discovery reporting is enabled for this node.

返回
Current discovery-enabled state.

◆ get_message_loop()

class MessageLoop * vlink::NodeImpl::get_message_loop ( ) const
nodiscard

Returns the MessageLoop this node is attached to.

返回
Pointer to the loop, or nullptr if not attached.
函数调用图:

◆ get_property()

std::string vlink::NodeImpl::get_property ( const std::string & prop) const
nodiscard

Retrieves a named transport property.

参数
propProperty name.
返回
Property value, or empty string if not set.

◆ get_status()

virtual Status::BasePtr vlink::NodeImpl::get_status ( Status::Type type) const
nodiscardvirtual

Retrieves a transport-specific status object.

Only supported on DDS-family transports. The base logs a warning and returns Status::Unknown.

参数
typeThe type of status to retrieve (e.g. deadline missed).
返回
Polymorphic status object; never nullptr.

◆ get_target_conf()

template<typename T>
const T * vlink::NodeImpl::get_target_conf ( ) const
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.

模板参数
TConcrete Conf subclass to cast to.
返回
const T* pointer, or nullptr if get_conf() returns null.
函数调用图:
这是这个函数的调用关系图:

◆ global_init()

void vlink::NodeImpl::global_init ( )
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.

这是这个函数的调用关系图:

◆ has_register_status()

bool vlink::NodeImpl::has_register_status ( ) const
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.

◆ init()

virtual void vlink::NodeImpl::init ( )
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.

◆ init_ext()

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.

◆ interrupt()

virtual void vlink::NodeImpl::interrupt ( )
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 重载.

◆ is_interrupted()

bool vlink::NodeImpl::is_interrupted ( ) const
nodiscard

Returns true if interrupt() has been called and not yet reset.

返回
true when the interrupted flag is set.

◆ is_support_loan()

virtual bool vlink::NodeImpl::is_support_loan ( ) const
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.

◆ is_suspend()

virtual bool vlink::NodeImpl::is_suspend ( ) const
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.

◆ loan()

virtual Bytes vlink::NodeImpl::loan ( int64_t size)
nodiscardvirtual

Borrows a write buffer of size bytes from the transport.

Returns an empty Bytes in the base implementation. Transports that support zero-copy override this to return a Bytes view into pre-allocated shared memory.

参数
sizeRequired buffer size in bytes.
返回
Borrowed Bytes, or empty on failure.

◆ register_status_handler()

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.

参数
callbackHandler invoked with each status change.

◆ reset_interrupted()

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.

◆ resume()

virtual bool vlink::NodeImpl::resume ( )
virtual

Resumes message delivery after a suspend() call.

The base implementation logs a warning and returns false.

返回
true if resumed successfully; false if unsupported.

◆ return_loan()

virtual bool vlink::NodeImpl::return_loan ( const Bytes & bytes)
virtual

Returns a previously loaned buffer to the transport.

Must be called if loan() returned a valid buffer and the caller decided not to publish (e.g. serialisation failed). The base returns false.

参数
bytesBuffer previously returned by loan().
返回
true on success; false if unsupported.

◆ set_discovery_enabled()

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().

参数
enabletrue to report to discovery (default); false to suppress.

◆ set_manual_unloan()

virtual void vlink::NodeImpl::set_manual_unloan ( bool manual_unloan)
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_unloantrue to enable manual release; false for automatic.

◆ set_property()

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.

参数
propProperty name.
valueProperty value.

◆ set_record_path()

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.

参数
pathFile path for the bag; empty disables recording.

◆ set_ssl_options()

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.

参数
optionsThe SSL/TLS configuration to merge.
参见
SslOptions::parse_to(), Node::set_ssl_options()

◆ suspend()

virtual bool vlink::NodeImpl::suspend ( )
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.

◆ try_record()

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_typeThe role this message is being recorded for.
dataRaw serialised message bytes.

类成员变量说明

◆ has_suspend

std::atomic_bool vlink::NodeImpl::has_suspend {false}

Atomic suspend state flag (currently unused by default impls).

◆ impl_type

ImplType vlink::NodeImpl::impl_type {kUnknownImplType}

Role of this implementation node.

◆ is_cdr_type

bool vlink::NodeImpl::is_cdr_type {false}

true when using DDS native CDR serialisation.

◆ is_discovery_enabled

bool vlink::NodeImpl::is_discovery_enabled {true}

Whether this node is reported to the discovery layer.

◆ is_security_type

bool vlink::NodeImpl::is_security_type {false}

true when security-authenticated transport is enabled.

◆ profiler

std::unique_ptr<class CpuProfiler> vlink::NodeImpl::profiler

Optional per-node CPU profiler (only when global profiling is on).

◆ schema_type

SchemaType vlink::NodeImpl::schema_type {SchemaType::kUnknown}

Coarse schema family reported to discovery and bag/proxy paths.

◆ ser_type

std::string vlink::NodeImpl::ser_type

Serialisation type string (e.g. "demo.proto.PointCloud").

◆ transport_type

TransportType vlink::NodeImpl::transport_type {TransportType::kUnknown}

Transport backend of this implementation node.

◆ url

std::string vlink::NodeImpl::url

Full URL string of this node (e.g. "dds://my/topic").


该类的文档由以下文件生成: