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

Concrete SQLite-backed bag file player. More...

#include <database_reader.h>

Inheritance diagram for vlink::DatabaseReader:
Collaboration diagram for vlink::DatabaseReader:

Public Member Functions

 DatabaseReader (const std::string &path, bool read_only=true, bool try_to_fix=false)
 Constructs a DatabaseReader for the given path.
 ~DatabaseReader () override
 Destructor – stops playback and closes the SQLite database handle.
void bind_plugin_interface (const std::shared_ptr< BagReaderPluginInterface > &plugin_interface) override
 Attaches a BagReaderPluginInterface for custom URL/type conversion.
void register_status_callback (StatusCallback &&status_callback) override
 Registers a callback fired whenever the playback status changes.
void register_ready_callback (ReadyCallback &&ready_callback) override
 Registers a callback fired when the reader is ready to start playing.
void register_finish_callback (FinishCallback &&finish_callback) override
 Registers a callback fired when playback ends or is interrupted.
void register_output_callback (OutputCallback &&output_callback) override
 Registers the callback that receives replayed messages.
void play (const Config &config) override
 Starts playback with the given configuration.
void stop () override
 Stops playback and resets the reader to the beginning.
void pause () override
 Pauses playback at the current position.
void resume () override
 Resumes a paused playback from the current position.
void pause_to_next () override
 Advances one message while paused, then pauses again.
void jump (int64_t begin_time, double rate, int times, bool force_to_play=false) override
 Seeks to begin_time and resumes playback.
std::future< bool > check () override
 Verifies the integrity of the SQLite bag file asynchronously.
std::future< bool > reindex () override
 Rebuilds the index tables asynchronously.
std::future< bool > fix (bool rebuild=false) override
 Repairs a corrupt SQLite bag file asynchronously.
void tag (const std::string &tag_name) override
 Updates the tag name stored in the bag metadata.
int64_t get_timestamp () const override
 Returns the current playback position as a recording-relative timestamp.
int64_t get_real_timestamp () const override
 Returns the real elapsed wall-clock time since playback started.
Status get_status () const override
 Returns the current playback status.
const Infoget_info () const override
 Returns the bag file metadata and per-URL statistics.
std::vector< SchemaDatadetect_schema () override
 Scans the SQLite bag and returns all embedded schemas.
std::string get_ser_type (const std::string &url) const override
 Returns the serialisation type string for a given URL.
SchemaType get_schema_type (const std::string &url) const override
 Returns the coarse schema family for a given URL.
bool is_split_mode () const override
 Returns true if the bag spans multiple split files.
int get_split_index () const override
 Returns the zero-based index of the current split file being read.
bool is_jumping () const override
 Returns true if a jump-to-timestamp seek is currently in progress.

Protected Member Functions

size_t get_max_task_count () const override
 Returns the maximum queue depth.
void on_begin () override
 Called from the loop thread just before the first task is processed.
void on_end () override
 Called from the loop thread just after the last task has been processed.

Additional Inherited Members

 Playback state of the reader. More...
 Queue implementation type. More...
 Idle strategy controlling CPU and latency trade-offs. More...
 Pre-defined task priority levels for kPriorityType loops. More...

Detailed Description

Concrete SQLite-backed bag file player.

All virtual methods from BagReader are implemented. Prefer using BagReader::create() for format-agnostic construction.

Constructor & Destructor Documentation

◆ DatabaseReader()

vlink::DatabaseReader::DatabaseReader ( const std::string & path,
bool read_only = true,
bool try_to_fix = false )
explicit

Constructs a DatabaseReader for the given path.

Parameters
pathPath to the .vdb file.
read_onlyOpen in read-only mode (no write operations allowed).
try_to_fixAttempt repair if the database is corrupt.
Here is the caller graph for this function:

◆ ~DatabaseReader()

vlink::DatabaseReader::~DatabaseReader ( )
override

Destructor – stops playback and closes the SQLite database handle.

Member Function Documentation

◆ bind_plugin_interface()

void vlink::DatabaseReader::bind_plugin_interface ( const std::shared_ptr< BagReaderPluginInterface > & plugin_interface)
overridevirtual

Attaches a BagReaderPluginInterface for custom URL/type conversion.

Parameters
plugin_interfacePlugin to bind. May be nullptr to detach.

Reimplemented from vlink::BagReader.

◆ check()

std::future< bool > vlink::DatabaseReader::check ( )
overridevirtual

Verifies the integrity of the SQLite bag file asynchronously.

Returns
std::future<bool> that resolves to true if the file is intact.

Implements vlink::BagReader.

◆ detect_schema()

std::vector< SchemaData > vlink::DatabaseReader::detect_schema ( )
nodiscardoverridevirtual

Scans the SQLite bag and returns all embedded schemas.

Returns
Vector of SchemaData descriptors found in the bag.

Implements vlink::BagReader.

◆ fix()

std::future< bool > vlink::DatabaseReader::fix ( bool rebuild = false)
overridevirtual

Repairs a corrupt SQLite bag file asynchronously.

Parameters
rebuildIf true, rebuilds the entire index from scratch.
Returns
std::future<bool> that resolves to true if repair succeeded.

Implements vlink::BagReader.

◆ get_info()

const Info & vlink::DatabaseReader::get_info ( ) const
nodiscardoverridevirtual

Returns the bag file metadata and per-URL statistics.

Returns
Const reference to the Info struct populated at open time.

Implements vlink::BagReader.

◆ get_max_task_count()

size_t vlink::DatabaseReader::get_max_task_count ( ) const
overrideprotectedvirtual

Returns the maximum queue depth.

Returns
kMaxTaskSize (10000) by default.

Reimplemented from vlink::MessageLoop.

◆ get_real_timestamp()

int64_t vlink::DatabaseReader::get_real_timestamp ( ) const
nodiscardoverridevirtual

Returns the real elapsed wall-clock time since playback started.

Returns
Elapsed wall-clock time in milliseconds.

Implements vlink::BagReader.

◆ get_schema_type()

SchemaType vlink::DatabaseReader::get_schema_type ( const std::string & url) const
nodiscardoverridevirtual

Returns the coarse schema family for a given URL.

Parameters
urlTopic URL to look up.
Returns
Schema family, or SchemaType::kUnknown if unavailable.

Implements vlink::BagReader.

◆ get_ser_type()

std::string vlink::DatabaseReader::get_ser_type ( const std::string & url) const
nodiscardoverridevirtual

Returns the serialisation type string for a given URL.

Parameters
urlTopic URL to look up.
Returns
Serialisation type (e.g., "demo.proto.PointCloud"), or empty if unknown.

Implements vlink::BagReader.

◆ get_split_index()

int vlink::DatabaseReader::get_split_index ( ) const
nodiscardoverridevirtual

Returns the zero-based index of the current split file being read.

Implements vlink::BagReader.

◆ get_status()

Status vlink::DatabaseReader::get_status ( ) const
nodiscardoverridevirtual

Returns the current playback status.

Returns
One of kStopped, kPaused, or kPlaying.

Implements vlink::BagReader.

◆ get_timestamp()

int64_t vlink::DatabaseReader::get_timestamp ( ) const
nodiscardoverridevirtual

Returns the current playback position as a recording-relative timestamp.

Returns
Current position in milliseconds relative to the recording start.

Implements vlink::BagReader.

◆ is_jumping()

bool vlink::DatabaseReader::is_jumping ( ) const
nodiscardoverridevirtual

Returns true if a jump-to-timestamp seek is currently in progress.

Implements vlink::BagReader.

◆ is_split_mode()

bool vlink::DatabaseReader::is_split_mode ( ) const
nodiscardoverridevirtual

Returns true if the bag spans multiple split files.

Implements vlink::BagReader.

◆ jump()

void vlink::DatabaseReader::jump ( int64_t begin_time,
double rate,
int times,
bool force_to_play = false )
overridevirtual

Seeks to begin_time and resumes playback.

Parameters
begin_timeSeek target timestamp in milliseconds (relative to recording start).
rateNew playback rate multiplier.
timesNumber of loops after the jump.
force_to_playIf true, forces play state even if currently paused.

Implements vlink::BagReader.

◆ on_begin()

void vlink::DatabaseReader::on_begin ( )
overrideprotectedvirtual

Called from the loop thread just before the first task is processed.

Override in subclasses to perform per-thread initialisation.

Reimplemented from vlink::MessageLoop.

◆ on_end()

void vlink::DatabaseReader::on_end ( )
overrideprotectedvirtual

Called from the loop thread just after the last task has been processed.

Override in subclasses to perform per-thread cleanup.

Reimplemented from vlink::MessageLoop.

Here is the call graph for this function:

◆ pause()

void vlink::DatabaseReader::pause ( )
overridevirtual

Pauses playback at the current position.

Implements vlink::BagReader.

◆ pause_to_next()

void vlink::DatabaseReader::pause_to_next ( )
overridevirtual

Advances one message while paused, then pauses again.

Implements vlink::BagReader.

◆ play()

void vlink::DatabaseReader::play ( const Config & config)
overridevirtual

Starts playback with the given configuration.

Parameters
configPlayback configuration (rate, times, filters, etc.).

Implements vlink::BagReader.

◆ register_finish_callback()

void vlink::DatabaseReader::register_finish_callback ( FinishCallback && finish_callback)
overridevirtual

Registers a callback fired when playback ends or is interrupted.

Parameters
finish_callbackCallback receiving the is_interrupted flag.

Reimplemented from vlink::BagReader.

◆ register_output_callback()

void vlink::DatabaseReader::register_output_callback ( OutputCallback && output_callback)
overridevirtual

Registers the callback that receives replayed messages.

Parameters
output_callbackCalled for each message during playback.

Reimplemented from vlink::BagReader.

◆ register_ready_callback()

void vlink::DatabaseReader::register_ready_callback ( ReadyCallback && ready_callback)
overridevirtual

Registers a callback fired when the reader is ready to start playing.

Parameters
ready_callbackCallback invoked once the file is open and parsed.

Reimplemented from vlink::BagReader.

◆ register_status_callback()

void vlink::DatabaseReader::register_status_callback ( StatusCallback && status_callback)
overridevirtual

Registers a callback fired whenever the playback status changes.

Parameters
status_callbackCallback receiving the new Status value.

Reimplemented from vlink::BagReader.

◆ reindex()

std::future< bool > vlink::DatabaseReader::reindex ( )
overridevirtual

Rebuilds the index tables asynchronously.

Returns
std::future<bool> that resolves to true on success.

Implements vlink::BagReader.

◆ resume()

void vlink::DatabaseReader::resume ( )
overridevirtual

Resumes a paused playback from the current position.

Implements vlink::BagReader.

◆ stop()

void vlink::DatabaseReader::stop ( )
overridevirtual

Stops playback and resets the reader to the beginning.

Implements vlink::BagReader.

◆ tag()

void vlink::DatabaseReader::tag ( const std::string & tag_name)
overridevirtual

Updates the tag name stored in the bag metadata.

Parameters
tag_nameNew tag name string.

Implements vlink::BagReader.


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