VLink  2.0.0
A high-performance communication middleware
url.h 文件参考

URL-driven configuration dispatcher that selects and forwards to a transport Conf. 更多...

#include <map>
#include <memory>
#include <string>
#include <utility>
#include "../base/logger.h"
#include "./conf.h"
#include "../modules/dds_conf.h"
#include "../modules/ddsc_conf.h"
#include "../modules/ddsr_conf.h"
#include "../modules/ddst_conf.h"
#include "../modules/fdbus_conf.h"
#include "../modules/intra_conf.h"
#include "../modules/mqtt_conf.h"
#include "../modules/qnx_conf.h"
#include "../modules/shm2_conf.h"
#include "../modules/shm_conf.h"
#include "../modules/someip_conf.h"
#include "../modules/zenoh_conf.h"
#include "./client_impl.h"
#include "./getter_impl.h"
#include "./publisher_impl.h"
#include "./server_impl.h"
#include "./setter_impl.h"
#include "./subscriber_impl.h"
url.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

struct  vlink::Protocol
 Plain-data record describing the parsed components of a VLink URL. 更多...
 
struct  vlink::Url
 Conf subclass that routes virtual calls to the transport selected by a URL string. 更多...
 

命名空间

 

详细描述

URL-driven configuration dispatcher that selects and forwards to a transport Conf.

This is an internal implementation header used by every public node template to translate a URL string into a concrete transport backend. It also re-exports all transport *Conf headers and the *Impl headers so the impl layer can be pulled in with a single include. Two types are introduced:

Protocol
A small plain-data struct populated by the UrlParser pipeline. It owns the URL string (after any VLINK_URL_REMAP rewriting) plus the resolved TransportType and the parsed host, path, query dictionary and fragment. Only Url may construct a Protocol – the constructor is private and Url is its only friend.
Url
A concrete Conf subclass that wraps a Protocol, builds the matching transport Conf in init_target_internal() and forwards every virtual Conf hook to that target. Constructing a Url is the entry point used by every public Node<> template to set up its transport backend.
Protocol struct fields
Field Meaning
str Full URL string after any VLINK_URL_REMAP rewrite.
transport Resolved transport backend identifier.
host Hostname or IP component, if any.
path Topic path component.
dictionary Query parameters parsed into a std::map.
fragment Fragment identifier following #.
Transport prefix to backend
URL prefix Conf class created in init_target_internal()
intra:// IntraConf
shm:// ShmConf
shm2:// Shm2Conf
zenoh:// ZenohConf
dds:// DdsConf
ddsc:// DdscConf
ddsr:// DdsrConf
ddst:// DdstConf
someip:// SomeipConf
mqtt:// MqttConf
fdbus:// FdbusConf
qnx:// QnxConf
other Unsupported; custom schemes are not registered.
Construction flow
URL string -> UrlParser -> Protocol -> init_target_internal() -> *Conf
|
v
parse(impl_type)
|
v
create_publisher() / create_subscriber() / ...
|
v
NodeImpl backend instance
URL Remapping
When VLINK_URL_USE_REMAP is enabled, the Protocol constructor inspects the VLINK_URL_REMAP environment variable and rewrites the URL before the transport is resolved. This enables transport switching without touching application code.
Plugin loading
When VLINK_URL_USE_PLUGIN is enabled, Url::init_plugins() loads shared libraries listed in the VLINK_URL_PLUGINS environment variable. Each library name must map to an existing TransportType; loaded ConfPluginInterface entries are consulted only for recognized transports whose backend is not linked in. TransportType::kUnknown is not passed to plugins, so arbitrary URL schemes cannot be added through this mechanism.
Transport enable flags
TransportEnableFlag is a bitmask that selects which built-in transports participate in global_init() and init_plugins(). Embedding environments (Android, QNX, etc.) use it to skip transports they cannot support at runtime.
Example
vlink::Url url("dds://vehicle/speed?domain=1");
if (url.parse(vlink::kSubscriber)) {
auto impl = url.get_target() != nullptr
? std::unique_ptr<vlink::SubscriberImpl>{}
: nullptr;
// Public Subscriber<T> template performs this call internally.
auto sub = vlink::Subscriber<MyMsg>::create_unique(url.get_str());
}
注解
This file is the single aggregation point for the VLink impl layer; it transitively includes every transport *_conf.h header and every *_impl.h header.