|
MeshNet
1.0.0
|
Optimized FIFO buffer for microcontrolers. More...
#include <meshBuffers.h>


Public Member Functions | |
| const T & | front () const |
| Gets the first (oldest) item from the buffer. More... | |
| T & | front () |
| Gets the first (oldest) item from the buffer. More... | |
| const T & | back () const |
| Gets the last (newest) item from the buffer. More... | |
| T & | back () |
| Gets the last (newest) item from the buffer. More... | |
| bool | get (T &item, uint8_t index) const |
| Gets item from the buffer by index. More... | |
| const T & | operator[] (int index) const |
| Gets item from the buffer by index. More... | |
| T & | operator[] (int index) |
| Gets item from the buffer by index. More... | |
| void | push (T const &item) |
| Pushes item after last item in buffer. When buffer is full, first (oldest) item will be overwritten and lostItemsCount() will be incremented by 1. More... | |
| void | push (T &&item) |
| Pushes item after last item in buffer. When buffer is full, first (oldest) item will be overwritten and lostItemsCount() will be incremented by 1. More... | |
| T && | popMove () |
| Reads and removes first (oldest) item from the buffer. When buffer is empty, exception may be thrown. This method is recommended to use only if std::move will be used. More... | |
| bool | pop () |
| Removes first (oldest) item from the buffer. More... | |
| bool | empty () const |
| Checks if buffer is empty. More... | |
| uint8_t | count () const |
| Gets how many items are stored in buffer. More... | |
| const uint8_t | size () const |
| Gets maximum count of items, that can be stored in buffer. More... | |
| uint8_t | lostItemsCount () const |
| void | restartLostItemsCounter () |
| Restarts lostItemsCount counter. More... | |
| bool | removeAt (uint8_t index) |
| Removes item at specified index. After removing, count() will return new value. More... | |
| uint8_t | removeMulti (uint8_t startPos_, uint8_t itmCount) |
| Removes number of item from specified index. After removing, count() will return new value. More... | |
| uint8_t | removeIf (bool(*dec)(const T &)) |
| Removes specified items. More... | |
| void | clear () |
| Clears whole buffer. More... | |
| size_t | getRawDataSize () const |
| Calculates, how many bytes will be printed, when using command printRaw. More... | |
| virtual size_t | printRaw (OSTREAM &stream, const char *customTag) |
| Prints raw FIFO data through stream. Those data can be decoded in PC or in another MCU. More... | |
| virtual size_t | print (OSTREAM &stream, bool showIndexes=true) const |
| Prints items as table from FIFO buffer to stream. More... | |
| virtual size_t | sizeOf () const |
| Gets size of the whole FIFO in bytes. More... | |
| size_t | printTo (Print &p) const override |
| Makes this class printable. More... | |
Protected Member Functions | |
| int16_t | getRawIndex (uint8_t index) const |
| Gets raw index in buffer from index. Index starts from startPos. Raw index starts from the beginning of the buffer. More... | |
| const T * | getRowPtr (uint8_t index) const |
| Gets pointer to the item in buffer by index. More... | |
| T * | getRowPtr (uint8_t index) |
| Gets pointer to the item in buffer by index. More... | |
| bool | isRawIndexOccupied (uint8_t rawIndex) const |
| Checks if there is item stored at raw index. More... | |
Protected Attributes | |
| T | buffer [BufferSize] |
| uint8_t | startPos = 0 |
| uint8_t | endPos = 0 |
| uint8_t | usedSize = 0 |
| uint8_t | lostItems = 0 |
Optimized FIFO buffer for microcontrolers.
Size of the FIFO buffer in this example is 255 rows with type MeshMessage.
| index (not physically stored) | Item [T] |
|---|---|
| 0 | XXX |
| 1 | XXX |
| ... | ... |
| XXX - depends on BufferSize | XXX |
|
inline |
Gets the last (newest) item from the buffer.
|
inline |
Gets the last (newest) item from the buffer.
|
inline |
Clears whole buffer.
|
inline |
Gets how many items are stored in buffer.
|
inline |
Checks if buffer is empty.
|
inline |
Gets the first (oldest) item from the buffer.
|
inline |
Gets the first (oldest) item from the buffer.
|
inline |
Gets item from the buffer by index.
| item | Reference to item, that will be filled by data from buffer. |
| index | Index of item to get. Index 0 is the first (oldest) item from the buffer, same as using front() method. |
|
inline |
Calculates, how many bytes will be printed, when using command printRaw.
|
inlineprotected |
Gets raw index in buffer from index. Index starts from startPos. Raw index starts from the beginning of the buffer.
| index | Index to convert. |
|
inlineprotected |
Gets pointer to the item in buffer by index.
| index | Index of the item to get. |
|
inlineprotected |
Gets pointer to the item in buffer by index.
| index | Index of the item to get. |
|
inlineprotected |
Checks if there is item stored at raw index.
| Raw | index, where to check if item is stored here. Raw index starts from the beginning of the buffer. |
|
inline |
@breif Gets how many items were lost (overwrote).
|
inline |
Gets item from the buffer by index.
| index | Index of item to get. Index 0 is the first (oldest) item from the buffer, same as using front() method. |
|
inline |
Gets item from the buffer by index.
| index | Index of item to get. Index 0 is the first (oldest) item from the buffer, same as using front() method. |
|
inline |
|
inline |
Reads and removes first (oldest) item from the buffer. When buffer is empty, exception may be thrown. This method is recommended to use only if std::move will be used.
|
inlinevirtual |
Prints items as table from FIFO buffer to stream.
| stream | Stream, where data will be printed. |
| showIndexes | True to show indexes of items in printed table. |
|
inlinevirtual |
Prints raw FIFO data through stream. Those data can be decoded in PC or in another MCU.
| Byte | Data | Data name |
|---|---|---|
| 0-3 | "MFF:" | Data label (Micro FIFO). |
| 4-7 | Custom tag | |
| 7 | Allocated buffer size (Max number of rows). | |
| 8 | Size of one row in bytes. (255 = unknown, size of each row has to be stored at the begining of row data) | |
| 9 | Used rows count (length and CRC bytes not included). | |
| 10.....x | Raw data | |
| last 4 bytes | CRC-32 (excluded 0-3 bytes) |
| stream | Stream where to print raw data. |
| customTag | Custom data type tag. Maximum length is 4 characters. |
|
inlineoverride |
Makes this class printable.
| p | Stream, where to print data. |
|
inline |
Pushes item after last item in buffer. When buffer is full, first (oldest) item will be overwritten and lostItemsCount() will be incremented by 1.
| item | Item to push into buffer. |
|
inline |
Pushes item after last item in buffer. When buffer is full, first (oldest) item will be overwritten and lostItemsCount() will be incremented by 1.
| item | Item to push into buffer. |
|
inline |
Removes item at specified index. After removing, count() will return new value.
Some optimizations are done here to reduce remove time.
| index | Index of item to remove. |
|
inline |
Removes specified items.
Some optimizations are done here to reduce remove time.
| dec | Function, which returns true to remove item. |
|
inline |
Removes number of item from specified index. After removing, count() will return new value.
Some optimizations are done here to reduce remove time.
| startPos_ | Index of first item to remove. |
| itmCount | Count of items to remove (including first one). |
|
inline |
Restarts lostItemsCount counter.
|
inline |
Gets maximum count of items, that can be stored in buffer.
|
inlinevirtual |
Gets size of the whole FIFO in bytes.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
1.8.17