|
VLink 2.0.0
A high-performance communication middleware
|
Type-safe field writer for the VLink field communication model. More...
#include <setter.h>
Public Types | |
| using | UniquePtr = std::unique_ptr<Setter<ValueT, SecT>> |
| Unique-pointer alias. | |
| using | SharedPtr = std::shared_ptr<Setter<ValueT, SecT>> |
| Shared-pointer alias. | |
| Public Types inherited from vlink::Node< SetterImpl, SecurityType::kWithoutSecurity > | |
| using | StatusCallback |
| Callback type for node status-change notifications. | |
Public Member Functions | |
| template<typename ConfT, typename = std::enable_if_t<std::is_base_of_v<Conf, ConfT>>> | |
| Setter (const ConfT &conf, InitType type=InitType::kWithInit) | |
| Constructs a setter from a typed transport configuration object. | |
| Setter (const std::string &url_str, InitType type=InitType::kWithInit) | |
| Constructs a setter from a URL string. | |
| bool | init () override |
| Initializes the setter transport and registers the late-getter sync callback. | |
| bool | deinit () override |
| Deinitializes the setter and releases the underlying transport resources. | |
| void | set (const ValueT &value) |
Writes a new field value and notifies all connected Getter nodes. | |
| void | mark_as_publisher () |
Changes this setter's role to kPublisher (event-emitter). | |
| Public Member Functions inherited from vlink::Node< SetterImpl, SecurityType::kWithoutSecurity > | |
| virtual void | interrupt () |
| Unblocks any active blocking wait on this node. | |
| bool | has_inited () const |
Returns true if init() has been successfully called. | |
| bool | is_support_loan () const |
Returns true if the transport supports zero-copy loaned buffers. | |
| Bytes | loan (int64_t size) |
| Allocates a loaned buffer from the transport memory pool. | |
| bool | return_loan (const Bytes &bytes) |
| Returns a previously loaned buffer back to the transport pool. | |
| virtual void | set_manual_unloan (bool manual_unloan) |
| Enables or disables manual-unloan mode for zero-copy receives. | |
| virtual bool | is_manual_unloan () const |
Returns true if manual-unloan mode is active. | |
| bool | suspend () |
| Suspends message delivery on this node. | |
| bool | resume () |
Resumes message delivery after a suspend(). | |
| bool | is_suspend () const |
Returns true if the node is currently suspended. | |
| bool | attach (class MessageLoop *message_loop) |
Attaches the node to a MessageLoop for callback dispatching. | |
| bool | detach () |
Detaches the node from its current MessageLoop. | |
| class MessageLoop * | get_message_loop () const |
Returns the MessageLoop this node is attached to. | |
| const AbstractNode * | get_abstract_node () const |
| Returns the abstract node handle for graph introspection. | |
| Status::BasePtr | get_status (Status::Type type) const |
| Returns the current status object for the specified status type. | |
| void | register_status_handler (StatusCallback &&callback) |
| Registers a handler called when the node's status changes. | |
| void | set_property (const std::string &prop, const std::string &value) |
| Sets a transport-specific key-value property on the node. | |
| std::string | get_property (const std::string &prop) const |
| Retrieves a transport-specific property value. | |
| TransportType | get_transport_type () const |
Returns the TransportType of the transport this node is bound to. | |
| const std::string & | get_url () const |
| Returns the URL string used to construct this node. | |
| void | set_security_key (const std::string &key) |
| Sets the symmetric encryption key for message security. | |
| void | set_record_path (const std::string &path) |
| Sets the filesystem path for message bag recording. | |
| void | set_security_callbacks (Security::Callback &&encrypt_callback, Security::Callback &&decrypt_callback) |
| Installs custom encrypt and decrypt callbacks. | |
| void | set_ser_type (const std::string &ser_type, SchemaType schema_type=SchemaType::kUnknown) |
| Overrides the runtime wire metadata for this node. | |
| const std::string & | get_ser_type () const |
| Returns the current serialisation type string. | |
| SchemaType | get_schema_type () const |
| Returns the current coarse schema family. | |
| void | set_discovery_enabled (bool enable) |
| Enables or disables peer-discovery on this node. | |
| bool | get_discovery_enabled () const |
Returns true if peer-discovery is currently enabled. | |
| void | bind_proto_arena (void *proto_arena) |
| Binds a Protobuf Arena for arena-allocated message objects. | |
| double | get_cpu_usage () const |
| Returns the cumulative CPU usage ratio for this node. | |
| bool | get_safety_quit () const |
Returns true if safe-quit mode is currently active. | |
| void | set_safety_quit (bool safety_quit) |
| Enables or disables safe-quit mode. | |
| void | set_ssl_options (const SslOptions &options) |
| Configures transport-layer SSL/TLS encryption for this node. | |
Static Public Member Functions | |
| static UniquePtr | create_unique (const std::string &url_str, InitType type=InitType::kWithInit) |
Creates a Setter on the heap wrapped in a unique_ptr. | |
| static SharedPtr | create_shared (const std::string &url_str, InitType type=InitType::kWithInit) |
Creates a Setter on the heap wrapped in a shared_ptr. | |
Static Public Attributes | |
| static constexpr ImplType | kImplType = kSetter |
Node role identifier (kSetter). | |
| static constexpr Serializer::Type | kValueType = Serializer::get_type_of<ValueT>() |
Serializer type resolved at compile time from ValueT. | |
Additional Inherited Members | |
| Protected Member Functions inherited from vlink::Node< SetterImpl, SecurityType::kWithoutSecurity > | |
| Node () | |
| virtual | ~Node () |
| void | enable_security () |
| void | invoke_callback (const CallbackT &callback, ArgsT &&... args) |
| TypeT | get_default_value () |
| Protected Attributes inherited from vlink::Node< SetterImpl, SecurityType::kWithoutSecurity > | |
| std::atomic_bool | has_inited_ |
| std::unique_ptr< SetterImpl > | impl_ |
| std::optional< Security > | security_ |
| std::optional< std::mutex > | quit_mtx_ |
| void * | proto_arena_ |
| bool | is_support_loan_ |
| bool | is_manual_unloan_ |
Type-safe field writer for the VLink field communication model.
| ValueT | Value type to write. |
| SecT | Security mode. |
| using vlink::Setter< ValueT, SecT >::SharedPtr = std::shared_ptr<Setter<ValueT, SecT>> |
Shared-pointer alias.
| using vlink::Setter< ValueT, SecT >::UniquePtr = std::unique_ptr<Setter<ValueT, SecT>> |
Unique-pointer alias.
|
inlineexplicit |
Constructs a setter from a typed transport configuration object.
Accepts any Conf-derived configuration. After init(), registers an internal sync() callback with the transport so that when a late Getter connects the cached value is re-sent automatically.
| ConfT | Conf-derived configuration type. |
| conf | Populated configuration object. |
| type | kWithInit to call init() immediately (default). |
|
inlineexplicit |
Constructs a setter from a URL string.
| url_str | Field URL (e.g. "dds://vehicle/gear"). |
| type | kWithInit to call init() immediately (default). |
|
inlinestaticnodiscard |
|
inlinestaticnodiscard |
|
inlineoverridevirtual |
Deinitializes the setter and releases the underlying transport resources.
Delegates to the base Node deinitialization path. After deinitialization, the setter stops participating in transport sync and write operations until it is initialized again.
true on success, false if the underlying transport reports failure. Reimplemented from vlink::Node< SetterImpl, SecurityType::kWithoutSecurity >.
|
inlineoverridevirtual |
Initializes the setter transport and registers the late-getter sync callback.
Calls the base Node initialization, then installs a transport sync() callback that re-sends the cached latest value when a new Getter joins after this setter has already been written to.
true on success, false if transport initialization fails. Reimplemented from vlink::Node< SetterImpl, SecurityType::kWithoutSecurity >.
|
inline |
Changes this setter's role to kPublisher (event-emitter).
Updates impl_->impl_type from kSetter to kPublisher so that event-model transport semantics are applied (no last-value retention). If called after init(), the extension is automatically reinitialised. Used when a Setter should behave as a plain publisher on transports that do not natively distinguish the two roles.
|
inline |
Writes a new field value and notifies all connected Getter nodes.
Caches value internally (guarded by mutex), then serializes and writes it to the transport. If security is enabled the serialized bytes are encrypted before transmission. The cached value is automatically re-sent when a late Getter connects.
| value | The new field value to write. |
|
staticconstexpr |
Node role identifier (kSetter).
|
staticconstexpr |
Serializer type resolved at compile time from ValueT.