5 #ifndef MERCATOR_BUFFER_H 6 #define MERCATOR_BUFFER_H 13 template<
typename DataType>
28 explicit Buffer(
unsigned int size,
unsigned int channels);
36 DataType &
operator()(
unsigned int x,
unsigned int y,
unsigned int channel) {
37 return m_data[(y * m_size + x) * m_channels + channel];
47 unsigned int channel)
const {
48 return m_data[(y * m_size + x) * m_channels + channel];
77 m_data.resize(m_size * m_size * m_channels);
84 return (!m_data.empty());
98 #endif // MERCATOR_BUFFER_H const DataType & operator()(unsigned int x, unsigned int y, unsigned int channel) const
Retrieve the data value at a given point.
DataType * getData()
Accessor for a pointer to buffer containing data values.
void invalidate()
De-allocate the storage for this buffer.
Template for managing buffers of data for a segment.
const unsigned int m_size
The size of segment, m_res + 1.
const unsigned int m_channels
The number of data values per height point.
void allocate()
Allocate the storage required by the buffer.
bool isValid() const
Determine if this buffer has valid allocated storage.
unsigned int getSize() const
Accessor for the size of segment, m_res + 1.
const DataType * getData() const
Accessor for a pointer to buffer containing data values.
DataType & operator()(unsigned int x, unsigned int y, unsigned int channel)
Retrieve the data value at a given point.
std::vector< DataType > m_data
Pointer to buffer containing data values.
Buffer(unsigned int size, unsigned int channels)
Constructor.
unsigned int getChannels() const
Accessor for the number of data values per height point.