VLink  2.1.0
A high-performance communication middleware
vlink::Url Struct Referencefinal

Conf subclass that routes virtual calls to the transport selected by a URL string. More...

#include <url.h>

Inheritance diagram for vlink::Url:
Collaboration diagram for vlink::Url:

Public Types

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 ,
  kEnableSomeip = 0b0000'0000'1000'0000 , kEnableMqtt = 0b0000'0000'0100'0000 , kEnableFdbus = 0b0000'0000'0010'0000 , kEnableAll = 0b1111'1111'1111'1111
}
 Bitmask that selects which transports participate in global_init(). More...
 

Public Member Functions

 Url (const std::string &str)
 Builds a Url from a transport address string. More...
 
 Url (const Url &url)
 Copy constructor. More...
 
 Url (Url &&url) noexcept
 Move constructor. More...
 
 ~Url () override
 Destructor. More...
 
Urloperator= (const Url &url)
 Copy assignment. More...
 
Urloperator= (Url &&url) noexcept
 Move assignment. More...
 
const std::string & get_str () const
 Returns the stored URL string (after any VLINK_URL_REMAP rewrite). More...
 
const Confget_target () const
 Returns the underlying transport Conf or nullptr. More...
 
bool parse (ImplType impl_type) const override
 Parses the URL for impl_type by delegating to target_. More...
 
bool is_valid () const override
 Reports whether the underlying target_ conf is valid. More...
 
ImplType get_impl_type () const override
 Returns the ImplType cached by the most recent target_->parse(). More...
 
TransportType get_transport_type () const override
 Returns the transport backend identifier resolved from the URL. More...
 

Static Public Member Functions

static VLINK_EXPORT void init_plugins (uint16_t transport_enable_flags=0)
 Explicitly preloads recognized transport plugins from VLINK_URL_PLUGINS. More...
 
static VLINK_EXPORT std::unique_ptr< Confload_for_plugin (TransportType type)
 Resolves a transport plugin and asks it for a Conf matching type. More...
 
static VLINK_EXPORT int get_sort_index (std::string_view url)
 Returns a numeric sort index for the transport backend of url. More...
 
static VLINK_EXPORT bool is_local_type (std::string_view url)
 Returns whether url designates a same-machine transport. More...
 
static VLINK_EXPORT bool is_intra_type (std::string_view url)
 Returns whether url designates the intra:// in-process transport. More...
 
static VLINK_EXPORT bool is_shm_type (std::string_view url)
 Returns whether url uses a shared-memory transport. More...
 
static void global_init (uint16_t transport_enable_flags=0)
 Initialises the process-wide state for every enabled transport. More...
 
static uint16_t get_transport_enable_flags ()
 Returns a bitmask of all compile-time-enabled transports. More...
 
static void init_target_internal (const Protocol &protocol, std::unique_ptr< Conf > &target)
 Builds target_ for the resolved transport in protocol. More...
 

Friends

VLINK_EXPORT friend std::ostream & operator<< (std::ostream &ostream, const Url &conf) noexcept
 

Additional Inherited Members

Detailed Description

Conf subclass that routes virtual calls to the transport selected by a URL string.

Construction parses the URL into a Protocol and then runs init_target_internal() to instantiate the matching transport Conf (target_). Every Conf virtual hook is forwarded to target_; the caller need only build one Url instance per topic.

Full lifecycle
// 1. Construct with URL string:
Url url("dds://vehicle/speed");
// -> Protocol("dds://vehicle/speed") -> transport == kDds
// -> init_target_internal() -> target_ = make_unique<DdsConf>()
// 2. Parse for a specific node role:
url.parse(kSubscriber);
// -> target_->parse(kSubscriber)
// -> target_->parse_protocol(&protocol_)
// 3. Create the transport implementation:
auto impl = url.create_subscriber();
// -> target_->create_subscriber()

Member Enumeration Documentation

◆ TransportEnableFlag

Bitmask that selects which transports participate in global_init().

Embedding environments (e.g. Android, QNX) pass a subset of these flags to skip transports they cannot support at runtime. Bit positions are independent of the numeric TransportType 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://
kEnableSomeip 7 someip://
kEnableMqtt 6 mqtt://
kEnableFdbus 5 fdbus://
kEnableAll all bits set Every transport
Enumerator
kEnableEmpty 

No transport enabled.

kEnableIntra 

Enable the intra:// transport.

kEnableShm 

Enable the shm:// (Iceoryx) transport.

kEnableShm2 

Enable the shm2:// (Iceoryx2) transport.

kEnableZenoh 

Enable the zenoh:// transport.

kEnableDds 

Enable the dds:// (Fast-DDS) transport.

kEnableDdsc 

Enable the ddsc:// (CycloneDDS) transport.

kEnableDdsr 

Enable the ddsr:// (RTI DDS) transport.

kEnableSomeip 

Enable the someip:// transport.

kEnableMqtt 

Enable the mqtt:// transport.

kEnableFdbus 

Enable the fdbus:// transport.

kEnableAll 

Enable every transport.

Constructor & Destructor Documentation

◆ Url() [1/3]

vlink::Url::Url ( const std::string &  str)
inlineexplicit

Builds a Url from a transport address string.

Details.

Parses str into a Protocol, then delegates to init_target_internal() to allocate the matching transport Conf. Triggers a fatal log entry when no transport backend matches the URL.

Parameters
strVLink URL string (e.g. "dds://vehicle/speed").
Here is the call graph for this function:

◆ Url() [2/3]

vlink::Url::Url ( const Url url)
inline

Copy constructor.

Copies the Protocol from url and rebuilds a fresh target_ via init_target_internal(), so the two Url objects do not share the same transport Conf instance.

Parameters
urlSource Url to copy.
Here is the call graph for this function:

◆ Url() [3/3]

vlink::Url::Url ( Url &&  url)
inlinenoexcept

Move constructor.

Transfers both protocol_ and target_ from url; no rebuild is performed.

Parameters
urlSource Url to move from.

◆ ~Url()

vlink::Url::~Url ( )
inlineoverridedefault

Destructor.

Member Function Documentation

◆ get_impl_type()

ImplType vlink::Url::get_impl_type ( ) const
inlineoverridevirtual

Returns the ImplType cached by the most recent target_->parse().

Returns
Cached ImplType, or kUnknownImplType when target_ is null.

Reimplemented from vlink::Conf.

◆ get_sort_index()

static VLINK_EXPORT int vlink::Url::get_sort_index ( std::string_view  url)
static

Returns a numeric sort index for the transport backend of url.

Used to order URLs by transport priority. Local transports (intra://, shm://) yield lower indices than network transports. Empty URLs return -1, while non-empty URLs whose transport is unknown still return 0 so they can participate in low-priority sorting.

Parameters
urlURL string to classify.
Returns
Sort index; lower values mean higher priority.

◆ get_str()

const std::string & vlink::Url::get_str ( ) const
inline

Returns the stored URL string (after any VLINK_URL_REMAP rewrite).

Returns
Reference to the string stored inside Protocol::str.

◆ get_target()

const Conf * vlink::Url::get_target ( ) const
inline

Returns the underlying transport Conf or nullptr.

Lets callers downcast the active transport conf for transport-specific inspection (for example to a DdsConf for native DDS QoS).

Returns
Pointer to the cached transport Conf; nullptr when the URL was invalid or init_target_internal() failed.

◆ get_transport_enable_flags()

uint16_t vlink::Url::get_transport_enable_flags ( )
inlinestatic

Returns a bitmask of all compile-time-enabled transports.

Computed from the VLINK_SUPPORT_* preprocessor flags. The result can be passed to global_init() to initialise the available transports exactly.

Returns
Bitmask of TransportEnableFlag values.
Here is the caller graph for this function:

◆ get_transport_type()

TransportType vlink::Url::get_transport_type ( ) const
inlineoverridevirtual

Returns the transport backend identifier resolved from the URL.

Returns
TransportType value, or TransportType::kUnknown when no transport was resolved.

Reimplemented from vlink::Conf.

◆ global_init()

void vlink::Url::global_init ( uint16_t  transport_enable_flags = 0)
inlinestatic

Initialises the process-wide state for every enabled transport.

Calls NodeImpl::global_init() first and then each *Conf::global_init() whose bit appears in transport_enable_flags. Passing 0 expands to all compiled-in transports. Must run once before any Url is created when fine-grained transport selection is required; otherwise the transports are lazily initialised on first use.

Parameters
transport_enable_flagsBitmask of TransportEnableFlag values.
Here is the call graph for this function:

◆ init_plugins()

static VLINK_EXPORT void vlink::Url::init_plugins ( uint16_t  transport_enable_flags = 0)
static

Explicitly preloads recognized transport plugins from VLINK_URL_PLUGINS.

Unless its complete value is the case-insensitive mode auto or none, entries in VLINK_URL_PLUGINS must map to existing VLink transport module names such as zenoh or ddsc; unknown names are rejected before the shared library loader is called. This API loads alternate implementations for known transports, not arbitrary new URL schemes.

Explicitly listed plugins are loaded process-wide even when the first caller has the same backend linked; the inline URL dispatcher still gives a caller's linked backend precedence. The first Url construction triggers this call automatically; explicit invocations are only needed for unusual initialisation sequences.

Explicit preload, auto, and none are mutually exclusive modes of the complete setting. Mode names are case-insensitive and cannot be combined with a module list.

Parameters
transport_enable_flagsRetained for source compatibility; explicit preload selection comes from VLINK_URL_PLUGINS.
Here is the caller graph for this function:

◆ init_target_internal()

void vlink::Url::init_target_internal ( const Protocol protocol,
std::unique_ptr< Conf > &  target 
)
inlinestatic

Builds target_ for the resolved transport in protocol.

Switches on Protocol::transport, allocates the matching *Conf class, and falls back to load_for_plugin() when no built-in backend matches. That fallback may perform opt-in on-demand loading as documented above. Logs a fatal entry when neither path succeeds.

Parameters
protocolParsed URL information used to select the transport.
targetOutput: receives the newly created Conf instance.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_intra_type()

static VLINK_EXPORT bool vlink::Url::is_intra_type ( std::string_view  url)
static

Returns whether url designates the intra:// in-process transport.

Parameters
urlURL string to classify.
Returns
true only for intra:// URLs.

◆ is_local_type()

static VLINK_EXPORT bool vlink::Url::is_local_type ( std::string_view  url)
static

Returns whether url designates a same-machine transport.

A URL is local when it uses intra://, shm:// or shm2://.

Parameters
urlURL string to classify.
Returns
true for local transports; false for network ones.

◆ is_shm_type()

static VLINK_EXPORT bool vlink::Url::is_shm_type ( std::string_view  url)
static

Returns whether url uses a shared-memory transport.

Parameters
urlURL string to classify.
Returns
true for both shm:// and shm2:// URLs.

◆ is_valid()

bool vlink::Url::is_valid ( ) const
inlineoverridevirtual

Reports whether the underlying target_ conf is valid.

Returns
Result of target_->is_valid(), or false when target_ is null.

Reimplemented from vlink::Conf.

◆ load_for_plugin()

static VLINK_EXPORT std::unique_ptr<Conf> vlink::Url::load_for_plugin ( TransportType  type)
static

Resolves a transport plugin and asks it for a Conf matching type.

Looks up a preloaded or previously auto-loaded ConfPluginInterface whose get_transport_type() returns type. If none is registered and the complete VLINK_URL_PLUGINS value equals auto, ignoring case, the runtime tries the fixed vlink- <module> library for the recognized transport, validates the plugin-reported type, and invokes create(). Empty and case-insensitive none values disable plugin loading; other non-empty values select explicit preload mode. The complete setting is sampled once when the process-wide plugin manager is first initialized.

Parameters
typeTransport backend to look up.
Returns
Newly created Conf, or nullptr for an unknown transport, a disabled or failed on-demand load, or when no plugin matches.
Here is the caller graph for this function:

◆ operator=() [1/2]

Url & vlink::Url::operator= ( const Url url)
inline

Copy assignment.

Copies protocol_ and re-runs init_target_internal() to rebuild target_.

Parameters
urlSource Url.
Returns
Reference to *this.
Here is the call graph for this function:

◆ operator=() [2/2]

Url & vlink::Url::operator= ( Url &&  url)
inlinenoexcept

Move assignment.

Parameters
urlSource Url.
Returns
Reference to *this.

◆ parse()

bool vlink::Url::parse ( ImplType  impl_type) const
inlineoverridevirtual

Parses the URL for impl_type by delegating to target_.

Chains Conf::parse(impl_type), target_->parse(impl_type) and target_->parse_protocol(); returns false on target_ being null or any step failing.

Parameters
impl_typeBitmask of ImplType roles to validate.
Returns
true when every step succeeds; false otherwise.

Reimplemented from vlink::Conf.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ 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: