VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
vlink::MessageConvertPlugin Class Referenceabstract

Abstract interface for VLink/webviz message conversion plugins supporting multiple visualization backends. More...

#include <message_convert_plugin.h>

Collaboration diagram for vlink::MessageConvertPlugin:

Public Member Functions

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 Member Functions

 MessageConvertPlugin ()=default
virtual ~MessageConvertPlugin ()=default

Detailed Description

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.

Constructor & Destructor Documentation

◆ MessageConvertPlugin()

vlink::MessageConvertPlugin::MessageConvertPlugin ( )
protecteddefault

◆ ~MessageConvertPlugin()

virtual vlink::MessageConvertPlugin::~MessageConvertPlugin ( )
protectedvirtualdefault

Member Function Documentation

◆ can_convert()

virtual bool vlink::MessageConvertPlugin::can_convert ( const std::string & vlink_ser,
ConvertTarget target )
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.

Parameters
vlink_serVLink serialisation type name (e.g. "proto.VehiclePose").
targetThe visualization backend requesting the conversion.
Returns
true if this plugin handles the type for the given target.

◆ can_convert_frontend()

virtual bool vlink::MessageConvertPlugin::can_convert_frontend ( const WebChannel & channel,
ConvertTarget 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.

◆ convert()

virtual bool vlink::MessageConvertPlugin::convert ( const std::string & vlink_ser,
const Bytes & raw,
ConvertTarget target,
Bytes & payload )
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.

Parameters
[in]vlink_serVLink serialisation type name.
[in]rawRaw serialised message bytes from VLink.
[in]targetThe visualization backend requesting the conversion.
[out]payloadOutput buffer for the converted payload.
Returns
true on success.

◆ convert_frontend()

virtual bool vlink::MessageConvertPlugin::convert_frontend ( const WebChannel & channel,
const Bytes & raw,
ConvertTarget target,
Bytes & payload )
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.

◆ extract_timestamp()

virtual int64_t vlink::MessageConvertPlugin::extract_timestamp ( const std::string & vlink_ser,
const Bytes & raw,
ConvertTarget target )
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.

Parameters
[in]vlink_serVLink serialisation type name.
[in]rawRaw serialised message bytes from VLink.
[in]targetThe visualization backend.
Returns
Timestamp in nanoseconds since epoch, or -1 if not available.

◆ get_publish_info()

virtual bool vlink::MessageConvertPlugin::get_publish_info ( const WebChannel & channel,
ConvertTarget target,
VlinkPublish & publish_info )
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.

◆ get_schema_info()

virtual bool vlink::MessageConvertPlugin::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 )
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.
Parameters
[in]vlink_serVLink serialisation type name.
[in]targetThe visualization backend requesting the metadata.
[out]type_nameSchema/archetype name.
[out]encodingWire encoding (e.g. "flatbuffers", "json").
[out]schema_encodingSchema encoding (Foxglove only, e.g. "flatbuffers").
[out]schema_dataBinary schema data bytes (Foxglove only).
Returns
true on success.

◆ init()

virtual bool vlink::MessageConvertPlugin::init ( const std::string & config)
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.

Parameters
configConfiguration string (may be empty).
Returns
true on success, false if initialisation failed.

The documentation for this class was generated from the following file: