Frapper  1.0a
Macros
InstanceCounterMacros.h File Reference

Header file containing instance counter debugging macros. More...

#include "Log.h"
Include dependency graph for InstanceCounterMacros.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ADD_INSTANCE_COUNTER
 Macro definition that adds static member variables to a class to keep track of the number of instances created from this class.
 
#define INIT_INSTANCE_COUNTER(className)
 Macro definition that initializes the static member variables added to a class using the ADD_INSTANCE_COUNTER macro.
 
#define INC_INSTANCE_COUNTER
 Macro definition that updates the static member variables added to a class using the ADD_INSTANCE_COUNTER macro.
 
#define DEC_INSTANCE_COUNTER   --s_numberOfInstances;
 Macro definition that updates the static member variables added to a class using the ADD_INSTANCE_COUNTER macro.
 
#define SHOW_INSTANCE_COUNTER(className)   Log::debug(QString("%1 of %2 instances of class " #className " left").arg(className::s_numberOfInstances).arg(className::s_totalNumberOfInstances), "main");
 Macro definition that displays the statistics about the number of instances created from a class to which instance counter member variables have been added using the ADD_INSTANCE_COUNTER macro.
 

Detailed Description

Header file containing instance counter debugging macros.

Author
Stefan Habel stefa.nosp@m.n.ha.nosp@m.bel@f.nosp@m.ilma.nosp@m.kadem.nosp@m.ie.d.nosp@m.e
Version
1.0
Date
07.04.2009 (last updated)

Macro Definition Documentation

#define ADD_INSTANCE_COUNTER
Value:
public:\
static int s_numberOfInstances;\
static int s_totalNumberOfInstances;\
private:

Macro definition that adds static member variables to a class to keep track of the number of instances created from this class.

Variables added to a class using this macro will have to be initialized in the implementation file of the class using the INIT_INSTANCE_COUNTER macro.

See Also
INIT_INSTANCE_COUNTER
#define INIT_INSTANCE_COUNTER (   className)
Value:
int className::s_numberOfInstances = 0;\
int className::s_totalNumberOfInstances = 0;

Macro definition that initializes the static member variables added to a class using the ADD_INSTANCE_COUNTER macro.

To be added in the implementation file of the class.

Parameters
classNameThe name of the class to which the static member variables have been added.
See Also
ADD_INSTANCE_COUNTER
#define INC_INSTANCE_COUNTER
Value:
++s_numberOfInstances;\
++s_totalNumberOfInstances;

Macro definition that updates the static member variables added to a class using the ADD_INSTANCE_COUNTER macro.

Should be called when an instance of this class is created (e.g. by adding it to constructors of the class).

See Also
DEC_INSTANCE_COUNTER
#define DEC_INSTANCE_COUNTER   --s_numberOfInstances;

Macro definition that updates the static member variables added to a class using the ADD_INSTANCE_COUNTER macro.

Should be called when an instance of this class is destroyed (e.g. by adding it to destructors of the class).

See Also
INC_INSTANCE_COUNTER
#define SHOW_INSTANCE_COUNTER (   className)    Log::debug(QString("%1 of %2 instances of class " #className " left").arg(className::s_numberOfInstances).arg(className::s_totalNumberOfInstances), "main");

Macro definition that displays the statistics about the number of instances created from a class to which instance counter member variables have been added using the ADD_INSTANCE_COUNTER macro.

Parameters
classNameThe name of the class to which the static member variables have been added.
See Also
ADD_INSTANCE_COUNTER