TMCSmartPtr< T > Class Template Reference
[MCCore]

Inheritance diagram for TMCSmartPtr< T >:
TMCPtr< T > TMCObject

List of all members.

Public Member Functions

 TMCSmartPtr (T *ptr=NULL)
 ~TMCSmartPtr ()
T * operator= (T *ptr)
void Allocate ()
void CopyObjectFrom (const TMCSmartPtr &fromSmart)
template<class U >
void TransferObjectFrom (TMCSmartPtr< U > &fromSmart)
void SetToNullWithoutDeleting ()
void AssignWithoutDeleting (T *lp)
TMCSmartPtrThis ()
 because & has been overriden differently :-(

Static Protected Member Functions

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

Private Member Functions

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

Friends

class TMCSmartPtr

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>
static T* TMCSmartPtr< T >::Assign ( T **  pp,
T *  lp 
) [inline, static, protected]
template<class T>
void TMCSmartPtr< T >::AssignWithoutDeleting ( T *  lp  )  [inline]

Assign a new value to the pointer without deleting the object previously pointed by it.

Parameters:
lp The new value of the pointer.
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>
template<class U >
void TMCSmartPtr< T >::TransferObjectFrom ( TMCSmartPtr< U > &  fromSmart  )  [inline]

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

Parameters:
fromSmart the pointer to acquire

Friends And Related Function Documentation

template<class T>
friend class TMCSmartPtr [friend]

The documentation for this class was generated from the following file:
Generated on Mon Apr 26 22:48:07 2010 for Carrara SDK Doc by  doxygen 1.6.3