RefCounter Class Reference

A base class that provides reference counting facilities. More...

#include <refcounter.hpp>

Inherited by GameObject.

List of all members.

Public Member Functions

 RefCounter ()
void ref ()
 increases reference count
void unref ()
 decreases reference count.

Protected Member Functions

virtual ~RefCounter ()

Private Attributes

int refcount


Detailed Description

A base class that provides reference counting facilities.

Definition at line 25 of file refcounter.hpp.


Constructor & Destructor Documentation

RefCounter::RefCounter (  )  [inline]

Definition at line 28 of file refcounter.hpp.

00029     : refcount(0)
00030   { }

virtual RefCounter::~RefCounter (  )  [inline, protected, virtual]

Definition at line 49 of file refcounter.hpp.

References refcount.

00050   {
00051     assert(refcount == 0);
00052   }


Member Function Documentation

void RefCounter::ref (  )  [inline]

increases reference count

Definition at line 33 of file refcounter.hpp.

References refcount.

Referenced by worldmap::WorldMap::add_object(), and Sector::add_object().

00034   {
00035     refcount++;
00036   }

void RefCounter::unref (  )  [inline]

decreases reference count.

Destroys the object if the reference count reaches 0

Definition at line 40 of file refcounter.hpp.

References refcount.

00041   {
00042     refcount--;
00043     if(refcount <= 0) {
00044       delete this;
00045     }
00046   }


Member Data Documentation

int RefCounter::refcount [private]

Definition at line 55 of file refcounter.hpp.

Referenced by ref(), unref(), and ~RefCounter().


The documentation for this class was generated from the following file:
Generated on Mon Jun 9 03:38:34 2014 for SuperTux by  doxygen 1.5.1