URL-based Conf dispatcher that routes to the correct transport backend.
More...
#include <url.h>
|
| enum | TransportEnableFlag : uint16_t {
kEnableEmpty = 0b0000'0000'0000'0000
, kEnableIntra = 0b1000'0000'0000'0000
, kEnableShm = 0b0100'0000'0000'0000
, kEnableShm2 = 0b0010'0000'0000'0000
,
kEnableZenoh = 0b0001'0000'0000'0000
, kEnableDds = 0b0000'1000'0000'0000
, kEnableDdsc = 0b0000'0100'0000'0000
, kEnableDdsr = 0b0000'0010'0000'0000
,
kEnableDdst = 0b0000'0001'0000'0000
, kEnableSomeip = 0b0000'0000'1000'0000
, kEnableMqtt = 0b0000'0000'0100'0000
, kEnableFdbus = 0b0000'0000'0010'0000
,
kEnableQnx = 0b0000'0000'0001'0000
, kEnableAll = 0b1111'1111'1111'1111
} |
| | Bitmask controlling which transport backends are active at runtime. More...
|
| using | PropertiesMap = std::map<std::string, std::string> |
| | Key/value property map type.
|
|
| | Url (const std::string &str) |
| | Constructs a Url from a transport address string.
|
| | Url (const Url &url) |
| | Copy constructor.
|
| | Url (Url &&url) noexcept |
| | Move constructor.
|
| | ~Url () override |
| | Destructor.
|
| Url & | operator= (const Url &url) |
| | Copy-assignment operator.
|
| Url & | operator= (Url &&url) noexcept |
| | Move-assignment operator.
|
| const std::string & | get_str () const |
| | Returns the original (or remapped) URL string.
|
| const Conf * | get_target () const |
| | Returns a pointer to the underlying transport Conf, or nullptr.
|
| bool | parse (ImplType impl_type) const override |
| | Parses the URL for the given node type, delegating to target_.
|
| bool | is_valid () const override |
| | Returns true if the underlying target_ Conf is valid.
|
| ImplType | get_impl_type () const override |
| | Returns the ImplType resolved by the underlying target_ Conf.
|
| TransportType | get_transport_type () const override |
| | Returns the transport backend resolved from the URL.
|
| virtual | ~Conf () |
| | Virtual destructor.
|
URL-based Conf dispatcher that routes to the correct transport backend.
Url is the user-facing transport configuration type. It is constructed from a URL string, parses it into a Protocol, then creates the matching transport Conf (target_) in init_target_internal(). All Conf virtual methods are forwarded to target_.
- Full Lifecycle
Url url(
"dds://vehicle/speed");
auto impl = url.create_subscriber();
@ kSubscriber
Event subscriber (receive broadcast).
Definition types.h:94
Url(const std::string &str)
Constructs a Url from a transport address string.
Definition url.h:457
◆ TransportEnableFlag
Bitmask controlling which transport backends are active at runtime.
Passed to global_init() and init_plugins() to selectively initialise only the transports that are compiled in and needed for the current process. The bits correspond directly to the TransportType enumeration values.
| Flag | Bit Position | Transport |
| kEnableIntra | 15 | intra:// |
| kEnableShm | 14 | shm:// |
| kEnableShm2 | 13 | shm2:// |
| kEnableZenoh | 12 | zenoh:// |
| kEnableDds | 11 | dds:// |
| kEnableDdsc | 10 | ddsc:// |
| kEnableDdsr | 9 | ddsr:// |
| kEnableDdst | 8 | ddst:// |
| kEnableSomeip | 7 | someip:// |
| kEnableMqtt | 6 | mqtt:// |
| kEnableFdbus | 5 | fdbus:// |
| kEnableQnx | 4 | qnx:// |
| kEnableAll | all bits set | all transports |
| Enumerator |
|---|
| kEnableEmpty | No transport enabled.
|
| kEnableIntra | Enable intra:// transport.
|
| kEnableShm | Enable shm:// (Iceoryx) transport.
|
| kEnableShm2 | Enable shm2:// (Iceoryx2) transport.
|
| kEnableZenoh | Enable zenoh:// transport.
|
| kEnableDds | Enable dds:// (Fast-DDS) transport.
|
| kEnableDdsc | Enable ddsc:// (CycloneDDS) transport.
|
| kEnableDdsr | Enable ddsr:// (RTI DDS) transport.
|
| kEnableDdst | Enable ddst:// (TravoDDS) transport.
|
| kEnableSomeip | Enable someip:// transport.
|
| kEnableMqtt | Enable mqtt:// transport.
|
| kEnableFdbus | Enable fdbus:// transport.
|
| kEnableQnx | Enable qnx:// transport (QNX only).
|
| kEnableAll | Enable all transports.
|
◆ Url() [1/3]
| vlink::Url::Url |
( |
const std::string & | str | ) |
|
|
inlineexplicit |
Constructs a Url from a transport address string.
Details.
Parses str into a Protocol, then calls init_target_internal() to create the matching Conf subclass. Logs a fatal error if no transport backend matches the URL.
- Parameters
-
| str | VLink URL string, e.g. "dds://vehicle/speed". |
◆ Url() [2/3]
| vlink::Url::Url |
( |
const Url & | url | ) |
|
|
inline |
Copy constructor.
Copies the Protocol from url and rebuilds target_ via init_target_internal(). The new object gets a fresh transport Conf rather than sharing the same instance.
- Parameters
-
◆ Url() [3/3]
| vlink::Url::Url |
( |
Url && | url | ) |
|
|
inlinenoexcept |
Move constructor.
Transfers protocol_ and target_ from url without rebuilding.
- Parameters
-
| url | Source Url to move from. |
◆ ~Url()
◆ get_impl_type()
| ImplType vlink::Url::get_impl_type |
( |
| ) |
const |
|
inlinenodiscardoverridevirtual |
Returns the ImplType resolved by the underlying target_ Conf.
Delegates to target_->get_impl_type(). Returns kUnknownImplType if target_ is null or parse() has not been called yet.
- Returns
- The
ImplType for this URL, or kUnknownImplType.
Reimplemented from vlink::Conf.
◆ get_sort_index()
| VLINK_EXPORT int vlink::Url::get_sort_index |
( |
std::string_view | url | ) |
|
|
staticnodiscard |
Returns a numeric sort index for the transport backend used by a URL.
Used to order multiple URLs by transport priority. Local transports (intra://, shm://) return lower indices than network transports.
- Parameters
-
| url | URL string to classify. |
- Returns
- Non-negative sort index; lower values = higher priority.
◆ get_str()
| const std::string & vlink::Url::get_str |
( |
| ) |
const |
|
inlinenodiscard |
Returns the original (or remapped) URL string.
- Returns
- Const reference to the canonical URL string stored in
Protocol::str.
◆ get_target()
| const Conf * vlink::Url::get_target |
( |
| ) |
const |
|
inlinenodiscard |
Returns a pointer to the underlying transport Conf, or nullptr.
Allows callers to inspect or downcast the concrete transport configuration (e.g. to a DdsConf to set DDS-specific QoS).
- Returns
- Pointer to the active transport
Conf; nullptr if the URL was invalid.
◆ get_transport_enable_flags()
| uint16_t vlink::Url::get_transport_enable_flags |
( |
| ) |
|
|
inlinestaticnodiscard |
Returns a bitmask of all compile-time-enabled transport backends.
Built at compile time from the VLINK_SUPPORT_* preprocessor flags. The result can be passed to global_init() to initialise exactly the available transports.
- Returns
TransportEnableFlag bitmask of supported transports.
◆ get_transport_type()
|
|
inlinenodiscardoverridevirtual |
◆ global_init()
| void vlink::Url::global_init |
( |
uint16_t | transport_enable_flags = 0 | ) |
|
|
inlinestatic |
Initialises the global state for all enabled transport backends.
Calls NodeImpl::global_init() and then *Conf::global_init() for each transport whose bit is set in transport_enable_flags. Must be called once before creating any Url objects if fine-grained transport control is needed. If not called explicitly, transports are lazily initialised on first use.
- Parameters
-
| transport_enable_flags | Bitmask of TransportEnableFlag values. Passing 0 (the default) expands to all compiled-in transports. |
◆ init_plugins()
| VLINK_EXPORT void vlink::Url::init_plugins |
( |
uint16_t | transport_enable_flags = 0 | ) |
|
|
static |
Loads and registers ConfPluginInterface plugins for the enabled transports.
Searches for plugin shared libraries listed in the VLINK_URL_PLUGINS environment variable and registers any that advertise a transport in transport_enable_flags. This is called automatically when a Url is first constructed; explicit calls are only needed in unusual initialisation order.
- Parameters
-
| transport_enable_flags | Bitmask of TransportEnableFlag values; default 0 (no plugins searched unless env var is set). |
◆ init_target_internal()
| void vlink::Url::init_target_internal |
( |
const Protocol & | protocol, |
|
|
std::unique_ptr< Conf > & | target ) |
|
inlinestatic |
Creates the target_ Conf for a given Protocol.
Called by constructors and assignment operators. Switches on Protocol::transport and instantiates the corresponding *Conf class. Falls back to load_for_plugin() if no built-in transport matches. Logs a fatal error if neither path succeeds.
- Parameters
-
| protocol | Parsed URL information used to select the transport. |
| target | Output: receives the newly created Conf instance. |
◆ is_intra_type()
| VLINK_EXPORT bool vlink::Url::is_intra_type |
( |
std::string_view | url | ) |
|
|
staticnodiscard |
Returns true if the URL uses the intra:// in-process transport.
- Parameters
-
| url | URL string to classify. |
- Returns
true only for intra:// URLs.
◆ is_local_type()
| VLINK_EXPORT bool vlink::Url::is_local_type |
( |
std::string_view | url | ) |
|
|
staticnodiscard |
Returns true if the URL refers to a local (same-machine) transport.
A URL is considered local if its transport is intra://, shm://, or shm2://.
- Parameters
-
| url | URL string to classify. |
- Returns
true for local transports; false for network transports.
◆ is_shm_type()
| VLINK_EXPORT bool vlink::Url::is_shm_type |
( |
std::string_view | url | ) |
|
|
staticnodiscard |
Returns true if the URL uses a shared-memory transport (shm:// or shm2://).
- Parameters
-
| url | URL string to classify. |
- Returns
true for shm:// and shm2:// URLs.
◆ is_valid()
| bool vlink::Url::is_valid |
( |
| ) |
const |
|
inlinenodiscardoverridevirtual |
Returns true if the underlying target_ Conf is valid.
Delegates to target_->is_valid(). Returns false if target_ is null.
- Returns
true if the transport conf is valid and ready for use.
Reimplemented from vlink::Conf.
◆ load_for_plugin()
Searches loaded plugins for a Conf factory matching type.
Iterates over all loaded ConfPluginInterface instances and returns the first one whose get_transport_type() matches type. Returns nullptr if no matching plugin is found.
- Parameters
-
| type | Transport backend to search for. |
- Returns
- A new
Conf instance from the plugin, or nullptr.
◆ operator=() [1/2]
| Url & vlink::Url::operator= |
( |
const Url & | url | ) |
|
|
inline |
Copy-assignment operator.
Copies protocol_ and reinitialises target_ via init_target_internal().
- Parameters
-
- Returns
- Reference to
*this.
◆ operator=() [2/2]
| Url & vlink::Url::operator= |
( |
Url && | url | ) |
|
|
inlinenoexcept |
Move-assignment operator.
- Parameters
-
- Returns
- Reference to
*this.
◆ parse()
| bool vlink::Url::parse |
( |
ImplType | impl_type | ) |
const |
|
inlineoverridevirtual |
Parses the URL for the given node type, delegating to target_.
Calls Conf::parse(impl_type), target_->parse(impl_type), and target_->parse_protocol() in sequence. Returns false if target_ is null or any step fails.
- Parameters
-
| impl_type | Bitmask of ImplType roles (e.g. kSubscriber). |
- Returns
true if all parse steps succeed; false otherwise.
Reimplemented from vlink::Conf.
◆ operator<<
| VLINK_EXPORT friend std::ostream & operator<< |
( |
std::ostream & | ostream, |
|
|
const Url & | conf ) |
|
friend |
The documentation for this struct was generated from the following file: