![]() |
MD_CirQueue Library
1.0
Library for FIFO queue implemented as a Ring Buffer
|
#include <MD_CirQueue.h>
Public Member Functions | |
MD_CirQueue (uint8_t itmQty, uint16_t itmSize) | |
~MD_CirQueue () | |
void | begin (void) |
void | clear () |
bool | push (uint8_t *itm) |
uint8_t * | pop (uint8_t *itm) |
uint8_t * | peek (uint8_t *itm) |
void | setFullOverwrite (bool b) |
bool | isEmpty (void) |
bool | isFull () |
Core object for the MD_CirQueue library
MD_CirQueue::MD_CirQueue | ( | uint8_t | itmQty, |
uint16_t | itmSize | ||
) |
Class Constructor.
Instantiate a new instance of the class. The parameters passed are used to configure the quantity and size of queue objects.
itmQty | number of items allowed in the queue. |
itmSize | size of each item in bytes. |
MD_CirQueue::~MD_CirQueue | ( | ) |
Class Destructor.
Released allocated memory and does the necessary to clean up once the queue is no longer required.
void MD_CirQueue::begin | ( | void | ) |
Initialize the object.
Initialize the object data. This needs to be called during setup() to initialize new data for the class that cannot be done during the object creation.
void MD_CirQueue::clear | ( | ) |
Clear contents of buffer
Clears the buffer by resetting the head and tail pointers. Does not zero out delete data in the buffer.
bool MD_CirQueue::isEmpty | ( | void | ) |
Check if the buffer is empty
bool MD_CirQueue::isFull | ( | ) |
Check if the buffer is full
uint8_t* MD_CirQueue::peek | ( | uint8_t * | itm | ) |
Peek at the next item in the queue
Return a copy of the first item in the queue, copied into the buffer specified, returning a pointer to the copied item. If no items are available (queue is empty), then no data is copied and the method returns a NULL pointer. This does not remove the item in the queue but gives a 'llok-ahead' capability in processing the queue.
itm | a pointer to data buffer for the copied item to be saved. Data size must be size specified in the constructor. |
uint8_t* MD_CirQueue::pop | ( | uint8_t * | itm | ) |
Pop an item from the queue
Return the first available item in the queue, copied into the buffer specified, returning a pointer to the copied item. If no items are available (queue is empty), then no data is copied and the method returns a NULL pointer.
itm | a pointer to data buffer for the retrieved item to be saved. Data size must be size specified in the constructor. |
bool MD_CirQueue::push | ( | uint8_t * | itm | ) |
Push an item into the queue
Place the item passed into the end of the queue. The item will be returned to the calling program, in FIFO order, using pop(). If the buffer is already full before the push(), the behavior will depend on the the setting controlled by the setFullOverwrite() method.
itm | a pointer to data buffer of the item to be saved. Data size must be size specified in the constructor. |
void MD_CirQueue::setFullOverwrite | ( | bool | b | ) |