133 #include "../base/logger.h"
137 #include "../modules/dds_conf.h"
138 #include "../modules/ddsc_conf.h"
139 #include "../modules/ddsr_conf.h"
140 #include "../modules/ddst_conf.h"
141 #include "../modules/fdbus_conf.h"
142 #include "../modules/intra_conf.h"
143 #include "../modules/mqtt_conf.h"
144 #include "../modules/qnx_conf.h"
145 #include "../modules/shm2_conf.h"
146 #include "../modules/shm_conf.h"
147 #include "../modules/someip_conf.h"
148 #include "../modules/zenoh_conf.h"
183 explicit Protocol(
const std::string& address);
266 explicit Url(
const std::string& str);
321 [[nodiscard]]
const std::string&
get_str()
const;
353 [[nodiscard]]
bool is_valid()
const override;
454 static void global_init(uint16_t transport_enable_flags = 0);
482 std::unique_ptr<ServerImpl> create_server()
const override;
484 std::unique_ptr<ClientImpl> create_client()
const override;
486 std::unique_ptr<PublisherImpl> create_publisher()
const override;
488 std::unique_ptr<SubscriberImpl> create_subscriber()
const override;
490 std::unique_ptr<SetterImpl> create_setter()
const override;
492 std::unique_ptr<GetterImpl> create_getter()
const override;
497 std::unique_ptr<Conf> target_;
511 inline Url::Url(
Url&& url) noexcept : protocol_(std::move(url.protocol_)), target_(std::move(url.target_)) {}
520 protocol_ = url.protocol_;
532 protocol_ = std::move(url.protocol_);
533 target_ = std::move(url.target_);
551 return target_->parse_protocol(&protocol_);
559 return target_->is_valid();
567 return target_->get_impl_type();
575 return target_->get_transport_type();
579 if (transport_enable_flags == 0) {
583 (void)transport_enable_flags;
587 #ifndef VLINK_ENABLE_C_INTERFACE
589 #ifdef VLINK_SUPPORT_INTRA
592 IntraConf::global_init();
596 #ifdef VLINK_SUPPORT_SHM
599 ShmConf::global_init();
603 #ifdef VLINK_SUPPORT_SHM2
606 Shm2Conf::global_init();
610 #ifdef VLINK_SUPPORT_ZENOH
613 ZenohConf::global_init();
617 #ifdef VLINK_SUPPORT_DDS
620 DdsConf::global_init();
624 #ifdef VLINK_SUPPORT_DDSC
627 DdscConf::global_init();
631 #ifdef VLINK_SUPPORT_DDSR
634 DdsrConf::global_init();
638 #ifdef VLINK_SUPPORT_DDST
641 DdstConf::global_init();
645 #ifdef VLINK_SUPPORT_SOMEIP
648 SomeipConf::global_init();
652 #ifdef VLINK_SUPPORT_MQTT
655 MqttConf::global_init();
659 #ifdef VLINK_SUPPORT_FDBUS
662 FdbusConf::global_init();
666 #ifdef VLINK_SUPPORT_QNX
669 QnxConf::global_init();
679 #ifdef VLINK_SUPPORT_INTRA
683 #ifdef VLINK_SUPPORT_SHM
687 #ifdef VLINK_SUPPORT_SHM2
691 #ifdef VLINK_SUPPORT_ZENOH
695 #ifdef VLINK_SUPPORT_DDS
699 #ifdef VLINK_SUPPORT_DDSC
703 #ifdef VLINK_SUPPORT_DDSR
707 #ifdef VLINK_SUPPORT_DDST
711 #ifdef VLINK_SUPPORT_SOMEIP
715 #ifdef VLINK_SUPPORT_MQTT
719 #ifdef VLINK_SUPPORT_FDBUS
723 #ifdef VLINK_SUPPORT_QNX
737 #ifdef VLINK_SUPPORT_INTRA
739 target = std::make_unique<IntraConf>();
743 #ifdef VLINK_SUPPORT_SHM
745 target = std::make_unique<ShmConf>();
749 #ifdef VLINK_SUPPORT_SHM2
751 target = std::make_unique<Shm2Conf>();
755 #ifdef VLINK_SUPPORT_ZENOH
757 target = std::make_unique<ZenohConf>();
761 #ifdef VLINK_SUPPORT_DDS
763 target = std::make_unique<DdsConf>();
767 #ifdef VLINK_SUPPORT_DDSC
769 target = std::make_unique<DdscConf>();
773 #ifdef VLINK_SUPPORT_DDSR
775 target = std::make_unique<DdsrConf>();
779 #ifdef VLINK_SUPPORT_DDST
781 target = std::make_unique<DdstConf>();
785 #ifdef VLINK_SUPPORT_SOMEIP
787 target = std::make_unique<SomeipConf>();
791 #ifdef VLINK_SUPPORT_MQTT
793 target = std::make_unique<MqttConf>();
797 #ifdef VLINK_SUPPORT_FDBUS
799 target = std::make_unique<FdbusConf>();
803 #ifdef VLINK_SUPPORT_QNX
805 target = std::make_unique<QnxConf>();
819 CLOG_F(
"Unsupported url[%s].", protocol.
str.c_str());
823 inline std::unique_ptr<ServerImpl> Url::create_server()
const {
828 return target_->create_server();
831 inline std::unique_ptr<ClientImpl> Url::create_client()
const {
836 return target_->create_client();
839 inline std::unique_ptr<PublisherImpl> Url::create_publisher()
const {
844 return target_->create_publisher();
847 inline std::unique_ptr<SubscriberImpl> Url::create_subscriber()
const {
852 return target_->create_subscriber();
855 inline std::unique_ptr<SetterImpl> Url::create_setter()
const {
860 return target_->create_setter();
863 inline std::unique_ptr<GetterImpl> Url::create_getter()
const {
868 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:226
Transport-neutral base for field-model getter (latest-value reader) implementations.
#define CLOG_F(...)
Definition: logger.h:803
#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:128
@ 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://).
@ kQnx
QNX IPC (qnx://; QNX only).
@ kIntra
In-process queue (intra://).
@ kDdsr
RTI DDS (ddsr://).
@ kDdst
TravoDDS (ddst://).
@ kShm
Iceoryx shared memory (shm://).
@ kFdbus
FDBus IPC (fdbus://).
ImplType
Bitmask identifying the role of a VLink node implementation.
Definition: types.h:110
@ kGetter
Field getter (reads latest value).
Definition: types.h:117
@ kSubscriber
Event subscriber (receives broadcasts).
Definition: types.h:115
@ kClient
Method client (RPC caller).
Definition: types.h:113
@ kSetter
Field setter (writes latest value).
Definition: types.h:116
@ kPublisher
Event publisher (one-to-many broadcast).
Definition: types.h:114
@ kUnknownImplType
Type not yet determined.
Definition: types.h:111
@ kServer
Method server (RPC responder).
Definition: types.h:112
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:115
friend struct Url
Definition: conf.h:193
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:173
TransportType transport
Resolved transport backend identifier.
Definition: url.h:175
std::string str
URL string after remap, if any.
Definition: url.h:174
std::map< std::string, std::string > dictionary
Query parameters parsed into a key/value dictionary.
Definition: url.h:178
std::string fragment
Fragment identifier (after #).
Definition: url.h:179
std::string host
Hostname or IP component, if any.
Definition: url.h:176
std::string path
Topic path component.
Definition: url.h:177
Conf subclass that routes virtual calls to the transport selected by a URL string.
Definition: url.h:213
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)
Asks loaded plugins for a Conf factory 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:554
TransportEnableFlag
Bitmask that selects which transports participate in global_init() / init_plugins().
Definition: url.h:239
@ kEnableShm2
Enable the shm2:// (Iceoryx2) transport.
Definition: url.h:243
@ kEnableZenoh
Enable the zenoh:// transport.
Definition: url.h:244
@ kEnableDds
Enable the dds:// (Fast-DDS) transport.
Definition: url.h:245
@ kEnableShm
Enable the shm:// (Iceoryx) transport.
Definition: url.h:242
@ kEnableDdsc
Enable the ddsc:// (CycloneDDS) transport.
Definition: url.h:246
@ kEnableDdst
Enable the ddst:// (TravoDDS) transport.
Definition: url.h:248
@ 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:247
@ kEnableFdbus
Enable the fdbus:// transport.
Definition: url.h:251
@ kEnableEmpty
No transport enabled.
Definition: url.h:240
@ kEnableQnx
Enable the qnx:// transport (QNX only).
Definition: url.h:252
@ kEnableIntra
Enable the intra:// transport.
Definition: url.h:241
@ kEnableAll
Enable every transport.
Definition: url.h:253
~Url() override
Destructor.
static VLINK_EXPORT void init_plugins(uint16_t transport_enable_flags=0)
Loads 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:730
static uint16_t get_transport_enable_flags()
Returns a bitmask of all compile-time-enabled transports.
Definition: url.h:676
ImplType get_impl_type() const override
Returns the ImplType cached by the most recent target_->parse().
Definition: url.h:562
const std::string & get_str() const
Returns the stored URL string (after any VLINK_URL_REMAP rewrite).
Definition: url.h:538
bool parse(ImplType impl_type) const override
Parses the URL for impl_type by delegating to target_.
Definition: url.h:542
Url & operator=(const Url &url)
Copy assignment.
Definition: url.h:515
TransportType get_transport_type() const override
Returns the transport backend identifier resolved from the URL.
Definition: url.h:570
static void global_init(uint16_t transport_enable_flags=0)
Initialises the process-wide state for every enabled transport.
Definition: url.h:578
const Conf * get_target() const
Returns the underlying transport Conf or nullptr.
Definition: url.h:540
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.