MVSim
Lightweight simulator for 2.5D vehicles and robots
Public Types | Public Member Functions | List of all members
CSVLogger Class Reference

Public Types

using Ptr = std::shared_ptr< CSVLogger >
 
using on_row_callback_t = std::function< void(const std::map< std::string_view, double > &)>
 

Public Member Functions

 CSVLogger (const CSVLogger &)=delete
 
CSVLoggeroperator= (const CSVLogger &)=delete
 
 CSVLogger (CSVLogger &&)=delete
 
CSVLoggeroperator= (CSVLogger &&)=delete
 
void updateColumn (const std::string_view &name, double value)
 
bool writeHeader ()
 
bool writeRow ()
 
void setFilepath (const std::string &path)
 
bool open ()
 
bool isOpen ()
 
bool close ()
 
bool clear ()
 
void setRecording (bool recording)
 
bool isRecording () const
 
void setFileWritingEnabled (bool enabled)
 
bool isFileWritingEnabled () const
 
void newSession ()
 
void registerOnRowCallback (const on_row_callback_t &cb)
 
bool isActive () const
 
const std::map< std::string_view, double > & getColumns () const
 Read-only access to the current column values.
 

Member Typedef Documentation

◆ on_row_callback_t

using CSVLogger::on_row_callback_t = std::function<void(const std::map<std::string_view, double>& )>

Callback type invoked on each writeRow(), receiving the current column name→value snapshot. Fired regardless of file-recording state.

Member Function Documentation

◆ isActive()

bool CSVLogger::isActive ( ) const
inline

Returns true when this logger should be "active", i.e. columns should be updated, because either file recording is on or at least one listener callback is registered.

◆ registerOnRowCallback()

void CSVLogger::registerOnRowCallback ( const on_row_callback_t cb)
inline

Register a callback to be invoked on every writeRow().

See also
isActive()

◆ setFileWritingEnabled()

void CSVLogger::setFileWritingEnabled ( bool  enabled)
inline

When disabled, writeRow() still fires callbacks but skips all file I/O. Useful when only in-memory callbacks are needed (e.g. unit tests, auto-tuning) to avoid generating useless .csv files on disk.


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