VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
getter.h 文件参考

Type-safe field-model reader for VLink topics. 更多...

#include <functional>
#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include "./base/condition_variable.h"
#include "./impl/getter_impl.h"
#include "./node.h"
#include "./internal/getter-inl.h"
getter.h 的引用(Include)关系图:
此图展示该文件被哪些文件直接或间接地引用了:

浏览该文件的源代码.

 Type-safe field reader for the VLink field communication model. 更多...
 Convenience alias for Getter with message security enabled. 更多...

命名空间

详细描述

Type-safe field-model reader for VLink topics.

Getter<ValueT, SecT> is the read side of the VLink field model. It maintains the latest value published by any matching Setter on the same URL. Unlike Subscriber, it retains only the most recent value rather than queuing a history of updates.

Field Model Overview
Setter<T> Transport Back-end Getter<T>
| | |
|-- set(value) ----------> | |
| serialize(value) |-- latest-value delivery ----> |
| | (overwrites previous) |--> listen callback(value)
| | | value_ updated
| | |--> get() returns latest
Key Differences: Getter vs Subscriber
Feature Getter<T> Subscriber<T>
Value retention Latest value cached No caching
Transport role kGetter kSubscriber
Blocking read wait_for_value() N/A
Change-reporting filter set_change_reporting(true) No built-in filter
Cross-transport use As subscriber: mark_as_subscriber() As getter: mark_as_getter()
Usage Patterns
// Pattern 1: polling
Getter<int> g("shm://my_field");
if (auto v = g.get()) {
std::cout << "value: " << *v << std::endl;
}
// Pattern 2: blocking wait
if (g.wait_for_value()) {
auto v = g.get();
}
// Pattern 3: value-change callback (fires when Setter writes a new value)
g.listen([](const int& v) { std::cout << "updated: " << v << std::endl; });
// Pattern 4: change-only reporting (suppress duplicate values)
g.set_change_reporting(true);
g.listen([](const int& v) { ... });
注解
get() and wait_for_value() both require a prior Setter write to return a value. Before any Setter has written, get() returns std::nullopt and wait_for_value() blocks until one does.
模板参数
ValueTValue type. Must satisfy Serializer::is_supported().
SecTSecurity mode; defaults to SecurityType::kWithoutSecurity.