![]() |
libgenua
Basic Geometry, Numerical Algorithms and Interfaces
|
Interface layer for monitoring long computations.
This class is to be overloaded by in order to display progress status and log messages to the user. Usually, this would be done to allow monitoring of int-running, hopefully multithreaded computations which regularly update the progress status indicator and check for the value of a termination flag.
This class is thread-safe as implemented. Note that child objects which overload the virtual log() function must permit concurrent calls to that function.
, ,
#include <logger.h>
Public Member Functions | |
Logger () | |
initialize progress variables | |
Logger (const Logger &a) | |
copy construction | |
Logger & | operator= (const Logger &a) |
explicit copy assignment | |
virtual | ~Logger () |
virtual destruction | |
void | storeLogMessages (bool flag) |
switch log storage on/off | |
const std::vector< std::string > & | logMessages () const |
access stored messages | |
virtual void | log (const std::string &s) const |
called by all convenience interfaces, overloaded by display client | |
template<typename FirstType , typename... MoreTypes> | |
void | log (const FirstType &a1, MoreTypes...as) const |
called by all convenience interfaces, overloaded by display client | |
void | reset () |
reset progress and interrupt flag | |
bool | increment (int step=1) |
increment progress, return true if interruption flag is set | |
virtual bool | nextStage (int steps) |
proceed to next stage, return true if interruption flag is set | |
int | progress () const |
query current progress | |
int | nsteps () const |
number of steps in present stage | |
float | percentage () const |
percentage of work completed in present stage | |
int | stage () const |
query current processing stage | |
void | interrupt (bool flag) |
set interruption flag | |
bool | interrupted () const |
query interrupt flag | |
Private Attributes | |
int | m_progress |
fine-grained progress status | |
int | m_stepsInStage |
number of steps in current stage | |
std::atomic< int > | m_stage |
coarse-grained progress | |
std::atomic< bool > | m_interrupt |
interruption flag | |
bool | m_storeLogMessages |
whether to store log message in list | |
std::vector< std::string > | m_logMessages |
one string per line if storage is switched on | |