Implements a circular buffer.
More...
#include <ecbuf.h>
|
| ECircularBuffer (Int capacity) |
| Class constructor. More...
|
|
| ~ECircularBuffer () |
| Class destructor. More...
|
|
Void | initialize () |
| Initializes the circular buffer. More...
|
|
Bool | isEmpty () |
| True - the buffer is empty, False - there is data in the buffer. More...
|
|
Int | capacity () |
| Returns the maximum capacity of the circular buffer. More...
|
|
Int | used () |
| Returns the number of bytes in use in the buffer. More...
|
|
Int | free () |
| Returns the number of bytes that are free in the buffer. More...
|
|
Int | peekData (pUChar dest, Int offset, Int length) |
| Reads data from the buffer without removing it from the buffer. More...
|
|
Int | readData (pUChar dest, Int offset, Int length) |
| Reads and removes data from the buffer. More...
|
|
void | writeData (pUChar src, Int offset, Int length, Bool nolock=False) |
| Writes data to the circular buffer. More...
|
|
void | modifyData (pUChar src, Int offset, Int length, Bool nolock=False) |
| Modifies data within the buffer. More...
|
|
EMutexPrivate & | getMutex () |
| Retrieves the mutex;. More...
|
|
Implements a circular buffer.
◆ ECircularBuffer()
ECircularBuffer::ECircularBuffer |
( |
Int |
capacity | ) |
|
Class constructor.
- Parameters
-
capacity | The maximum number of bytes in the buffer. |
◆ ~ECircularBuffer()
ECircularBuffer::~ECircularBuffer |
( |
| ) |
|
◆ capacity()
Int ECircularBuffer::capacity |
( |
| ) |
|
|
inline |
Returns the maximum capacity of the circular buffer.
◆ free()
Int ECircularBuffer::free |
( |
| ) |
|
|
inline |
Returns the number of bytes that are free in the buffer.
◆ getMutex()
Retrieves the mutex;.
- Returns
- the mutex.
◆ initialize()
Void ECircularBuffer::initialize |
( |
| ) |
|
Initializes the circular buffer.
◆ isEmpty()
Bool ECircularBuffer::isEmpty |
( |
| ) |
|
|
inline |
True - the buffer is empty, False - there is data in the buffer.
◆ modifyData()
void ECircularBuffer::modifyData |
( |
pUChar |
src, |
|
|
Int |
offset, |
|
|
Int |
length, |
|
|
Bool |
nolock = False |
|
) |
| |
Modifies data within the buffer.
- Parameters
-
src | A pointer to the data that will be written to the buffer. |
offset | The offset within the buffer to start writing. |
length | The number of bytes to write to the buffer. |
nolock | True bypasses the lock, otherwise the object is locked. |
- Exceptions
-
ECircularBufferError_AttemptToModifyDataOutsideBoundsOfCurrentBuffer | |
Generally speaking, data is written to the head and read from the tail. modifyData updates data starting at the tail, the next data to read. This method was added to support partial socket writes where the message length, the first 4 bytes, needed to updated to reflect the remaining bytes to be written. **** USE WITH EXTREME CAUTION ***
◆ peekData()
Int ECircularBuffer::peekData |
( |
pUChar |
dest, |
|
|
Int |
offset, |
|
|
Int |
length |
|
) |
| |
|
inline |
Reads data from the buffer without removing it from the buffer.
- Parameters
-
dest | A pointer to a buffer where the data will be written. |
offset | The offset in the buffer where to start reading from. |
length | The number of bytes to read. |
- Exceptions
-
ECircularBufferError_HeadAndTailOutOfSync | |
ECircularBufferError_UsedLessThanZero | |
ECircularBufferError_TailExceededCapacity | |
◆ readData()
Int ECircularBuffer::readData |
( |
pUChar |
dest, |
|
|
Int |
offset, |
|
|
Int |
length |
|
) |
| |
|
inline |
Reads and removes data from the buffer.
- Parameters
-
dest | A pointer to a buffer where the data will be written. |
offset | The offset in the buffer where to start reading from. |
length | The number of bytes to read. |
◆ used()
Int ECircularBuffer::used |
( |
| ) |
|
|
inline |
Returns the number of bytes in use in the buffer.
◆ writeData()
void ECircularBuffer::writeData |
( |
pUChar |
src, |
|
|
Int |
offset, |
|
|
Int |
length, |
|
|
Bool |
nolock = False |
|
) |
| |
Writes data to the circular buffer.
- Parameters
-
src | A pointer to the data that will be written to the buffer. |
offset | *** NOT USED *** |
length | The number of bytes to write to the buffer. |
nolock | True bypasses the lock, otherwise the object is locked. |
- Exceptions
-
ECircularBufferError_AttemptToExceedCapacity | |
ECircularBufferError_BufferSizeHasBeenExceeded | |
ECircularBufferError_HeadHasExceededCapacity | |
The documentation for this class was generated from the following files:
- /home/vagrant/share/code/epctools/include/epc/ecbuf.h
- /home/vagrant/share/code/epctools/src/ecbuf.cpp