mercator  0.4.0
A terrain generation library for the Worldforge system.
Mercator::Buffer< DataType > Class Template Reference

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

#include <Buffer.h>

Collaboration diagram for Mercator::Buffer< DataType >:

Public Member Functions

 Buffer (unsigned int size, unsigned int channels)
 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...
 
unsigned int getSize () const
 Accessor for the size of segment, m_res + 1. More...
 
unsigned int getChannels () const
 Accessor for the number of data values per height point. More...
 
DataType * getData ()
 Accessor for a pointer to buffer containing data values. More...
 
const DataType * getData () const
 Accessor for a pointer to buffer containing data values. More...
 
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...
 

Protected Attributes

const unsigned int m_channels
 The number of data values per height point. More...
 
const unsigned int m_size
 The size of segment, m_res + 1. More...
 
std::vector< DataType > m_data
 Pointer to buffer containing data values. More...
 

Detailed Description

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

Template for managing buffers of data for a segment.

Definition at line 14 of file Buffer.h.

Constructor & Destructor Documentation

◆ Buffer()

template<typename DataType >
Mercator::Buffer< DataType >::Buffer ( unsigned int  size,
unsigned int  channels 
)
explicit

Constructor.

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

Definition at line 10 of file Buffer_impl.h.

Member Function Documentation

◆ allocate()

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.

Definition at line 76 of file Buffer.h.

Referenced by Mercator::Segment::populate().

◆ getChannels()

template<typename DataType>
unsigned int Mercator::Buffer< DataType >::getChannels ( ) const
inline

◆ getData() [1/2]

◆ getData() [2/2]

template<typename DataType>
const DataType* Mercator::Buffer< DataType >::getData ( ) const
inline

Accessor for a pointer to buffer containing data values.

Definition at line 68 of file Buffer.h.

◆ getSize()

template<typename DataType>
unsigned int Mercator::Buffer< DataType >::getSize ( ) const
inline

Accessor for the size of segment, m_res + 1.

Definition at line 53 of file Buffer.h.

Referenced by Mercator::EdgeAtZ::operator()(), and Mercator::TileShader::shade().

◆ invalidate()

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

De-allocate the storage for this buffer.

Free the storage allocate for this buffer.

Definition at line 90 of file Buffer.h.

Referenced by Mercator::Segment::invalidate().

◆ isValid()

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

Determine if this buffer has valid allocated storage.

Returns
true if storage is allocated.

Definition at line 83 of file Buffer.h.

Referenced by Mercator::Segment::isValid(), and Mercator::Segment::populateNormals().

◆ operator()() [1/2]

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.

Definition at line 36 of file Buffer.h.

◆ operator()() [2/2]

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.

Definition at line 45 of file Buffer.h.

Member Data Documentation

◆ m_channels

template<typename DataType>
const unsigned int Mercator::Buffer< DataType >::m_channels
protected

The number of data values per height point.

Definition at line 17 of file Buffer.h.

Referenced by Mercator::Buffer< ColorT >::getChannels().

◆ m_data

template<typename DataType>
std::vector<DataType> Mercator::Buffer< DataType >::m_data
protected

Pointer to buffer containing data values.

Definition at line 21 of file Buffer.h.

◆ m_size

template<typename DataType>
const unsigned int Mercator::Buffer< DataType >::m_size
protected

The size of segment, m_res + 1.

Definition at line 19 of file Buffer.h.

Referenced by Mercator::Buffer< ColorT >::getSize().


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