ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
ucommon::temporary< T > Class Template Reference

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

#include <temporary.h>

Public Member Functions

 temporary (size_t size=1)
 Construct a temporary object, create our stack frame reference. More...
 
 temporary (size_t size, const T initial)
 
 temporary (const T initial)
 
 ~temporary ()
 
 operator T& () const
 
T & operator* () const
 Access heap object through our temporary directly. More...
 
T * operator-> () const
 Access members of our heap object through our temporary. More...
 
 operator bool () const
 
bool operator! () const
 
temporaryoperator= (const T initial)
 
void release ()
 
T & operator[] (size_t index) const
 
T * operator() (size_t index) const
 
void operator() (size_t index, const T value)
 
T & value (size_t index) const
 
void value (size_t index, const T value)
 
size_t read (FILE *fp)
 
size_t write (FILE *fp)
 
size_t seek (FILE *fp, long pos)
 

Protected Attributes

T * array
 
size_t used
 

Private Member Functions

 __DELETE_COPY (temporary)
 

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.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 80 of file temporary.h.

Constructor & Destructor Documentation

◆ temporary() [1/3]

template<typename T >
ucommon::temporary< T >::temporary ( size_t  size = 1)
inline

Construct a temporary object, create our stack frame reference.

Definition at line 93 of file temporary.h.

References ucommon::temporary< T >::array, and ucommon::temporary< T >::used.

◆ temporary() [2/3]

template<typename T >
ucommon::temporary< T >::temporary ( size_t  size,
const T  initial 
)
inline

Definition at line 98 of file temporary.h.

References ucommon::temporary< T >::array, and ucommon::temporary< T >::used.

◆ temporary() [3/3]

template<typename T >
ucommon::temporary< T >::temporary ( const T  initial)
inlineexplicit

Definition at line 105 of file temporary.h.

References ucommon::temporary< T >::array, and ucommon::temporary< T >::used.

◆ ~temporary()

template<typename T >
ucommon::temporary< T >::~temporary ( )
inline

Definition at line 111 of file temporary.h.

References ucommon::temporary< T >::array.

Member Function Documentation

◆ __DELETE_COPY()

template<typename T >
ucommon::temporary< T >::__DELETE_COPY ( temporary< T >  )
private

◆ operator bool()

template<typename T >
ucommon::temporary< T >::operator bool ( ) const
inline

Definition at line 138 of file temporary.h.

References ucommon::temporary< T >::array.

◆ operator T&()

template<typename T >
ucommon::temporary< T >::operator T& ( ) const
inline

Definition at line 118 of file temporary.h.

References ucommon::temporary< T >::array.

◆ operator!()

template<typename T >
bool ucommon::temporary< T >::operator! ( ) const
inline

Definition at line 142 of file temporary.h.

References ucommon::temporary< T >::array.

◆ operator()() [1/2]

template<typename T >
T * ucommon::temporary< T >::operator() ( size_t  index) const
inline

Definition at line 163 of file temporary.h.

References ucommon::temporary< T >::array, crit, and ucommon::temporary< T >::used.

◆ operator()() [2/2]

template<typename T >
void ucommon::temporary< T >::operator() ( size_t  index,
const T  value 
)
inline

Definition at line 168 of file temporary.h.

References ucommon::temporary< T >::array, crit, ucommon::temporary< T >::used, and ucommon::temporary< T >::value().

Here is the call graph for this function:

◆ operator*()

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

Access heap object through our temporary directly.

Returns
reference to heap resident object.

Definition at line 126 of file temporary.h.

References ucommon::temporary< T >::array.

◆ operator->()

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

Access members of our heap object through our temporary.

Returns
member reference of heap object.

Definition at line 134 of file temporary.h.

References ucommon::temporary< T >::array.

◆ operator=()

template<typename T >
temporary & ucommon::temporary< T >::operator= ( const T  initial)
inline

Definition at line 146 of file temporary.h.

References ucommon::temporary< T >::array.

◆ operator[]()

template<typename T >
T & ucommon::temporary< T >::operator[] ( size_t  index) const
inline

Definition at line 158 of file temporary.h.

References ucommon::temporary< T >::array, crit, and ucommon::temporary< T >::used.

◆ read()

template<typename T >
size_t ucommon::temporary< T >::read ( FILE *  fp)
inline

Definition at line 183 of file temporary.h.

References ucommon::temporary< T >::array, and ucommon::temporary< T >::used.

◆ release()

template<typename T >
void ucommon::temporary< T >::release ( )
inline

Definition at line 151 of file temporary.h.

References ucommon::temporary< T >::array.

◆ seek()

template<typename T >
size_t ucommon::temporary< T >::seek ( FILE *  fp,
long  pos 
)
inline

Definition at line 193 of file temporary.h.

◆ value() [1/2]

template<typename T >
T & ucommon::temporary< T >::value ( size_t  index) const
inline

◆ value() [2/2]

template<typename T >
void ucommon::temporary< T >::value ( size_t  index,
const T  value 
)
inline

Definition at line 178 of file temporary.h.

References ucommon::temporary< T >::array, crit, ucommon::temporary< T >::used, and ucommon::temporary< T >::value().

Here is the call graph for this function:

◆ write()

template<typename T >
size_t ucommon::temporary< T >::write ( FILE *  fp)
inline

Definition at line 188 of file temporary.h.

References ucommon::temporary< T >::array, and ucommon::temporary< T >::used.

Member Data Documentation

◆ array

◆ used


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