91 #include <shared_mutex>
95 #include "../base/macros.h"
172 uint32_t hash_code{0};
179 [[nodiscard]]
virtual std::unique_ptr<class ServerImpl>
create_server()
const;
181 [[nodiscard]]
virtual std::unique_ptr<class ClientImpl>
create_client()
const;
187 [[nodiscard]]
virtual std::unique_ptr<class SetterImpl>
create_setter()
const;
189 [[nodiscard]]
virtual std::unique_ptr<class GetterImpl>
create_getter()
const;
193 template <
typename,
typename, SecurityType>
195 template <
typename,
typename, SecurityType>
197 template <
typename, SecurityType>
199 template <
typename, SecurityType>
201 template <
typename, SecurityType>
203 template <
typename, SecurityType>
225 #define VLINK_DECLARE_CONF_FRIEND() \
226 template <typename, typename, SecurityType> \
227 friend class Server; \
228 template <typename, typename, SecurityType> \
229 friend class Client; \
230 template <typename, SecurityType> \
231 friend class Publisher; \
232 template <typename, SecurityType> \
233 friend class Subscriber; \
234 template <typename, SecurityType> \
235 friend class Setter; \
236 template <typename, SecurityType> \
250 #define VLINK_CONF_IMPL(classname) \
252 VLINK_DECLARE_CONF_FRIEND() \
254 [[nodiscard]] bool parse_protocol(struct Protocol* protocol) override; \
256 [[nodiscard]] std::unique_ptr<class ServerImpl> create_server() const override; \
258 [[nodiscard]] std::unique_ptr<class ClientImpl> create_client() const override; \
260 [[nodiscard]] std::unique_ptr<class PublisherImpl> create_publisher() const override; \
262 [[nodiscard]] std::unique_ptr<class SubscriberImpl> create_subscriber() const override; \
264 [[nodiscard]] std::unique_ptr<class SetterImpl> create_setter() const override; \
266 [[nodiscard]] std::unique_ptr<class GetterImpl> create_getter() const override; \
268 VLINK_EXPORT friend std::ostream& operator<<(std::ostream& ostream, const classname& conf) noexcept; \
271 classname() = default; \
273 ~classname() = default; \
275 [[nodiscard]] bool is_valid() const override;
291 #define VLINK_ALLOW_IMPL_TYPE(type) \
293 [[nodiscard]] static constexpr int get_allow_impl_type() { return type; }
308 #define VLINK_DECLARE_GLOBAL_PROPERTY() \
310 static size_t thread_count_; \
311 static PropertiesMap global_properties_; \
312 static std::shared_mutex global_mtx_; \
315 [[nodiscard]] static size_t get_thread_count() { return thread_count_; } \
317 static void set_thread_count(size_t thread_count) { thread_count_ = thread_count; } \
319 static void set_global_property(const std::string& prop, const std::string& value) { \
320 std::lock_guard lock(global_mtx_); \
321 global_properties_[prop] = value; \
324 [[nodiscard]] static std::string get_global_property(const std::string& prop) { \
325 std::shared_lock lock(global_mtx_); \
326 auto iter = global_properties_.find(prop); \
327 return iter != global_properties_.end() ? iter->second : std::string(); \
330 [[nodiscard]] static PropertiesMap get_global_all_properties() { \
331 std::shared_lock lock(global_mtx_); \
332 return global_properties_; \
335 static void global_init();
348 #define VLINK_DEFINE_GLOBAL_PROPERTY(classname) \
349 size_t classname::thread_count_{1}; \
350 Conf::PropertiesMap classname::global_properties_; \
351 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:148
#define VLINK_EXPORT
Definition: macros.h:81
TransportType
Enumeration of every transport backend recognised by VLink.
Definition: types.h:126
ImplType
Bitmask identifying the role of a VLink node implementation.
Definition: types.h:108
@ kUnknownImplType
Type not yet determined.
Definition: types.h:109
Abstract base for every transport-specific configuration aggregate.
Definition: conf.h:114
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:122
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:176
Conf subclass that routes virtual calls to the transport selected by a URL string.
Definition: url.h:216
Core enumerations and small value types shared by the entire VLink implementation layer.