Archon::Utilities::Array< T > Struct Template Reference

A wrapper around a simple conventional array whose memory allocation and deallocation is handled automatically. More...

#include <archon/util/memory.H>

Collaboration diagram for Archon::Utilities::Array< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Array (T *p=0)
 Create a Array from of a previously allocated array.
 Array (size_t n)
 Create a Array of a certain fixed number of elements.
 Array (size_t n, T v)
 Create a Array of a certain fixed number elements.
 ~Array ()
const Tget () const
 Return a pointer to the conventional array.
Tget ()
Tout ()
 Dismount and return the conventional array.
void reset (T *q=0)
 Dispose the previously managed conventional array and replace it with the passed conventional array.
void reset (size_t n)
 Dispose the previously managed conventional array and replace it with a new one of the specified size.
void reset (size_t n, T v)
 Dispose the previously managed conventional array and replace it with a new one of the specified size.
const Toperator[] (int i) const
 Fetch a reference to the subscribed constant element.
Toperator[] (int i)
 Fetch a reference to the subscribed mutable element.
 operator bool () const
 Test if any memory is currently owned by this object.

Detailed Description

template<typename T>
struct Archon::Utilities::Array< T >

A wrapper around a simple conventional array whose memory allocation and deallocation is handled automatically.

Using this class instead of plain dynamically allocated arrays may greatly improve your applications resistance to memory leakage.

Definition at line 195 of file memory.H.


Constructor & Destructor Documentation

template<typename T>
Archon::Utilities::Array< T >::Array T p = 0  )  [inline]
 

Create a Array from of a previously allocated array.

This class assumes ownership of the passed memory.

Definition at line 201 of file memory.H.

template<typename T>
Archon::Utilities::Array< T >::Array size_t  n  )  [inline]
 

Create a Array of a certain fixed number of elements.

If the element type is of class type the elements are default initialized, otherwise the elements are uninitialized.

Parameters:
n The number of elements that must fit into the array.

Definition at line 211 of file memory.H.

template<typename T>
Archon::Utilities::Array< T >::Array size_t  n,
T  v
[inline]
 

Create a Array of a certain fixed number elements.

Then initialize all entries with the specified initializer.

Parameters:
n The number of elements that must fit into the array.

Definition at line 220 of file memory.H.


Member Function Documentation

template<typename T>
T* Archon::Utilities::Array< T >::get  )  [inline]
 

See also:
get() const

Definition at line 241 of file memory.H.

template<typename T>
const T* Archon::Utilities::Array< T >::get  )  const [inline]
 

Return a pointer to the conventional array.

The ownership of the returned memory remains with this class. The caller must not attempt to deallocate it unless "out" is also called.

See also:
out

Definition at line 236 of file memory.H.

Referenced by Archon::Utilities::Image::Image(), Archon::Utilities::FormatLibpng::load(), Archon::Utilities::FormatLibjpeg::load(), Archon::Utilities::ImageData::queryPixelMap(), Archon::Utilities::FormatLibpng::save(), and Archon::Utilities::FormatLibjpeg::save().

template<typename T>
Archon::Utilities::Array< T >::operator bool  )  const [inline]
 

Test if any memory is currently owned by this object.

Returns:
True iff any memory is currently owned by this object.

Definition at line 303 of file memory.H.

template<typename T>
T* Archon::Utilities::Array< T >::out  )  [inline]
 

Dismount and return the conventional array.

It is the responsibility of the caller to deallocate the returned memory. This class no longer knows of it.

Succeeding calls to get or out will return 0.

Definition at line 251 of file memory.H.

Referenced by Archon::Utilities::Image::Image().

template<typename T>
void Archon::Utilities::Array< T >::reset size_t  n,
T  v
[inline]
 

Dispose the previously managed conventional array and replace it with a new one of the specified size.

Then initialize all entries with the specified initializer.

Definition at line 281 of file memory.H.

template<typename T>
void Archon::Utilities::Array< T >::reset size_t  n  )  [inline]
 

Dispose the previously managed conventional array and replace it with a new one of the specified size.

If the element type is of class type the elements are default initialized, otherwise the elements are uninitialized.

Definition at line 271 of file memory.H.

template<typename T>
void Archon::Utilities::Array< T >::reset T q = 0  )  [inline]
 

Dispose the previously managed conventional array and replace it with the passed conventional array.

This object assumes control over the passed memory.

Definition at line 258 of file memory.H.

Referenced by Archon::Utilities::FormatLibpng::load(), Archon::Utilities::FormatLibjpeg::load(), Archon::Utilities::Array< C >::reset(), Archon::Utilities::FormatLibpng::save(), and Archon::Utilities::FormatLibjpeg::save().


The documentation for this struct was generated from the following file:
Generated on Sun Jul 30 22:57:42 2006 for Archon by  doxygen 1.4.4