Blender V2.61 - r43446
|
#include <MEM_RefCountPtr.h>
Public Member Functions | |
void | IncRef () const |
int | DecRef () |
~MEM_RefCountable () | |
Protected Member Functions | |
MEM_RefCountable () | |
MEM_RefCountable (const MEM_RefCountable &) |
This is a base class for reference countable objects. If you want an object to be shared using a reference counted system derrivce from this class. All subclasses should insist that they are created on the heap, this can be done by makeing all constructors private and defining a static New() method that returns a ref counted ptr to a new()ly allocated instance.
class MySharedObject : public MEM_RefCountable {
private : MySharedObject() : MEM_RefCountable() { //class specific initialization}; MySharedObject(const MySharedObject &other) // not implemented public : static MEM_RefCountPtr<MySharedObject> New( ) { return MEM_RefCountPtr<MySharedObject>( new MySharedObject()); }
// other member functions };
Alternitively you may first wish to define a fully functional class and then define a reference counting wrapper for this class. This is useful when the base type can be used without reference counting.
E.g. class UsefullClass { private : ... public :
UsefullClass() UsefullMethod(...) AnotherUsefullMethod(...) };
class RcUsefullClass : public UsefullClass, public MEM_RefCountable { private : // Override base class public constructor --- forces // use of New(...) RcUsefullClass(...) public :
// Override each public constructor of UsefullClass with // an equivalent static New method returning a MEM_RefCountPtr
static MEM_RefCountPtr<RcUsefullClass> New(...){ return MEM_RefCountPtr<RcUsefullClass> output( new UsefullClass(...) ); }
// warning never call destructor directly allow ref counting // mechanism to handle object lifetime. ~RcUsefullClass(); };
Definition at line 115 of file MEM_RefCountPtr.h.
MEM_RefCountable::MEM_RefCountable | ( | ) | [inline, protected] |
Protected constructors This class is not for direct instanciation. Sub classes should only be allocated on the heap.
Definition at line 137 of file MEM_RefCountPtr.h.
MEM_RefCountable::MEM_RefCountable | ( | const MEM_RefCountable & | ) | [inline, protected] |
Definition at line 143 of file MEM_RefCountPtr.h.
MEM_RefCountable::~MEM_RefCountable | ( | ) | [inline] |
Definition at line 164 of file MEM_RefCountPtr.h.
int MEM_RefCountable::DecRef | ( | ) | [inline] |
Definition at line 159 of file MEM_RefCountPtr.h.
void MEM_RefCountable::IncRef | ( | ) | const [inline] |
Definition at line 153 of file MEM_RefCountPtr.h.