TMCSmartPtr< T > Class Template Reference
[MCCore]

Inheritance diagram for TMCSmartPtr< T >:

TMCPtr< T > List of all members.

Public Member Functions

 TMCSmartPtr (T *ptr=NULL)
 ~TMCSmartPtr ()
T * operator= (T *ptr)
void Allocate ()
void CopyObjectFrom (const TMCSmartPtr &fromSmart)
void TransferObjectFrom (TMCSmartPtr &fromSmart)
void SetToNullWithoutDeleting ()
TMCSmartPtr * This ()
 because & has been overriden differently :-(

Static Protected Member Functions

T * Assign (T **pp, T *lp)

Private Member Functions

 TMCSmartPtr (const TMCSmartPtr &ptr)
TMCSmartPtr & operator= (const TMCSmartPtr &fromSmart)

Detailed Description

template<class T>
class TMCSmartPtr< T >

Like TMCPtr, TMCSmartPtr is a transparent wrapper around a regular pointer But TMCSmartPtr owns the pointed data, and will delete it in its destructor. It is very useful when you need to create a temporary object as you don't need to worry about destruction (and exceptions). Example:
    TMCSmartPtr<TMCOffscreen> offscreen;
    offscreen= TMCOffscreen::Create(width, height, bitDepth);

Note:
When you need a temporary buffer, it is better to use a TMCArray instead of TMCSmartPtr and new[] as the array will assert if you go too far.


Constructor & Destructor Documentation

template<class T>
TMCSmartPtr< T >::TMCSmartPtr (  const TMCSmartPtr< T > &  ptr  )  [inline, private]
 

template<class T>
TMCSmartPtr< T >::TMCSmartPtr (  T *  ptr = NULL  )  [inline]
 

template<class T>
TMCSmartPtr< T >::~TMCSmartPtr (   )  [inline]
 


Member Function Documentation

template<class T>
void TMCSmartPtr< T >::Allocate (   )  [inline]
 

template<class T>
T* TMCSmartPtr< T >::Assign (  T **  pp,
T *  lp
)  [inline, static, protected]
 

template<class T>
void TMCSmartPtr< T >::CopyObjectFrom (  const TMCSmartPtr< T > &  fromSmart  )  [inline]
 

Creates a copy of the object pointed to by fromSmart and points to it. The previous object pointed by this will be deleted.

Parameters:
fromSmart a pointer to the object that will be copied

template<class T>
T* TMCSmartPtr< T >::operator= (  T *  ptr  )  [inline]
 

Reimplemented from TMCPtr< T >.

template<class T>
TMCSmartPtr& TMCSmartPtr< T >::operator= (  const TMCSmartPtr< T > &  fromSmart  )  [inline, private]
 

template<class T>
void TMCSmartPtr< T >::SetToNullWithoutDeleting (   )  [inline]
 

Sets the internal pointer to NULL without deleting the pointed object. Use this to transfer ownership of the pointed object to a TMCPtrArray But don't forget to call DeleteAndRemoveAll on the array !

template<class T>
TMCSmartPtr* TMCSmartPtr< T >::This (   )  [inline]
 

because & has been overriden differently :-(

template<class T>
void TMCSmartPtr< T >::TransferObjectFrom (  TMCSmartPtr< T > &  fromSmart  )  [inline]
 

Transfers the pointed object from fromSmart to this and sets fromSmart to null

Parameters:
fromSmart the pointer to acquire


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