Torque2D Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Attributes | List of all members
FrameTemp< T > Class Template Reference

`#include <frameAllocator.h>`

## Public Member Functions
| FrameTemp (const U32 count=1)
| ~FrameTemp ()
| Destructor restores the watermark. More...
U32 | getObjectCount (void) const
T * | operator~ ()
| NOTE: This will return the memory, NOT perform a ones-complement. More...
const T * | operator~ () const
| NOTE: This will return the memory, NOT perform a ones-complement. More...
T & | operator+ ()
| NOTE: This will dereference the memory, NOT do standard unary plus behavior. More...
const T & | operator+ () const
| NOTE: This will dereference the memory, NOT do standard unary plus behavior. More...
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
T & | operator[] (const U32 idx)
const T & | operator[] (const U32 idx) const
T & | operator[] (const S32 idx)
const T & | operator[] (const S32 idx) const

## Protected Attributes
U32 | mWaterMark
T * | mMemory
U32 | mNumObjectsInMemory

## 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.

## Constructor & Destructor Documentation

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

~FrameTemp | ( |  | ) |
| inline

Destructor restores the watermark.

## Member Function Documentation

U32 getObjectCount | ( | void |  | ) | const
| inline

operator const T | ( |  | ) | const
| inline

operator const T & | ( |  | ) | const
| inline

operator const T * | ( |  | ) | const
| inline

operator T | ( |  | ) |
| inline

operator T & | ( |  | ) |
| inline

operator T * | ( |  | ) |
| inline

T** operator& | ( |  | ) |
| inline

const T** operator& | ( |  | ) | const
| inline

T& operator* | ( |  | ) |
| inline

const T& operator* | ( |  | ) | const
| inline

T& operator+ | ( |  | ) |
| inline

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

const T& operator+ | ( |  | ) | const
| inline

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

T& operator[] | ( | const U32 | idx | ) |
| inline

const T& operator[] | ( | const U32 | idx | ) | const
| inline

T& operator[] | ( | const S32 | idx | ) |
| inline

const T& operator[] | ( | const S32 | idx | ) | const
| inline

T* operator~ | ( |  | ) |
| inline

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

const T* operator~ | ( |  | ) | const
| inline

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

## Member Data Documentation

T* mMemory
| protected

U32 mNumObjectsInMemory
| protected

U32 mWaterMark
| protected

The documentation for this class was generated from the following file:

- memory/frameAllocator.h