Public Types |
Public Member Functions |
Private Member Functions |
Private Attributes |
List of all members
mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK > Class Template Reference
A basic ring buffer with iterator. More...
#include <mn_ringbuffer.hpp>
Collaboration diagram for mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK >:
Public Types | |
using | value_type = T |
using | pointer = T * |
using | const_pointer = const T * |
using | reference = T & |
using | const_reference = const T & |
using | size_type = size_t |
using | difference_type = ptrdiff_t |
using | lock_type = TLOCK |
using | lock_guard = basic_autolock< TLOCK > |
using | self_type = basic_ring_buffer< T, TCAPACITY, TLOCK > |
using | iterator = basic_ring_buffer_iterator< self_type, value_type > |
using | const_iterator = basic_ring_buffer_iterator< self_type, const value_type > |
Public Member Functions | |
basic_ring_buffer () | |
void | clear () |
Clear the ringbuffer and set read/write positoin to 0. More... | |
void | reset () |
Set read/write positoin to 0, for clear use function clear() More... | |
void | push_back (const value_type &value) |
push a value to the end of the buffer More... | |
reference | pop_front () |
pop (read) the element from the front and remove it from buffer More... | |
const_reference | pop_front () const |
pop (read) the element from the front and remove it from buffer More... | |
iterator | begin () |
iterator | end () |
const_iterator | cbegin () |
const_iterator | cend () |
reference | rfront () |
const_reference | crfront () const |
const_reference | crback () const |
reference | rback () |
size_type | size () const |
Get the size of the ringbuffer. More... | |
size_type | capacity () const |
Get the number of stored elements in the buffer. More... | |
bool | empty () const |
Is the buffer empty? More... | |
bool | full () const |
Is the buffer full? More... | |
size_type | max () const |
size_t | get_head () |
size_t | get_tail () |
Private Member Functions | |
void | inc_tail () |
void | inc_head () |
Private Attributes | |
T | m_Array [TCAPACITY] |
size_t | m_Head |
size_t | m_Tail |
size_t | m_ContentsSize |
lock_type | m_lockObject |
Detailed Description
template<class T, size_t TCAPACITY = 100, typename TLOCK = LockType_t>
class mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK >
A basic ring buffer with iterator.
- Note
- A ring buffer is a FIFO (first-in, first-out) container which acts much like a queue. The difference is that a ring buffer is implemented via chasing pointers around a container and moving the read and write positions forward (and possibly wrapping around) as the container is read and written via pop_front and push_back.
- Template Parameters
-
T Type of element. Required to be a complete type. TCAPACITY The maximal capacity of elements, TLOCK The lock object for task saftly
Member Typedef Documentation
◆ const_iterator
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
using mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK >::const_iterator = basic_ring_buffer_iterator<self_type, const value_type> |
◆ const_pointer
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
using mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK >::const_pointer = const T* |
◆ const_reference
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
using mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK >::const_reference = const T& |
◆ difference_type
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
using mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK >::difference_type = ptrdiff_t |
◆ iterator
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
using mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK >::iterator = basic_ring_buffer_iterator<self_type, value_type> |
◆ lock_guard
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
using mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK >::lock_guard = basic_autolock<TLOCK> |
◆ lock_type
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
using mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK >::lock_type = TLOCK |
◆ pointer
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
using mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK >::pointer = T* |
◆ reference
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
using mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK >::reference = T& |
◆ self_type
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
using mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK >::self_type = basic_ring_buffer<T, TCAPACITY, TLOCK> |
◆ size_type
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
using mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK >::size_type = size_t |
◆ value_type
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
using mn::container::basic_ring_buffer< T, TCAPACITY, TLOCK >::value_type = T |
Constructor & Destructor Documentation
◆ basic_ring_buffer()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
Member Function Documentation
◆ begin()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
◆ capacity()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
Get the number of stored elements in the buffer.
- Returns
- The number of stored elements in the buffer
◆ cbegin()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
◆ cend()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
◆ clear()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
Clear the ringbuffer and set read/write positoin to 0.
◆ crback()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
◆ crfront()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
◆ empty()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
Is the buffer empty?
- Returns
- true The buffer is empty
- false The buffer is not empty
◆ end()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
◆ full()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
Is the buffer full?
- Returns
- true The buffer is full
- false The buffer is not full
◆ get_head()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
Get the write position (head)
- Returns
- The write position (head)
◆ get_tail()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
Get the read position index (head)
- Returns
- The read position (head)
◆ inc_head()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inlineprivate |
◆ inc_tail()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inlineprivate |
◆ max()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
◆ pop_front() [1/2]
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
pop (read) the element from the front and remove it from buffer
- Returns
- The poped value
◆ pop_front() [2/2]
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
pop (read) the element from the front and remove it from buffer
- Returns
- The poped value
◆ push_back()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
push a value to the end of the buffer
- Parameters
-
value The value to add
◆ rback()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
◆ reset()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
Set read/write positoin to 0, for clear use function clear()
◆ rfront()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
◆ size()
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
inline |
Get the size of the ringbuffer.
- Returns
- The size of the ringbuffer
Member Data Documentation
◆ m_Array
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
private |
◆ m_ContentsSize
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
private |
◆ m_Head
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
private |
◆ m_lockObject
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
private |
◆ m_Tail
template<class T , size_t TCAPACITY = 100, typename TLOCK = LockType_t>
|
private |
The documentation for this class was generated from the following file: