Mercator
Public Member Functions | Public Attributes | Private Attributes | List of all members
Mercator::Buffer< DataType > Class Template Reference

Template for managing buffers of data for a segment. More...

#include <Buffer.h>

Public Member Functions

 Buffer (const Segment &segment, unsigned int channels=4)
 Constructor. More...
 
DataType & operator() (unsigned int x, unsigned int y, unsigned int channel)
 Retrieve the data value at a given point. More...
 
const DataType & operator() (unsigned int x, unsigned int y, unsigned int channel) const
 Retrieve the data value at a given point. More...
 
const SegmentgetSegment () const
 Accessor for the terrain height segment this buffer is associated with.
 
unsigned int getSize () const
 Accessor for the size of segment, m_res + 1.
 
unsigned int getChannels () const
 Accessor for the number of data values per height point.
 
DataType * getData ()
 Accessor for a pointer to buffer containing data values.
 
void allocate ()
 Allocate the storage required by the buffer. More...
 
bool isValid () const
 Determine if this buffer has valid allocated storage. More...
 
void invalidate ()
 De-allocate the storage for this buffer. More...
 

Public Attributes

const Segmentm_segment
 The terrain height segment this buffer is associated with.
 

Private Attributes

const unsigned int m_channels
 The number of data values per height point.
 
const unsigned int m_size
 The size of segment, m_res + 1.
 
DataType * m_data
 Pointer to buffer containing data values.
 

Detailed Description

template<typename DataType>
class Mercator::Buffer< DataType >

Template for managing buffers of data for a segment.

Constructor & Destructor Documentation

template<typename DataType >
Mercator::Buffer< DataType >::Buffer ( const Segment segment,
unsigned int  channels = 4 
)
explicit

Constructor.

Parameters
segmentterrain height segment this buffer is associated with.
channelsnumber of data values per height point.

References Mercator::Buffer< DataType >::m_data.

Member Function Documentation

template<typename DataType>
void Mercator::Buffer< DataType >::allocate ( )
inline

Allocate the storage required by the buffer.

Allocate memory based on the size and number of channels required by the buffer.

template<typename DataType>
void Mercator::Buffer< DataType >::invalidate ( )
inline

De-allocate the storage for this buffer.

Free the storage allocate for this buffer.

template<typename DataType>
bool Mercator::Buffer< DataType >::isValid ( ) const
inline

Determine if this buffer has valid allocated storage.

Returns
true if storage is allocated.
template<typename DataType>
DataType& Mercator::Buffer< DataType >::operator() ( unsigned int  x,
unsigned int  y,
unsigned int  channel 
)
inline

Retrieve the data value at a given point.

Access the data value associated with given point in the segment in a given channel in this buffer.

Returns
a reference to the value at the point requested.
template<typename DataType>
const DataType& Mercator::Buffer< DataType >::operator() ( unsigned int  x,
unsigned int  y,
unsigned int  channel 
) const
inline

Retrieve the data value at a given point.

Return the data value associated with given point in the segment in a given channel in this buffer.

Returns
the value at the point requested.

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