VLink  2.0.0
A high-performance communication middleware
vlink::Setter< ValueT, SecT > 模板类 参考

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

#include <setter.h>

类 vlink::Setter< ValueT, SecT > 继承关系图:
vlink::Setter< ValueT, SecT > 的协作图:

Public 类型

using UniquePtr = std::unique_ptr< Setter< ValueT, SecT > >
 Owning unique-pointer alias. 更多...
 
using SharedPtr = std::shared_ptr< Setter< ValueT, SecT > >
 Owning shared-pointer alias. 更多...
 

Public 成员函数

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

静态 Public 成员函数

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. 更多...
 
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. 更多...
 

静态 Public 属性

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

额外继承的成员函数

详细描述

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.

模板参数
ValueTC++ value type. Must satisfy Serializer::is_supported().
SecTSecurity mode; defaults to SecurityType::kWithoutSecurity.

成员类型定义说明

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

构造及析构函数说明

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

模板参数
ConfTConcrete configuration type derived from Conf.
参数
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.

参数
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.

成员函数说明

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

参数
url_strField URL string.
typeWhether to call init() inline; default is InitType::kWithInit.
返回
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.

参数
url_strField URL such as "shm://vehicle/gear".
typeWhether to call init() inline; default is InitType::kWithInit.
返回
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.

返回
true on first successful deinitialisation; false if not initialised.

重载 vlink::Node< SetterImpl, SecurityType::kWithoutSecurity > .

函数调用图:

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

返回
true on first successful initialisation; false otherwise.

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

参数
valueNew field value to publish.

类成员变量说明

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


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