Skip to content

Commit

Permalink
Added two methods to delete action parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed Feb 5, 2024
1 parent 4d9a13c commit f860a0c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/vscp/common/mdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,47 @@ CMDF_Action::addActionParam(CMDF_ActionParameter *pactionparam)
return true;
}

///////////////////////////////////////////////////////////////////////////////
// deleteActionParam
//

bool
CMDF_Action::deleteActionParam(CMDF_ActionParameter *pactionparam)
{
if (nullptr == pactionparam) {
return false;
}

std::deque<CMDF_ActionParameter *>::iterator it;
for (auto it = m_list_ActionParameter.begin();
it != m_list_ActionParameter.end();
++it) {
if (pactionparam->getOffset() == (*it)->getOffset()) {
m_list_ActionParameter.erase(it);
delete pactionparam;
return true;
}
}

return false;
}

bool
CMDF_Action::deleteActionParam(uint8_t offset)
{
for (auto it = m_list_ActionParameter.begin();
it != m_list_ActionParameter.end();
++it) {
if (offset == (*it)->getOffset()) {
m_list_ActionParameter.erase(it);
delete *it;
return true;
}
}

return false;
}

///////////////////////////////////////////////////////////////////////////////
// Constructor/Destructor
//
Expand Down
14 changes: 14 additions & 0 deletions src/vscp/common/mdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,20 @@ class CMDF_Action : public CMDF_Object {
*/
bool addActionParam(CMDF_ActionParameter *pactionparam);

/*!
Delete action parameter
@param pactionparam Pointer to action parameter to delete
@return true on success, false on failure.
*/
bool deleteActionParam(CMDF_ActionParameter *pactionparam);

/*!
Delete action parameter
@param offset Offset of action parametewr to delete.
@return true on success, false on failure.
*/
bool deleteActionParam(uint8_t offset);

/*!
Get action parameter list
@return Action parameter list
Expand Down

0 comments on commit f860a0c

Please sign in to comment.