Implements a vanilla ring buffer.
More...
#include <RingBuffer.hxx>
|
| void | destroy () |
| | Destroy an existing ring buffer instance.
|
| |
| size_t | put (const T *buf, size_t items) |
| | Insert a number of items to the buffer.
|
| |
| size_t | get (T *buf, size_t items) |
| | remove a number of items from the buffer.
|
| |
| size_t | data_read_pointer (T **buf) |
| | Get a reference to the current location in the buffer for read.
|
| |
| size_t | data_write_pointer (T **buf) |
| | Get a reference to the current location in the buffer for write.
|
| |
| size_t | consume (size_t items) |
| | Remove a number of items from the buffer by advancing the readIndex.
|
| |
| size_t | advance (size_t items) |
| | Add a number of items to the buffer by advancing the writeIndex.
|
| |
| size_t | items () |
| | Number of items in the buffer.
|
| |
| size_t | size () |
| | Size of buffer in number of items.
|
| |
| size_t | space () |
| | space left in buffer of buffer in number items.
|
| |
|
| | RingBuffer (size_t size) |
| | Constructor.
|
| |
|
| RingBuffer () |
| | Default Constructor.
|
| |
|
| ~RingBuffer () |
| | Default destructor.
|
| |
|
| DISALLOW_COPY_AND_ASSIGN (RingBuffer) |
| |
|
| size_t | _size |
| | size in items of ring buffer
|
| |
| size_t | count |
| | total number of items in ring buffer
|
| |
| size_t | readIndex |
| | read index
|
| |
| size_t | writeIndex |
| | write index
|
| |
| T | data [] |
| | ring buffer data
|
| |
template<typename T>
class RingBuffer< T >
Implements a vanilla ring buffer.
Not thread safe.
Definition at line 42 of file RingBuffer.hxx.
◆ RingBuffer()
Constructor.
- Parameters
-
| size | size in bytes for the ring buffer |
Definition at line 225 of file RingBuffer.hxx.
◆ advance()
Add a number of items to the buffer by advancing the writeIndex.
- Parameters
-
| items | total number of items to add |
- Returns
- total number of items added
Definition at line 179 of file RingBuffer.hxx.
◆ consume()
Remove a number of items from the buffer by advancing the readIndex.
- Parameters
-
| items | total number of items to remove |
- Returns
- total number of items removed
Definition at line 150 of file RingBuffer.hxx.
◆ create()
Factory method to create a ring buffer instance.
- Parameters
-
| size | size in items for the ring buffer |
- Returns
- the newly cleated RingBuffer object.
Definition at line 49 of file RingBuffer.hxx.
◆ data_read_pointer()
template<typename T >
| size_t RingBuffer< T >::data_read_pointer |
( |
T ** |
buf | ) |
|
|
inline |
Get a reference to the current location in the buffer for read.
- Parameters
-
| buf | location to store resulting reference |
- Returns
- number of items in contiguous memory. May be less than total number of items in the buffer.
Definition at line 119 of file RingBuffer.hxx.
◆ data_write_pointer()
template<typename T >
| size_t RingBuffer< T >::data_write_pointer |
( |
T ** |
buf | ) |
|
|
inline |
Get a reference to the current location in the buffer for write.
- Parameters
-
| buf | location to store resulting reference |
- Returns
- amount of space in contiguous memory. May be less than total amount of space avaiable.
Definition at line 135 of file RingBuffer.hxx.
◆ destroy()
Destroy an existing ring buffer instance.
Definition at line 61 of file RingBuffer.hxx.
◆ get()
template<typename T >
| size_t RingBuffer< T >::get |
( |
T * |
buf, |
|
|
size_t |
items |
|
) |
| |
|
inline |
remove a number of items from the buffer.
- Parameters
-
| buf | reference to the data removed |
| items | total number of items to remove |
- Returns
- total number of items removed
- Todo:
- (Stuart Baker) significant optimization opportunity
Definition at line 95 of file RingBuffer.hxx.
◆ items()
Number of items in the buffer.
- Returns
- number of items in the buffer
Definition at line 200 of file RingBuffer.hxx.
◆ put()
template<typename T >
| size_t RingBuffer< T >::put |
( |
const T * |
buf, |
|
|
size_t |
items |
|
) |
| |
|
inline |
Insert a number of items to the buffer.
- Parameters
-
| buf | reference to the first item to insert |
| items | total number of items to insert |
- Returns
- total number of items inserted
- Todo:
- (Stuart Baker) significant optimization opportunity
Definition at line 71 of file RingBuffer.hxx.
◆ size()
Size of buffer in number of items.
- Returns
- size of buffer in number of items
Definition at line 208 of file RingBuffer.hxx.
◆ space()
space left in buffer of buffer in number items.
- Returns
- space left in buffer in number of items
Definition at line 216 of file RingBuffer.hxx.
◆ _size
◆ count
◆ data
◆ readIndex
◆ writeIndex
The documentation for this class was generated from the following file: