Class that may be used as base for reference counting of instances. More...
#include <refcnt.h>
Public Member Functions | |
RefCnt (void) | |
constructor; | |
void | incRef (void) |
increase reference counter | |
void | decRef (void) |
decrease reference counter | |
unsigned int | referenceCount (void) |
number of times this instance was referenced | |
void | forceDelete (void) |
if the caller knows what is doing it should use this | |
Protected Member Functions | |
virtual | ~RefCnt (void) |
destructor; | |
Class that may be used as base for reference counting of instances.
The class simply provides two methods - incRef() and decRef() - and adds a counter to the class. Whitin decRef(), if the counter reaches 0 the instance is deleted.
Inside the constructor the reference counter is set to 1. The caller needs to decrement the counter when it is done with its reference.