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

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

#include <getter.h>

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

Public 类型

using UniquePtr = std::unique_ptr< Getter< ValueT, SecT > >
 Owning unique-pointer alias. 更多...
 
using SharedPtr = std::shared_ptr< Getter< ValueT, SecT > >
 Owning shared-pointer alias. 更多...
 
using MsgCallback = Function< void(const ValueT &)>
 User callback signature for value updates. 更多...
 

Public 成员函数

template<typename ConfT , typename = std::enable_if_t<std::is_base_of_v<Conf, ConfT>>>
 Getter (const ConfT &conf, InitType type=InitType::kWithInit)
 Constructs a getter from a typed transport configuration object. 更多...
 
 Getter (const std::string &url_str, InitType type=InitType::kWithInit)
 Constructs a getter from a URL string. 更多...
 
 ~Getter () override
 Destroys the getter and drains in-flight transport callbacks. 更多...
 
std::optional< ValueT > get () const
 Returns the most recent cached value, if any has been received. 更多...
 
bool wait_for_value (std::chrono::milliseconds timeout=Timeout::kDefaultInterval)
 Blocks until a value is received or timeout expires. 更多...
 
bool listen (MsgCallback &&callback)
 Installs a callback invoked whenever a new value arrives. 更多...
 
void set_change_reporting (bool enable)
 Toggles change-only reporting (duplicate suppression). 更多...
 
void set_manual_unloan (bool manual_unloan) override
 Enables or disables manual-unloan mode for zero-copy receives. 更多...
 
void set_latency_and_lost_enabled (bool enable)
 Toggles per-value latency and sample-loss measurement. 更多...
 
bool is_latency_and_lost_enabled () const
 Reports whether latency and sample-loss tracking is currently active. 更多...
 
int64_t get_latency () const
 Returns the most recent end-to-end latency measurement. 更多...
 
SampleLostInfo get_lost () const
 Returns cumulative sample-delivery statistics. 更多...
 
bool get_change_reporting () const
 Reports whether change-only reporting is currently active. 更多...
 
bool init () override
 Initialises the getter and installs the internal delivery hook. 更多...
 
void interrupt () override
 Aborts any blocking wait_for_value() call. 更多...
 
void mark_as_subscriber ()
 Promotes this getter to behave as a Subscriber at the transport layer. 更多...
 

静态 Public 成员函数

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

静态 Public 属性

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

额外继承的成员函数

详细描述

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

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

Inherits the full Node API and adds field-specific operations: cached get(), blocking wait_for_value(), single-shot listen() callback, change-reporting filter, and latency / sample-loss tracking.

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

成员类型定义说明

◆ MsgCallback

template<typename ValueT , SecurityType SecT = SecurityType::kWithoutSecurity>
using vlink::Getter< ValueT, SecT >::MsgCallback = Function<void(const ValueT&)>

User callback signature for value updates.

◆ SharedPtr

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

Owning shared-pointer alias.

◆ UniquePtr

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

Owning unique-pointer alias.

构造及析构函数说明

◆ Getter() [1/2]

template<typename ValueT , SecurityType SecT>
template<typename ConfT , typename >
vlink::Getter< ValueT, SecT >::Getter ( const ConfT &  conf,
InitType  type = InitType::kWithInit 
)
inlineexplicit

Constructs a getter from a typed transport configuration object.

模板参数
ConfTConcrete configuration type derived from Conf.
参数
confPopulated configuration aggregate.
typeWhether to call init() inline; default is InitType::kWithInit.

◆ Getter() [2/2]

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

Constructs a getter from a URL string.

参数
url_strField URL such as "shm://vehicle/gear".
typeWhether to call init() inline; default is InitType::kWithInit.

◆ ~Getter()

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

Destroys the getter and drains in-flight transport callbacks.

Required so the internal delivery callback installed by init() cannot fire on the transport thread after this getter's mutex and value have already been destroyed.

成员函数说明

◆ create_shared()

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

Heap-allocates a Getter 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 getter.

◆ create_unique()

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

Heap-allocates a Getter 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 getter.

◆ get()

template<typename ValueT , SecurityType SecT>
std::optional< ValueT > vlink::Getter< ValueT, SecT >::get
inline

Returns the most recent cached value, if any has been received.

Thread-safe. Returns std::nullopt before the first matching Setter write reaches this getter.

返回
std::optional<ValueT> – the latest value, or empty.

◆ get_change_reporting()

template<typename ValueT , SecurityType SecT>
bool vlink::Getter< ValueT, SecT >::get_change_reporting
inline

Reports whether change-only reporting is currently active.

返回
true if duplicate suppression is enabled.

◆ get_latency()

template<typename ValueT , SecurityType SecT>
int64_t vlink::Getter< ValueT, SecT >::get_latency
inline

Returns the most recent end-to-end latency measurement.

返回
Latency in nanoseconds; 0 if tracking is disabled.

◆ get_lost()

template<typename ValueT , SecurityType SecT>
SampleLostInfo vlink::Getter< ValueT, SecT >::get_lost
inline

Returns cumulative sample-delivery statistics.

返回
SampleLostInfo with total expected and total lost counts.

◆ init()

template<typename ValueT , SecurityType SecT>
bool vlink::Getter< ValueT, SecT >::init
inlineoverridevirtual

Initialises the getter and installs the internal delivery hook.

Overrides Node::init() to additionally register a bytes-level callback that deserialises each delivery, invokes the user listen() callback (if installed), then updates value_ and wakes the condition variable used by wait_for_value().

返回
true on first successful initialisation; false otherwise.

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

◆ interrupt()

template<typename ValueT , SecurityType SecT>
void vlink::Getter< ValueT, SecT >::interrupt
inlineoverridevirtual

Aborts any blocking wait_for_value() call.

Overrides Node::interrupt() to additionally notify the local condition variable so that the blocking wait returns false promptly.

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

◆ is_latency_and_lost_enabled()

template<typename ValueT , SecurityType SecT>
bool vlink::Getter< ValueT, SecT >::is_latency_and_lost_enabled
inline

Reports whether latency and sample-loss tracking is currently active.

返回
true if set_latency_and_lost_enabled(true) was invoked.

◆ listen()

template<typename ValueT , SecurityType SecT>
bool vlink::Getter< ValueT, SecT >::listen ( MsgCallback &&  callback)
inline

Installs a callback invoked whenever a new value arrives.

The callback receives a deserialised ValueT reference. It runs for every setter write unless set_change_reporting(true) is active, in which case duplicate consecutive payloads are filtered out. Internally the getter first fires the callback, then updates value_ and wakes wait_for_value().

注解
Calling listen() more than once is fatal.
参数
callbackvoid(const ValueT&) invoked on each new value.
返回
true on successful installation; a second call is fatal and never returns.

◆ mark_as_subscriber()

template<typename ValueT , SecurityType SecT>
void vlink::Getter< ValueT, SecT >::mark_as_subscriber
inline

Promotes this getter to behave as a Subscriber at the transport layer.

Switches impl_type from kGetter to kSubscriber so that event-style semantics (no latest-value retention) are applied. Reinitialises the transport extension if called post-init(). Used when bridging a getter through event-only transports.

◆ set_change_reporting()

template<typename ValueT , SecurityType SecT>
void vlink::Getter< ValueT, SecT >::set_change_reporting ( bool  enable)
inline

Toggles change-only reporting (duplicate suppression).

When enabled, incoming payloads whose raw serialised bytes match the previous delivery are dropped before any caching or callback dispatch. Useful when a Setter repeatedly writes the same value.

参数
enabletrue to suppress duplicates; false (default) to deliver all.

◆ set_latency_and_lost_enabled()

template<typename ValueT , SecurityType SecT>
void vlink::Getter< ValueT, SecT >::set_latency_and_lost_enabled ( bool  enable)
inline

Toggles per-value latency and sample-loss measurement.

参数
enabletrue to begin tracking; false to stop.

◆ set_manual_unloan()

template<typename ValueT , SecurityType SecT>
void vlink::Getter< ValueT, SecT >::set_manual_unloan ( bool  manual_unloan)
inlineoverridevirtual

Enables or disables manual-unloan mode for zero-copy receives.

参数
manual_unloantrue to enable manual return; false for auto-return.

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

◆ wait_for_value()

template<typename ValueT , SecurityType SecT>
bool vlink::Getter< ValueT, SecT >::wait_for_value ( std::chrono::milliseconds  timeout = Timeout::kDefaultInterval)
inline

Blocks until a value is received or timeout expires.

Returns immediately if a value is already cached. A timeout of 0 is treated as infinite (with a warning). interrupt() causes the wait to abort and return false. Use get() afterwards to retrieve the value when this method returns true.

参数
timeoutMaximum wait duration. Default: Timeout::kDefaultInterval.
返回
true if a value was received; false on timeout or interrupt.

类成员变量说明

◆ kImplType

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

Node role tag (kGetter).

◆ kValueType

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

Codec resolved from ValueT.


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