MRPT
2.0.1
|
A circular buffer of fixed size (defined at construction-time), implemented with a std::vector as the underlying storage.
Definition at line 22 of file circular_buffer.h.
#include <mrpt/containers/circular_buffer.h>
Public Member Functions | |
circular_buffer (const size_t size) | |
void | push (T d) |
Insert a copy of the given element in the buffer. More... | |
void | push_ref (const T &d) |
Insert a reference of the given element in the buffer. More... | |
void | push_many (T *array_elements, size_t count) |
Insert an array of elements in the buffer. More... | |
T | pop () |
Retrieve an element from the buffer. More... | |
void | pop (T &out_val) |
Retrieve an element from the buffer. More... | |
void | pop_many (T *out_array, size_t count) |
Pop a number of elements into a user-provided array. More... | |
T | peek () const |
Peek (see without modifying) what is to be read from the buffer if pop() was to be called. More... | |
T | peek (size_t index) const |
Like peek(), but seeking ahead in the buffer (index=0 means the immediate next element, index=1 the following one, etc.) More... | |
void | peek_many (T *out_array, size_t count) const |
Like peek(), for multiple elements, storing a number of elements into a user-provided array. More... | |
size_t | size () const |
Return the number of elements available for read ("pop") in the buffer (this is NOT the maximum size of the internal buffer) More... | |
size_t | capacity () const |
Return the maximum capacity of the buffer. More... | |
size_t | available () const |
The maximum number of elements that can be written ("push") without rising an overflow error. More... | |
void | clear () |
Delete all the stored data, if any. More... | |
Private Attributes | |
std::vector< T > | m_data |
size_t | m_size |
not "const" to allow copy/move = ops. More... | |
size_t | m_next_read |
size_t | m_next_write |
|
inline |
Definition at line 31 of file circular_buffer.h.
|
inline |
The maximum number of elements that can be written ("push") without rising an overflow error.
Definition at line 158 of file circular_buffer.h.
Referenced by mrpt::hwdrivers::CGPSInterface::doProcess(), mrpt::hwdrivers::CHokuyoURG::ensureBufferHasBytes(), and mrpt::comms::CInterfaceFTDI::Read().
|
inline |
Return the maximum capacity of the buffer.
Definition at line 154 of file circular_buffer.h.
Referenced by mrpt::containers::circular_buffer< uint8_t >::available(), mrpt::hwdrivers::CHokuyoURG::ensureBufferHasBytes(), and TEST().
|
inline |
Delete all the stored data, if any.
Definition at line 160 of file circular_buffer.h.
Referenced by mrpt::comms::CInterfaceFTDI::Close(), mrpt::comms::CInterfaceFTDI::OpenByDescription(), mrpt::comms::CInterfaceFTDI::OpenBySerialNumber(), mrpt::comms::CInterfaceFTDI::Purge(), and mrpt::comms::CInterfaceFTDI::ResetDevice().
|
inline |
Peek (see without modifying) what is to be read from the buffer if pop() was to be called.
std::out_of_range | If the buffer is empty. |
Definition at line 106 of file circular_buffer.h.
Referenced by mrpt::hwdrivers::CHokuyoURG::parseResponse(), and TEST().
|
inline |
Like peek(), but seeking ahead in the buffer (index=0 means the immediate next element, index=1 the following one, etc.)
std::out_of_range | If trying to read passing the number of available elements. |
Definition at line 116 of file circular_buffer.h.
|
inline |
Like peek(), for multiple elements, storing a number of elements into a user-provided array.
std::out_of_range | If the buffer has less elements than requested. |
Definition at line 127 of file circular_buffer.h.
Referenced by impl_WritePeekCheck(), and TEST().
|
inline |
Retrieve an element from the buffer.
std::out_of_range | If the buffer is empty. |
Definition at line 73 of file circular_buffer.h.
Referenced by mrpt::hwdrivers::CGPSInterface::parseBuffer(), mrpt::hwdrivers::CHokuyoURG::parseResponse(), mrpt::containers::circular_buffer< uint8_t >::pop_many(), and TEST().
|
inline |
Retrieve an element from the buffer.
std::out_of_range | If the buffer is empty. |
Definition at line 86 of file circular_buffer.h.
|
inline |
Pop a number of elements into a user-provided array.
std::out_of_range | If the buffer has less elements than requested. |
Definition at line 98 of file circular_buffer.h.
Referenced by mrpt::comms::CInterfaceFTDI::Read(), and TEST().
|
inline |
Insert a copy of the given element in the buffer.
std::out_of_range | If the buffer run out of space. |
Definition at line 40 of file circular_buffer.h.
Referenced by impl_WritePeekCheck(), mrpt::containers::circular_buffer< uint8_t >::push_many(), and TEST().
|
inline |
Insert an array of elements in the buffer.
std::out_of_range | If the buffer run out of space. |
Definition at line 65 of file circular_buffer.h.
Referenced by mrpt::hwdrivers::CGPSInterface::doProcess(), mrpt::hwdrivers::CHokuyoURG::ensureBufferHasBytes(), mrpt::comms::CInterfaceFTDI::Read(), and TEST().
|
inline |
Insert a reference of the given element in the buffer.
std::out_of_range | If the buffer run out of space. |
Definition at line 53 of file circular_buffer.h.
|
inline |
Return the number of elements available for read ("pop") in the buffer (this is NOT the maximum size of the internal buffer)
Definition at line 143 of file circular_buffer.h.
Referenced by mrpt::containers::circular_buffer< uint8_t >::available(), mrpt::hwdrivers::CHokuyoURG::ensureBufferHasBytes(), mrpt::hwdrivers::CGPSInterface::parseBuffer(), mrpt::containers::circular_buffer< uint8_t >::peek(), mrpt::comms::CInterfaceFTDI::Read(), and TEST().
|
private |
Definition at line 25 of file circular_buffer.h.
Referenced by mrpt::containers::circular_buffer< uint8_t >::peek(), mrpt::containers::circular_buffer< uint8_t >::peek_many(), mrpt::containers::circular_buffer< uint8_t >::pop(), mrpt::containers::circular_buffer< uint8_t >::push(), and mrpt::containers::circular_buffer< uint8_t >::push_ref().
|
private |
Definition at line 28 of file circular_buffer.h.
Referenced by mrpt::containers::circular_buffer< uint8_t >::clear(), mrpt::containers::circular_buffer< uint8_t >::peek(), mrpt::containers::circular_buffer< uint8_t >::peek_many(), mrpt::containers::circular_buffer< uint8_t >::pop(), mrpt::containers::circular_buffer< uint8_t >::push(), mrpt::containers::circular_buffer< uint8_t >::push_ref(), and mrpt::containers::circular_buffer< uint8_t >::size().
|
private |
Definition at line 28 of file circular_buffer.h.
Referenced by mrpt::containers::circular_buffer< uint8_t >::clear(), mrpt::containers::circular_buffer< uint8_t >::peek(), mrpt::containers::circular_buffer< uint8_t >::peek_many(), mrpt::containers::circular_buffer< uint8_t >::pop(), mrpt::containers::circular_buffer< uint8_t >::push(), mrpt::containers::circular_buffer< uint8_t >::push_ref(), and mrpt::containers::circular_buffer< uint8_t >::size().
|
private |
not "const" to allow copy/move = ops.
Definition at line 27 of file circular_buffer.h.
Referenced by mrpt::containers::circular_buffer< uint8_t >::capacity(), mrpt::containers::circular_buffer< uint8_t >::circular_buffer(), mrpt::containers::circular_buffer< uint8_t >::peek(), mrpt::containers::circular_buffer< uint8_t >::peek_many(), mrpt::containers::circular_buffer< uint8_t >::pop(), mrpt::containers::circular_buffer< uint8_t >::push(), mrpt::containers::circular_buffer< uint8_t >::push_ref(), and mrpt::containers::circular_buffer< uint8_t >::size().
Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020 |