All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Radiant::GridMemT< T > Class Template Reference

Grid (aka 2D array) base class with memory management. More...

#include <Radiant/Grid.hpp>

Public Member Functions

void clear ()
 Frees up the memory, and sets the width and height of this object to zero. More...
 
void copy (const T *src, unsigned w, unsigned h)
 Copies data from memory. More...
 
 GridMemT (unsigned w=0, unsigned h=0)
 Constructs a new grid with the given size. More...
 
 GridMemT (void *data, unsigned w, unsigned h)
 Constructs a new grid with the given size. More...
 
 GridMemT (const GridMemT &that)
 Constructs a copy. More...
 
GridMemToperator= (const GridMemT &that)
 Copies a grid. More...
 
void resize (unsigned w, unsigned h)
 Resizes this grid, by allocating new memory as necessary Any old data will be lost in this function call. More...
 
void resize (Nimble::Vector2i size)
 Resizes the grid. More...
 
 ~GridMemT ()
 Destructor.
 

Protected Attributes

T * m_data
 Pointer to the raw data.
 
unsigned m_height
 Height of the grid.
 
unsigned m_size
 Reserved data size in bytes.
 
unsigned m_width
 Width of the grid.
 

Detailed Description

template<class T>
class Radiant::GridMemT< T >

Grid (aka 2D array) base class with memory management.

Template Parameters
TType of objects to store

Constructor & Destructor Documentation

template<class T >
Radiant::GridMemT< T >::GridMemT ( unsigned  w = 0,
unsigned  h = 0 
)
inline

Constructs a new grid with the given size.

Parameters
wThe width of the grid
hThe height of the grid
template<class T >
Radiant::GridMemT< T >::GridMemT ( void *  data,
unsigned  w,
unsigned  h 
)
inline

Constructs a new grid with the given size.

Parameters
datapointer to grid data
wThe width of the grid
hThe height of the grid
template<class T >
Radiant::GridMemT< T >::GridMemT ( const GridMemT< T > &  that)
inline

Constructs a copy.

Parameters
thatGrid memory to copy

Member Function Documentation

template<class T >
void Radiant::GridMemT< T >::clear ( void  )
inline

Frees up the memory, and sets the width and height of this object to zero.

template<class T >
void Radiant::GridMemT< T >::copy ( const T *  src,
unsigned  w,
unsigned  h 
)
inline

Copies data from memory.

Parameters
srcSource image data
wWidth of source image
hHeight of source image
template<class T >
GridMemT& Radiant::GridMemT< T >::operator= ( const GridMemT< T > &  that)
inline

Copies a grid.

Parameters
thatSource grid
Returns
Reference to self
template<class T >
void Radiant::GridMemT< T >::resize ( unsigned  w,
unsigned  h 
)
inline

Resizes this grid, by allocating new memory as necessary Any old data will be lost in this function call.

If the number of elements in the grid stays the same, then only the dimensions of the grid are updated, but not the contents.

Parameters
wThe new width of the grid
hThe new height of the grid
template<class T >
void Radiant::GridMemT< T >::resize ( Nimble::Vector2i  size)
inline

Resizes the grid.

Parameters
sizeNew size of the grid
See Also
resize(unsigned w, unsigned h)