stmm-games-doc  0.32.0
Classes | Public Member Functions | Static Public Attributes | List of all members
stmg::LogEvent::MsgLog Class Reference

Holds information about the messages received by all instances of LogEvent. More...

Classes

class  Entry
 Information about one received message. More...
 

Public Member Functions

void reset () noexcept
 Clear the log. More...
 
int32_t totEntries () const noexcept
 The number of entries added to the log. More...
 
int32_t totBuffered () const noexcept
 The number of buffered entries. More...
 
const Entrylast () const noexcept
 The last buffered entry. More...
 
const Entrylast (int32_t nBack) const noexcept
 The n-th last buffered entry. More...
 
template<class Pred >
int32_t findEntry (Pred oPred) const noexcept
 Find for a specific entry. More...
 
void dump () const noexcept
 

Static Public Attributes

static const int32_t s_nMaxLastBufferedEntries
 The maximum number of entries that can be buffered. More...
 

Detailed Description

Holds information about the messages received by all instances of LogEvent.

Only the last MsgLog::s_nMaxLastBufferedEntries entries are buffered and can be accessed with MsgLog::last(int32_t nBack).

Member Function Documentation

◆ dump()

void stmg::LogEvent::MsgLog::dump ( ) const
noexcept

◆ findEntry()

template<class Pred >
int32_t stmg::LogEvent::MsgLog::findEntry ( Pred  oPred) const
inlinenoexcept

Find for a specific entry.

Visits all buffered entries from the last backwards and stops at the first entry that satisfies the predicate.

Parameters
oPredThe predicate to check for.
Returns
-1 if no entry satisfies oPred or the param to pass to last(nBack).

◆ last() [1/2]

const Entry& stmg::LogEvent::MsgLog::last ( ) const
noexcept

The last buffered entry.

Corresponds to the last message received by any instance of LogEvent. Is the same as calling last(0).

Returns
The last entry or an empty entry if totBuffered() is 0.

◆ last() [2/2]

const Entry& stmg::LogEvent::MsgLog::last ( int32_t  nBack) const
noexcept

The n-th last buffered entry.

Parameters
nBackThe back index. Must be >= 0 and < totBuffered().
Returns
The last entry or an empty entry if nBack not smaller than totBuffered().

◆ reset()

void stmg::LogEvent::MsgLog::reset ( )
noexcept

Clear the log.

◆ totBuffered()

int32_t stmg::LogEvent::MsgLog::totBuffered ( ) const
inlinenoexcept

The number of buffered entries.

Returns
The number of buffered entries.

◆ totEntries()

int32_t stmg::LogEvent::MsgLog::totEntries ( ) const
inlinenoexcept

The number of entries added to the log.

Since creation or the last reset().

Returns
The number of entries.

Member Data Documentation

◆ s_nMaxLastBufferedEntries

const int32_t stmg::LogEvent::MsgLog::s_nMaxLastBufferedEntries
static

The maximum number of entries that can be buffered.