VLink  2.1.0
A high-performance communication middleware
vlink::Url结构体 参考final

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

#include <url.h>

类 vlink::Url 继承关系图:
vlink::Url 的协作图:

Public 类型

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(). 更多...
 

Public 成员函数

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

静态 Public 成员函数

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

友元

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

额外继承的成员函数

详细描述

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

成员枚举类型说明

◆ 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
枚举值
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.

构造及析构函数说明

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

参数
strVLink 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 a fresh target_ via init_target_internal(), so the two Url objects do not share the same transport Conf instance.

参数
urlSource Url to copy.
函数调用图:

◆ Url() [3/3]

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

Move constructor.

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

参数
urlSource Url to move from.

◆ ~Url()

vlink::Url::~Url ( )
inlineoverridedefault

Destructor.

成员函数说明

◆ get_impl_type()

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

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

返回
Cached ImplType, or kUnknownImplType when target_ is null.

重载 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.

参数
urlURL string to classify.
返回
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).

返回
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).

返回
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.

返回
Bitmask of TransportEnableFlag values.
这是这个函数的调用关系图:

◆ get_transport_type()

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

Returns the transport backend identifier resolved from the URL.

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

重载 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.

参数
transport_enable_flagsBitmask of TransportEnableFlag values.
函数调用图:

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

参数
transport_enable_flagsRetained for source compatibility; explicit preload selection comes from VLINK_URL_PLUGINS.
这是这个函数的调用关系图:

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

参数
protocolParsed URL information used to select the transport.
targetOutput: receives the newly created Conf instance.
函数调用图:
这是这个函数的调用关系图:

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

参数
urlURL string to classify.
返回
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://.

参数
urlURL string to classify.
返回
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.

参数
urlURL string to classify.
返回
true for both shm:// and shm2:// URLs.

◆ is_valid()

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

Reports whether the underlying target_ conf is valid.

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

重载 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.

参数
typeTransport backend to look up.
返回
Newly created Conf, or nullptr for an unknown transport, a disabled or failed on-demand load, or when no plugin matches.
这是这个函数的调用关系图:

◆ operator=() [1/2]

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

Copy assignment.

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

参数
urlSource Url.
返回
Reference to *this.
函数调用图:

◆ operator=() [2/2]

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

Move assignment.

参数
urlSource Url.
返回
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.

参数
impl_typeBitmask of ImplType roles to validate.
返回
true when every step succeeds; false otherwise.

重载 vlink::Conf .

函数调用图:

友元及相关函数文档

◆ operator<<

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

该结构体的文档由以下文件生成: