VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
getter.h File Reference

Type-safe field-model reader for VLink topics. More...

#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"
Include dependency graph for getter.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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

Namespaces

Detailed Description

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) { ... });
Note
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.
Template Parameters
ValueTValue type. Must satisfy Serializer::is_supported().
SecTSecurity mode; defaults to SecurityType::kWithoutSecurity.