MatLogger2
1.0.0
Library for logging of numeric data to HDF5 MAT-files, which is RT-safe and multithreaded.
|
The MatAppender class allows to flush data to disk from multiple MatLogger2 loggers at once, both synchronously and from a separate flusher thread. More...
#include <mat_appender.h>
Classes | |
struct | Impl |
Public Types | |
typedef std::weak_ptr< MatAppender > | WeakPtr |
typedef std::shared_ptr< MatAppender > | Ptr |
Public Member Functions | |
bool | add_logger (std::shared_ptr< MatLogger2 > logger) |
Register a MAT-logger to the appender. More... | |
int | flush_available_data () |
Flush buffers from all registered loggers to disk. More... | |
void | start_flush_thread () |
Spawn a thread that will automatically flush data to disk whenever enough data is available, or some buffer is about to fill. More... | |
~MatAppender () | |
Destructor will join with the flusher thread if it was spawned by the user. More... | |
Static Public Member Functions | |
static Ptr | MakeInstance () |
Returns a shared pointer to a new MatAppender object. More... | |
The MatAppender class allows to flush data to disk from multiple MatLogger2 loggers at once, both synchronously and from a separate flusher thread.
Construction: use the factory method MakeInstance()
Usage: register instances of MatLogger2 type with the add_logger() method. Then, either call flush_available_data() in a loop, or call start_flush_thread().
Definition at line 24 of file mat_appender.h.
typedef std::shared_ptr<MatAppender> XBot::MatAppender::Ptr |
Definition at line 30 of file mat_appender.h.
typedef std::weak_ptr<MatAppender> XBot::MatAppender::WeakPtr |
Definition at line 29 of file mat_appender.h.
XBot::MatAppender::~MatAppender | ( | ) |
Destructor will join with the flusher thread if it was spawned by the user.
Definition at line 271 of file mat_appender.cpp.
bool XBot::MatAppender::add_logger | ( | std::shared_ptr< MatLogger2 > | logger | ) |
Register a MAT-logger to the appender.
Note that this class will internally store a weak pointer to the provided logger. This means that the logger may be destructed any time without problems.
!! This is the main synchronization point between loggers and the flusher
Definition at line 118 of file mat_appender.cpp.
int XBot::MatAppender::flush_available_data | ( | ) |
Flush buffers from all registered loggers to disk.
Caution: do NOT call this method if start_flush_thread() was called!
|
static |
Returns a shared pointer to a new MatAppender object.
Definition at line 67 of file mat_appender.cpp.
void XBot::MatAppender::start_flush_thread | ( | ) |
Spawn a thread that will automatically flush data to disk whenever enough data is available, or some buffer is about to fill.
Definition at line 188 of file mat_appender.cpp.