LogOnce Struct Reference

CPP API: mio::LogOnce Struct Reference

LogOnce and LogAlways can be used as a base class to write a logger for History. More...

#include <history.h>

Inheritance diagram for mio::LogOnce:

Public Member Functions

template<class T >
bool should_log (const T &)
 For any type T, returns true on the first call only, and false thereafter. More...
 

Public Attributes

bool was_logged = false
 Remember if this Logger was logged already. More...
 

Detailed Description

LogOnce and LogAlways can be used as a base class to write a logger for History.

They each provide the function bool should_log(const T&), so that only the type Type and the function Type log(const T&) have to be implemented for the derived logger, where T is some input type (the same type that is given to History::log). LogOnce logs only on the first call to History::log, while LogAlways logs on every call.

For any other logging behaviour, should_log has to be defined in the logger (no base class required).

See also
History for a full list of requirements for a logger.

Member Function Documentation

◆ should_log()

template<class T >
bool mio::LogOnce::should_log ( const T &  )
inline

For any type T, returns true on the first call only, and false thereafter.

Member Data Documentation

◆ was_logged

bool mio::LogOnce::was_logged = false

Remember if this Logger was logged already.