Conf subclass that routes virtual calls to the transport selected by a URL string.
更多...
#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 that selects which transports participate in global_init() / init_plugins(). 更多...
|
| |
| using | PropertiesMap = std::map< std::string, std::string > |
| | Key/value property map shared between confs and node implementations. 更多...
|
| |
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
Url url(
"dds://vehicle/speed");
auto impl = url.create_subscriber();
@ kSubscriber
Event subscriber (receives broadcasts).
Definition: types.h:115
friend struct Url
Definition: conf.h:193
◆ TransportEnableFlag
Bitmask that selects which transports participate in global_init() / init_plugins().
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:// |
kEnableDdst | 8 | ddst:// |
kEnableSomeip | 7 | someip:// |
kEnableMqtt | 6 | mqtt:// |
kEnableFdbus | 5 | fdbus:// |
kEnableQnx | 4 | qnx:// |
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.
|
| kEnableDdst | Enable the ddst:// (TravoDDS) transport.
|
| kEnableSomeip | Enable the someip:// transport.
|
| kEnableMqtt | Enable the mqtt:// transport.
|
| kEnableFdbus | Enable the fdbus:// transport.
|
| kEnableQnx | Enable the qnx:// transport (QNX only).
|
| 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.
- 参数
-
| str | VLink URL string (e.g. "dds://vehicle/speed"). |
◆ Url() [2/3]
| vlink::Url::Url |
( |
const Url & |
url | ) |
|
|
inline |
◆ Url() [3/3]
| vlink::Url::Url |
( |
Url && |
url | ) |
|
|
inlinenoexcept |
Move constructor.
Transfers both protocol_ and target_ from url; no rebuild is performed.
- 参数
-
| url | Source Url to move from. |
◆ ~Url()
◆ 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.
- 参数
-
| url | URL 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()
◆ 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_flags | Bitmask of TransportEnableFlag values. |
◆ init_plugins()
| static VLINK_EXPORT void vlink::Url::init_plugins |
( |
uint16_t |
transport_enable_flags = 0 | ) |
|
|
static |
Loads recognized transport plugins from VLINK_URL_PLUGINS.
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.
Discovered plugins whose TransportType already appears in transport_enable_flags are skipped so that linked transports continue to take precedence. The first Url construction triggers this call automatically; explicit invocations are only needed for unusual initialisation sequences.
- 参数
-
| transport_enable_flags | Bitmask of built-in transports already available; matching plugins are ignored. |
◆ 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. Logs a fatal entry when neither path succeeds.
- 参数
-
| protocol | Parsed URL information used to select the transport. |
| target | Output: 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.
- 参数
-
| url | URL 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://.
- 参数
-
| url | URL 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.
- 参数
-
| url | URL 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()
Asks loaded plugins for a Conf factory matching type.
Looks up a previously registered ConfPluginInterface whose get_transport_type() returns type and invokes create() on it.
- 参数
-
| type | Transport backend to look up. |
- 返回
- Newly created
Conf, or nullptr 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_.
- 参数
-
- 返回
- Reference to
*this.
◆ operator=() [2/2]
| Url & vlink::Url::operator= |
( |
Url && |
url | ) |
|
|
inlinenoexcept |
Move assignment.
- 参数
-
- 返回
- 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_type | Bitmask 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 |
该结构体的文档由以下文件生成: