a template-based ring buffer class that can store different kinds of objects in buffers of whatever size is needed.
More...
|
| RingBufferT () |
| Construct a ring buffer to store elements of type T indexed by integer type N, with size SIZE. All of these are passed as template parameters. *.
|
|
T | pull () |
| Extract the next (first) element from the ring buffer. More...
|
|
T | peek (N index=0) |
| Examine an element in the ring buffer. More...
|
|
bool | push (T element) |
| Push an element into the ring buffer. The element is appended to the back of the buffer. More...
|
|
bool | isEmpty () |
| Determine if the buffer is empty . More...
|
|
bool | isNotEmpty () |
| Determine if the buffer is not empty. More...
|
|
bool | isFull () |
| Determine if the buffer is full and cannot accept more bytes. More...
|
|
bool | isNotFull () |
| Determine if the buffer is not full and can accept more bytes. More...
|
|
void | discardFromFront (N nbrElements) |
| discard a number of elements from the front of the ring buffer. More...
|
|
void | clear () |
| Clear the ring buffer, leaving it empty.
|
|
template<typename T, typename N, unsigned int SIZE>
class RingBufferT< T, N, SIZE >
a template-based ring buffer class that can store different kinds of objects in buffers of whatever size is needed.
The implementation of RingBufferT is interrupt safe: the key operations are atomic, allowing for RingBuffer objects to be shared between interrupt functions and ordinary code.
The template-based RingBufferT class provides a very flexible ring buffer implementation; however different instantiations of RingBufferT (e.g., RingBufferT< char, int, 32 > and RingBufferT< char, int, 16 >) result in replicated code for each instantiation, even when they could logically share code. For a more efficient ring buffer that avoids such code bloat but can only store bytes, use RingBuffer.
- Template Parameters
-
T | is the type of object that will be stored in the RingBufferT instantiation. |
N | is the integer type that will be used to index the RingBufferT elements. |
SIZE | is an integer indicating the size of the RingBufferT instantiation. |