VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
vlink::Getter< ValueT, SecT > 模板类 参考

Type-safe field 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>>
 Unique-pointer alias.
using SharedPtr = std::shared_ptr<Getter<ValueT, SecT>>
 Shared-pointer alias.
using MsgCallback = std::function<void(const ValueT&)>
 User-facing callback type for value-change notifications.

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.
std::optional< ValueT > get () const
 Returns the latest cached value, if one has been received.
bool wait_for_value (std::chrono::milliseconds timeout=Timeout::kDefaultInterval)
 Blocks until a value is received or the timeout expires.
bool listen (MsgCallback &&callback)
 Registers a callback invoked whenever a new value arrives.
void set_change_reporting (bool enable)
 Enables or disables change-reporting (suppress duplicate values).
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)
 Enables or disables per-value latency and sample-loss tracking.
bool is_latency_and_lost_enabled () const
 Returns true if latency and sample-loss tracking is active.
int64_t get_latency () const
 Returns the most recently measured end-to-end value latency.
SampleLostInfo get_lost () const
 Returns cumulative sample delivery statistics.
bool get_change_reporting () const
 Returns true if change-reporting mode is currently active.
bool init () override
 Initialises the getter and registers the internal delivery callback.
void interrupt () override
 Interrupts any blocking wait_for_value() call.
void mark_as_subscriber ()
 Changes this getter's role to kSubscriber (event-receiver).

静态 Public 成员函数

static UniquePtr create_unique (const std::string &url_str, InitType type=InitType::kWithInit)
 Creates a Getter on the heap wrapped in a unique_ptr.
static SharedPtr create_shared (const std::string &url_str, InitType type=InitType::kWithInit)
 Creates a Getter on the heap wrapped in a shared_ptr.

静态 Public 属性

static constexpr ImplType kImplType = kGetter
 Node role identifier (kGetter).
static constexpr Serializer::Type kValueType = Serializer::get_type_of<ValueT>()
 Serializer type resolved at compile time from ValueT.

额外继承的成员函数

详细描述

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

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

模板参数
ValueTValue type to read.
SecTSecurity mode.

成员类型定义说明

◆ MsgCallback

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

User-facing callback type for value-change notifications.

◆ SharedPtr

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

Shared-pointer alias.

◆ UniquePtr

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

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.

模板参数
ConfTConf-derived configuration type.
参数
confPopulated configuration object.
typekWithInit to call init() immediately (default).
函数调用图:
这是这个函数的调用关系图:

◆ 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 (e.g. "shm://vehicle/gear").
typekWithInit to call init() immediately (default).
函数调用图:

成员函数说明

◆ 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 )
inlinestaticnodiscard

Creates a Getter on the heap wrapped in a shared_ptr.

参数
url_strField URL string.
typekWithInit to call init() immediately (default).
返回
SharedPtr owning 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 )
inlinestaticnodiscard

Creates a Getter on the heap wrapped in a unique_ptr.

参数
url_strField URL string (e.g. "shm://vehicle/gear").
typekWithInit to call init() immediately (default).
返回
UniquePtr owning the new getter.

◆ get()

template<typename ValueT, SecurityType SecT>
std::optional< ValueT > vlink::Getter< ValueT, SecT >::get ( ) const
inlinenodiscard

Returns the latest cached value, if one has been received.

Thread-safe. Returns std::nullopt if no Setter has written a value yet since this getter was initialised.

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

◆ get_change_reporting()

template<typename ValueT, SecurityType SecT>
bool vlink::Getter< ValueT, SecT >::get_change_reporting ( ) const
inlinenodiscard

Returns true if change-reporting mode is currently active.

返回
true if duplicate suppression is enabled.

◆ get_latency()

template<typename ValueT, SecurityType SecT>
int64_t vlink::Getter< ValueT, SecT >::get_latency ( ) const
inlinenodiscard

Returns the most recently measured end-to-end value latency.

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

◆ get_lost()

template<typename ValueT, SecurityType SecT>
SampleLostInfo vlink::Getter< ValueT, SecT >::get_lost ( ) const
inlinenodiscard

Returns cumulative sample delivery statistics.

返回
SampleLostInfo with total expected and lost value counts.

◆ init()

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

Initialises the getter and registers the internal delivery callback.

Overrides Node::init() to also set up the internal listen_bytes() callback that receives raw bytes, deserialises them into ValueT, stores the result in value_, and fires the user listen() callback.

返回
true on success; false if already initialised.

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

函数调用图:
这是这个函数的调用关系图:

◆ interrupt()

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

Interrupts any blocking wait_for_value() call.

Overrides Node::interrupt() to additionally notify the getter's own condition variable, causing wait_for_value() to return false.

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

Returns true if latency and sample-loss tracking is active.

返回
true if set_latency_and_lost_enabled(true) was called.

◆ listen()

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

Registers a callback invoked whenever a new value arrives.

The callback receives a pre-deserialized ValueT reference. It is invoked on every setter write unless set_change_reporting(true) is active, in which case duplicate values (same raw bytes as the last) are suppressed before the callback is called.

Internally, Getter also maintains value_ and notifies wait_for_value(). The listen callback is stored once; calling listen() more than once is a fatal error.

参数
callbackvoid(const ValueT&) invoked on each new value.
返回
true always (registration is deferred to init()).

◆ mark_as_subscriber()

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

Changes this getter's role to kSubscriber (event-receiver).

Updates impl_->impl_type from kGetter to kSubscriber so that transport-specific event semantics are applied. If called after init(), the extension is automatically reinitialised. Used internally when routing a Getter through an event-capable transport.

◆ set_change_reporting()

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

Enables or disables change-reporting (suppress duplicate values).

When true, incoming values whose raw serialized bytes are identical to the previous delivery are silently dropped – neither the callback nor wait_for_value() is notified. Useful for reducing CPU load when a Setter writes the same value repeatedly.

参数
enabletrue to enable change-only reporting; false to disable.

◆ set_latency_and_lost_enabled()

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

Enables or disables per-value latency and sample-loss tracking.

参数
enabletrue to start 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; false for automatic (default).

重载 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 the timeout expires.

Returns immediately if a value is already available. A timeout of 0 is treated as infinite (a warning is logged). Can be interrupted by interrupt(), which causes this method to return false.

After returning true, call get() to retrieve the value.

参数
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>
ImplType vlink::Getter< ValueT, SecT >::kImplType = kGetter
staticconstexpr

Node role identifier (kGetter).

◆ kValueType

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

Serializer type resolved at compile time from ValueT.


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