VLink  2.0.0
A high-performance communication middleware
qnx_conf.h
浏览该文件的文档.
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 qnx_conf.h
26  * @brief Transport configuration for the @c qnx:// QNX native channel transport.
27  *
28  * @details
29  * @c QnxConf binds the @c qnx:// URL scheme to the QNX Neutrino native IPC
30  * primitives (channels and connections). Messaging is performed directly through
31  * @c ChannelCreate / @c ConnectAttach / @c MsgSend / @c MsgReceive without any
32  * intermediate broker; this yields deterministic, low-jitter latency suitable
33  * for hard real-time workloads. The transport is available only when the binary
34  * is compiled for a QNX target.
35  *
36  * @par Supported Node Types
37  *
38  * | Publisher | Subscriber | Server | Client | Getter | Setter |
39  * | :-------: | :--------: | :----: | :----: | :----: | :----: |
40  * | yes | yes | yes | yes | yes | yes |
41  *
42  * @par URL Format
43  * @code
44  * qnx://<address>[?event=<name>]
45  * @endcode
46  *
47  * | Component | Description |
48  * | ---------- | ---------------------------------------------------------------------- |
49  * | @c address | QNX channel/topic name (URL host concatenated with path); not empty |
50  * | @c event | Optional secondary event filter (@c ?event=) |
51  *
52  * @par Channel / Connection Topology
53  * @code
54  * Publisher / Server Subscriber / Client
55  * ------------------ ------------------------
56  * ChannelCreate(<address>) <---- MsgSend ---- ConnectAttach(<address>)
57  * | |
58  * v v
59  * MsgReceive() loop MsgSend() / pulse
60  * @endcode
61  *
62  * @par Example
63  * @code
64  * auto pub = vlink::Publisher<MyMsg>::create_unique("qnx://control/cmd");
65  * auto sub = vlink::Subscriber<MyMsg>::create_unique("qnx://control/cmd");
66  * @endcode
67  *
68  * @note Compiled only when @c VLINK_SUPPORT_QNX is defined.
69  * @note QNX-only transport; not usable on Linux, Windows, or macOS hosts.
70  * @note @c is_valid() returns @c false when @c address is empty.
71  */
72 
73 #pragma once
74 
75 #ifdef VLINK_SUPPORT_QNX
76 
77 #include <cstdint>
78 #include <string>
79 
80 #include "../impl/conf.h"
81 
82 namespace vlink {
83 
84 /**
85  * @struct QnxConf
86  * @brief Concrete @c Conf describing a QNX-native channel endpoint addressed by a @c qnx:// URL.
87  *
88  * @details
89  * Carries only the channel/topic name and an optional secondary event filter.
90  * Other QNX-specific settings (priority inheritance, pulse code, etc.) are
91  * inferred from the @c Qos object attached at endpoint construction time.
92  */
93 struct VLINK_EXPORT QnxConf final : public Conf {
94  std::string address; ///< QNX channel/topic address (URL host concatenated with path); must not be empty.
95  std::string event; ///< Optional secondary event filter string.
96 
97  /**
98  * @brief Builds a @c QnxConf from its two logical fields.
99  *
100  * @param _address Channel/topic address string; must not be empty.
101  * @param _event Optional secondary event filter; empty by default.
102  */
103  explicit QnxConf(const std::string& _address, const std::string& _event = "");
104 
105  /**
106  * @brief Component-wise equality on @c address and @c event.
107  *
108  * @param conf Configuration to compare with.
109  * @return @c true when both fields match.
110  */
111  [[nodiscard]] bool operator==(const QnxConf& conf) const noexcept;
112 
113  /**
114  * @brief Logical negation of @c operator==.
115  *
116  * @param conf Configuration to compare with.
117  * @return @c true when either field differs from @p conf.
118  */
119  [[nodiscard]] bool operator!=(const QnxConf& conf) const noexcept;
120 
121  /**
122  * @brief Reports this object's transport tag.
123  *
124  * @return @c TransportType::kQnx.
125  */
126  [[nodiscard]] TransportType get_transport_type() const override;
127 
128 #ifndef VLINK_ENABLE_C_INTERFACE
130 #endif
132  VLINK_CONF_IMPL(QnxConf)
133 };
134 
135 ////////////////////////////////////////////////////////////////
136 /// Details
137 ////////////////////////////////////////////////////////////////
138 
139 inline QnxConf::QnxConf(const std::string& _address, const std::string& _event) : address(_address), event(_event) {}
140 
141 inline bool QnxConf::operator==(const QnxConf& conf) const noexcept {
142  return address == conf.address && event == conf.event;
143 }
144 
145 inline bool QnxConf::operator!=(const QnxConf& conf) const noexcept { return !(*this == conf); }
146 
147 inline TransportType QnxConf::get_transport_type() const { return TransportType::kQnx; }
148 
149 } // namespace vlink
150 
151 #endif
#define VLINK_CONF_IMPL(classname)
Convenience macro that emits the standard concrete conf boilerplate.
Definition: conf.h:251
#define VLINK_DECLARE_GLOBAL_PROPERTY()
Declares per-transport static configuration storage and access helpers.
Definition: conf.h:309
#define VLINK_ALLOW_IMPL_TYPE(type)
Records the bitmask of ImplType values supported by a conf.
Definition: conf.h:292
#define VLINK_EXPORT
Definition: macros.h:81