|
VLink 2.0.0
A high-performance communication middleware
|
Abstract interface for VLink/webviz message conversion plugins supporting multiple visualization backends. 更多...
#include <message_convert_plugin.h>
Public 成员函数 | |
| virtual bool | init (const std::string &config)=0 |
| Initialises the plugin with an optional configuration string. | |
| virtual bool | can_convert (const std::string &vlink_ser, ConvertTarget target)=0 |
| Tests whether this plugin can handle the given VLink serialisation type for the specified target backend. | |
| virtual bool | get_schema_info (const std::string &vlink_ser, ConvertTarget target, std::string &type_name, std::string &encoding, std::string &schema_encoding, std::string &schema_data)=0 |
| Returns schema/type metadata for the given VLink type and target backend. | |
| virtual bool | convert (const std::string &vlink_ser, const Bytes &raw, ConvertTarget target, Bytes &payload)=0 |
| Converts a raw VLink message to a backend-specific payload. | |
| virtual int64_t | extract_timestamp (const std::string &vlink_ser, const Bytes &raw, ConvertTarget target) |
| Extracts a message-level timestamp from the raw message, in nanoseconds. | |
| virtual bool | can_convert_frontend (const WebChannel &channel, ConvertTarget target) |
| Tests whether this plugin handles a frontend-published channel. | |
| virtual bool | get_publish_info (const WebChannel &channel, ConvertTarget target, VlinkPublish &publish_info) |
| Resolves the destination VLink publish URL and serialisation type for an inbound frontend channel. | |
| virtual bool | convert_frontend (const WebChannel &channel, const Bytes &raw, ConvertTarget target, Bytes &payload) |
| Converts a frontend-published payload into a raw VLink message payload. | |
Protected 成员函数 | |
| MessageConvertPlugin ()=default | |
| virtual | ~MessageConvertPlugin ()=default |
Abstract interface for VLink/webviz message conversion plugins supporting multiple visualization backends.
Loaded as a dynamic plugin via Plugin::load<MessageConvertPlugin>().
The plugin must be thread-safe: convert() may be called concurrently from multiple ProxyAPI data callback threads.
A plugin may support only one target or both. Return false from can_convert() for unsupported targets.
|
protecteddefault |
|
protectedvirtualdefault |
|
nodiscardpure virtual |
Tests whether this plugin can handle the given VLink serialisation type for the specified target backend.
Called during channel/topic discovery for each new VLink type. If this returns true, get_schema_info() and convert() will be used for that type. The result may be cached by the caller.
| vlink_ser | VLink serialisation type name (e.g. "proto.VehiclePose"). |
| target | The visualization backend requesting the conversion. |
true if this plugin handles the type for the given target.
|
inlinenodiscardvirtual |
Tests whether this plugin handles a frontend-published channel.
This hook is used for inbound command/control flows such as Foxglove clientPublish. The default implementation returns false.
|
nodiscardpure virtual |
Converts a raw VLink message to a backend-specific payload.
Called for every incoming message whose type was accepted by can_convert().
For ConvertTarget::kFoxglove, the plugin should build the target Foxglove FlatBuffer (or Protobuf) and write the result to payload using Bytes::deep_copy() or Bytes::create().
For ConvertTarget::kRerun, the plugin should produce a UTF-8 JSON string describing the Rerun archetype components. The JSON format is documented in the file-level documentation. Write the JSON bytes to payload.
This method must be thread-safe.
| [in] | vlink_ser | VLink serialisation type name. |
| [in] | raw | Raw serialised message bytes from VLink. |
| [in] | target | The visualization backend requesting the conversion. |
| [out] | payload | Output buffer for the converted payload. |
true on success.
|
inlinenodiscardvirtual |
Converts a frontend-published payload into a raw VLink message payload.
Called for each inbound frontend message after get_publish_info() resolved the destination topic. The plugin should write the destination raw VLink payload to payload.
The default implementation returns false.
|
inlinenodiscardvirtual |
Extracts a message-level timestamp from the raw message, in nanoseconds.
Called after convert() to obtain a per-message timestamp derived from the message content (e.g. a sensor timestamp field). This allows the visualization frontend to use the actual data timestamp rather than the proxy transport timestamp.
The default implementation returns -1 (not available), meaning the server falls back to the proxy-provided timestamp. Override this method to extract timestamps from your message format.
| [in] | vlink_ser | VLink serialisation type name. |
| [in] | raw | Raw serialised message bytes from VLink. |
| [in] | target | The visualization backend. |
-1 if not available.
|
inlinenodiscardvirtual |
Resolves the destination VLink publish URL and serialisation type for an inbound frontend channel.
Called when a frontend channel is advertised. Returning true enables the host to provision the required VLink publisher(s) ahead of time.
The default implementation returns false.
|
nodiscardpure virtual |
Returns schema/type metadata for the given VLink type and target backend.
Called once per type during channel/topic registration.
For ConvertTarget::kFoxglove, the plugin must fill in the Foxglove schema name, encoding type, schema encoding, and the binary schema data (typically a serialised FlatBuffers binary schema .bfbs file content).
For ConvertTarget::kRerun, the plugin should fill in:
type_name: Rerun archetype name (e.g. "Points3D", "EncodedImage")encoding: "json" (the payload format)schema_encoding and schema_data may be left empty.| [in] | vlink_ser | VLink serialisation type name. |
| [in] | target | The visualization backend requesting the metadata. |
| [out] | type_name | Schema/archetype name. |
| [out] | encoding | Wire encoding (e.g. "flatbuffers", "json"). |
| [out] | schema_encoding | Schema encoding (Foxglove only, e.g. "flatbuffers"). |
| [out] | schema_data | Binary schema data bytes (Foxglove only). |
true on success.
|
pure virtual |
Initialises the plugin with an optional configuration string.
Called once after the plugin is loaded. The config parameter may contain a file path, JSON string, or any format the plugin understands. Returning false causes the plugin to be unloaded.
| config | Configuration string (may be empty). |
true on success, false if initialisation failed.