MatLogger2  1.0.0
Library for logging of numeric data to HDF5 MAT-files, which is RT-safe and multithreaded.
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
XBot::MatAppender Class Reference

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>

+ Inheritance diagram for XBot::MatAppender:
+ Collaboration diagram for XBot::MatAppender:

Classes

struct  Impl
 

Public Types

typedef std::weak_ptr< MatAppenderWeakPtr
 
typedef std::shared_ptr< MatAppenderPtr
 

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...
 

Detailed Description

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.

Member Typedef Documentation

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.

Constructor & Destructor Documentation

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.

Member Function Documentation

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.

Returns
True if the logger is not null and it was not already registered.

!! 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!

Returns
Amount of flushed bytes
MatAppender::Ptr XBot::MatAppender::MakeInstance ( )
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.


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