eq::base::Buffer< T > Class Template Reference

#include <buffer.h>

Collaboration diagram for eq::base::Buffer< T >:

[legend]

List of all members.


Detailed Description

template<typename T>
class eq::base::Buffer< T >

A simple memory buffer with some helper functions.

For bigger data (>100k) using a std::vector< uint8_t > has a high overhead when resizing (>1ms). This buffer just memcpy's elements, i.e., it should be used on PODs only since the copy constructor or assignment operator is not called on the copied elements.

Definition at line 25 of file buffer.h.


Public Member Functions

void clear ()
 Flush the buffer, deleting all data.
 Buffer (Buffer &from)
 Copy constructor - transfers ownership!
const Bufferoperator= (Buffer &from)
 Assignment operator.
T & operator[] (const size_t position)
const T & operator[] (const size_t position) const
void resize (const uint64_t newSize)
 Ensure that the buffer contains at least newSize elements, retains existing data.
void reserve (const uint64_t newSize)
 Ensure that the buffer contains at least newSize elements, deletes existing data.
void append (const T *addData, const uint64_t addSize)
 Append addSize elements to the buffer, increasing its size.
void append (const T &element)
 Append one elements to the buffer, increasing its size.
void replace (const void *newData, const uint64_t newSize)
 Replace the existing data.
void swap (Buffer &buffer)
 Swap the buffer contents.
uint64_t getMaxSize () const

Public Attributes

T * data
 A pointer to the data.
uint64_t size
 The number of valid items in data.

Member Function Documentation

template<typename T>
void eq::base::Buffer< T >::clear (  )  [inline]

Flush the buffer, deleting all data.

Definition at line 32 of file buffer.h.

template<typename T>
void eq::base::Buffer< T >::append ( const T *  addData,
const uint64_t  addSize 
) [inline]

Append addSize elements to the buffer, increasing its size.

Definition at line 89 of file buffer.h.

template<typename T>
void eq::base::Buffer< T >::append ( const T &  element  )  [inline]

Append one elements to the buffer, increasing its size.

Definition at line 100 of file buffer.h.

template<typename T>
void eq::base::Buffer< T >::replace ( const void *  newData,
const uint64_t  newSize 
) [inline]

Replace the existing data.

Definition at line 107 of file buffer.h.

Referenced by eq::base::Buffer< pollfd >::operator=().

Here is the caller graph for this function:

template<typename T>
uint64_t eq::base::Buffer< T >::getMaxSize (  )  const [inline]

Returns:
the maximum size of the buffer.

Definition at line 134 of file buffer.h.


Member Data Documentation

template<typename T>
T* eq::base::Buffer< T >::data

template<typename T>
uint64_t eq::base::Buffer< T >::size


The documentation for this class was generated from the following file:
Generated on Sat Dec 6 12:01:48 2008 for Equalizer 0.6 by  1.5.5