
Public Member Functions | |
| TMCCountedGetHelper (T **ptr) | |
| TMCCountedGetHelper (void **ptr) | |
| ~TMCCountedGetHelper () | |
| 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.
TMCCountedGetHelper makes it easier to return a pointer to a counted object through a function's parameter. Here's a typical code sample:
class TMCCountedGetHelperSample { public: void GetMyFile(IMCFile** outFile) { TMCCountedGetHelper<IMCFile> result(outFile); //releases *outFile if its not null result= fMyPreciousFile; //puts fMyPreciousFile into *outFile and addrefs it (if its not null) } protected: TMCCountedPtr<IMCFile> fMyPreciousFile; }
For more information, please refer to the "Counted Pointers" chapter in the overview of the SDK.
| TMCCountedGetHelper< T >::TMCCountedGetHelper | ( | T ** | ptr | ) | [inline] |
| TMCCountedGetHelper< T >::TMCCountedGetHelper | ( | void ** | ptr | ) | [inline] |
| TMCCountedGetHelper< T >::~TMCCountedGetHelper | ( | ) | [inline] |
| T*& TMCCountedGetHelper< T >::operator= | ( | T * | ptr | ) | const [inline] |
| T* TMCCountedGetHelper< T >::operator-> | ( | ) | const [inline] |
| TMCCountedGetHelper< T >::operator T * | ( | ) | const [inline] |
| T& TMCCountedGetHelper< T >::operator * | ( | ) | const [inline] |
T** TMCCountedGetHelper< T >::fPtr [protected] |
1.5.3