FrameTemp

Engine/source/core/frameAllocator.h

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

More...

Vector-like Interface

Public Functions

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

Destructor restores the watermark.

T **
T &

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

const T &

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

T *

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

const T *

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

Detailed Description

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, 32 * sizeof(char) );
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 in front 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 to perform crazy pointer stuff with it using regular operators on it.

Vector-like Interface

address()

size()

Protected Attributes

T * mMemory 
U32 mNumObjectsInMemory 
U32 mWaterMark 

Public Functions

FrameTemp(const U32 count)

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()

Destructor restores the watermark.

operator const T()

operator const T&()

operator const T*()

operator T()

operator T&()

operator T*()

operator&()

operator&()

operator*()

operator*()

operator+()

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

operator+()

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

operator[](S32 i)

operator[](S32 i)

operator[](U32 i)

operator[](U32 i)

operator~()

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

operator~()

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