Skip to content

Commit

Permalink
Added addActionParam to MDF action class
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed Feb 5, 2024
1 parent caeab19 commit 4d9a13c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
23 changes: 22 additions & 1 deletion src/vscp/common/mdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ CMDF_Action::clearStorage(void)
}

///////////////////////////////////////////////////////////////////////////////
// getAction
// getActionParam
//

CMDF_ActionParameter *
Expand All @@ -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
//
Expand Down
11 changes: 10 additions & 1 deletion src/vscp/common/mdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1392,7 +1401,7 @@ class CMDF_DecisionMatrix : public CMDF_Object {
std::deque<CMDF_Action *> *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.
*/
Expand Down

0 comments on commit 4d9a13c

Please sign in to comment.