VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
vlink.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 vlink.h
26 * @brief Umbrella header that exposes the complete VLink public communication API.
27 *
28 * @details
29 * Including this single header is sufficient to access all six communication
30 * primitives together with the message-loop dispatcher and common utility helpers.
31 * No other VLink headers need to be included directly.
32 *
33 * @par Included APIs
34 * | Header | Primitive(s) | Communication Model |
35 * | ----------------------- | ------------------------------- | ------------------------- |
36 * | @c client.h | @c Client<ReqT,RespT> | Method -- caller side |
37 * | @c server.h | @c Server<ReqT,RespT> | Method -- handler side |
38 * | @c publisher.h | @c Publisher<MsgT> | Event -- message emitter |
39 * | @c subscriber.h | @c Subscriber<MsgT> | Event -- message receiver |
40 * | @c getter.h | @c Getter<ValueT> | Field -- value reader |
41 * | @c setter.h | @c Setter<ValueT> | Field -- value writer |
42 * | @c base/message_loop.h | @c MessageLoop | Callback dispatcher |
43 * | @c base/utils.h | utility functions | General helpers |
44 *
45 * @par Transport Back-end Selection
46 * Switch the underlying transport by changing only the transport prefix in the URL.
47 * All API calls remain identical:
48 *
49 * @code
50 * Publisher<MyMsg> pub("dds://vehicle/speed"); // DDS transport
51 * Publisher<MyMsg> pub("shm://vehicle/speed"); // shared-memory transport
52 * Publisher<MyMsg> pub("zenoh://vehicle/speed"); // Zenoh transport
53 * @endcode
54 *
55 * .-~~~~~~~~~-._ _.-~~~~~~~~~-.
56 * __.' ~. .~ `.__
57 * .'// \./ \\`.
58 * .'// | \\`.
59 * .'// .-~"""""""~~~~-._ | _,-~~~~"""""""~-. \\`.
60 * .'//.-" `-. | .-' "-.\\`.
61 * .'//______.============-.. \ | / ..-============.______\\`.
62 * .'______________________________\|/______________________________`.
63 *
64 * @par Quick-start Example
65 * @code
66 * #include <vlink/vlink.h>
67 * using namespace vlink;
68 *
69 * // --- Event model ---
70 * Subscriber<MyMsg> sub("dds://my_topic");
71 * sub.listen([](const MyMsg& msg) { ... });
72 *
73 * Publisher<MyMsg> pub("dds://my_topic");
74 * pub.publish(MyMsg{});
75 *
76 * // --- Method model (synchronous) ---
77 * Server<Req, Resp> server("dds://my_service");
78 * server.listen([](const Req& req, Resp& resp) { resp = ...; });
79 *
80 * Client<Req, Resp> client("dds://my_service");
81 * Resp resp;
82 * client.invoke(Req{}, resp);
83 *
84 * // --- Field model ---
85 * Setter<int> setter("shm://my_field");
86 * setter.set(42);
87 *
88 * Getter<int> getter("shm://my_field");
89 * auto val = getter.get(); // returns std::optional<int>
90 * @endcode
91 *
92 * @note To enable message security, replace the type with the security variant:
93 * @c SecurityPublisher<T>, @c SecuritySubscriber<T>, @c SecurityClient<Req,Resp>,
94 * @c SecurityServer<Req,Resp>, @c SecurityGetter<T>, @c SecuritySetter<T>.
95 */
96
97#pragma once
98
99// NOLINTBEGIN
100
101// method
102#include "./client.h"
103#include "./server.h"
104
105// event
106#include "./publisher.h"
107#include "./subscriber.h"
108
109// field
110#include "./getter.h"
111#include "./setter.h"
112
113// message_loop
114#include "./base/message_loop.h"
115
116// utils
117#include "./base/utils.h"
118
119// NOLINTEND
Type-safe method-model client (caller side) for VLink RPC.
Type-safe field-model reader for VLink topics.
Single-threaded event loop with three queue types, timer management and task scheduling.
Type-safe event-model publisher for VLink topics.
Type-safe method-model server (handler side) for VLink RPC.
Type-safe field-model writer for VLink topics.
Type-safe event-model subscriber for VLink topics.
Platform-agnostic system utilities for process, thread, network and signal management.