cc_frm: add overloaded versions of getCCItemId() and removeCCItem()

Allows to use with item name as parameter.
Note: Requires that unique names are assigned!


Origin commit data
------------------
Branch: ni/coolstream
Commit: 2ef4f86aa4
Author: Thilo Graf <dbt@novatux.de>
Date: 2020-01-18 (Sat, 18 Jan 2020)



------------------
This commit was generated by Migit
This commit is contained in:
2020-01-18 00:10:20 +01:00
committed by vanhofen
parent 1efd877df1
commit a8f08a4439
2 changed files with 46 additions and 2 deletions

View File

@@ -240,6 +240,16 @@ int CComponentsForm::getCCItemId(CComponentsItem* cc_Item) const
return -1;
}
int CComponentsForm::getCCItemId(const std::string &item_name) const
{
if (!item_name.empty()){
for (size_t i= 0; i< v_cc_items.size(); i++)
if (v_cc_items.at(i)->getItemName() == item_name)
return i;
}
return -1;
}
int CComponentsForm::genIndex()
{
int count = v_cc_items.size();
@@ -339,6 +349,12 @@ void CComponentsForm::removeCCItem(CComponentsItem* cc_Item)
removeCCItem(id);
}
void CComponentsForm::removeCCItem(const std::string &item_name)
{
uint id = getCCItemId(item_name);
removeCCItem(id);
}
void CComponentsForm::exchangeCCItem(const uint& cc_item_id_a, const uint& cc_item_id_b)
{
if (!v_cc_items.empty())

View File

@@ -100,11 +100,27 @@ class CComponentsForm : public CComponentsItem
int addCCItem(const std::vector<CComponentsItem*> &cc_items);
void insertCCItem(const uint& cc_item_id, CComponentsItem* cc_Item);
///removes item object from container and deallocates instance
/**Function to remove item from item collection and deallocates instance.
* @param[in] cc_item_id
* @li item id as unsigned int
*/
void removeCCItem(const uint& cc_item_id);
///removes item object from container and deallocates instance
/**Function to remove item from item collection and deallocates instance.
* @param[in] cc_Item
* @li CComponentsItem*
*/
void removeCCItem(CComponentsItem* cc_Item);
/**Function to remove item from item collection and deallocates instance.
* @param[in] item_name
* @li std::string
* NOTE: Requires that unique names are assigned!
* @see
* getItemName()
*/
void removeCCItem(const std::string &item_name);
void replaceCCItem(const uint& cc_item_id, CComponentsItem* new_cc_Item);
void replaceCCItem(CComponentsItem* old_cc_Item, CComponentsItem* new_cc_Item);
void exchangeCCItem(const uint& item_id_a, const uint& item_id_b);
@@ -118,6 +134,18 @@ class CComponentsForm : public CComponentsItem
*/
int getCCItemId(CComponentsItem* cc_Item) const;
/**Function to get current item id from passed item name.
* @param[in] item_name
* @li std::string
* @return
* int, in case of not found item returns -1
* NOTE: Requires that unique names are assigned!
* @see
* setItemName()
* getItemName()
*/
int getCCItemId(const std::string &item_name) const;
/**Function to get current item from item collection.
* @param[in] cc_item_id
* @li item id as unsigned int