A simple memory buffer with some helper functions. More...
#include <buffer.h>
Public Member Functions | |
| Buffer () | |
| Construct a new, empty buffer. | |
| Buffer (const uint64_t size) | |
| Construct a new buffer of the given size. | |
| ~Buffer () | |
| Destruct the buffer. | |
| void | clear () |
| Flush the buffer, deleting all data. | |
| Buffer (Buffer &from) | |
| Copy constructor, transfers ownership to new Buffer. | |
| const Buffer & | operator= (Buffer &from) |
| Assignment operator, copies data from Buffer. | |
| T & | operator[] (const uint64_t position) |
| Direct access to the element at the given index. | |
| const T & | operator[] (const uint64_t position) const |
| Direct const access to an element. | |
| void | resize (const uint64_t newSize) |
| Ensure that the buffer contains at least newSize elements. | |
| void | grow (const uint64_t newSize) |
| Ensure that the buffer contains at least newSize elements. | |
| void | reserve (const uint64_t newSize) |
| Ensure that the buffer contains at least newSize elements. | |
| void | append (const T *data, const uint64_t size) |
| Append elements to the buffer, increasing the size. | |
| void | append (const T &element) |
| Append one element to the buffer. | |
| void | replace (const void *data, const uint64_t size) |
| Replace the existing data with new data. | |
| void | swap (Buffer &buffer) |
| Swap the buffer contents with another Buffer. | |
| T * | getData () |
| const T * | getData () const |
| bool | setSize (const uint64_t size) |
| Set the size of the buffer without changing its allocation. | |
| uint64_t | getSize () const |
| bool | isEmpty () const |
| uint64_t | getMaxSize () const |
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 only be used for PODs since the copy constructor or assignment operator is not called on the copied elements. Primarily used for binary data, e.g., in eq::Image. The implementation works like a pool, that is, data is only released when the buffer is deleted or clear() is called.
Definition at line 37 of file buffer.h.
| eq::base::Buffer< T >::Buffer | ( | ) | [inline] |
| eq::base::Buffer< T >::Buffer | ( | const uint64_t | size | ) | [inline] |
| eq::base::Buffer< T >::~Buffer | ( | ) | [inline] |
| eq::base::Buffer< T >::Buffer | ( | Buffer< T > & | from | ) | [inline] |
| void eq::base::Buffer< T >::clear | ( | ) | [inline] |
Flush the buffer, deleting all data.
Definition at line 51 of file buffer.h.
Referenced by eq::base::Buffer< pollfd >::~Buffer().

| const Buffer& eq::base::Buffer< T >::operator= | ( | Buffer< T > & | from | ) | [inline] |
| T& eq::base::Buffer< T >::operator[] | ( | const uint64_t | position | ) | [inline] |
| const T& eq::base::Buffer< T >::operator[] | ( | const uint64_t | position | ) | const [inline] |
| void eq::base::Buffer< T >::resize | ( | const uint64_t | newSize | ) | [inline] |
Ensure that the buffer contains at least newSize elements.
Existing data is retained. The size is set.
Definition at line 82 of file buffer.h.
Referenced by eq::base::Buffer< pollfd >::append(), eq::base::Buffer< pollfd >::Buffer(), and eq::base::Buffer< pollfd >::grow().

| void eq::base::Buffer< T >::grow | ( | const uint64_t | newSize | ) | [inline] |
| void eq::base::Buffer< T >::reserve | ( | const uint64_t | newSize | ) | [inline] |
Ensure that the buffer contains at least newSize elements.
Existing data may be deleted.
Definition at line 115 of file buffer.h.
Referenced by eq::base::Buffer< pollfd >::replace(), and eq::net::RSPConnection::RSPConnection().

| void eq::base::Buffer< T >::append | ( | const T * | data, | |
| const uint64_t | size | |||
| ) | [inline] |
Append elements to the buffer, increasing the size.
Definition at line 128 of file buffer.h.
Referenced by eq::net::DataOStream::write(), eq::net::BufferConnection::write(), and eq::net::DataOStream::writeOnce().

| void eq::base::Buffer< T >::append | ( | const T & | element | ) | [inline] |
| void eq::base::Buffer< T >::replace | ( | const void * | data, | |
| const uint64_t | size | |||
| ) | [inline] |
Replace the existing data with new data.
Definition at line 146 of file buffer.h.
Referenced by eq::base::Buffer< pollfd >::operator=().

| void eq::base::Buffer< T >::swap | ( | Buffer< T > & | buffer | ) | [inline] |
| T* eq::base::Buffer< T >::getData | ( | ) | [inline] |
Definition at line 173 of file buffer.h.
Referenced by eq::net::DataOStream::disable(), EqCompressorGetResult(), eq::net::DataOStream::flush(), eq::net::RSPConnection::readSync(), eq::net::DataOStream::resend(), eq::net::ConnectionSet::select(), eq::Image::setPixelData(), eq::FrameData::transmit(), and eq::net::RSPConnection::write().

| const T* eq::base::Buffer< T >::getData | ( | ) | const [inline] |
| bool eq::base::Buffer< T >::setSize | ( | const uint64_t | size | ) | [inline] |
| uint64_t eq::base::Buffer< T >::getSize | ( | ) | const [inline] |
Definition at line 197 of file buffer.h.
Referenced by eq::net::DataOStream::disable(), eq::net::DataOStream::disableSave(), eq::net::DataOStream::enableSave(), EqCompressorGetResult(), eq::net::DataOStream::flush(), eq::net::DataOStream::resend(), eq::net::ConnectionSet::select(), eq::Image::setPixelData(), eq::FrameData::transmit(), and eq::net::DataOStream::write().

| bool eq::base::Buffer< T >::isEmpty | ( | ) | const [inline] |
| uint64_t eq::base::Buffer< T >::getMaxSize | ( | ) | const [inline] |
Definition at line 203 of file buffer.h.
Referenced by EqCompressorGetResult().

0.9.1 by
1.6.1