RefCnt Pile   version 0.0.1
C++ class implementing a simple reference counting mechanism.
RefCnt Class Reference

A reference counted base class. More...

#include <refcnt.h>

Public Member Functions

int reference (void *owner)
 
int dereference (void *owner)
 
int release (void *owner)
 
int referenceCount ()
 
int forceRelease ()
 
void changeOwner (void *, void *)
 
bool isOwner (void *)
 

Protected Member Functions

 RefCnt ()
 Default constructor.
 
virtual ~RefCnt ()
 Destructor.
 

Detailed Description

A reference counted base class.

In debug builds an internal list of owners is stored so that allocations can be traced. In release builds this adds no overhead. This is controlled using the REFCNT_DEBUG definition.

Member Function Documentation

void RefCnt::changeOwner ( void *  ,
void *   
)
inline

change the owner of a reference

This does absolutely nothing in release builds.

int RefCnt::dereference ( void *  owner)

decrements the reference counter

Returns
the value of the reference counter after decrement.
int RefCnt::forceRelease ( )

deletes the instance

Returns
the value of the reference counter.
bool RefCnt::isOwner ( void *  )
inline

tell if a pointer owns a reference to this object

In release builds this always returns false.

int RefCnt::reference ( void *  owner)

increments the reference counter

Returns
the value of the reference counter after increment.
int RefCnt::referenceCount ( )
inline

get the value of the reference count

Returns
the value of the reference counter after decrement.
int RefCnt::release ( void *  owner)

decrements the reference counter and deletes the instance if 0

The caller must make sure that the reference count does not go below 0.

Returns
the value of the reference counter after decrement.

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