|
VLink
2.0.0
A high-performance communication middleware
|
Backbone of every transport-specific VLink node implementation. 更多...
#include <node_impl.h>
Public 类型 | |
| using | ConnectCallback = Function< void(bool)> |
| Callback fired when peer presence changes. 更多... | |
| using | StatusCallback = Function< void(const Status::BasePtr &ptr)> |
| Callback fired on DDS-family status notifications (e.g. deadline missed). 更多... | |
| using | SyncCallback = Function< void()> |
Callback fired when a SetterImpl completes a late-getter sync. 更多... | |
| using | ReqRespCallback = Function< void(uint64_t, const Bytes &, Bytes *)> |
Request / response handler installed by ServerImpl::listen(). 更多... | |
| using | MsgCallback = Function< void(const Bytes &)> |
| Callback delivering a serialised payload to a subscriber or getter. 更多... | |
| using | IntraMsgCallback = Function< void(const IntraData &)> |
| Callback delivering an in-process payload to an intra:// subscriber. 更多... | |
Public 成员函数 | |
| virtual void | init ()=0 |
| Brings the underlying transport channel online. 更多... | |
| virtual void | deinit ()=0 |
| Tears the underlying transport channel down. 更多... | |
| virtual bool | suspend () |
| Pauses message delivery without releasing the channel. 更多... | |
| virtual bool | resume () |
Resumes message delivery after suspend(). 更多... | |
| virtual bool | is_suspend () const |
| Reports whether the node is currently suspended. 更多... | |
| virtual void | interrupt () |
| Marks the node interrupted and wakes blocking operations. 更多... | |
| virtual bool | is_support_loan () const |
| Indicates whether zero-copy loaning is available on this backend. 更多... | |
| 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) |
| Toggles automatic versus manual release of received loaned buffers. 更多... | |
| virtual const struct Conf * | get_conf () const |
Returns the associated transport Conf, or nullptr in the base. 更多... | |
| virtual const AbstractNode * | get_abstract_node () const |
Returns the companion AbstractNode, when the impl is split. 更多... | |
| virtual Status::BasePtr | get_status (Status::Type type) const |
| Retrieves a transport-specific status object. 更多... | |
| virtual bool | check_version (const Version &version) |
Compares version with 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 currently attached MessageLoop. 更多... | |
| template<typename T > | |
| const T * | get_target_conf () const |
Convenience downcast wrapper around get_conf(). 更多... | |
| void | register_status_handler (StatusCallback &&callback) |
| Installs a DDS-family status handler. 更多... | |
| bool | has_register_status () const |
| Reports whether a status handler has been registered. 更多... | |
| void | call_status (Status::BasePtr ptr) |
| Delivers a status notification to the registered handler. 更多... | |
| void | set_property (const std::string &prop, const std::string &value) |
| Sets a named property on this node. 更多... | |
| std::string | get_property (const std::string &prop) const |
| Retrieves the value of a named property. 更多... | |
| Conf::PropertiesMap | get_all_properties () const |
| Returns a copy of every property currently set on this node. 更多... | |
| void | set_discovery_enabled (bool enable) |
| Toggles whether this node is reported to the discovery layer. 更多... | |
| bool | get_discovery_enabled () const |
| Returns the current discovery-reporting flag. 更多... | |
| void | set_record_path (const std::string &path) |
| Configures per-node message recording. 更多... | |
| bool | enable_security (const Security::Config &cfg) |
| Installs application-layer security from a const-reference config. 更多... | |
| bool | enable_security (Security::Config &&cfg) |
Installs application-layer security by consuming cfg. 更多... | |
| void | set_ssl_options (const SslOptions &options) |
| Merges SSL 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 |
Reports whether interrupt() has been called and not yet reset. 更多... | |
| void | init_ext () |
| Registers the node with the runtime-owned discovery reporter. 更多... | |
| void | deinit_ext () |
| Deregisters the node from the runtime-owned discovery reporter. 更多... | |
静态 Public 成员函数 | |
| static void | global_init () |
| Initialises process-wide VLink singletons. 更多... | |
Public 属性 | |
| std::string | url |
Full URL string of the node, e.g. "dds://my/topic". 更多... | |
| std::string | ser_type |
Concrete serialisation type tag (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 identifier for this node. 更多... | |
| bool | is_cdr_type {false} |
true when DDS native CDR serialisation is in use. 更多... | |
| bool | is_security_type {false} |
true when an authenticated transport is enabled. 更多... | |
| bool | is_discovery_enabled {true} |
| Whether the node is reported to the discovery layer. 更多... | |
| std::atomic_bool | has_suspend {false} |
| Atomic suspend flag (currently unused by the default impls). 更多... | |
| std::unique_ptr< CpuProfiler > | profiler |
| Optional per-node CPU profiler activated under global profiling. 更多... | |
| std::unique_ptr< Security > | security |
Installed per-node message-security context, or nullptr. 更多... | |
Protected 成员函数 | |
| NodeImpl (ImplType type) | |
| virtual | ~NodeImpl () |
Backbone of every transport-specific VLink node implementation.
Every concrete transport backend ultimately derives from NodeImpl. The class centralises lifecycle, instrumentation and observability so that subclass authors only need to focus on transport mechanics. The contract table at file scope summarises which knobs the base owns and which require a transport override.
suspend() and resume() are optional capabilities; the base implementation logs a warning and returns false so that backends lacking the operation can be detected gracefully.register_status_handler() and call_status() are only meaningful on DDS-family transports (kDds, kDdsc, kDdsr, kDdst); other backends log a warning and treat them as no-ops. | using vlink::NodeImpl::ConnectCallback = Function<void(bool)> |
Callback fired when peer presence changes.
The boolean argument is true when the peer becomes reachable and false when it disappears.
| using vlink::NodeImpl::IntraMsgCallback = Function<void(const IntraData&)> |
Callback delivering an in-process payload to an intra:// subscriber.
IntraData is a shared_ptr to the payload type, so no copy occurs as the callback is dispatched.
| using vlink::NodeImpl::MsgCallback = Function<void(const Bytes&)> |
Callback delivering a serialised payload to a subscriber or getter.
| bytes | Payload bytes; lifetime is scoped to the callback. |
| using vlink::NodeImpl::ReqRespCallback = Function<void(uint64_t, const Bytes&, Bytes*)> |
Request / response handler installed by ServerImpl::listen().
Parameters are (req_id, request_bytes, response_bytes_ptr). The handler writes the response into *response_bytes_ptr; when the pointer is nullptr the server is running in fire-and-forget mode.
| using vlink::NodeImpl::StatusCallback = Function<void(const Status::BasePtr& ptr)> |
Callback fired on DDS-family status notifications (e.g. deadline missed).
| ptr | Polymorphic status object; downcast to the concrete subtype. |
| using vlink::NodeImpl::SyncCallback = Function<void()> |
Callback fired when a SetterImpl completes a late-getter sync.
|
explicitprotected |
|
protectedvirtual |
|
virtual |
Attaches the node to a MessageLoop for callback dispatch.
Records message_loop atomically; subsequent call_status() posts onto the loop thread. When another non-null loop is already attached the call is rejected. Passing nullptr does not establish a usable binding even though it may succeed when the node was already detached.
| message_loop | Loop to bind to. |
true when the pointer was stored; false on conflict. | void vlink::NodeImpl::call_status | ( | Status::BasePtr | ptr | ) |
Delivers a status notification to the registered handler.
Posts the call onto the attached MessageLoop when one exists; otherwise invokes the handler synchronously.
| ptr | Status object to forward. |
|
virtual |
Compares version with the runtime VLink library version.
Logs a warning (once per process) on the first mismatch. Version checks are advisory and do not block node creation.
| version | Compile-time version constants embedded by the caller. |
true when the versions agree.
|
pure virtual |
Tears the underlying transport channel down.
Called by the Node<> template destructor; releases all transport-owned resources.
| void vlink::NodeImpl::deinit_ext | ( | ) |
Deregisters the node from the runtime-owned discovery reporter.
Mirrors init_ext(); called after deinit() to release the discovery entry and restart the global profiler if it had been paused.
|
virtual |
Detaches the node from its MessageLoop.
Clears the cached pointer and, when called from a thread different from the loop, blocks until the previous loop becomes idle so no callback is still in flight on return.
true on success; false if no loop was attached. | bool vlink::NodeImpl::enable_security | ( | const Security::Config & | cfg | ) |
Installs application-layer security from a const-reference config.
Performs the wire-metadata validation and AAD-context plumbing, then forwards a fully prepared Security::Config into a Security instance stored in security. Unsupported transports return false without installing anything.
| cfg | Security configuration supplied by the public node wrapper. |
true once a usable Security instance is installed. | bool vlink::NodeImpl::enable_security | ( | Security::Config && | cfg | ) |
Installs application-layer security by consuming cfg.
Same validation path as the const-reference overload, but avoids copying callback targets and key material when the caller owns the config. The AAD context may be filled before the config is moved into Security.
| cfg | Security configuration to consume. |
true once a usable Security instance is installed.
|
virtual |
Returns the companion AbstractNode, when the impl is split.
nullptr. | Conf::PropertiesMap vlink::NodeImpl::get_all_properties | ( | ) | const |
Returns a copy of every property currently set on this node.
PropertiesMap.
|
virtual |
| bool vlink::NodeImpl::get_discovery_enabled | ( | ) | const |
Returns the current discovery-reporting flag.
true when the node will be visible to discovery. | class MessageLoop* vlink::NodeImpl::get_message_loop | ( | ) | const |
Returns the currently attached MessageLoop.
nullptr when none is bound. | std::string vlink::NodeImpl::get_property | ( | const std::string & | prop | ) | const |
Retrieves the value of a named property.
| prop | Property key. |
|
virtual |
Retrieves a transport-specific status object.
Only meaningful on DDS-family transports; the base logs a warning and returns Status::Unknown.
| type | Requested status category. |
nullptr.
|
inline |
Convenience downcast wrapper around get_conf().
Details
| T | Expected concrete Conf subclass. |
nullptr when get_conf() returns nullptr.
|
static |
Initialises process-wide VLink singletons.
Brings the logger, memory pool, and global bag writer online, and prepares the runtime-owned discovery reporter holder without starting the reporter until a discoverable node is registered. Safe to call multiple times; only the first call has an effect. The base constructor invokes this automatically.
| bool vlink::NodeImpl::has_register_status | ( | ) | const |
Reports whether a status handler has been registered.
true when a non-null status handler exists.
|
pure virtual |
Brings the underlying transport channel online.
Called by the public Node<> template after properties have been wired in. Backends create their DDS entities, shared-memory channels or any other resources here.
| void vlink::NodeImpl::init_ext | ( | ) |
Registers the node with the runtime-owned discovery reporter.
Invoked at the end of init() by every public Node<> template. Also starts the per-node CpuProfiler when global profiling is enabled. Skips registration for CDR, security, and (by default) intra nodes.
|
virtual |
Marks the node interrupted and wakes blocking operations.
Sets the internal interrupted flag and is overridden by subclasses to signal additional condition variables (e.g. wait_for_subscribers()). Pair with reset_interrupted() before reusing blocking helpers.
被 vlink::PublisherImpl , 以及 vlink::ClientImpl 重载.
| bool vlink::NodeImpl::is_interrupted | ( | ) | const |
Reports whether interrupt() has been called and not yet reset.
true when the interrupted flag is set.
|
virtual |
Indicates whether zero-copy loaning is available on this backend.
true when loan() / return_loan() can be used.
|
virtual |
|
virtual |
Borrows a write buffer of size bytes from the transport.
Backends that support zero-copy override this method to return a Bytes view onto pre-allocated transport memory. The default returns an empty Bytes.
| size | Requested buffer size in bytes. |
Bytes; empty when loaning is unsupported or failed. | void vlink::NodeImpl::register_status_handler | ( | StatusCallback && | callback | ) |
Installs a DDS-family status handler.
No-op on non-DDS transports. When a MessageLoop is attached the callback is invoked on the loop thread.
| callback | Handler invoked for each status notification. |
| void vlink::NodeImpl::reset_interrupted | ( | ) |
Clears the interrupted flag set by interrupt().
Required before re-running a blocking helper such as wait_for_subscribers() after a prior interruption.
|
virtual |
Resumes message delivery after suspend().
Default no-op returns false. Override in backends that support suspension.
true on success; false otherwise.
|
virtual |
| void vlink::NodeImpl::set_discovery_enabled | ( | bool | enable | ) |
Toggles whether this node is reported to the discovery layer.
Must be called before init_ext(). Disabling discovery hides the node from DiscoveryReporter / DiscoveryViewer; the proxy implementation uses this to keep its internal channels off topology views.
| enable | true to report to discovery (default); false to hide. |
|
virtual |
Toggles automatic versus manual release of received loaned buffers.
With manual_unloan set to true the backend does not release loaned buffers after callback dispatch; the application must call return_loan() itself.
| manual_unloan | true for manual release; false for automatic. |
| void vlink::NodeImpl::set_property | ( | const std::string & | prop, |
| const std::string & | value | ||
| ) |
Sets a named property on this node.
Properties are key / value strings consumed during init(). The underlying map is guarded by a shared mutex for thread safety.
| prop | Property key. |
| value | Property value. |
| void vlink::NodeImpl::set_record_path | ( | const std::string & | path | ) |
Configures per-node message recording.
A non-empty path acquires (or shares) a BagWriter so that subsequent try_record() calls capture frames. An empty path turns recording off.
| path | File path; empty or unsupported suffix disables recording. |
| void vlink::NodeImpl::set_ssl_options | ( | const SslOptions & | options | ) |
Merges SSL options into the node property map.
Acquires the helper mutex and delegates to SslOptions::parse_to() so the transport factory reads the resulting ssl.* entries during connection setup.
| options | SSL / TLS configuration to merge. |
|
virtual |
Pauses message delivery without releasing the channel.
The base implementation logs a warning and returns false. Only a few backends implement true suspension; others should leave the default.
true on success; false when the operation is unsupported. | void vlink::NodeImpl::try_record | ( | ActionType | action_type, |
| const Bytes & | data | ||
| ) |
Records a message to the global and / or per-node bag writers.
Skips DDS CDR payloads and (when the ignore-intra filter is on) intra messages. Used by every node role to feed BagWriter pipelines.
| action_type | Logical role under which the message is being recorded. |
| data | Raw serialised payload bytes. |
| std::atomic_bool vlink::NodeImpl::has_suspend {false} |
Atomic suspend flag (currently unused by the default impls).
| ImplType vlink::NodeImpl::impl_type {kUnknownImplType} |
Role of this implementation node.
| bool vlink::NodeImpl::is_cdr_type {false} |
true when DDS native CDR serialisation is in use.
| bool vlink::NodeImpl::is_discovery_enabled {true} |
Whether the node is reported to the discovery layer.
| bool vlink::NodeImpl::is_security_type {false} |
true when an authenticated transport is enabled.
| std::unique_ptr<CpuProfiler> vlink::NodeImpl::profiler |
Optional per-node CPU profiler activated under global profiling.
| SchemaType vlink::NodeImpl::schema_type {SchemaType::kUnknown} |
Coarse schema family reported to discovery and bag / proxy paths.
| std::unique_ptr<Security> vlink::NodeImpl::security |
Installed per-node message-security context, or nullptr.
| std::string vlink::NodeImpl::ser_type |
Concrete serialisation type tag (e.g. "demo.proto.PointCloud").
| TransportType vlink::NodeImpl::transport_type {TransportType::kUnknown} |
Transport backend identifier for this node.
| std::string vlink::NodeImpl::url |
Full URL string of the node, e.g. "dds://my/topic".