VLink  2.0.0
A high-performance communication middleware
vlink::BagPluginInterface类 参考abstract

Abstract plugin base shared by bag playback and bag recording. 更多...

#include <bag_plugin_interface.h>

vlink::BagPluginInterface 的协作图:

struct  VersionInfo
 Build identity returned by get_version_info(). 更多...
 

Public 类型

enum  Direction : uint8_t { kRead = 0 , kWrite = 1 }
 Identifies whether the plugin is bound to a reader or a writer. 更多...
 
using Callback = FrameCallback
 Forwarding sink used by do_callback() to re-emit a frame downstream. 更多...
 

Public 成员函数

virtual VersionInfo get_version_info () const =0
 Returns the build identity used by the host for logging and diagnostics. 更多...
 
void bind_direction (Direction direction)
 Records the binding direction so the plugin can branch on read vs write. 更多...
 
Direction get_direction () const
 Returns the side this plugin is currently bound to. 更多...
 
void register_callback (Callback &&callback)
 Stores the forwarding sink used by do_callback(). 更多...
 
virtual bool convert_url_meta (std::string &url, std::string &ser_type, SchemaType &schema_type)
 Rewrites or filters a stored URL before playback begins (read side). 更多...
 
virtual void on_read (const Frame &frame)
 Intercepts a replayed frame on its way to the user (read side). 更多...
 
virtual void on_write (const Frame &frame)
 Intercepts a frame before it is persisted (write side). 更多...
 
virtual void flush ()
 Drains any internally-buffered frames downstream before the host unbinds and tears down. 更多...
 
void do_callback (const Frame &frame)
 Forwards one frame downstream through the registered sink. 更多...
 

Protected 成员函数

 BagPluginInterface ()=default
 
virtual ~BagPluginInterface ()=default
 

Protected 属性

Direction direction_ {Direction::kRead}
 

详细描述

Abstract plugin base shared by bag playback and bag recording.

The host binds an instance through BagReader::bind_plugin_interface() or BagWriter::bind_plugin_interface(). At bind time the host calls bind_direction() to record which side the plugin serves and register_callback() to supply the forwarding sink. Every hook carries a default implementation, so an implementation overrides only the hooks relevant to its direction (plus the mandatory get_version_info()). Implementations are expected to be thread-compatible with the host's loop thread.

成员类型定义说明

◆ Callback

Forwarding sink used by do_callback() to re-emit a frame downstream.

Supplied by the host (BagReader or BagWriter) at bind time and stored internally. A single const Frame& sink serves both directions: read plugins re-emit toward playback, write plugins toward persistence.

成员枚举类型说明

◆ Direction

Identifies whether the plugin is bound to a reader or a writer.

枚举值
kRead 

Bound to a BagReader; the plugin forwards replayed frames.

kWrite 

Bound to a BagWriter; the plugin forwards frames before they are persisted.

构造及析构函数说明

◆ BagPluginInterface()

vlink::BagPluginInterface::BagPluginInterface ( )
protecteddefault

◆ ~BagPluginInterface()

virtual vlink::BagPluginInterface::~BagPluginInterface ( )
protectedvirtualdefault

成员函数说明

◆ bind_direction()

void vlink::BagPluginInterface::bind_direction ( Direction  direction)
inline

Records the binding direction so the plugin can branch on read vs write.

Details

Invoked by the host at attach time before any other hook. The value is observable from the hooks through get_direction().

参数
directionSide the plugin is being bound to.

◆ convert_url_meta()

bool vlink::BagPluginInterface::convert_url_meta ( std::string &  url,
std::string &  ser_type,
SchemaType schema_type 
)
inlinevirtual

Rewrites or filters a stored URL before playback begins (read side).

Called once per URL contained in the bag when the reader opens the file. Implementations may modify any of the three parameters in place to remap topics or override schema metadata. The default implementation keeps every URL unchanged.

参数
urlURL string; may be modified in place.
ser_typeSerialisation type; may be modified in place.
schema_typeCoarse schema family; may be modified in place.
返回
true to retain the URL in playback; false to exclude it.

◆ do_callback()

void vlink::BagPluginInterface::do_callback ( const Frame frame)
inline

Forwards one frame downstream through the registered sink.

The emit helper a plugin calls – typically from on_read() / on_write() or from a reorder buffer's output callback – to deliver a frame downstream without touching callback_ directly. Invokes callback_ when one is registered and is otherwise a no-op.

参数
frameFrame to forward to the sink.
这是这个函数的调用关系图:

◆ flush()

void vlink::BagPluginInterface::flush ( )
inlinevirtual

Drains any internally-buffered frames downstream before the host unbinds and tears down.

Called by the host on its own thread, while its sink is still valid, right before it detaches this plugin (read side: at reader teardown; write side: at writer teardown, before the recording loop is stopped). A plugin that buffers frames for asynchronous re-emit (e.g. a BagProcessor reorder buffer) must override this to flush those frames synchronously – typically processor_.flush() – so a buffered tail is recorded / replayed instead of dropped. The default implementation is a no-op (a synchronous plugin holds nothing back). After flush() returns the host stops delivering this plugin's emitted frames, so any frame produced afterwards is ignored.

◆ get_direction()

BagPluginInterface::Direction vlink::BagPluginInterface::get_direction ( ) const
inline

Returns the side this plugin is currently bound to.

返回
Direction::kRead when bound to a reader, Direction::kWrite when bound to a writer.

◆ get_version_info()

virtual VersionInfo vlink::BagPluginInterface::get_version_info ( ) const
pure virtual

Returns the build identity used by the host for logging and diagnostics.

返回
Populated VersionInfo describing this plugin.

◆ on_read()

void vlink::BagPluginInterface::on_read ( const Frame frame)
inlinevirtual

Intercepts a replayed frame on its way to the user (read side).

Called for every replayed frame after timing pacing. Forward it downstream by calling do_callback(); transforming the payload, dropping the frame (by not emitting), fanning it out (emitting several), or buffering and re-emitting frames reordered by data-plane time (e.g. via BagProcessor) is permitted. The default implementation forwards the frame unchanged.

注解
frame::ser_type / schema_type are empty on the read side; query BagReader::get_ser_type() / get_schema_type() (or stash them from convert_url_meta()) if needed. The payload is a shallow view valid for the duration of the call; copy it before buffering for asynchronous emit.
参数
frameReplayed frame.
函数调用图:

◆ on_write()

void vlink::BagPluginInterface::on_write ( const Frame frame)
inlinevirtual

Intercepts a frame before it is persisted (write side).

Called for every frame handed to the writer, before it is recorded. Re-emit it by calling do_callback(). Transcoding (rewrite frame.data plus frame.ser_type / schema_type, e.g. raw image to JPEG), dropping the frame (by not emitting), fanning it out, or buffering and re-emitting frames reordered by data-plane time (a sliding-window reorder, e.g. via BagProcessor) is permitted. The default implementation forwards the frame unchanged.

注解
The payload is a view valid for the duration of the call; a plugin that emits asynchronously must copy it before buffering.
When a plugin renames the URL, the recorder learns the source-to-recorded mapping only for synchronous emits (within this on_write() call) and only when the rewrite is one-to-one, so URL-level metadata such as loss stays correctly attributed. A plugin that both renames and emits asynchronously is responsible for any loss attribution itself.
BagWriter::push() resolves a negative Frame::timestamp to the writer clock before calling this hook; that auto-assignment does not re-run on the frames a plugin emits. A re-emitted frame is persisted with its own Frame::timestamp verbatim, so a plugin that constructs a fresh frame must set a resolved (non-negative) timestamp on it.
参数
frameFrame to persist.
函数调用图:

◆ register_callback()

void vlink::BagPluginInterface::register_callback ( Callback &&  callback)
inline

Stores the forwarding sink used by do_callback().

Invoked by the host's bind_plugin_interface() at attach time. The plugin keeps callback in callback_ and calls it from do_callback() to deliver a frame downstream – toward the user's playback callback on the read side, or toward persistence on the write side. Cleared (with an empty callable) on rebind and at host teardown, so a plugin-owned worker thread cannot reach a destroyed host.

参数
callbackSink that forwards a frame downstream.

类成员变量说明

◆ direction_

Direction vlink::BagPluginInterface::direction_ {Direction::kRead}
protected

该类的文档由以下文件生成: