138 #include "../base/logger.h"
142 #include "../modules/dds_conf.h"
143 #include "../modules/ddsc_conf.h"
144 #include "../modules/ddsr_conf.h"
145 #include "../modules/fdbus_conf.h"
146 #include "../modules/intra_conf.h"
147 #include "../modules/mqtt_conf.h"
148 #include "../modules/shm2_conf.h"
149 #include "../modules/shm_conf.h"
150 #include "../modules/someip_conf.h"
151 #include "../modules/zenoh_conf.h"
186 explicit Protocol(
const std::string& address);
265 explicit Url(
const std::string& str);
320 [[nodiscard]]
const std::string&
get_str()
const;
352 [[nodiscard]]
bool is_valid()
const override;
465 static void global_init(uint16_t transport_enable_flags = 0);
494 std::unique_ptr<ServerImpl> create_server()
const override;
496 std::unique_ptr<ClientImpl> create_client()
const override;
498 std::unique_ptr<PublisherImpl> create_publisher()
const override;
500 std::unique_ptr<SubscriberImpl> create_subscriber()
const override;
502 std::unique_ptr<SetterImpl> create_setter()
const override;
504 std::unique_ptr<GetterImpl> create_getter()
const override;
509 std::unique_ptr<Conf> target_;
523 inline Url::Url(
Url&& url) noexcept : protocol_(std::move(url.protocol_)), target_(std::move(url.target_)) {}
532 protocol_ = url.protocol_;
544 protocol_ = std::move(url.protocol_);
545 target_ = std::move(url.target_);
563 return target_->parse_protocol(&protocol_);
571 return target_->is_valid();
579 return target_->get_impl_type();
587 return target_->get_transport_type();
591 if (transport_enable_flags == 0) {
595 (void)transport_enable_flags;
599 #ifndef VLINK_ENABLE_C_INTERFACE
601 #ifdef VLINK_SUPPORT_INTRA
604 IntraConf::global_init();
608 #ifdef VLINK_SUPPORT_SHM
611 ShmConf::global_init();
615 #ifdef VLINK_SUPPORT_SHM2
618 Shm2Conf::global_init();
622 #ifdef VLINK_SUPPORT_ZENOH
625 ZenohConf::global_init();
629 #ifdef VLINK_SUPPORT_DDS
632 DdsConf::global_init();
636 #ifdef VLINK_SUPPORT_DDSC
639 DdscConf::global_init();
643 #ifdef VLINK_SUPPORT_DDSR
646 DdsrConf::global_init();
650 #ifdef VLINK_SUPPORT_SOMEIP
653 SomeipConf::global_init();
657 #ifdef VLINK_SUPPORT_MQTT
660 MqttConf::global_init();
664 #ifdef VLINK_SUPPORT_FDBUS
667 FdbusConf::global_init();
677 #ifdef VLINK_SUPPORT_INTRA
681 #ifdef VLINK_SUPPORT_SHM
685 #ifdef VLINK_SUPPORT_SHM2
689 #ifdef VLINK_SUPPORT_ZENOH
693 #ifdef VLINK_SUPPORT_DDS
697 #ifdef VLINK_SUPPORT_DDSC
701 #ifdef VLINK_SUPPORT_DDSR
705 #ifdef VLINK_SUPPORT_SOMEIP
709 #ifdef VLINK_SUPPORT_MQTT
713 #ifdef VLINK_SUPPORT_FDBUS
727 #ifdef VLINK_SUPPORT_INTRA
729 target = std::make_unique<IntraConf>();
733 #ifdef VLINK_SUPPORT_SHM
735 target = std::make_unique<ShmConf>();
739 #ifdef VLINK_SUPPORT_SHM2
741 target = std::make_unique<Shm2Conf>();
745 #ifdef VLINK_SUPPORT_ZENOH
747 target = std::make_unique<ZenohConf>();
751 #ifdef VLINK_SUPPORT_DDS
753 target = std::make_unique<DdsConf>();
757 #ifdef VLINK_SUPPORT_DDSC
759 target = std::make_unique<DdscConf>();
763 #ifdef VLINK_SUPPORT_DDSR
765 target = std::make_unique<DdsrConf>();
769 #ifdef VLINK_SUPPORT_SOMEIP
771 target = std::make_unique<SomeipConf>();
775 #ifdef VLINK_SUPPORT_MQTT
777 target = std::make_unique<MqttConf>();
781 #ifdef VLINK_SUPPORT_FDBUS
783 target = std::make_unique<FdbusConf>();
797 CLOG_F(
"Unsupported url[%s].", protocol.
str.c_str());
801 inline std::unique_ptr<ServerImpl> Url::create_server()
const {
806 return target_->create_server();
809 inline std::unique_ptr<ClientImpl> Url::create_client()
const {
814 return target_->create_client();
817 inline std::unique_ptr<PublisherImpl> Url::create_publisher()
const {
822 return target_->create_publisher();
825 inline std::unique_ptr<SubscriberImpl> Url::create_subscriber()
const {
830 return target_->create_subscriber();
833 inline std::unique_ptr<SetterImpl> Url::create_setter()
const {
838 return target_->create_setter();
841 inline std::unique_ptr<GetterImpl> Url::create_getter()
const {
846 return target_->create_getter();
static void global_init()
Initialises process-wide VLink singletons.
Transport-neutral backbone shared by every method-model client implementation.
Transport-configuration base contract and the supporting boilerplate macros.
#define VLINK_DECLARE_CONF_FRIEND()
Macro Definitions
Definition: conf.h:225
Transport-neutral base for field-model getter (latest-value reader) implementations.
#define CLOG_F(...)
Definition: logger.h:855
#define VUNLIKELY(...)
Short alias for VLINK_UNLIKELY.
Definition: macros.h:289
#define VLINK_EXPORT
Definition: macros.h:81
TransportType
Enumeration of every transport backend recognised by VLink.
Definition: types.h:126
@ kShm2
Iceoryx2 shared memory (shm2://).
@ kSomeip
SOME/IP through vsomeip (someip://).
@ kUnknown
Unknown or unsupported transport.
@ kZenoh
Zenoh publish / subscribe (zenoh://).
@ kDds
Fast-DDS RTPS (dds://).
@ kDdsc
CycloneDDS (ddsc://).
@ kIntra
In-process queue (intra://).
@ kDdsr
RTI DDS (ddsr://).
@ kShm
Iceoryx shared memory (shm://).
@ kFdbus
FDBus IPC (fdbus://).
ImplType
Bitmask identifying the role of a VLink node implementation.
Definition: types.h:108
@ kGetter
Field getter (reads latest value).
Definition: types.h:115
@ kSubscriber
Event subscriber (receives broadcasts).
Definition: types.h:113
@ kClient
Method client (RPC caller).
Definition: types.h:111
@ kSetter
Field setter (writes latest value).
Definition: types.h:114
@ kPublisher
Event publisher (one-to-many broadcast).
Definition: types.h:112
@ kUnknownImplType
Type not yet determined.
Definition: types.h:109
@ kServer
Method server (RPC responder).
Definition: types.h:110
Transport-neutral base class for every event-model publisher implementation.
Transport-neutral base class for every method-model server implementation.
Transport-neutral base class for every field-model setter (latest-value writer).
Abstract base for every transport-specific configuration aggregate.
Definition: conf.h:114
friend struct Url
Definition: conf.h:192
virtual bool parse(ImplType impl_type) const
Validates the conf for impl_type and caches it for subsequent factories.
Plain-data record describing the parsed components of a VLink URL.
Definition: url.h:176
TransportType transport
Resolved transport backend identifier.
Definition: url.h:178
std::string str
URL string after remap, if any.
Definition: url.h:177
std::map< std::string, std::string > dictionary
Query parameters parsed into a key/value dictionary.
Definition: url.h:181
std::string fragment
Fragment identifier (after #).
Definition: url.h:182
std::string host
Hostname or IP component, if any.
Definition: url.h:179
std::string path
Topic path component.
Definition: url.h:180
Conf subclass that routes virtual calls to the transport selected by a URL string.
Definition: url.h:216
static VLINK_EXPORT int get_sort_index(std::string_view url)
Returns a numeric sort index for the transport backend of url.
static VLINK_EXPORT std::unique_ptr< Conf > load_for_plugin(TransportType type)
Resolves a transport plugin and asks it for a Conf matching type.
VLINK_EXPORT friend std::ostream & operator<<(std::ostream &ostream, const Url &conf) noexcept
static VLINK_EXPORT bool is_intra_type(std::string_view url)
Returns whether url designates the intra:// in-process transport.
bool is_valid() const override
Reports whether the underlying target_ conf is valid.
Definition: url.h:566
TransportEnableFlag
Bitmask that selects which transports participate in global_init().
Definition: url.h:240
@ kEnableShm2
Enable the shm2:// (Iceoryx2) transport.
Definition: url.h:244
@ kEnableZenoh
Enable the zenoh:// transport.
Definition: url.h:245
@ kEnableDds
Enable the dds:// (Fast-DDS) transport.
Definition: url.h:246
@ kEnableShm
Enable the shm:// (Iceoryx) transport.
Definition: url.h:243
@ kEnableDdsc
Enable the ddsc:// (CycloneDDS) transport.
Definition: url.h:247
@ kEnableMqtt
Enable the mqtt:// transport.
Definition: url.h:250
@ kEnableSomeip
Enable the someip:// transport.
Definition: url.h:249
@ kEnableDdsr
Enable the ddsr:// (RTI DDS) transport.
Definition: url.h:248
@ kEnableFdbus
Enable the fdbus:// transport.
Definition: url.h:251
@ kEnableEmpty
No transport enabled.
Definition: url.h:241
@ kEnableIntra
Enable the intra:// transport.
Definition: url.h:242
@ kEnableAll
Enable every transport.
Definition: url.h:252
~Url() override
Destructor.
static VLINK_EXPORT void init_plugins(uint16_t transport_enable_flags=0)
Explicitly preloads recognized transport plugins from VLINK_URL_PLUGINS.
static VLINK_EXPORT bool is_local_type(std::string_view url)
Returns whether url designates a same-machine transport.
static void init_target_internal(const Protocol &protocol, std::unique_ptr< Conf > &target)
Builds target_ for the resolved transport in protocol.
Definition: url.h:720
static uint16_t get_transport_enable_flags()
Returns a bitmask of all compile-time-enabled transports.
Definition: url.h:674
ImplType get_impl_type() const override
Returns the ImplType cached by the most recent target_->parse().
Definition: url.h:574
const std::string & get_str() const
Returns the stored URL string (after any VLINK_URL_REMAP rewrite).
Definition: url.h:550
bool parse(ImplType impl_type) const override
Parses the URL for impl_type by delegating to target_.
Definition: url.h:554
Url & operator=(const Url &url)
Copy assignment.
Definition: url.h:527
TransportType get_transport_type() const override
Returns the transport backend identifier resolved from the URL.
Definition: url.h:582
static void global_init(uint16_t transport_enable_flags=0)
Initialises the process-wide state for every enabled transport.
Definition: url.h:590
const Conf * get_target() const
Returns the underlying transport Conf or nullptr.
Definition: url.h:552
static VLINK_EXPORT bool is_shm_type(std::string_view url)
Returns whether url uses a shared-memory transport.
Transport-neutral base class for every event-model subscriber implementation.