CAPD DynSys Library 5.2.0
|
Counter add to each object of given class unique id and also counts number of objects created and existing. More...
#include <capd/auxil/Counter.h>
Public Types | |
typedef std::set< int > | IndicesSetType |
typedef T | CountedType |
Public Member Functions | |
Counter () | |
Counter (const Counter &c) | |
void | operator= (const Counter &c) |
~Counter () | |
Public Attributes | |
int | id |
unique id of the object More... | |
Static Public Attributes | |
static int | maxIndex = 0 |
number of created objects More... | |
static int | numberOfObjects = 0 |
number of existing objects More... | |
static IndicesSetType | indicesSet |
set of indices of existing objects More... | |
static bool | storeIndices = true |
decides if indices of existing objects should be stored More... | |
static std::string | name = "" |
string that help distinguish counters for different classes More... | |
Counter add to each object of given class unique id and also counts number of objects created and existing.
This class is for debugging purpose mainly. It reports each creation and destruction to capd::slog stream. You can turn on/off its output by
For example output: < + A [34][12] > means that there was created object (+) of class A with id=34 (we start with id=1) and that at this moment there exist 12 objects. Destruction is denoted by '-' and substitution by '='.
To add counter to your class A simply inherit from Counter i.e.:
typedef T capd::auxil::Counter< T >::CountedType |
typedef std::set<int> capd::auxil::Counter< T >::IndicesSetType |
|
inline |
|
inline |
|
inline |
|
inline |
int capd::auxil::Counter< T >::id |
unique id of the object
|
static |
set of indices of existing objects
|
static |
number of created objects
|
static |
string that help distinguish counters for different classes
|
static |
number of existing objects
|
static |
decides if indices of existing objects should be stored