ug4
ug::RevisionCounter Class Reference

Class used to identify a state of adaption of a grid, approx-space, ... More...

#include <revision_counter.h>

Public Member Functions

bool invalid () const
 returns if state is invalid More...
 
void invalidate ()
 invalidates state More...
 
const void * obj () const
 returns the associated object More...
 
bool operator!= (const RevisionCounter &rhs) const
 compare two states More...
 
RevisionCounteroperator++ ()
 increase state (prefix) More...
 
RevisionCounter operator++ (int)
 increase state (postfix) More...
 
bool operator< (const RevisionCounter &rhs) const
 compare two states More...
 
bool operator== (const RevisionCounter &rhs) const
 compare two states More...
 
bool operator> (const RevisionCounter &rhs) const
 compare two states More...
 
 RevisionCounter ()
 constructor (with invalid state initialization) More...
 
template<typename T >
 RevisionCounter (const T *pObj)
 constructor (with valid state initialization) More...
 
 RevisionCounter (const void *pObj)
 constructor (with valid state initialization) More...
 
bool valid () const
 returns if state is valid More...
 

Protected Attributes

uint64 m_cnt
 state counter (0 = invalid) More...
 
const void * m_pObj
 associated object More...
 

Detailed Description

Class used to identify a state of adaption of a grid, approx-space, ...

This class is used as a state counter of an object. E.g., this is very useful to track the state of an adaptive multigrid. Based on this counter reinitialization of dependent structures can be triggered, that should only be reinitialized when actually used again (and not on every state change

  • use observers or msg listeners in that case).

NOTE: the current implementation allows only std::numeric_limits<unit64>::max() states (approx 10^20 states), which should be pretty enough for most considered uses. If this is not enough a different implementation, handling counter overflow, should be used. (However, if the state is altered every nano-second, the overflow will appear after more than 3000 years)

Constructor & Destructor Documentation

◆ RevisionCounter() [1/3]

ug::RevisionCounter::RevisionCounter ( )
inline

constructor (with invalid state initialization)

◆ RevisionCounter() [2/3]

ug::RevisionCounter::RevisionCounter ( const void *  pObj)
inline

constructor (with valid state initialization)

◆ RevisionCounter() [3/3]

template<typename T >
ug::RevisionCounter::RevisionCounter ( const T *  pObj)
inline

constructor (with valid state initialization)

Member Function Documentation

◆ invalid()

bool ug::RevisionCounter::invalid ( ) const
inline

returns if state is invalid

References valid().

Referenced by operator++(), and operator==().

◆ invalidate()

void ug::RevisionCounter::invalidate ( )
inline

invalidates state

References m_cnt, and m_pObj.

◆ obj()

const void* ug::RevisionCounter::obj ( ) const
inline

returns the associated object

References m_pObj.

Referenced by ug::StdTransfer< TDomain, TAlgebra >::remove_outdated().

◆ operator!=()

bool ug::RevisionCounter::operator!= ( const RevisionCounter rhs) const
inline

compare two states

◆ operator++() [1/2]

RevisionCounter& ug::RevisionCounter::operator++ ( )
inline

increase state (prefix)

References invalid(), m_cnt, and UG_THROW.

◆ operator++() [2/2]

RevisionCounter ug::RevisionCounter::operator++ ( int  )
inline

increase state (postfix)

◆ operator<()

bool ug::RevisionCounter::operator< ( const RevisionCounter rhs) const
inline

compare two states

References m_cnt, and m_pObj.

◆ operator==()

bool ug::RevisionCounter::operator== ( const RevisionCounter rhs) const
inline

compare two states

References invalid(), m_cnt, and m_pObj.

◆ operator>()

bool ug::RevisionCounter::operator> ( const RevisionCounter rhs) const
inline

compare two states

References m_cnt, and m_pObj.

◆ valid()

bool ug::RevisionCounter::valid ( ) const
inline

returns if state is valid

References m_cnt, and m_pObj.

Referenced by invalid().

Member Data Documentation

◆ m_cnt

uint64 ug::RevisionCounter::m_cnt
protected

state counter (0 = invalid)

Referenced by invalidate(), operator++(), operator<(), operator==(), operator>(), and valid().

◆ m_pObj

const void* ug::RevisionCounter::m_pObj
protected

associated object

Referenced by invalidate(), obj(), operator<(), operator==(), operator>(), and valid().


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