
Public Member Functions | |
| TMCCountedCreateHelper (T **ptr) | |
| TMCCountedCreateHelper (void **ptr) | |
| ~TMCCountedCreateHelper () | |
| T *& | operator= (T *ptr) const |
| T * | operator-> () const |
| operator T * () const | |
| T & | operator * () const |
Protected Attributes | |
| T ** | fPtr |
It is possible to call AddRef and Release "by hand" but it is a bad idea for at least two reasons. First, it is very easy to forget to add a call to Release, therefore causing a memory leak. Second the code becomes more complex because in every function that calls AddRef, you must consider exceptions. So you have to use a try/catch block, add a call to Release at the end of the try AND another one before re-throwing in the catch section...
Because they automatically call AddRef and Release, TMCCountedPtr, TMCCountedGetHelper and TMCCountedCreateHelper are your best friends.
TMCCountedCreateHelper makes it easier implement a function that creates a counted object and returns it through a parameter. Here's a typical code sample:
class TCreateHelperSample : public TMCSMPCountedObject { public: static void Create(TCreateHelperSample** outSample) { TMCCountedCreateHelper<TCreateHelperSample> result(outSample); //releases *outSample if its not null //Puts the new sample into *outSample but does NOT addref it (the refcount is initialized to 1) result= new TCreateHelperSample(); } protected: TCreateHelperSample() {} ~TCreateHelperSample() {} }
| TMCCountedCreateHelper< T >::TMCCountedCreateHelper | ( | T ** | ptr | ) | [inline] |
| TMCCountedCreateHelper< T >::TMCCountedCreateHelper | ( | void ** | ptr | ) | [inline] |
| TMCCountedCreateHelper< T >::~TMCCountedCreateHelper | ( | ) | [inline] |
| T*& TMCCountedCreateHelper< T >::operator= | ( | T * | ptr | ) | const [inline] |
| T* TMCCountedCreateHelper< T >::operator-> | ( | ) | const [inline] |
| TMCCountedCreateHelper< T >::operator T * | ( | ) | const [inline] |
| T& TMCCountedCreateHelper< T >::operator * | ( | ) | const [inline] |
T** TMCCountedCreateHelper< T >::fPtr [protected] |
1.5.3