Vaca::Referenceable Class Reference

#include <Referenceable.h>

Inheritance diagram for Vaca::Referenceable:

Vaca::NonCopyable Vaca::GdiObject< HBITMAP > Vaca::GdiObject< HBRUSH > Vaca::GdiObject< HCURSOR, Vaca::Win32DestroyCursor > Vaca::GdiObject< HFONT > Vaca::GdiObject< HICON, Vaca::Win32DestroyIcon > Vaca::GdiObject< HIMAGELIST, Vaca::Win32DestroyImageList > Vaca::GdiObject< HPEN > Vaca::GdiObject< HRGN > Vaca::Component Vaca::GdiObject< T, Destroyer >

List of all members.


Detailed Description

Class that counts references and can be wrapped by a SmartPtr.

Public Member Functions

 Referenceable ()
 Constructs a new referenceable object starting with zero references.
virtual ~Referenceable ()
 Destroys a referenceable object.
void ref ()
 Makes a new reference to this object.
unsigned unref ()
 Deletes an old reference to this object.
unsigned getRefCount ()
 Returns the current number of references that this object has.

Static Public Member Functions

static void showLeaks ()

Private Attributes

unsigned m_refCount

Static Private Attributes

static Mutex mutex
static volatile int instanceCounter = 0
static std::vector
< Referenceable * > 
list

Constructor & Destructor Documentation

Referenceable::Referenceable (  ) 

Constructs a new referenceable object starting with zero references.

Referenceable::~Referenceable (  )  [virtual]

Destroys a referenceable object.

When compiling with assertions it checks that the references' counter is really zero.


Member Function Documentation

void Referenceable::ref (  ) 

Makes a new reference to this object.

You are responsible for removing references using the unref method. Remember that for each call to ref that you made, there should be a corresponding unref.

See also:
unref

unsigned Referenceable::unref (  ) 

Deletes an old reference to this object.

If assertions are activated this routine checks that the reference counter never get negative, because that implies an error of the programmer.

See also:
ref

unsigned Referenceable::getRefCount (  ) 

Returns the current number of references that this object has.

If it's zero you can delete the object safely.

void Referenceable::showLeaks (  )  [static]


Member Data Documentation

unsigned Vaca::Referenceable::m_refCount [private]

Mutex Referenceable::mutex [static, private]

volatile int Referenceable::instanceCounter = 0 [static, private]

std::vector< Referenceable * > Referenceable::list [static, private]