VLink  2.0.0
A high-performance communication middleware
conf.h File Reference

Transport-configuration base contract and the supporting boilerplate macros. More...

#include <map>
#include <memory>
#include <shared_mutex>
#include <string>
#include <utility>
#include "../base/macros.h"
#include "./types.h"
Include dependency graph for conf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  vlink::Conf
 Abstract base for every transport-specific configuration aggregate. More...
 

Namespaces

 

Macros

#define VLINK_DECLARE_CONF_FRIEND()
 Macro Definitions. More...
 
#define VLINK_CONF_IMPL(classname)
 Convenience macro that emits the standard concrete conf boilerplate. More...
 
#define VLINK_ALLOW_IMPL_TYPE(type)
 Records the bitmask of ImplType values supported by a conf. More...
 
#define VLINK_DECLARE_GLOBAL_PROPERTY()
 Declares per-transport static configuration storage and access helpers. More...
 
#define VLINK_DEFINE_GLOBAL_PROPERTY(classname)
 Provides storage for the statics declared by VLINK_DECLARE_GLOBAL_PROPERTY. More...
 

Detailed Description

Transport-configuration base contract and the supporting boilerplate macros.

This is an internal implementation header used by the public node templates and by every transport-specific *Conf class; user code should never include it directly. The Conf base struct is the bridge between the URL parsing layer and the concrete factories that produce NodeImpl instances. A typical node construction follows the chain Url -> concrete Conf -> Conf::create_xxx() -> NodeImpl subclass.

Inheritance hierarchy
+--------+
| Conf |
+---+----+
|
+---------+--------+--------+---------+----------+--------------+-----------+
| | | | | | | |
IntraConf ShmConf Shm2Conf ZenohConf DdsConf DdscConf MqttConf ...etc
(DdsrConf, DdstConf, SomeipConf,
FdbusConf, QnxConf, plugin Conf)
Virtual interface contract
Method Default behaviour Subclass responsibility
parse(impl_type) Caches impl_type; rejects kUnknown. Validate transport-specific data.
is_valid() Returns false. Report readiness for factories.
get_impl_type() Returns the cached value from parse(). Usually inherited unchanged.
get_transport_type() Returns TransportType::kUnknown. Return the backend identifier.
parse_protocol(protocol) Returns false. Pull URL fields into the conf.
create_publisher() / etc. Returns nullptr. Allocate the matching NodeImpl.
Macro reference
Macro Purpose
VLINK_DECLARE_CONF_FRIEND Grants friend access to all six public Node<> templates.
VLINK_CONF_IMPL(classname) Bundles friend grant + standard override declarations + ostream op.
VLINK_ALLOW_IMPL_TYPE(type) Records which ImplType bits a conf may serve, for compile checks.
VLINK_DECLARE_GLOBAL_PROPERTY Declares static thread-count and global-property storage in a conf.
VLINK_DEFINE_GLOBAL_PROPERTY Provides the storage definitions for the declaration above.
Example
// include/myapp/my_conf.h
struct MyConf final : public vlink::Conf {
std::string host;
uint16_t port{0};
};
// src/myapp/my_conf.cc
void MyConf::global_init() { setup_shared_transport_state(); }
bool MyConf::is_valid() const { return !host.empty() && port != 0; }
#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_DEFINE_GLOBAL_PROPERTY(classname)
Provides storage for the statics declared by VLINK_DECLARE_GLOBAL_PROPERTY.
Definition: conf.h:349
#define VLINK_ALLOW_IMPL_TYPE(type)
Records the bitmask of ImplType values supported by a conf.
Definition: conf.h:292

Macro Definition Documentation

◆ VLINK_ALLOW_IMPL_TYPE

#define VLINK_ALLOW_IMPL_TYPE (   type)
Value:
public: \
[[nodiscard]] static constexpr int get_allow_impl_type() { return type; }

Records the bitmask of ImplType values supported by a conf.

Expands to a public get_allow_impl_type() that returns type so the Node<> template can validate at compile time that the conf supports the requested node role. Combine roles with bitwise OR, e.g.

Parameters
typeBitmask of ImplType values supported by the conf.

◆ VLINK_CONF_IMPL

#define VLINK_CONF_IMPL (   classname)
Value:
private: \
VLINK_DECLARE_CONF_FRIEND() \
\
[[nodiscard]] bool parse_protocol(struct Protocol* protocol) override; \
\
[[nodiscard]] std::unique_ptr<class ServerImpl> create_server() const override; \
\
[[nodiscard]] std::unique_ptr<class ClientImpl> create_client() const override; \
\
[[nodiscard]] std::unique_ptr<class PublisherImpl> create_publisher() const override; \
\
[[nodiscard]] std::unique_ptr<class SubscriberImpl> create_subscriber() const override; \
\
[[nodiscard]] std::unique_ptr<class SetterImpl> create_setter() const override; \
\
[[nodiscard]] std::unique_ptr<class GetterImpl> create_getter() const override; \
\
VLINK_EXPORT friend std::ostream& operator<<(std::ostream& ostream, const classname& conf) noexcept; \
\
public: \
classname() = default; \
\
~classname() = default; \
\
[[nodiscard]] bool is_valid() const override;

Convenience macro that emits the standard concrete conf boilerplate.

Expands to the friend grant, the six factory overrides, an ostream insertion operator declaration, the default constructor / destructor and an is_valid() override declaration whose body the subclass must provide.

Parameters
classnameSubclass name being declared.

◆ VLINK_DECLARE_CONF_FRIEND

#define VLINK_DECLARE_CONF_FRIEND ( )
Value:
template <typename, typename, SecurityType> \
friend class Server; \
template <typename, typename, SecurityType> \
friend class Client; \
template <typename, SecurityType> \
friend class Publisher; \
template <typename, SecurityType> \
friend class Subscriber; \
template <typename, SecurityType> \
friend class Setter; \
template <typename, SecurityType> \
friend class Getter;

Macro Definitions.

Grants the six public Node<> templates friend access to the conf.

Inject this macro into a concrete Conf subclass to expose the protected factory methods to Server, Client, Publisher, Subscriber, Setter and Getter. VLINK_CONF_IMPL already expands it; use this macro on its own only when VLINK_CONF_IMPL is not suitable.

◆ VLINK_DECLARE_GLOBAL_PROPERTY

#define VLINK_DECLARE_GLOBAL_PROPERTY ( )
Value:
private: \
static size_t thread_count_; \
static PropertiesMap global_properties_; \
static std::shared_mutex global_mtx_; \
\
public: \
[[nodiscard]] static size_t get_thread_count() { return thread_count_; } \
\
static void set_thread_count(size_t thread_count) { thread_count_ = thread_count; } \
\
static void set_global_property(const std::string& prop, const std::string& value) { \
std::lock_guard lock(global_mtx_); \
global_properties_[prop] = value; \
} \
\
[[nodiscard]] static std::string get_global_property(const std::string& prop) { \
std::shared_lock lock(global_mtx_); \
auto iter = global_properties_.find(prop); \
return iter != global_properties_.end() ? iter->second : std::string(); \
} \
\
[[nodiscard]] static PropertiesMap get_global_all_properties() { \
std::shared_lock lock(global_mtx_); \
return global_properties_; \
} \
\
static void global_init();

Declares per-transport static configuration storage and access helpers.

Inject into a concrete Conf subclass body to expose:

  • thread_count_, global_properties_ and global_mtx_ static members.
  • get_thread_count() / set_thread_count() accessors.
  • set_global_property() / get_global_property() / get_global_all_properties().
  • A global_init() declaration whose definition the subclass supplies.

Pair with VLINK_DEFINE_GLOBAL_PROPERTY in the matching translation unit.

◆ VLINK_DEFINE_GLOBAL_PROPERTY

#define VLINK_DEFINE_GLOBAL_PROPERTY (   classname)
Value:
size_t classname::thread_count_{1}; \
Conf::PropertiesMap classname::global_properties_; \
std::shared_mutex classname::global_mtx_;

Provides storage for the statics declared by VLINK_DECLARE_GLOBAL_PROPERTY.

Place once in the .cc file of the matching subclass. Sets thread_count_ to 1, default-constructs the property map, and default-initialises the shared mutex.

Parameters
classnameSubclass that owns the static members.