VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
vlink::Url Struct Referencefinal

URL-based Conf dispatcher that routes to the correct transport backend. 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 ,
  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...

Public Member Functions

 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.
Urloperator= (const Url &url)
 Copy-assignment operator.
Urloperator= (Url &&url) noexcept
 Move-assignment operator.
const std::string & get_str () const
 Returns the original (or remapped) URL string.
const Confget_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.

Static Public Member Functions

static VLINK_EXPORT void init_plugins (uint16_t transport_enable_flags=0)
 Loads and registers ConfPluginInterface plugins for the enabled transports.
static VLINK_EXPORT std::unique_ptr< Confload_for_plugin (TransportType type)
 Searches loaded plugins for a Conf factory matching type.
static VLINK_EXPORT int get_sort_index (std::string_view url)
 Returns a numeric sort index for the transport backend used by a URL.
static VLINK_EXPORT bool is_local_type (std::string_view url)
 Returns true if the URL refers to a local (same-machine) transport.
static VLINK_EXPORT bool is_intra_type (std::string_view url)
 Returns true if the URL uses the intra:// in-process transport.
static VLINK_EXPORT bool is_shm_type (std::string_view url)
 Returns true if the URL uses a shared-memory transport (shm:// or shm2://).
static void global_init (uint16_t transport_enable_flags=0)
 Initialises the global state for all enabled transport backends.
static uint16_t get_transport_enable_flags ()
 Returns a bitmask of all compile-time-enabled transport backends.
static void init_target_internal (const Protocol &protocol, std::unique_ptr< Conf > &target)
 Creates the target_ Conf for a given Protocol.

Friends

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

Additional Inherited Members

Detailed Description

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
// 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 type:
url.parse(kSubscriber);
// -> target_->parse(kSubscriber)
// -> target_->parse_protocol(&protocol_)
// 3. Create transport implementation:
auto impl = url.create_subscriber();
// -> target_->create_subscriber()

Member Enumeration Documentation

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

Constructor & Destructor Documentation

◆ 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
strVLink URL string, e.g. "dds://vehicle/speed".
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
urlSource Url to copy.
Here is the call graph for this function:

◆ Url() [3/3]

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

Move constructor.

Transfers protocol_ and target_ from url without rebuilding.

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

◆ ~Url()

vlink::Url::~Url ( )
inlineoverridedefault

Destructor.

Here is the call graph for this function:

Member Function Documentation

◆ 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
urlURL 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.
Here is the call graph for this function:

◆ 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.
Here is the caller graph for this function:

◆ get_transport_type()

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

Returns the transport backend resolved from the URL.

Delegates to target_->get_transport_type(). Returns TransportType::kUnknown if target_ is null.

Returns
The TransportType for this URL.

Reimplemented from vlink::Conf.

◆ 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_flagsBitmask of TransportEnableFlag values. Passing 0 (the default) expands to all compiled-in transports.
Here is the call graph for this function:

◆ 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_flagsBitmask of TransportEnableFlag values; default 0 (no plugins searched unless env var is set).
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

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
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()

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
urlURL 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
urlURL 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
urlURL 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()

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

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
typeTransport backend to search for.
Returns
A new Conf instance from the plugin, or nullptr.
Here is the caller graph for this function:

◆ operator=() [1/2]

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

Copy-assignment operator.

Copies protocol_ and reinitialises target_ via init_target_internal().

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 operator.

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

◆ 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_typeBitmask of ImplType roles (e.g. kSubscriber).
Returns
true if all parse steps succeed; false otherwise.

Reimplemented from vlink::Conf.

Here is the call graph for this function:

◆ 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:
  • include/vlink/impl/url.h