TMCCountedObject Class Reference
[MCCore]

Inheritance diagram for TMCCountedObject:

IMCUnknown TBasicMenuCallBack TBasicThread TMCGaussianRandom TSmpThreadsLauncher List of all members.

Public Member Functions

virtual MCErr MCCOMAPI QueryInterface (const MCIID &riid, void **ppvObj)
virtual uint32 MCCOMAPI AddRef ()
virtual uint32 MCCOMAPI Release ()

Static Public Member Functions

void Create (TMCCountedObject **outObject)

Protected Member Functions

 TMCCountedObject (void)
virtual ~TMCCountedObject ()

Protected Attributes

uint32 fRefCount

Detailed Description

Counted objects are objects that use a counter to keep track of how many other objects need them, and delete themselves when nobody needs them anymore. A counted object has an AddRef method that increments its counter, and a Release method that decrements it. When the value of the counter reaches zero, the object is deleted.

Take a look at TMCCountedCreateHelper to see how to create and return a counted object

Note:
If your object can be accessed by two threads at the same time, you ought to derive it from TMCSMPCountedObject (it uses an atomic counter).


Constructor & Destructor Documentation

TMCCountedObject::TMCCountedObject (  void   )  [protected]
 

virtual TMCCountedObject::~TMCCountedObject (   )  [protected, virtual]
 


Member Function Documentation

uint32 TMCCountedObject::AddRef (   )  [inline, virtual]
 

Increments the reference count of the object

Implements IMCUnknown.

Reimplemented in TBasicMenuCallBack, and TBasicThread.

void TMCCountedObject::Create (  TMCCountedObject **  outObject  )  [static]
 

virtual MCErr MCCOMAPI TMCCountedObject::QueryInterface (  const MCIID &  riid,
void **  ppvObj
)  [virtual]
 

Check if the object supports a given interface and returns a pointer to that interface if it does. Note that QueryInterface will increment the reference count of the object by one if the interface is found.

Parameters:
riid GUID of the interface
ppvObj A pointer to the pointer being returned.

Implements IMCUnknown.

Reimplemented in TBasicMenuCallBack, and TBasicThread.

uint32 TMCCountedObject::Release (   )  [inline, virtual]
 

Decrements the reference count of the object. If the reference count reaches zero, the object is destroyed.

Implements IMCUnknown.

Reimplemented in TBasicMenuCallBack, and TBasicThread.


Member Data Documentation

uint32 TMCCountedObject::fRefCount [protected]
 


The documentation for this class was generated from the following file:
Generated on Mon Mar 14 12:29:08 2005 for Carrara SDK Doc by  doxygen 1.3.9.1