Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

peon::IUnknown Class Reference

This object represents a base level object that we can derive other objects from in the Peon library. More...

#include <IUnknown.h>

Inheritance diagram for peon::IUnknown:

peon::IApplicationState peon::ISceneObject peon::SceneFont peon::SceneRenderer peon::SceneTexture peon::Billboard peon::IActor peon::SceneCamera peon::SceneLight peon::SceneRoot List of all members.

Public Member Functions

 IUnknown ()
 Constructor.
virtual ~IUnknown ()
 Destructor.
int getID ()
 This method just returns our id "tag" of the object.
void setID (int new_id)
 This method just sets our id "tag" of the object.
void addRefCount ()
 This method increases our object's reference count.
bool dropRefCount ()
 This method decreases our object's reference count.

Protected Attributes

int m_id
 the "id" of our object...can be anything we want
int m_refCount
 the internal reference count of this object

Detailed Description

This object represents a base level object that we can derive other objects from in the Peon library.

It mainly works around a primitive and crude form of reference counting. As you copy interfaces around the engine, you increase the reference count of the object. As you delete/free them, you decrease the reference count. If the engine exits with some reference counts still above 0, then you know you're not freeing something properly.

For those not happy with this implementation, you might want to take a look at the smart pointer object which comes with some of the boost libraries. http://www.boost.org. It's a handy collection of some C++ objects.


Member Function Documentation

void peon::IUnknown::addRefCount  )  [inline]
 

This method increases our object's reference count.

A simple example is when we pass around our SceneRenderer interface around through the engine. If another object uses an internal handle to it, then we've just copied a reference to the SceneRenderer!

Instead just add a ref count when you assign it to another object

bool peon::IUnknown::dropRefCount  )  [inline]
 

This method decreases our object's reference count.

Returns:
bool - have we cleaned up every instance of this object?

int peon::IUnknown::getID  )  [inline]
 

This method just returns our id "tag" of the object.

Returns:
int - our object's id

void peon::IUnknown::setID int  new_id  )  [inline]
 

This method just sets our id "tag" of the object.

Parameters:
new_id - the new id we want to set our object to


The documentation for this class was generated from the following file:
Generated on Thu Dec 1 01:55:41 2005 for Peon by  doxygen 1.4.1