92 #include <shared_mutex>
96 #include "../base/macros.h"
173 uint32_t hash_code{0};
180 [[nodiscard]]
virtual std::unique_ptr<class ServerImpl>
create_server()
const;
182 [[nodiscard]]
virtual std::unique_ptr<class ClientImpl>
create_client()
const;
188 [[nodiscard]]
virtual std::unique_ptr<class SetterImpl>
create_setter()
const;
190 [[nodiscard]]
virtual std::unique_ptr<class GetterImpl>
create_getter()
const;
194 template <
typename,
typename, SecurityType>
196 template <
typename,
typename, SecurityType>
198 template <
typename, SecurityType>
200 template <
typename, SecurityType>
202 template <
typename, SecurityType>
204 template <
typename, SecurityType>
226 #define VLINK_DECLARE_CONF_FRIEND() \
227 template <typename, typename, SecurityType> \
228 friend class Server; \
229 template <typename, typename, SecurityType> \
230 friend class Client; \
231 template <typename, SecurityType> \
232 friend class Publisher; \
233 template <typename, SecurityType> \
234 friend class Subscriber; \
235 template <typename, SecurityType> \
236 friend class Setter; \
237 template <typename, SecurityType> \
251 #define VLINK_CONF_IMPL(classname) \
253 VLINK_DECLARE_CONF_FRIEND() \
255 [[nodiscard]] bool parse_protocol(struct Protocol* protocol) override; \
257 [[nodiscard]] std::unique_ptr<class ServerImpl> create_server() const override; \
259 [[nodiscard]] std::unique_ptr<class ClientImpl> create_client() const override; \
261 [[nodiscard]] std::unique_ptr<class PublisherImpl> create_publisher() const override; \
263 [[nodiscard]] std::unique_ptr<class SubscriberImpl> create_subscriber() const override; \
265 [[nodiscard]] std::unique_ptr<class SetterImpl> create_setter() const override; \
267 [[nodiscard]] std::unique_ptr<class GetterImpl> create_getter() const override; \
269 VLINK_EXPORT friend std::ostream& operator<<(std::ostream& ostream, const classname& conf) noexcept; \
272 classname() = default; \
274 ~classname() = default; \
276 [[nodiscard]] bool is_valid() const override;
292 #define VLINK_ALLOW_IMPL_TYPE(type) \
294 [[nodiscard]] static constexpr int get_allow_impl_type() { return type; }
309 #define VLINK_DECLARE_GLOBAL_PROPERTY() \
311 static size_t thread_count_; \
312 static PropertiesMap global_properties_; \
313 static std::shared_mutex global_mtx_; \
316 [[nodiscard]] static size_t get_thread_count() { return thread_count_; } \
318 static void set_thread_count(size_t thread_count) { thread_count_ = thread_count; } \
320 static void set_global_property(const std::string& prop, const std::string& value) { \
321 std::lock_guard lock(global_mtx_); \
322 global_properties_[prop] = value; \
325 [[nodiscard]] static std::string get_global_property(const std::string& prop) { \
326 std::shared_lock lock(global_mtx_); \
327 auto iter = global_properties_.find(prop); \
328 return iter != global_properties_.end() ? iter->second : std::string(); \
331 [[nodiscard]] static PropertiesMap get_global_all_properties() { \
332 std::shared_lock lock(global_mtx_); \
333 return global_properties_; \
336 static void global_init();
349 #define VLINK_DEFINE_GLOBAL_PROPERTY(classname) \
350 size_t classname::thread_count_{1}; \
351 Conf::PropertiesMap classname::global_properties_; \
352 std::shared_mutex classname::global_mtx_;
Type-safe RPC caller for the VLink method communication model.
Definition: client.h:132
Type-safe latest-value reader for the VLink field communication model.
Definition: getter.h:122
Type-safe topic emitter for the VLink event communication model.
Definition: publisher.h:130
Type-safe RPC handler for the VLink method communication model.
Definition: server.h:126
Type-safe latest-value writer for the VLink field communication model.
Definition: setter.h:113
Type-safe topic listener for the VLink event communication model.
Definition: subscriber.h:142
#define VLINK_EXPORT
Definition: macros.h:81
TransportType
Enumeration of every transport backend recognised by VLink.
Definition: types.h:128
ImplType
Bitmask identifying the role of a VLink node implementation.
Definition: types.h:110
@ kUnknownImplType
Type not yet determined.
Definition: types.h:111
Abstract base for every transport-specific configuration aggregate.
Definition: conf.h:115
virtual ImplType get_impl_type() const
Returns the ImplType cached by the most recent parse() call.
virtual std::unique_ptr< class ServerImpl > create_server() const
virtual std::unique_ptr< class GetterImpl > create_getter() const
virtual bool parse_protocol(struct Protocol *protocol)
virtual std::unique_ptr< class SubscriberImpl > create_subscriber() const
std::map< std::string, std::string > PropertiesMap
Key/value property map shared between confs and node implementations.
Definition: conf.h:123
virtual std::unique_ptr< class SetterImpl > create_setter() const
virtual bool parse(ImplType impl_type) const
Validates the conf for impl_type and caches it for subsequent factories.
virtual bool is_valid() const
Indicates whether the conf currently holds usable data.
virtual TransportType get_transport_type() const
Returns the transport backend this conf wraps.
virtual std::unique_ptr< class ClientImpl > create_client() const
virtual ~Conf()
Virtual destructor.
virtual std::unique_ptr< class PublisherImpl > create_publisher() const
Plain-data record describing the parsed components of a VLink URL.
Definition: url.h:173
Conf subclass that routes virtual calls to the transport selected by a URL string.
Definition: url.h:213
Core enumerations and small value types shared by the entire VLink implementation layer.