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

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

#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include "./impl/setter_impl.h"
#include "./node.h"
#include "./internal/setter-inl.h"
Include dependency graph for setter.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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

Namespaces

Detailed Description

Type-safe field-model writer for VLink topics.

Setter<ValueT, SecT> is the write side of the VLink field model. Each call to set() serialises the value and writes it to the transport as the new "latest value" for the topic. All Getter nodes on the same URL will be notified of the update.

Field Model Overview
Setter<T> Transport Back-end Getter<T>
| | |
|-- set(value) ----------> | |
| serialize(value) | |
| |-- latest-value delivery ----> |
| | (overwrites previous) |--> callback(value)
| | |--> get() => value
Key Differences: Setter vs Publisher
Feature Setter<T> Publisher<T>
Transport role kSetter kPublisher
Value retention Last value re-sent to late getters No re-send to late subs
Sync callback on connect Yes – sync() callback No
Cross-transport use As publisher: mark_as_publisher() As setter: mark_as_setter()
Sync on Late Connect
When a Getter connects after the Setter has already written, the transport fires the sync() callback registered internally. The Setter re-sends its cached value so the late Getter receives the current state immediately:
Setter<int> s("shm://my_field");
s.set(42); // Getter joins later and immediately receives 42
Usage
Setter<MyStruct> setter("dds://vehicle/gear");
setter.set(MyStruct{3, "Drive"}); // write a new field value
Template Parameters
ValueTValue type. Must satisfy Serializer::is_supported().
SecTSecurity mode; defaults to SecurityType::kWithoutSecurity.