Ignition Transport

API Reference

8.1.0
Recorder Class Reference

Records ignition transport topics This class makes it easy to record topics to a log file. Responsibilities: topic name matching, time received tracking, multiple thread safety, subscribing to topics. More...

#include <Recorder.hh>

Public Member Functions

 Recorder ()
 Default constructor. More...
 
 Recorder (Recorder &&_old)
 move constructor More...
 
 ~Recorder ()
 destructor More...
 
RecorderError AddTopic (const std::string &_topic)
 Add a topic to be recorded (exact match only) More...
 
int64_t AddTopic (const std::regex &_topic)
 Add a topic to be recorded (regex match) More...
 
std::size_t BufferSize () const
 Get the buffer size of the queue that is used to store data from topic callbacks. More...
 
std::string Filename () const
 Get the name of the log file. More...
 
void SetBufferSize (std::size_t _size)
 Set the maximum size (in MB) of the buffer that is used to store data from topic callbacks. When the buffer reaches this size, the recorder will start dropping older messages to make room for new ones. More...
 
RecorderError Start (const std::string &_file)
 Begin recording topics. More...
 
void Stop ()
 Stop recording topics. This function will block if there is any data in the internal buffer that has not yet been written to disk. More...
 
RecorderError Sync (const Clock *_clockIn)
 Synchronize recording with the given clock. More...
 
const std::set< std::string > & Topics () const
 Get the set of topics have have been added. More...
 

Detailed Description

Records ignition transport topics This class makes it easy to record topics to a log file. Responsibilities: topic name matching, time received tracking, multiple thread safety, subscribing to topics.

Constructor & Destructor Documentation

◆ Recorder() [1/2]

Recorder ( )

Default constructor.

◆ Recorder() [2/2]

Recorder ( Recorder &&  _old)

move constructor

Parameters
[in]_oldthe instance being moved into this one

◆ ~Recorder()

~Recorder ( )

destructor

Member Function Documentation

◆ AddTopic() [1/2]

RecorderError AddTopic ( const std::string _topic)

Add a topic to be recorded (exact match only)

Parameters
[in]_topicThe exact topic name
Note
This method attempts to subscribe to the topic immediately. The subscription will be kept until this is destructed.
Returns
NO_ERROR if the subscription was created.

◆ AddTopic() [2/2]

int64_t AddTopic ( const std::regex _topic)

Add a topic to be recorded (regex match)

Parameters
[in]_topicPattern to match against topic names
Note
This method attempts to subscribe to topics immediately. These subscriptions will be kept until this is destructed. New topics that match the pattern will be added as they appear, including while recording is active.
Returns
number of topics subscribed or negative number on error

◆ BufferSize()

std::size_t BufferSize ( ) const

Get the buffer size of the queue that is used to store data from topic callbacks.

Returns
Current buffer size in MB.

◆ Filename()

std::string Filename ( ) const

Get the name of the log file.

Returns
The name of the log file, or an empty string if Start has not been successfully called.

◆ SetBufferSize()

void SetBufferSize ( std::size_t  _size)

Set the maximum size (in MB) of the buffer that is used to store data from topic callbacks. When the buffer reaches this size, the recorder will start dropping older messages to make room for new ones.

Parameters
[in]_sizeBuffer size in MB

◆ Start()

RecorderError Start ( const std::string _file)

Begin recording topics.

Parameters
[in]_filepath to log file
Returns
NO_ERROR if recording was successfully started. If the file already existed, this will return FAILED_TO_OPEN.

◆ Stop()

void Stop ( )

Stop recording topics. This function will block if there is any data in the internal buffer that has not yet been written to disk.

◆ Sync()

RecorderError Sync ( const Clock _clockIn)

Synchronize recording with the given clock.

Parameters
[in]_clockInclock to synchronize and stamp incoming messages with
Returns
SUCCESS if the clock was successfully changed, ALREADY_RECORDING if a recording is already in progress.
Remarks
Clock lifetime must exceed that of this Recorder.

◆ Topics()

const std::set<std::string>& Topics ( ) const

Get the set of topics have have been added.

Returns
The set of topic names that have been added using the AddTopic functions.

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