VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
vlink::Url结构体 参考final

URL-based Conf dispatcher that routes to the correct transport backend. 更多...

#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 ,
  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. 更多...

Public 成员函数

 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.

静态 Public 成员函数

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.

友元

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

额外继承的成员函数

详细描述

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

成员枚举类型说明

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

参数
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 target_ via init_target_internal(). The new object gets a fresh transport Conf rather than sharing the same instance.

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

◆ Url() [3/3]

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

Move constructor.

Transfers protocol_ and target_ from url without rebuilding.

参数
urlSource Url to move from.
函数调用图:

◆ ~Url()

vlink::Url::~Url ( )
inlineoverridedefault

Destructor.

函数调用图:

成员函数说明

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

返回
The ImplType for this URL, or kUnknownImplType.

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

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

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

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

返回
TransportEnableFlag bitmask of supported transports.
这是这个函数的调用关系图:

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

返回
The TransportType for this URL.

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

参数
transport_enable_flagsBitmask 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.

参数
transport_enable_flagsBitmask 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.

参数
protocolParsed URL information used to select the transport.
targetOutput: 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.

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

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

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

返回
true if the transport conf is valid and ready for use.

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

参数
typeTransport backend to search for.
返回
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().

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

◆ operator=() [2/2]

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

Move-assignment operator.

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

参数
impl_typeBitmask of ImplType roles (e.g. kSubscriber).
返回
true if all parse steps succeed; false otherwise.

重载 vlink::Conf .

函数调用图:

◆ operator<<

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

该结构体的文档由以下文件生成:
  • include/vlink/impl/url.h