VLink  2.0.0
A high-performance communication middleware
vlink::Setter< ValueT, SecT > Class Template Reference

Type-safe latest-value 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 > >
 Owning unique-pointer alias. More...
 
using SharedPtr = std::shared_ptr< Setter< ValueT, SecT > >
 Owning shared-pointer alias. More...
 

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. More...
 
 Setter (const std::string &url_str, InitType type=InitType::kWithInit)
 Constructs a setter from a URL string. More...
 
 ~Setter () override
 Destroys the setter and drains in-flight transport callbacks. More...
 
bool init () override
 Initialises the setter and registers the late-getter sync() hook. More...
 
bool deinit () override
 Deinitialises the setter and releases the underlying transport resources. More...
 
void set (const ValueT &value)
 Writes a new field value and emits it to every connected Getter. More...
 
void mark_as_publisher ()
 Promotes this setter to behave as a Publisher at the transport layer. More...
 

Static Public Member Functions

static UniquePtr create_unique (const std::string &url_str, InitType type=InitType::kWithInit)
 Heap-allocates a Setter and wraps it in a std::unique_ptr. More...
 
static SharedPtr create_shared (const std::string &url_str, InitType type=InitType::kWithInit)
 Heap-allocates a Setter and wraps it in a std::shared_ptr. More...
 

Static Public Attributes

static constexpr ImplType kImplType = kSetter
 Node role tag (kSetter). More...
 
static constexpr Serializer::Type kValueType = Serializer::get_type_of<ValueT>()
 Codec resolved from ValueT. More...
 

Additional Inherited Members

Detailed Description

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

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

Inherits the full Node API and adds field-specific operations: cached set(), automatic late-joiner sync via an internally registered sync() callback, and bridging hooks to behave as a plain publisher on transports that do not natively differentiate the two roles.

Template Parameters
ValueTC++ value type. Must satisfy Serializer::is_supported().
SecTSecurity mode; defaults to SecurityType::kWithoutSecurity.

Member Typedef Documentation

◆ SharedPtr

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

Owning shared-pointer alias.

◆ UniquePtr

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

Owning 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. Following init() the setter registers a transport-level sync() callback that re-emits the cached value whenever a late Getter connects.

Template Parameters
ConfTConcrete configuration type derived from Conf.
Parameters
confPopulated configuration aggregate.
typeWhether to call init() inline; default is InitType::kWithInit.

◆ 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 such as "dds://vehicle/gear".
typeWhether to call init() inline; default is InitType::kWithInit.

◆ ~Setter()

template<typename ValueT , SecurityType SecT>
vlink::Setter< ValueT, SecT >::~Setter
inlineoverride

Destroys the setter and drains in-flight transport callbacks.

Required so the sync() callback installed by init() cannot fire on the transport thread after this setter's mutex and cached value have already been destroyed. Mirrors the lifecycle contract of Client and Getter.

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

Heap-allocates a Setter and wraps it in a std::shared_ptr.

Parameters
url_strField URL string.
typeWhether to call init() inline; default is InitType::kWithInit.
Returns
Owning SharedPtr to 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 
)
inlinestatic

Heap-allocates a Setter and wraps it in a std::unique_ptr.

Parameters
url_strField URL such as "shm://vehicle/gear".
typeWhether to call init() inline; default is InitType::kWithInit.
Returns
Owning UniquePtr to the new setter.

◆ deinit()

template<typename ValueT , SecurityType SecT>
bool vlink::Setter< ValueT, SecT >::deinit
inlineoverridevirtual

Deinitialises the setter and releases the underlying transport resources.

Delegates to the base Node teardown path. After deinitialisation the setter no longer participates in sync() or writes until init() is called again.

Returns
true on first successful deinitialisation; false if not initialised.

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

Initialises the setter and registers the late-getter sync() hook.

Calls the base Node initialisation, then installs a transport-level callback that resends the cached value whenever a new Getter joins after this setter has already been written.

Returns
true on first successful initialisation; false otherwise.

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

◆ mark_as_publisher()

template<typename ValueT , SecurityType SecT>
void vlink::Setter< ValueT, SecT >::mark_as_publisher
inline

Promotes this setter to behave as a Publisher at the transport layer.

Switches impl_type from kSetter to kPublisher so that event-mode semantics are applied (no latest-value retention). Reinitialises the transport extension if called post-init(). Useful 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 emits it to every connected Getter.

Caches value under mtx_, then serialises and writes it via the transport. When security is enabled the serialised payload is encrypted before transmission. The cached value is automatically re-emitted when a late Getter joins (see init()).

Parameters
valueNew field value to publish.

Member Data Documentation

◆ kImplType

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

Node role tag (kSetter).

◆ kValueType

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

Codec resolved from ValueT.


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