diff --git a/src/vscp/common/mdf.cpp b/src/vscp/common/mdf.cpp index 3e7e0c8da..29b79ccb1 100644 --- a/src/vscp/common/mdf.cpp +++ b/src/vscp/common/mdf.cpp @@ -704,7 +704,7 @@ CMDF_Action::clearStorage(void) } /////////////////////////////////////////////////////////////////////////////// -// getAction +// getActionParam // CMDF_ActionParameter * @@ -721,6 +721,27 @@ CMDF_Action::getActionParam(uint16_t offset) return nullptr; } +/////////////////////////////////////////////////////////////////////////////// +// addActionParam +// + +bool +CMDF_Action::addActionParam(CMDF_ActionParameter *pactionparam) +{ + // Check pointer + if (nullptr == pactionparam) { + return false; + } + + // Offset must be unique + if (nullptr != getActionParam(pactionparam->getOffset())) { + return false; + } + + m_list_ActionParameter.push_back(pactionparam); + return true; +} + /////////////////////////////////////////////////////////////////////////////// // Constructor/Destructor // diff --git a/src/vscp/common/mdf.h b/src/vscp/common/mdf.h index 49f5c6d94..7027c68a4 100644 --- a/src/vscp/common/mdf.h +++ b/src/vscp/common/mdf.h @@ -124,6 +124,7 @@ typedef enum mdf_record_type { mdf_type_action_sub_item, mdf_type_action_param, mdf_type_action_param_item, + mdf_type_action_param_sub_item, mdf_type_event, mdf_type_event_item, mdf_type_event_data, @@ -1271,6 +1272,14 @@ class CMDF_Action : public CMDF_Object { */ CMDF_ActionParameter *getActionParam(uint16_t offset); + /*! + Add action parameter + @param pactionparam Pointer to action parameter to add. The offset + of the action parameter must be unique. + @return true on success, false otherwise. + */ + bool addActionParam(CMDF_ActionParameter *pactionparam); + /*! Get action parameter list @return Action parameter list @@ -1392,7 +1401,7 @@ class CMDF_DecisionMatrix : public CMDF_Object { std::deque *getActionList(void) { return &m_list_action; }; /*! - Get pointer to action object from its code + Get pointer to action object from 6its code @param code Code for action to fetch @return Pointer to action or nullptr if no action with that code is found. */