VLink
2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
qos_profile.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2026 by Thun Lu. All rights reserved.
3
* Author: Thun Lu <thun.lu@zohomail.cn>
4
* Repo: https://github.com/thun-res/vlink
5
* _ __ __ _ __
6
* | | / / / / (_) ____ / /__
7
* | | / / / / / / / __ \ / //_/
8
* | |/ / / /___ / / / / / / / ,<
9
* |___/ /_____/ /_/ /_/ /_/ /_/|_|
10
*
11
* Licensed under the Apache License, Version 2.0 (the "License");
12
* you may not use this file except in compliance with the License.
13
* You may obtain a copy of the License at
14
*
15
* http://www.apache.org/licenses/LICENSE-2.0
16
*
17
* Unless required by applicable law or agreed to in writing, software
18
* distributed under the License is distributed on an "AS IS" BASIS,
19
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
* See the License for the specific language governing permissions and
21
* limitations under the License.
22
*/
23
24
/**
25
* @file qos_profile.h
26
* @brief Pre-defined QoS profiles for common VLink communication patterns.
27
*
28
* @details
29
* The @c QosProfile namespace provides a set of ready-to-use @c Qos constant instances
30
* covering the most common autonomy and embedded system use cases. Each profile has
31
* @c valid = @c true and can be passed directly to any VLink endpoint.
32
*
33
* Available profiles:
34
*
35
* | Profile | Reliability | History | Durability | PubMode | Priority | Use case |
36
* | ---------- | ---------- | -------------- | -------------- | ------- | ---------- | --------------------------- |
37
* | kEvent | Reliable | KeepLast(10) | Volatile | Sync | RealTime | Discrete control events |
38
* | kMethod | Reliable | KeepAll(1) | Volatile | Sync | High | RPC request/response |
39
* | kField | Reliable | KeepLast(1) | TransientLocal | Sync | High | Latest-value state sync |
40
* | kSensor | BestEffort | KeepLast(20) | Volatile | ASync | Normal | High-rate sensor data |
41
* | kParameter | Reliable | KeepLast(1000) | Volatile | Sync | Normal | Configuration parameters |
42
* | kService | Reliable | KeepLast(10) | TransientLocal | Sync | Normal | Service discovery |
43
* | kClock | BestEffort | KeepLast(1) | Volatile | ASync | Low | Time synchronisation |
44
* | kStatic | Reliable | KeepAll(1) | TransientLocal | Sync | Normal | Static/slow-changing data |
45
* | kLight | Reliable | KeepLast(1) | Volatile | ASync | High | Lightweight fast messaging |
46
* | kPoor | BestEffort | KeepLast(5) | Volatile | ASync | Background | Low-priority best-effort |
47
* | kBetter | BestEffort | KeepLast(50) | Volatile | Sync | RealTime | High-throughput best-effort |
48
* | kBest | Reliable | KeepLast(200) | Volatile | Sync | RealTime | High-throughput reliable |
49
* | kLarge | Reliable | KeepLast(500) | Volatile | Sync | Low | Large payload transfers |
50
*
51
* @par Lookup by name
52
* @c get_available_qos_map() returns an @c unordered_map from profile name string to @c Qos,
53
* enabling runtime profile selection:
54
* @code
55
* auto& qos_map = vlink::QosProfile::get_available_qos_map();
56
* auto it = qos_map.find("sensor");
57
* if (it != qos_map.end()) {
58
* pub->set_qos(it->second);
59
* }
60
* @endcode
61
*
62
* @par Direct usage
63
* @code
64
* auto pub = vlink::Publisher<MyMsg>::create("dds://sensor_data");
65
* pub->set_qos(vlink::QosProfile::kSensor);
66
* @endcode
67
*/
68
69
#pragma once
70
71
#include <string>
72
#include <unordered_map>
73
74
#include "
../base/macros.h
"
75
#include "
./qos.h
"
76
77
namespace
vlink
{
78
79
/**
80
* @namespace vlink::QosProfile
81
* @brief Pre-built @c Qos constant instances covering common communication patterns.
82
*
83
* @details
84
* All profiles have @c valid = @c true. Choose the profile that best matches your
85
* use case, or customise a copy for specific requirements.
86
*
87
* @see Qos, get_available_qos_map()
88
*/
89
namespace
QosProfile
{
// NOLINT(readability-identifier-naming)
90
91
/**
92
* @brief Reliable, KeepLast(10), Volatile, Sync, RealTime priority.
93
*
94
* @details Designed for discrete control events where delivery must be guaranteed
95
* and late arrivals are acceptable up to a depth of 10.
96
*/
97
[[maybe_unused]]
static
inline
constexpr
Qos
kEvent{
98
"event"
,
99
true
,
100
Qos::Reliability
{
Qos::Reliability::kReliable
},
101
Qos::History
{
Qos::History::kKeepLast
, 10},
102
Qos::Durability
{
Qos::Durability::kVolatile
},
103
Qos::PublishMode
{
Qos::PublishMode::kSync
},
104
Qos::Liveliness
{},
105
Qos::DestinationOrder
{},
106
Qos::Ownership
{},
107
Qos::Deadline
{},
108
Qos::Lifespan
{},
109
Qos::LatencyBudget
{},
110
Qos::ResourceLimits
{},
111
Qos::Additions
{
Qos::Additions::kPriorityRealTime
,
false
},
112
};
113
114
/**
115
* @brief Reliable, KeepAll, Volatile, Sync, High priority.
116
*
117
* @details Designed for RPC-style request/response (Method model).
118
* KeepAll ensures no request is dropped even under load.
119
*/
120
[[maybe_unused]]
static
inline
constexpr
Qos
kMethod{
121
"method"
,
122
true
,
123
Qos::Reliability
{
Qos::Reliability::kReliable
},
124
Qos::History
{
Qos::History::kKeepAll
, 1},
125
Qos::Durability
{
Qos::Durability::kVolatile
},
126
Qos::PublishMode
{
Qos::PublishMode::kSync
},
127
Qos::Liveliness
{},
128
Qos::DestinationOrder
{},
129
Qos::Ownership
{},
130
Qos::Deadline
{},
131
Qos::Lifespan
{},
132
Qos::LatencyBudget
{},
133
Qos::ResourceLimits
{},
134
Qos::Additions
{
Qos::Additions::kPriorityHigh
,
false
},
135
};
136
137
/**
138
* @brief Reliable, KeepLast(1), TransientLocal, Sync, High priority.
139
*
140
* @details Designed for Field model (Getter/Setter) where only the latest value matters
141
* and late-joining subscribers must receive the last published value.
142
*/
143
[[maybe_unused]]
static
inline
constexpr
Qos
kField{
144
"field"
,
145
true
,
146
Qos::Reliability
{
Qos::Reliability::kReliable
},
147
Qos::History
{
Qos::History::kKeepLast
, 1},
148
Qos::Durability
{
Qos::Durability::kTransientLocal
},
149
Qos::PublishMode
{
Qos::PublishMode::kSync
},
150
Qos::Liveliness
{},
151
Qos::DestinationOrder
{},
152
Qos::Ownership
{},
153
Qos::Deadline
{},
154
Qos::Lifespan
{},
155
Qos::LatencyBudget
{},
156
Qos::ResourceLimits
{},
157
Qos::Additions
{
Qos::Additions::kPriorityHigh
,
false
},
158
};
159
160
/**
161
* @brief BestEffort, KeepLast(20), Volatile, ASync, Normal priority, express.
162
*
163
* @details Designed for high-rate sensor streams (LiDAR, camera, IMU) where throughput
164
* is more important than delivery guarantees. Express mode hints for minimal queuing delay.
165
*/
166
[[maybe_unused]]
static
inline
constexpr
Qos
kSensor{
167
"sensor"
,
168
true
,
169
Qos::Reliability
{
Qos::Reliability::kBestEffort
},
170
Qos::History
{
Qos::History::kKeepLast
, 20},
171
Qos::Durability
{
Qos::Durability::kVolatile
},
172
Qos::PublishMode
{
Qos::PublishMode::kASync
},
173
Qos::Liveliness
{},
174
Qos::DestinationOrder
{},
175
Qos::Ownership
{},
176
Qos::Deadline
{},
177
Qos::Lifespan
{},
178
Qos::LatencyBudget
{},
179
Qos::ResourceLimits
{},
180
Qos::Additions
{
Qos::Additions::kPriorityNormal
,
true
},
181
};
182
183
/**
184
* @brief Reliable, KeepLast(1000), Volatile, Sync, Normal priority.
185
*
186
* @details Designed for configuration parameters that change infrequently but must
187
* be delivered reliably with a large history window.
188
*/
189
[[maybe_unused]]
static
inline
constexpr
Qos
kParameter{
190
"parameter"
,
191
true
,
192
Qos::Reliability
{
Qos::Reliability::kReliable
},
193
Qos::History
{
Qos::History::kKeepLast
, 1000},
194
Qos::Durability
{
Qos::Durability::kVolatile
},
195
Qos::PublishMode
{
Qos::PublishMode::kSync
},
196
Qos::Liveliness
{},
197
Qos::DestinationOrder
{},
198
Qos::Ownership
{},
199
Qos::Deadline
{},
200
Qos::Lifespan
{},
201
Qos::LatencyBudget
{},
202
Qos::ResourceLimits
{},
203
Qos::Additions
{
Qos::Additions::kPriorityNormal
,
false
},
204
};
205
206
/**
207
* @brief Reliable, KeepLast(10), TransientLocal, Sync, Normal priority.
208
*
209
* @details Designed for service discovery and advertisement where late joiners
210
* must see the current service registry.
211
*/
212
[[maybe_unused]]
static
inline
constexpr
Qos
kService{
213
"service"
,
214
true
,
215
Qos::Reliability
{
Qos::Reliability::kReliable
},
216
Qos::History
{
Qos::History::kKeepLast
, 10},
217
Qos::Durability
{
Qos::Durability::kTransientLocal
},
218
Qos::PublishMode
{
Qos::PublishMode::kSync
},
219
Qos::Liveliness
{},
220
Qos::DestinationOrder
{},
221
Qos::Ownership
{},
222
Qos::Deadline
{},
223
Qos::Lifespan
{},
224
Qos::LatencyBudget
{},
225
Qos::ResourceLimits
{},
226
Qos::Additions
{
Qos::Additions::kPriorityNormal
,
false
},
227
};
228
229
/**
230
* @brief BestEffort, KeepLast(1), Volatile, ASync, Low priority.
231
*
232
* @details Designed for time synchronisation broadcasts where the newest value
233
* is always more useful than older ones and missing a tick is acceptable.
234
*/
235
[[maybe_unused]]
static
inline
constexpr
Qos
kClock{
236
"clock"
,
237
true
,
238
Qos::Reliability
{
Qos::Reliability::kBestEffort
},
239
Qos::History
{
Qos::History::kKeepLast
, 1},
240
Qos::Durability
{
Qos::Durability::kVolatile
},
241
Qos::PublishMode
{
Qos::PublishMode::kASync
},
242
Qos::Liveliness
{},
243
Qos::DestinationOrder
{},
244
Qos::Ownership
{},
245
Qos::Deadline
{},
246
Qos::Lifespan
{},
247
Qos::LatencyBudget
{},
248
Qos::ResourceLimits
{},
249
Qos::Additions
{
Qos::Additions::kPriorityLow
,
false
},
250
};
251
252
/**
253
* @brief Reliable, KeepAll, TransientLocal, Sync, Normal priority.
254
*
255
* @details Designed for slowly-changing or static data (maps, calibration files) that
256
* must be fully received by any late-joining subscriber.
257
*/
258
[[maybe_unused]]
static
inline
constexpr
Qos
kStatic{
259
"static"
,
260
true
,
261
Qos::Reliability
{
Qos::Reliability::kReliable
},
262
Qos::History
{
Qos::History::kKeepAll
, 1},
263
Qos::Durability
{
Qos::Durability::kTransientLocal
},
264
Qos::PublishMode
{
Qos::PublishMode::kSync
},
265
Qos::Liveliness
{},
266
Qos::DestinationOrder
{},
267
Qos::Ownership
{},
268
Qos::Deadline
{},
269
Qos::Lifespan
{},
270
Qos::LatencyBudget
{},
271
Qos::ResourceLimits
{},
272
Qos::Additions
{
Qos::Additions::kPriorityNormal
,
false
},
273
};
274
275
/**
276
* @brief Reliable, KeepLast(1), Volatile, ASync, High priority.
277
*
278
* @details Designed for lightweight, frequent messages where only the latest value
279
* is needed and asynchronous delivery provides low overhead.
280
*/
281
[[maybe_unused]]
static
inline
constexpr
Qos
kLight{
282
"light"
,
283
true
,
284
Qos::Reliability
{
Qos::Reliability::kReliable
},
285
Qos::History
{
Qos::History::kKeepLast
, 1},
286
Qos::Durability
{
Qos::Durability::kVolatile
},
287
Qos::PublishMode
{
Qos::PublishMode::kASync
},
288
Qos::Liveliness
{},
289
Qos::DestinationOrder
{},
290
Qos::Ownership
{},
291
Qos::Deadline
{},
292
Qos::Lifespan
{},
293
Qos::LatencyBudget
{},
294
Qos::ResourceLimits
{},
295
Qos::Additions
{
Qos::Additions::kPriorityHigh
,
false
},
296
};
297
298
/**
299
* @brief BestEffort, KeepLast(5), Volatile, ASync, Background priority.
300
*
301
* @details Designed for low-priority non-critical data streams where some loss
302
* is acceptable and the lowest possible CPU overhead is desired.
303
*/
304
[[maybe_unused]]
static
inline
constexpr
Qos
kPoor{
305
"poor"
,
306
true
,
307
Qos::Reliability
{
Qos::Reliability::kBestEffort
},
308
Qos::History
{
Qos::History::kKeepLast
, 5},
309
Qos::Durability
{
Qos::Durability::kVolatile
},
310
Qos::PublishMode
{
Qos::PublishMode::kASync
},
311
Qos::Liveliness
{},
312
Qos::DestinationOrder
{},
313
Qos::Ownership
{},
314
Qos::Deadline
{},
315
Qos::Lifespan
{},
316
Qos::LatencyBudget
{},
317
Qos::ResourceLimits
{},
318
Qos::Additions
{
Qos::Additions::kPriorityBackground
,
false
},
319
};
320
321
/**
322
* @brief BestEffort, KeepLast(50), Volatile, Sync, RealTime priority.
323
*
324
* @details Designed for high-throughput best-effort streams that benefit from
325
* a larger history buffer and real-time dispatch priority.
326
*/
327
[[maybe_unused]]
static
inline
constexpr
Qos
kBetter{
328
"better"
,
329
true
,
330
Qos::Reliability
{
Qos::Reliability::kBestEffort
},
331
Qos::History
{
Qos::History::kKeepLast
, 50},
332
Qos::Durability
{
Qos::Durability::kVolatile
},
333
Qos::PublishMode
{
Qos::PublishMode::kSync
},
334
Qos::Liveliness
{},
335
Qos::DestinationOrder
{},
336
Qos::Ownership
{},
337
Qos::Deadline
{},
338
Qos::Lifespan
{},
339
Qos::LatencyBudget
{},
340
Qos::ResourceLimits
{},
341
Qos::Additions
{
Qos::Additions::kPriorityRealTime
,
false
},
342
};
343
344
/**
345
* @brief Reliable, KeepLast(200), Volatile, Sync, RealTime priority.
346
*
347
* @details Designed for high-throughput reliable streams with a large history buffer.
348
* Combines reliability guarantees with synchronous sending for predictable latency.
349
*/
350
[[maybe_unused]]
static
inline
constexpr
Qos
kBest{
351
"best"
,
352
true
,
353
Qos::Reliability
{
Qos::Reliability::kReliable
},
354
Qos::History
{
Qos::History::kKeepLast
, 200},
355
Qos::Durability
{
Qos::Durability::kVolatile
},
356
Qos::PublishMode
{
Qos::PublishMode::kSync
},
357
Qos::Liveliness
{},
358
Qos::DestinationOrder
{},
359
Qos::Ownership
{},
360
Qos::Deadline
{},
361
Qos::Lifespan
{},
362
Qos::LatencyBudget
{},
363
Qos::ResourceLimits
{},
364
Qos::Additions
{
Qos::Additions::kPriorityRealTime
,
false
},
365
};
366
367
/**
368
* @brief Reliable, KeepLast(500), Volatile, Sync, Low priority, extended heartbeat.
369
*
370
* @details Designed for large payload transfers (maps, point clouds, images) where
371
* a large history window and extended heartbeat interval accommodate slower transport.
372
*/
373
[[maybe_unused]]
static
inline
constexpr
Qos
kLarge{
374
"large"
,
375
true
,
376
Qos::Reliability
{
Qos::Reliability::kReliable
, 100, 500},
377
Qos::History
{
Qos::History::kKeepLast
, 500},
378
Qos::Durability
{
Qos::Durability::kVolatile
},
379
Qos::PublishMode
{
Qos::PublishMode::kSync
},
380
Qos::Liveliness
{},
381
Qos::DestinationOrder
{},
382
Qos::Ownership
{},
383
Qos::Deadline
{},
384
Qos::Lifespan
{},
385
Qos::LatencyBudget
{},
386
Qos::ResourceLimits
{},
387
Qos::Additions
{
Qos::Additions::kPriorityLow
,
false
},
388
};
389
390
/**
391
* @brief Returns a reference to the global map of all named QoS profiles.
392
*
393
* @details
394
* The map is keyed by the profile name string (e.g., @c "sensor", @c "event") and maps
395
* to the corresponding @c Qos constant. The map is populated with all profiles defined
396
* in this namespace and is safe to query from any thread after construction.
397
*
398
* @return Const reference to an @c unordered_map<string, Qos> of all available profiles.
399
*/
400
[[nodiscard]]
VLINK_EXPORT
const
std::unordered_map<std::string, Qos>&
get_available_qos_map
() noexcept;
401
402
}
// namespace QosProfile
403
404
}
// namespace vlink
macros.h
Platform-independent macro definitions for the VLink library.
VLINK_EXPORT
#define VLINK_EXPORT
Definition
macros.h:85
vlink::QosProfile
Pre-built Qos constant instances covering common communication patterns.
vlink::QosProfile::get_available_qos_map
VLINK_EXPORT const std::unordered_map< std::string, Qos > & get_available_qos_map() noexcept
Returns a reference to the global map of all named QoS profiles.
vlink
Definition
bytes.h:103
qos.h
Quality of Service (QoS) policy aggregate for VLink publishers and subscribers.
vlink::Qos::Additions
VLink-specific extensions beyond standard DDS QoS.
Definition
qos.h:280
vlink::Qos::Additions::kPriorityLow
@ kPriorityLow
Low-priority background work.
Definition
qos.h:296
vlink::Qos::Additions::kPriorityRealTime
@ kPriorityRealTime
Highest priority; hard real-time.
Definition
qos.h:293
vlink::Qos::Additions::kPriorityHigh
@ kPriorityHigh
High-priority processing.
Definition
qos.h:294
vlink::Qos::Additions::kPriorityBackground
@ kPriorityBackground
Lowest priority; background tasks.
Definition
qos.h:297
vlink::Qos::Additions::kPriorityNormal
@ kPriorityNormal
Default application priority.
Definition
qos.h:295
vlink::Qos::Deadline
Specifies the maximum period between successive data publications.
Definition
qos.h:231
vlink::Qos::DestinationOrder
Controls the ordering of received samples.
Definition
qos.h:196
vlink::Qos::Durability
Controls how samples persist after they are published.
Definition
qos.h:137
vlink::Qos::Durability::kVolatile
@ kVolatile
No persistence beyond the DataWriter lifetime.
Definition
qos.h:139
vlink::Qos::Durability::kTransientLocal
@ kTransientLocal
DataWriter caches samples for late-joining readers.
Definition
qos.h:140
vlink::Qos::History
Controls how many samples are kept for late-joining subscribers.
Definition
qos.h:116
vlink::Qos::History::kKeepAll
@ kKeepAll
Keep all unread samples.
Definition
qos.h:119
vlink::Qos::History::kKeepLast
@ kKeepLast
Keep only the depth most recent samples.
Definition
qos.h:118
vlink::Qos::LatencyBudget
Provides a hint about the maximum acceptable end-to-end latency.
Definition
qos.h:254
vlink::Qos::Lifespan
Specifies the maximum age of a sample before it is discarded.
Definition
qos.h:242
vlink::Qos::Liveliness
Controls how the liveness of a DataWriter is asserted and detected.
Definition
qos.h:176
vlink::Qos::Ownership
Controls whether multiple writers can write to the same instance.
Definition
qos.h:214
vlink::Qos::PublishMode
Controls whether the DataWriter sends synchronously or asynchronously.
Definition
qos.h:157
vlink::Qos::PublishMode::kASync
@ kASync
Asynchronous publish via background thread.
Definition
qos.h:160
vlink::Qos::PublishMode::kSync
@ kSync
Synchronous publish.
Definition
qos.h:159
vlink::Qos::Reliability
Controls whether message delivery is guaranteed.
Definition
qos.h:96
vlink::Qos::Reliability::kBestEffort
@ kBestEffort
Fire-and-forget; no retransmission.
Definition
qos.h:98
vlink::Qos::Reliability::kReliable
@ kReliable
Retransmit until acknowledged.
Definition
qos.h:99
vlink::Qos::ResourceLimits
Limits on the number of samples, instances, and samples per instance.
Definition
qos.h:266
vlink::Qos
Aggregate Quality of Service policy for a VLink communication endpoint.
Definition
qos.h:86
include
vlink
extension
qos_profile.h
Generated by
1.16.1