#include <IUnknown.h>
Inheritance diagram for peon::IUnknown:
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 |
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.
|
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 |
|
This method decreases our object's reference count.
|
|
This method just returns our id "tag" of the object.
|
|
This method just sets our id "tag" of the object.
|