Skip to content

Commit

Permalink
Added method to get specidic action and actionparameter
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed Jan 26, 2024
1 parent 5991482 commit caeab19
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/vscp/common/mdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ CMDF_ActionParameter::CMDF_ActionParameter()
m_name.clear();
m_offset = 0;
m_min = 0;
m_max = 0;
m_max = 255;
}

CMDF_ActionParameter::~CMDF_ActionParameter()
Expand Down Expand Up @@ -703,6 +703,24 @@ CMDF_Action::clearStorage(void)
m_mapInfoURL.clear();
}

///////////////////////////////////////////////////////////////////////////////
// getAction
//

CMDF_ActionParameter *
CMDF_Action::getActionParam(uint16_t offset)
{
std::deque<CMDF_ActionParameter *>::iterator it;
for (it = m_list_ActionParameter.begin(); it != m_list_ActionParameter.end(); ++it) {
CMDF_ActionParameter *pActionParam = *it;
printf("offset=%d\n", pActionParam->getOffset());
if ((nullptr != pActionParam) && (offset == pActionParam->getOffset())) {
return pActionParam;
}
}
return nullptr;
}

///////////////////////////////////////////////////////////////////////////////
// Constructor/Destructor
//
Expand Down Expand Up @@ -738,6 +756,24 @@ CMDF_DecisionMatrix::clearStorage()
m_list_action.clear();
}

///////////////////////////////////////////////////////////////////////////////
// getAction
//

CMDF_Action *
CMDF_DecisionMatrix::getAction(uint16_t code)
{
std::deque<CMDF_Action *>::iterator it;
for (it = m_list_action.begin(); it != m_list_action.end(); ++it) {
CMDF_Action *pAction = *it;
printf("code=%d\n", pAction->getCode());
if ((nullptr != pAction) && (code == pAction->getCode())) {
return pAction;
}
}
return nullptr;
}

///////////////////////////////////////////////////////////////////////////////
// Constructor/Destructor
//
Expand Down
16 changes: 16 additions & 0 deletions src/vscp/common/mdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,12 @@ typedef enum mdf_record_type {
mdf_type_remotevar_item,
mdf_type_remotevar_sub_item,
mdf_type_decision_matrix,
mdf_type_decision_matrix_item,
mdf_type_action,
mdf_type_action_item,
mdf_type_action_sub_item,
mdf_type_action_param,
mdf_type_action_param_item,
mdf_type_event,
mdf_type_event_item,
mdf_type_event_data,
Expand Down Expand Up @@ -1262,6 +1264,13 @@ class CMDF_Action : public CMDF_Object {
*/
void setCode(uint16_t code) { m_code = code; };

/*!
Get pointer to action parameter object from its offset
@param code Offset for action parameter to fetch
@return Pointer to action parameter object or nullptr if no action parameter with that offset is found.
*/
CMDF_ActionParameter *getActionParam(uint16_t offset);

/*!
Get action parameter list
@return Action parameter list
Expand Down Expand Up @@ -1382,6 +1391,13 @@ class CMDF_DecisionMatrix : public CMDF_Object {
*/
std::deque<CMDF_Action *> *getActionList(void) { return &m_list_action; };

/*!
Get pointer to action object from its code
@param code Code for action to fetch
@return Pointer to action or nullptr if no action with that code is found.
*/
CMDF_Action *getAction(uint16_t code);

// int getRegister(uint8_t row, CMDF_DecisionMatrix__dmindex idx);

private:
Expand Down

0 comments on commit caeab19

Please sign in to comment.