This class emulates table storage. This table is created without dynamic allocation. Rows in table are represented by RowT.
More...
|
| MicroTable (const uint32_t rowLife) |
| Constructor. More...
|
|
const RowT & | get (int16_t index) const |
| Gets row from table by index. More...
|
|
RowT | get (int16_t index) |
| Gets row from table by index. More...
|
|
const RowT & | operator[] (int16_t index) const |
| Gets row from table by index. More...
|
|
RowT | operator[] (int16_t index) |
| Gets row from table by index. More...
|
|
bool | set (int16_t index, const RowT &row) |
| Sets row values in table. Row life time is set to maximum. More...
|
|
bool | set (int16_t index, const RowT &row, int16_t rawLifeTime_) |
| Sets row values in table. More...
|
|
bool | remove (const RowT &rowRef) |
| Removes first row, which is equal to rowRef. More...
|
|
bool | remove (int16_t index) |
| Removes row at index. More...
|
|
void | clear () |
| Removes all rows data. More...
|
|
void | validate () |
| Decreases all valid column values in specified interval (row lifetime). If valid value is 0, row will not be longer valid. More...
|
|
bool | setRawRemainingLifeTime (int16_t index, uint8_t rawLifeTime_=255) |
| Sets row life time. Valid counter for this rowcan be changed, only when row is still valid. More...
|
|
virtual int16_t | getIndexOf (const RowT &rowRef) const |
| Gets index of row which is equal to rowRef. More...
|
|
int16_t | getFirstBlankRowIndex (int16_t startPos=0) const |
| Gets index of first blank row. More...
|
|
int16_t | getOldestRowIndex () const |
| Gets index of first oldest row. More...
|
|
bool | exists (int16_t index) const |
| Checks if row at specified index exists in table. More...
|
|
bool | exists (const RowT &rowRef) const |
| Checks if any row, which is equal to rowRef exists in table. More...
|
|
bool | isRowBlank (int16_t index) const |
| Checks if row is blank or not. Row, that is not valid is blank. More...
|
|
int16_t | size () const |
| Gets capacity of table in rows. More...
|
|
int16_t | count () const |
| Gets number of used rows in buffer. More...
|
|
uint8_t | getMaxRowLifeTime () const |
| Gets the maximum row life time in millisseconds. More...
|
|
int16_t | getRealUsedSize () const |
| Gets real used count of rows in table. This value is calculated like this: last_used_row_index + 1. More...
|
|
template<class = typename std::enable_if<!IndexIsValue>::type> |
uint8_t | getFragmentation () const |
| Calculates fragmentation in %. Fragmentation is calculated like this: (getRealUsedSize() - count())/getRealUsedSize() More...
|
|
template<class = typename std::enable_if<!IndexIsValue>::type> |
void | defragment () |
| Removes blank spaces between rows. Call this to speed up searching when buffer is fragmented. More...
|
|
uint32_t | getRowRemainingLifeTime (int16_t index) const |
| Gets selected row's remaining life time in milliseconds. More...
|
|
uint8_t | getRawRowRemainingLifeTime (int16_t index) const |
| Gets selected row's raw remaining life time. More...
|
|
uint32_t | getLifeTimeResolution () const |
| Gets life time resolution in milliseconds. More...
|
|
uint8_t | convertLifeTimeToRaw (uint32_t lifeTime) const |
| Converts life time in milliseconds to raw life time value. Value is rounded up. More...
|
|
uint32_t | convertRawToLifeTime (uint8_t rawLifeTime) const |
| Converts raw life time value to life time in milliseconds. Value is aproximate. To get accurate result, use getRowRemainingLifeTime() method. More...
|
|
virtual size_t | getRawDataSize () const |
| Calculates, how many bytes will be printed, when using command printRaw. More...
|
|
virtual size_t | printRaw (OSTREAM &stream, const char tableIdentifier[4]) const |
| Prints raw table data through stream. Those data can be decoded in PC or in another MCU. More...
|
|
size_t | print (OSTREAM &stream, bool showIndexes=true, bool doNotPrintBlank=true, bool showRemainingRowLifetime=true) const |
| Prints items from table to stream. More...
|
|
size_t | printTo (Print &p) const override |
| Makes this class printable. More...
|
|
|
virtual void | onCreate (int16_t index, const RowT &newValue, uint8_t newRawLifeTime) |
| This method is called when valid row is set to blank space. It is called after count calculation is done, but before buffer is updated. More...
|
|
virtual void | onSet (int16_t index, const RowT &oldValue, uint8_t oldRawLifeTime, const RowT &newValue, uint8_t newRawLifeTime) |
| This method is called when valid row is set to new value. It is called after count calculation is done, but before buffer is updated. More...
|
|
virtual void | onRemove (int16_t index, const RowT &oldValue, uint8_t oldRawLifeTime, bool removedByValidation=false) |
| This method is called when valid row is removed. It is called after count calculation is done, but before buffer is updated. More...
|
|
virtual void | onClear () |
| This method is called when table is cleared. It is called after cleaning is done, so all variables are fresh. More...
|
|
virtual void | onRowLifeChanged (int16_t index, uint8_t old_raw, uint8_t new_raw) |
| This method is called when table is cleared. It is called after cleaning is done, so all variables are fresh. More...
|
|
template<typename RowT, int16_t RowsCount, bool IndexIsValue = false>
class MicroTable< RowT, RowsCount, IndexIsValue >
This class emulates table storage. This table is created without dynamic allocation. Rows in table are represented by RowT.
Template parameters
RowT - row type RowsCount - maximum count of rows, table capacity IndexIsValue - True if index column is taken as value. Default is false. If set to true, defragmentation cannot be done and printRow() method will contain extra parameter, where index is copyied.
RowT requirements
- RowT is class or struct
- Class has to contain method
static size_t printHeader(
OSTREAM& stream);
Which prints header to stream. Each cell has to be separated by '|' character. Printed text cannot contain '
' or '\r' characters. Make sure, that cells has same width in each columns. Count of printed characters has to be returned.
- Class has to contain method if IndexIsValue == false
size_t printRow(
OSTREAM& stream)
const;
Which prints one row to stream. Each cell has to be separated by '|' character. Printed text cannot contain '
' or '\r' characters. Make sure, that cells has same width in each columns. Count of printed characters has to be returned.
- Class has to contain method if IndexIsValue == true
size_t printRow(
OSTREAM& stream, int16_t index)
const;
Which prints one row to stream. Each cell has to be separated by '|' character. Printed text cannot contain '
' or '\r' characters. Make sure, that cells has same width in each columns. Count of printed characters has to be returned. Parameter index will contain index of row, because index is here taken as value.
- Class can contain method Which clears structure data, when data has to be removed. This member function is called only if exists.
- RowT is not class nor struct
- In that case, variable has to be printable to stream.