Mercator
Public Member Functions | Public Attributes | Private Attributes
Mercator::Buffer< DataType > Class Template Reference

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

#include <Buffer.h>

List of all members.

Public Member Functions

 Buffer (const Segment &segment, unsigned int channels=4)
 Constructor.
DataType & operator() (unsigned int x, unsigned int y, unsigned int channel)
 Retrieve the data value at a given point.
const DataType & operator() (unsigned int x, unsigned int y, unsigned int channel) const
 Retrieve the data value at a given point.
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.
bool isValid () const
 Determine if this buffer has valid allocated storage.
void invalidate ()
 De-allocate the storage for this buffer.

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.

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: