CAPD::DynSys Library  6.0.0
capd::auxil::Counter< T > Class Template Reference

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...
 

Detailed Description

template<typename T>
class capd::auxil::Counter< T >

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

capd::slog.show = true/false;
bool show
If this variable is set to true then everything that is written to this stream is also written to 'co...
Definition: OutputStream.h:63
extern ::capd::auxil::OutputStream slog
The output stream to which one can send messages for logging only. Those messages are not shown to th...
Definition: logger_deprecated.h:48

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.:

class A: public capd::auxil::Counter<A>{
...
};
Counter add to each object of given class unique id and also counts number of objects created and exi...
Definition: Counter.h:52
Remarks
If class A defines its own copy constructor and/or operator= and you do not manually call corresponding functions from Counter than default constructor will be reported for copy constructor and nothing for =.

Member Typedef Documentation

◆ CountedType

template<typename T >
typedef T capd::auxil::Counter< T >::CountedType

◆ IndicesSetType

template<typename T >
typedef std::set<int> capd::auxil::Counter< T >::IndicesSetType

Constructor & Destructor Documentation

◆ Counter() [1/2]

template<typename T >
capd::auxil::Counter< T >::Counter ( )
inline

◆ Counter() [2/2]

template<typename T >
capd::auxil::Counter< T >::Counter ( const Counter< T > &  c)
inline

◆ ~Counter()

template<typename T >
capd::auxil::Counter< T >::~Counter ( )
inline

Member Function Documentation

◆ operator=()

template<typename T >
void capd::auxil::Counter< T >::operator= ( const Counter< T > &  c)
inline

Member Data Documentation

◆ id

template<typename T >
int capd::auxil::Counter< T >::id

unique id of the object

◆ indicesSet

template<typename T >
std::set< int > capd::auxil::Counter< T >::indicesSet
static

set of indices of existing objects

◆ maxIndex

template<typename T >
int capd::auxil::Counter< T >::maxIndex = 0
static

number of created objects

◆ name

template<typename T >
std::string capd::auxil::Counter< T >::name = ""
static

string that help distinguish counters for different classes

◆ numberOfObjects

template<typename T >
int capd::auxil::Counter< T >::numberOfObjects = 0
static

number of existing objects

◆ storeIndices

template<typename T >
bool capd::auxil::Counter< T >::storeIndices = true
static

decides if indices of existing objects should be stored


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