Adeon
Loading...
Searching...
No Matches
ItemList Class Reference

Classes

class  Item
 

Public Member Functions

ItemaddItem (const char *pId, uint16_t val)
 Add item into a list. More...
 
void deleteItem (Item *pItem)
 Delete item from a list. More...
 
void deleteHead ()
 Delete head of list. More...
 
char * editItemId (Item *pItem, const char *pNewId)
 Edit item id in a list. More...
 
void editItemVal (Item *pItem, uint16_t val)
 Edit item value in a list. More...
 
ItemfindItem (const char *pId)
 Find item in a list. More...
 
bool isInList (Item *pItem)
 Check if item is in a list. More...
 
bool isIdLenValid (const char *pId)
 Check if lingth of id is valid. More...
 
bool isListEmpty ()
 
uint8_t getNumOfItems ()
 Get number of item in a list. More...
 
uint16_t getItemVal (Item *pItem)
 Get item value. More...
 
void printData ()
 Print data from list to serial. More...
 

Protected Member Functions

 ItemList ()
 Empty constructor for the class ItemList. More...
 

Protected Attributes

Item_pHead = nullptr
 
Item_pLast = nullptr
 
uint8_t _numOfItems = 0
 

Detailed Description

Definition at line 32 of file list.h.

Constructor & Destructor Documentation

◆ ItemList()

ItemList::ItemList ( )
protected

Empty constructor for the class ItemList.

Definition at line 30 of file list.cpp.

Member Function Documentation

◆ addItem()

ItemList::Item * ItemList::addItem ( const char *  pId,
uint16_t  val 
)

Add item into a list.

Parameters
pIdis pointer to costant id string.
valis value of item.
Returns
pItem is pointer to new created object

At the beginning is checked validity of id. Than is called Item class constructor which create new item in list.

Definition at line 43 of file list.cpp.

◆ deleteHead()

void ItemList::deleteHead ( )

Delete head of list.

If head of list is null the linking to list is lost – list deleted.

Definition at line 102 of file list.cpp.

◆ deleteItem()

void ItemList::deleteItem ( Item pItem)

Delete item from a list.

Parameters
pItemis pointer to object Item.

At the beginning is checked if pointer to object is not null. If item is not pHead (pointer to first item in list) than the pNext pointer of deleted object is saved into pNext pointer of previous object in list.

Definition at line 72 of file list.cpp.

◆ editItemId()

char * ItemList::editItemId ( Item pItem,
const char *  pNewId 
)

Edit item id in a list.

Parameters
pItemis pointer to object Item.
pNewIdis pointer to new item id.
Returns
pItem->id which is pointer to new id string

Definition at line 113 of file list.cpp.

◆ editItemVal()

void ItemList::editItemVal ( Item pItem,
uint16_t  val 
)

Edit item value in a list.

Parameters
pItemis pointer to object Item.
valis new value of the item.

If pointer to callback function is not null, than call callback.

Definition at line 128 of file list.cpp.

◆ findItem()

ItemList::Item * ItemList::findItem ( const char *  pId)

Find item in a list.

Parameters
pIdis pointer to item id.
Returns
pItem which is a pointer to object item (null if id is not valid).

Definition at line 142 of file list.cpp.

◆ getItemVal()

uint16_t ItemList::getItemVal ( Item pItem)

Get item value.

Returns
pItem->value (0 if item object is null)

Definition at line 191 of file list.cpp.

◆ getNumOfItems()

uint8_t ItemList::getNumOfItems ( )

Get number of item in a list.

Returns
_numOfItems

Definition at line 183 of file list.cpp.

◆ isIdLenValid()

bool ItemList::isIdLenValid ( const char *  pId)

Check if lingth of id is valid.

Parameters
pIdis pointer to item id.
Returns
true if lingth of id is valid, false otherwise.

Definition at line 171 of file list.cpp.

◆ isInList()

bool ItemList::isInList ( Item pItem)

Check if item is in a list.

Parameters
pItemis pointer to object Item.
valis new value of the item. *
Returns
true if item is in the list, false otherwise.

Definition at line 162 of file list.cpp.

◆ isListEmpty()

bool ItemList::isListEmpty ( )

Definition at line 175 of file list.cpp.

◆ printData()

void ItemList::printData ( )

Print data from list to serial.

It is functional only if user calls Serial.begin(baudrate) in a setup.

Definition at line 203 of file list.cpp.

Member Data Documentation

◆ _numOfItems

uint8_t ItemList::_numOfItems = 0
protected

Definition at line 54 of file list.h.

◆ _pHead

Item* ItemList::_pHead = nullptr
protected

Definition at line 52 of file list.h.

◆ _pLast

Item* ItemList::_pLast = nullptr
protected

Definition at line 53 of file list.h.


The documentation for this class was generated from the following files: