torque Torque Game Engine Documentation
TGE Version 1.5.2

FrameTemp< T > Class Template Reference

#include <frameAllocator.h>


Detailed Description


template<class T> class FrameTemp< T >

Class for temporary variables that you want to allocate easily using the FrameAllocator.

For example:

 FrameTemp<char> tempStr(32); // NOTE! This parameter is NOT THE SIZE IN BYTES. See constructor docs.
 dStrcat( tempStr, SomeOtherString );
 tempStr[2] = 'l';
 Con::printf( tempStr );
 Con::printf( "Foo: %s", ~tempStr );

This will automatically handle getting and restoring the watermark of the FrameAllocator when it goes out of scope. You should notice the strange operator infront of tempStr on the printf call. This is normally a unary operator for ones-complement, but in this class it will simply return the memory of the allocation. It's the same as doing (const char *)tempStr in the above case. The reason why it is necessary for the second printf and not the first is because the second one is taking a variable arg list and so it isn't getting the cast so that it's cast operator can properly return the memory instead of the FrameTemp object itself.

Note:
It is important to note that this object is designed to just be a temporary array of a dynamic size. Some wierdness may occur if you try do perform crazy pointer stuff with it using regular operators on it. I implemented what I thought were the most common operators that it would be used for. If strange things happen, you will need to debug them yourself.


Public Member Functions

 FrameTemp (const U32 count=1)
 Constructor will store the FrameAllocator watermark and allocate the memory off of the FrameAllocator.
 ~FrameTemp ()
 Destructor restores the watermark.
T * operator~ ()
 NOTE: This will return the memory, NOT perform a ones-complement.
const T * operator~ () const
 NOTE: This will return the memory, NOT perform a ones-complement.
T & operator+ ()
 NOTE: This will dereference the memory, NOT do standard unary plus behavior.
const T & operator+ () const
 NOTE: This will dereference the memory, NOT do standard unary plus behavior.
T & operator * ()
const T & operator * () const
T ** operator & ()
const T ** operator & () const
 operator T * ()
 operator const T * () const
 operator T & ()
 operator const T & () const
 operator T ()
 operator const T () const

Protected Attributes

U32 mWaterMark
T * mMemory


Constructor & Destructor Documentation

template<class T>
FrameTemp< T >::FrameTemp ( const U32  count = 1  )  [inline]

Constructor will store the FrameAllocator watermark and allocate the memory off of the FrameAllocator.

Note:
It is important to note that, unlike the FrameAllocatorMarker and the FrameAllocator itself, the argument to allocate is NOT the size in bytes, doing:
 FrameTemp<F64> f64s(5);
Is the same as
 F64 *f64s = new F64[5];
Parameters:
count The number of objects to allocate

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

Destructor restores the watermark.


Member Function Documentation

template<class T>
T* FrameTemp< T >::operator~ (  )  [inline]

NOTE: This will return the memory, NOT perform a ones-complement.

template<class T>
const T* FrameTemp< T >::operator~ (  )  const [inline]

NOTE: This will return the memory, NOT perform a ones-complement.

template<class T>
T& FrameTemp< T >::operator+ (  )  [inline]

NOTE: This will dereference the memory, NOT do standard unary plus behavior.

template<class T>
const T& FrameTemp< T >::operator+ (  )  const [inline]

NOTE: This will dereference the memory, NOT do standard unary plus behavior.

template<class T>
T& FrameTemp< T >::operator * (  )  [inline]

template<class T>
const T& FrameTemp< T >::operator * (  )  const [inline]

template<class T>
T** FrameTemp< T >::operator & (  )  [inline]

template<class T>
const T** FrameTemp< T >::operator & (  )  const [inline]

template<class T>
FrameTemp< T >::operator T * (  )  [inline]

template<class T>
FrameTemp< T >::operator const T * (  )  const [inline]

template<class T>
FrameTemp< T >::operator T & (  )  [inline]

template<class T>
FrameTemp< T >::operator const T & (  )  const [inline]

template<class T>
FrameTemp< T >::operator T (  )  [inline]

template<class T>
FrameTemp< T >::operator const T (  )  const [inline]


Field Documentation

template<class T>
U32 FrameTemp< T >::mWaterMark [protected]

template<class T>
T* FrameTemp< T >::mMemory [protected]




All Rights Reserved GarageGames.com, Inc. 1999-2005
Auto-magically Generated with Doxygen