diff --git a/src/vscp/common/mdf.cpp b/src/vscp/common/mdf.cpp index 29b79ccb1..a5513e866 100644 --- a/src/vscp/common/mdf.cpp +++ b/src/vscp/common/mdf.cpp @@ -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::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 // diff --git a/src/vscp/common/mdf.h b/src/vscp/common/mdf.h index 7027c68a4..88bb1e831 100644 --- a/src/vscp/common/mdf.h +++ b/src/vscp/common/mdf.h @@ -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