VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
vlink::Setter< ValueT, SecT > Class Template Reference

Type-safe field writer for the VLink field communication model. More...

#include <setter.h>

Inheritance diagram for vlink::Setter< ValueT, SecT >:
Collaboration diagram for vlink::Setter< ValueT, SecT >:

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

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

Detailed Description

template<typename ValueT, SecurityType SecT = SecurityType::kWithoutSecurity>
class vlink::Setter< ValueT, SecT >

Type-safe field writer for the VLink field communication model.

Template Parameters
ValueTValue type to write.
SecTSecurity mode.

Member Typedef Documentation

◆ SharedPtr

template<typename ValueT, SecurityType SecT = SecurityType::kWithoutSecurity>
using vlink::Setter< ValueT, SecT >::SharedPtr = std::shared_ptr<Setter<ValueT, SecT>>

Shared-pointer alias.

◆ UniquePtr

template<typename ValueT, SecurityType SecT = SecurityType::kWithoutSecurity>
using vlink::Setter< ValueT, SecT >::UniquePtr = std::unique_ptr<Setter<ValueT, SecT>>

Unique-pointer alias.

Constructor & Destructor Documentation

◆ Setter() [1/2]

template<typename ValueT, SecurityType SecT>
template<typename ConfT, typename>
vlink::Setter< ValueT, SecT >::Setter ( const ConfT & conf,
InitType type = InitType::kWithInit )
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.

Template Parameters
ConfTConf-derived configuration type.
Parameters
confPopulated configuration object.
typekWithInit to call init() immediately (default).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Setter() [2/2]

template<typename ValueT, SecurityType SecT>
vlink::Setter< ValueT, SecT >::Setter ( const std::string & url_str,
InitType type = InitType::kWithInit )
inlineexplicit

Constructs a setter from a URL string.

Parameters
url_strField URL (e.g. "dds://vehicle/gear").
typekWithInit to call init() immediately (default).
Here is the call graph for this function:

Member Function Documentation

◆ create_shared()

template<typename ValueT, SecurityType SecT>
Setter< ValueT, SecT >::SharedPtr vlink::Setter< ValueT, SecT >::create_shared ( const std::string & url_str,
InitType type = InitType::kWithInit )
inlinestaticnodiscard

Creates a Setter on the heap wrapped in a shared_ptr.

Parameters
url_strField URL string.
typekWithInit to call init() immediately (default).
Returns
SharedPtr owning the new setter.

◆ create_unique()

template<typename ValueT, SecurityType SecT>
Setter< ValueT, SecT >::UniquePtr vlink::Setter< ValueT, SecT >::create_unique ( const std::string & url_str,
InitType type = InitType::kWithInit )
inlinestaticnodiscard

Creates a Setter on the heap wrapped in a unique_ptr.

Parameters
url_strField URL string (e.g. "shm://vehicle/gear").
typekWithInit to call init() immediately (default).
Returns
UniquePtr owning the new setter.

◆ deinit()

template<typename ValueT, SecurityType SecT>
bool vlink::Setter< ValueT, SecT >::deinit ( )
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.

Returns
true on success, false if the underlying transport reports failure.

Reimplemented from vlink::Node< SetterImpl, SecurityType::kWithoutSecurity >.

Here is the call graph for this function:

◆ init()

template<typename ValueT, SecurityType SecT>
bool vlink::Setter< ValueT, SecT >::init ( )
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.

Returns
true on success, false if transport initialization fails.

Reimplemented from vlink::Node< SetterImpl, SecurityType::kWithoutSecurity >.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mark_as_publisher()

template<typename ValueT, SecurityType SecT>
void vlink::Setter< ValueT, SecT >::mark_as_publisher ( )
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.

◆ set()

template<typename ValueT, SecurityType SecT>
void vlink::Setter< ValueT, SecT >::set ( const ValueT & value)
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.

Parameters
valueThe new field value to write.

Member Data Documentation

◆ kImplType

template<typename ValueT, SecurityType SecT = SecurityType::kWithoutSecurity>
ImplType vlink::Setter< ValueT, SecT >::kImplType = kSetter
staticconstexpr

Node role identifier (kSetter).

◆ kValueType

template<typename ValueT, SecurityType SecT = SecurityType::kWithoutSecurity>
Serializer::Type vlink::Setter< ValueT, SecT >::kValueType = Serializer::get_type_of<ValueT>()
staticconstexpr

Serializer type resolved at compile time from ValueT.


The documentation for this class was generated from the following files: