|
VLink 2.0.0
A high-performance communication middleware
|
URL-based Conf dispatcher that routes to the correct transport backend.
更多...
#include <url.h>
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 类型 继承自 vlink::Conf | |
| using | PropertiesMap = std::map<std::string, std::string> |
| Key/value property map type. | |
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. | |
| Url & | operator= (const Url &url) |
| Copy-assignment operator. | |
| Url & | operator= (Url &&url) noexcept |
| Move-assignment operator. | |
| const std::string & | get_str () const |
| Returns the original (or remapped) URL string. | |
| const Conf * | get_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 成员函数 继承自 vlink::Conf | |
| virtual | ~Conf () |
| Virtual destructor. | |
静态 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< Conf > | load_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 |
额外继承的成员函数 | |
| Public 属性 继承自 vlink::Conf | |
| uint32_t | hash_code {0} |
| Hash of the URL string; used for fast URL lookup in caches. | |
| Protected 成员函数 继承自 vlink::Conf | |
| Conf () | |
| virtual bool | parse_protocol (struct Protocol *protocol) |
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_.
| enum vlink::Url::TransportEnableFlag : uint16_t |
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 |
|
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.
| str | VLink URL string, e.g. "dds://vehicle/speed". |
|
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.
| url | Source Url to copy. |
|
inlinenoexcept |
Move constructor.
Transfers protocol_ and target_ from url without rebuilding.
| url | Source Url to move from. |
|
inlineoverridedefault |
Destructor.
|
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.
ImplType for this URL, or kUnknownImplType. 重载 vlink::Conf .
|
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.
| url | URL string to classify. |
|
inlinenodiscard |
Returns the original (or remapped) URL string.
Protocol::str.
|
inlinenodiscard |
|
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.
|
inlinenodiscardoverridevirtual |
Returns the transport backend resolved from the URL.
Delegates to target_->get_transport_type(). Returns TransportType::kUnknown if target_ is null.
TransportType for this URL. 重载 vlink::Conf .
|
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_flags | Bitmask of TransportEnableFlag values. Passing 0 (the default) expands to all compiled-in transports. |
|
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_flags | Bitmask of TransportEnableFlag values; default 0 (no plugins searched unless env var is set). |
|
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.
| protocol | Parsed URL information used to select the transport. |
| target | Output: receives the newly created Conf instance. |
|
staticnodiscard |
Returns true if the URL uses the intra:// in-process transport.
| url | URL string to classify. |
true only for intra:// URLs.
|
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://.
| url | URL string to classify. |
true for local transports; false for network transports.
|
staticnodiscard |
Returns true if the URL uses a shared-memory transport (shm:// or shm2://).
| url | URL string to classify. |
true for shm:// and shm2:// URLs.
|
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 .
|
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.
| type | Transport backend to search for. |
Conf instance from the plugin, or nullptr. Copy-assignment operator.
Copies protocol_ and reinitialises target_ via init_target_internal().
| url | Source Url. |
*this.
|
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_type | Bitmask of ImplType roles (e.g. kSubscriber). |
true if all parse steps succeed; false otherwise. 重载 vlink::Conf .
|
friend |