aqhome-react: make more functions virtual.
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "./aqhome_react_p.h"
|
#include "./aqhome_react_p.h"
|
||||||
#include "aqhome-react/units/u_or.h"
|
#include "aqhome-react/units/u_logical.h"
|
||||||
#include "aqhome-react/units/u_valuefilter.h"
|
#include "aqhome-react/units/u_valuefilter.h"
|
||||||
#include "aqhome-react/units/u_valueset.h"
|
#include "aqhome-react/units/u_valueset.h"
|
||||||
#include "aqhome-react/units/u_stabilize.h"
|
#include "aqhome-react/units/u_stabilize.h"
|
||||||
@@ -193,6 +193,10 @@ AQHREACT_UNIT *AqHomeReact_CreateUnitByName(AQHOME_REACT *aqh, const char *unitT
|
|||||||
if (aqh && unitType && *unitType) {
|
if (aqh && unitType && *unitType) {
|
||||||
if (strcasecmp(unitType, "or")==0)
|
if (strcasecmp(unitType, "or")==0)
|
||||||
return AqHomeReact_UnitOr_new(aqh);
|
return AqHomeReact_UnitOr_new(aqh);
|
||||||
|
else if (strcasecmp(unitType, "and")==0)
|
||||||
|
return AqHomeReact_UnitAnd_new(aqh);
|
||||||
|
else if (strcasecmp(unitType, "xor")==0)
|
||||||
|
return AqHomeReact_UnitXor_new(aqh);
|
||||||
else if (strcasecmp(unitType, "valueFilter")==0)
|
else if (strcasecmp(unitType, "valueFilter")==0)
|
||||||
return AqHomeReact_UnitValueFilter_new(aqh);
|
return AqHomeReact_UnitValueFilter_new(aqh);
|
||||||
else if (strcasecmp(unitType, "valueSet")==0)
|
else if (strcasecmp(unitType, "valueSet")==0)
|
||||||
|
|||||||
@@ -221,20 +221,26 @@ void AQHREACT_Unit_AddParam(AQHREACT_UNIT *unit, AQHREACT_PARAM *param)
|
|||||||
|
|
||||||
AQHREACT_PARAM *AQHREACT_Unit_GetParamByName(const AQHREACT_UNIT *unit, const char *paramName)
|
AQHREACT_PARAM *AQHREACT_Unit_GetParamByName(const AQHREACT_UNIT *unit, const char *paramName)
|
||||||
{
|
{
|
||||||
if (unit && unit->paramList && paramName && *paramName) {
|
if (unit) {
|
||||||
AQHREACT_PARAM *param;
|
if (unit->getParamByNameFn)
|
||||||
|
return unit->getParamByNameFn(unit, paramName);
|
||||||
|
else {
|
||||||
|
if (unit->paramList && paramName && *paramName) {
|
||||||
|
AQHREACT_PARAM *param;
|
||||||
|
|
||||||
param=AQHREACT_Param_List_First(unit->paramList);
|
param=AQHREACT_Param_List_First(unit->paramList);
|
||||||
while(param) {
|
while(param) {
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
s=AQHREACT_Param_GetName(param);
|
s=AQHREACT_Param_GetName(param);
|
||||||
if (s && *s && strcasecmp(paramName, s)==0)
|
if (s && *s && strcasecmp(paramName, s)==0)
|
||||||
return param;
|
return param;
|
||||||
param=AQHREACT_Param_List_Next(param);
|
param=AQHREACT_Param_List_Next(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
} /* else */
|
||||||
|
} /* if (unit) */
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -335,6 +341,34 @@ AQHREACT_UNIT_INPUTDATA_FN AQHREACT_Unit_SetInputDataFn(AQHREACT_UNIT *unit, AQH
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_UNIT_OUTPUTDATA_FN AQHREACT_Unit_SetOutputDataFn(AQHREACT_UNIT *unit, AQHREACT_UNIT_OUTPUTDATA_FN f)
|
||||||
|
{
|
||||||
|
if (unit) {
|
||||||
|
AQHREACT_UNIT_OUTPUTDATA_FN oldFn;
|
||||||
|
|
||||||
|
oldFn=unit->outputDataFn;
|
||||||
|
unit->outputDataFn=f;
|
||||||
|
return oldFn;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_UNIT_GETPARAMBYNAME_FN AQHREACT_Unit_SetGetParamByNameFn(AQHREACT_UNIT *unit, AQHREACT_UNIT_GETPARAMBYNAME_FN f)
|
||||||
|
{
|
||||||
|
if (unit) {
|
||||||
|
AQHREACT_UNIT_GETPARAMBYNAME_FN oldFn;
|
||||||
|
|
||||||
|
oldFn=unit->getParamByNameFn;
|
||||||
|
unit->getParamByNameFn=f;
|
||||||
|
return oldFn;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AQHREACT_UNIT_PROCESS_FN AQHREACT_Unit_SetProcessFn(AQHREACT_UNIT *unit, AQHREACT_UNIT_PROCESS_FN f)
|
AQHREACT_UNIT_PROCESS_FN AQHREACT_Unit_SetProcessFn(AQHREACT_UNIT *unit, AQHREACT_UNIT_PROCESS_FN f)
|
||||||
{
|
{
|
||||||
if (unit) {
|
if (unit) {
|
||||||
@@ -351,34 +385,40 @@ AQHREACT_UNIT_PROCESS_FN AQHREACT_Unit_SetProcessFn(AQHREACT_UNIT *unit, AQHREAC
|
|||||||
|
|
||||||
void AQHREACT_Unit_OutputData(AQHREACT_UNIT *unit, int slotIdForUnit, const AQHREACT_DATAOBJECT *dataObject)
|
void AQHREACT_Unit_OutputData(AQHREACT_UNIT *unit, int slotIdForUnit, const AQHREACT_DATAOBJECT *dataObject)
|
||||||
{
|
{
|
||||||
if (unit && unit->outputSlotList) {
|
if (unit) {
|
||||||
AQHREACT_OUTPUT_SLOT *slot;
|
if (unit->outputDataFn)
|
||||||
|
(unit->outputDataFn)(unit, slotIdForUnit, dataObject);
|
||||||
|
else {
|
||||||
|
if (unit->outputSlotList) {
|
||||||
|
AQHREACT_OUTPUT_SLOT *slot;
|
||||||
|
|
||||||
slot=AQHREACT_Unit_GetOutputSlotByIdForUnit(unit, slotIdForUnit);
|
slot=AQHREACT_Unit_GetOutputSlotByIdForUnit(unit, slotIdForUnit);
|
||||||
if (slot) {
|
if (slot) {
|
||||||
AQHREACT_LINK_LIST *linkList;
|
AQHREACT_LINK_LIST *linkList;
|
||||||
|
|
||||||
linkList=AQHREACT_OutputSlot_GetLinkList(slot);
|
linkList=AQHREACT_OutputSlot_GetLinkList(slot);
|
||||||
if (linkList) {
|
if (linkList) {
|
||||||
AQHREACT_LINK *lnk;
|
AQHREACT_LINK *lnk;
|
||||||
|
|
||||||
lnk=AQHREACT_Link_List_First(linkList);
|
lnk=AQHREACT_Link_List_First(linkList);
|
||||||
while(lnk) {
|
while(lnk) {
|
||||||
AQHREACT_UNIT *targetUnit;
|
AQHREACT_UNIT *targetUnit;
|
||||||
int targetSlotIdForUnit;
|
int targetSlotIdForUnit;
|
||||||
|
|
||||||
targetUnit=AQHREACT_Link_GetTargetUnit(lnk);
|
targetUnit=AQHREACT_Link_GetTargetUnit(lnk);
|
||||||
targetSlotIdForUnit=AQHREACT_Link_GetTargetInputSlotIdForUnit(lnk);
|
targetSlotIdForUnit=AQHREACT_Link_GetTargetInputSlotIdForUnit(lnk);
|
||||||
if (targetUnit && targetSlotIdForUnit>=0) {
|
if (targetUnit && targetSlotIdForUnit>=0) {
|
||||||
DBG_DEBUG(NULL, "%s: Sending data to %s:%d",
|
DBG_DEBUG(NULL, "%s: Sending data to %s:%d",
|
||||||
AQHREACT_Unit_GetId(unit),
|
AQHREACT_Unit_GetId(unit),
|
||||||
AQHREACT_Link_GetTargetUnitId(lnk), AQHREACT_Link_GetTargetInputSlotIdForUnit(lnk));
|
AQHREACT_Link_GetTargetUnitId(lnk), AQHREACT_Link_GetTargetInputSlotIdForUnit(lnk));
|
||||||
AQHREACT_Unit_InputData(targetUnit, targetSlotIdForUnit, dataObject);
|
AQHREACT_Unit_InputData(targetUnit, targetSlotIdForUnit, dataObject);
|
||||||
}
|
}
|
||||||
lnk=AQHREACT_Link_List_Next(lnk);
|
lnk=AQHREACT_Link_List_Next(lnk);
|
||||||
} /* while */
|
} /* while */
|
||||||
} /* if linkList */
|
} /* if linkList */
|
||||||
} /* if slot */
|
} /* if slot */
|
||||||
|
} /* if output slot list */
|
||||||
|
} /* else */
|
||||||
} /* if unit */
|
} /* if unit */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ GWEN_INHERIT_FUNCTION_DEFS(AQHREACT_UNIT)
|
|||||||
|
|
||||||
|
|
||||||
typedef void (*AQHREACT_UNIT_INPUTDATA_FN)(AQHREACT_UNIT *unit, int slotIdForUnit, const AQHREACT_DATAOBJECT *dataObject);
|
typedef void (*AQHREACT_UNIT_INPUTDATA_FN)(AQHREACT_UNIT *unit, int slotIdForUnit, const AQHREACT_DATAOBJECT *dataObject);
|
||||||
|
typedef void (*AQHREACT_UNIT_OUTPUTDATA_FN)(AQHREACT_UNIT *unit, int slotIdForUnit, const AQHREACT_DATAOBJECT *dataObject);
|
||||||
|
typedef AQHREACT_PARAM* (*AQHREACT_UNIT_GETPARAMBYNAME_FN)(const AQHREACT_UNIT *unit, const char *paramName);
|
||||||
typedef int (*AQHREACT_UNIT_PROCESS_FN)(AQHREACT_UNIT *unit);
|
typedef int (*AQHREACT_UNIT_PROCESS_FN)(AQHREACT_UNIT *unit);
|
||||||
|
|
||||||
|
|
||||||
@@ -87,9 +89,9 @@ void AQHREACT_Unit_SetParamValueDouble(AQHREACT_UNIT *unit, const char *paramNam
|
|||||||
const char *AQHREACT_Unit_GetParamValueString(const AQHREACT_UNIT *unit, const char *paramName, const char *defVal);
|
const char *AQHREACT_Unit_GetParamValueString(const AQHREACT_UNIT *unit, const char *paramName, const char *defVal);
|
||||||
void AQHREACT_Unit_SetParamValueString(AQHREACT_UNIT *unit, const char *paramName, const char *val);
|
void AQHREACT_Unit_SetParamValueString(AQHREACT_UNIT *unit, const char *paramName, const char *val);
|
||||||
|
|
||||||
void AQHREACT_Unit_OutputData(AQHREACT_UNIT *unit, int slotIndex, const AQHREACT_DATAOBJECT *dataObject);
|
void AQHREACT_Unit_OutputData(AQHREACT_UNIT *unit, int slotIdForUnit, const AQHREACT_DATAOBJECT *dataObject);
|
||||||
void AQHREACT_Unit_OutputDoubleData(AQHREACT_UNIT *unit, int slotIndex, double data);
|
void AQHREACT_Unit_OutputDoubleData(AQHREACT_UNIT *unit, int slotIdForUnit, double data);
|
||||||
void AQHREACT_Unit_OutputStringData(AQHREACT_UNIT *unit, int slotIndex, const char *data);
|
void AQHREACT_Unit_OutputStringData(AQHREACT_UNIT *unit, int slotIdForUnit, const char *data);
|
||||||
|
|
||||||
|
|
||||||
void AQHREACT_Unit_InputData(AQHREACT_UNIT *unit, int slotIdForUnit, const AQHREACT_DATAOBJECT *dataObject);
|
void AQHREACT_Unit_InputData(AQHREACT_UNIT *unit, int slotIdForUnit, const AQHREACT_DATAOBJECT *dataObject);
|
||||||
@@ -104,6 +106,8 @@ int AQHREACT_Unit_Process(AQHREACT_UNIT *unit);
|
|||||||
|
|
||||||
|
|
||||||
AQHREACT_UNIT_INPUTDATA_FN AQHREACT_Unit_SetInputDataFn(AQHREACT_UNIT *unit, AQHREACT_UNIT_INPUTDATA_FN f);
|
AQHREACT_UNIT_INPUTDATA_FN AQHREACT_Unit_SetInputDataFn(AQHREACT_UNIT *unit, AQHREACT_UNIT_INPUTDATA_FN f);
|
||||||
|
AQHREACT_UNIT_OUTPUTDATA_FN AQHREACT_Unit_SetOutputDataFn(AQHREACT_UNIT *unit, AQHREACT_UNIT_OUTPUTDATA_FN f);
|
||||||
|
AQHREACT_UNIT_GETPARAMBYNAME_FN AQHREACT_Unit_SetGetParamByNameFn(AQHREACT_UNIT *unit, AQHREACT_UNIT_GETPARAMBYNAME_FN f);
|
||||||
AQHREACT_UNIT_PROCESS_FN AQHREACT_Unit_SetProcessFn(AQHREACT_UNIT *unit, AQHREACT_UNIT_PROCESS_FN f);
|
AQHREACT_UNIT_PROCESS_FN AQHREACT_Unit_SetProcessFn(AQHREACT_UNIT *unit, AQHREACT_UNIT_PROCESS_FN f);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ struct AQHREACT_UNIT {
|
|||||||
AQHREACT_PARAM_LIST *paramList;
|
AQHREACT_PARAM_LIST *paramList;
|
||||||
|
|
||||||
AQHREACT_UNIT_INPUTDATA_FN inputDataFn;
|
AQHREACT_UNIT_INPUTDATA_FN inputDataFn;
|
||||||
|
AQHREACT_UNIT_OUTPUTDATA_FN outputDataFn;
|
||||||
|
AQHREACT_UNIT_GETPARAMBYNAME_FN getParamByNameFn;
|
||||||
AQHREACT_UNIT_PROCESS_FN processFn;
|
AQHREACT_UNIT_PROCESS_FN processFn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user