ucommon::temporary< T > Class Template Reference

Manage temporary object stored on the heap. More...

#include <generics.h>


Public Member Functions

T & operator * ()
 Access heap object through our temporary directly.
 operator bool ()
bool operator! ()
T * operator-> ()
 Access members of our heap object through our temporary.
T & operator= (T *temp)
 Assign a temporary object.
void set (T *temp)
 Assign a temporary object.
 temporary (T *ptr)
 Construct an assigned pointer.
 temporary (temporary< T > &)
 Disable copy constructor.
 temporary ()
 Construct a temporary object, create our stack frame reference.
 ~temporary ()

Protected Attributes

T * object


Detailed Description

template<typename T>
class ucommon::temporary< T >

Manage temporary object stored on the heap.

This is used to create a object on the heap who's scope is controlled by the scope of a member function call. Sometimes we have data types and structures which cannot themselves appear as auto variables. We may also have a limited stack frame size in a thread context, and yet have a dynamic object that we only want to exist during the life of the method call. Using temporary allows any type to be created from the heap but have a lifespan of a method's stack frame.

Author:
David Sugar <dyfet@gnutelephony.org>

Definition at line 259 of file generics.h.


Member Function Documentation

template<typename T>
T& ucommon::temporary< T >::operator * (  )  [inline]

Access heap object through our temporary directly.

Returns:
reference to heap resident object.

Definition at line 311 of file generics.h.

template<typename T>
T* ucommon::temporary< T >::operator-> (  )  [inline]

Access members of our heap object through our temporary.

Returns:
member reference of heap object.

Definition at line 318 of file generics.h.

template<typename T>
T& ucommon::temporary< T >::operator= ( T *  temp  )  [inline]

Assign a temporary object.

This adds a pointer to an existing type to the current temporary pointer. If the temporary was already assigned, then it is deleted.

Parameters:
temp object to assign.

Definition at line 288 of file generics.h.

template<typename T>
void ucommon::temporary< T >::set ( T *  temp  )  [inline]

Assign a temporary object.

This adds a pointer to an existing type to the current temporary pointer. If the temporary was already assigned, then it is deleted.

Parameters:
temp object to assign.

Definition at line 301 of file generics.h.


The documentation for this class was generated from the following file:
Generated on 14 Aug 2013 for UCommon by  doxygen 1.4.7