Hopsan
ParameterEvaluatorHandler Class Reference

Public Member Functions

 ParameterEvaluatorHandler (Component *pComponent)
 Constructor.
 
 ~ParameterEvaluatorHandler ()
 Destructor.
 
bool addParameter (const HString &rName, const HString &rValue, const HString &rDescription, const HString &rQuantity, const HString &rUnit, const HString &rType, void *pData=0, bool internal=false, bool force=false, std::vector< HString > conditions=std::vector< HString >())
 Add a new parameter.
 
void deleteParameter (const HString &rName)
 Deletes a parameter.
 
bool renameParameter (const HString &rOldName, const HString &rNewName)
 Rename a parameter (only useful for system parameters)
 
const std::vector< ParameterEvaluator * > * getParametersVectorPtr () const
 
const ParameterEvaluatorgetParameter (const HString &rName) const
 
void getParameterNames (std::vector< HString > &rParameterNames)
 
bool setParameter (const HString &rName, const HString &rValue, const HString &rDescription="", const HString &rQuantity="", const HString &rUnit="", const HString &rType="", const bool internal=false, const bool force=false)
 
void getParameterValue (const HString &rName, HString &rValue)
 Get the value of specified parameter.
 
bool setParameterValue (const HString &rName, const HString &rValue, bool force=false)
 Set the parameter value for an existing parameter.
 
void * getParameterDataPtr (const HString &rName)
 Returns a pointer directly to the parameter data variable.
 
bool refreshParameterValueText (const HString &rParameterName)
 
bool evaluateParameters ()
 Evaluate all parameters.
 
bool evaluateInComponent (const HString &rName, HString &rEvaluatedParameterValue, const HString &rType)
 Evaluate a specific parameter.
 
bool evaluateRecursivelyInSystemParents (const HString &rName, HString &rEvaluatedParameterValue, const HString &rType)
 
bool evaluateParameterExpression (const HString &rExpression, HString &rEvaluatedParameterValue)
 
bool hasParameter (const HString &rName) const
 Check if a parameter with given name exist among the parameters.
 
bool checkParameters (HString &rErrParName)
 Check all parameters that need evaluation are able to be evaluated.
 
void setParameterTriggersReconfiguration (const HString &rParameterName)
 
bool parameterTriggersReconfiguration (const HString &rParameterName)
 
ComponentgetComponent () const
 

Protected Attributes

ComponentmComponent
 
std::vector< ParameterEvaluator * > mParameters
 
std::vector< ParameterEvaluator * > mParametersNeedEvaluation
 

Constructor & Destructor Documentation

◆ ParameterEvaluatorHandler()

Constructor.

Parameters
[in]pParentComponentA pointer to the Component that contains the Parameters

Member Function Documentation

◆ addParameter()

bool addParameter ( const HString & rName,
const HString & rValue,
const HString & rDescription,
const HString & rQuantity,
const HString & rUnit,
const HString & rType,
void * pData = 0,
bool internal = false,
bool force = false,
std::vector< HString > conditions = std::vector<HString>() )

Add a new parameter.

Parameters
[in]rNameThe desired parameter name, e.g. m
[in]rValueThe value of the parameter, always a string
[in]rDescriptionThe description of the parameter e.g. Mass
[in]rQuantityThe physical quantity of the parameter e.g. mass
[in]rUnitThe physical unit of the parameter e.g. kg
[in]rTypeThe type of the parameter e.g. double
[in]pDataOnly used by Components, system parameters don't use this, default: 0
[in]forceShould we force to add parameter even if it fails to evaluate
[in]conditionsConditions for a conditional constant parameter
Returns
true if success, otherwise false

◆ checkParameters()

bool checkParameters ( HString & rErrParName)

Check all parameters that need evaluation are able to be evaluated.

Parameters
[out]rErrParNameThe name of the parameter that could not be evaluated
Returns
true if success, otherwise false

Check all parameters that need evaluation are able to be evaluated. The function will stop as soon as one parameter turns out to be faulty. So in the case of many bad parameters only the name of the first one is returned.

◆ deleteParameter()

void deleteParameter ( const HString & rName)

Deletes a parameter.

Parameters
[in]rNameThe name of the parameter to delete

◆ evaluateInComponent()

bool evaluateInComponent ( const HString & rName,
HString & rEvaluatedParameterValue,
const HString & rType )

Evaluate a specific parameter.

Parameters
[in]rNameThe name of the parameter to be evaluated
[out]rEvaluatedParameterValueThe result of the evaluation
[in]rTypeThe type of how the parameter should be interpreted
Returns
true if success, otherwise false

◆ evaluateParameterExpression()

bool evaluateParameterExpression ( const HString & rExpression,
HString & rEvaluatedParameterValue )

◆ evaluateParameters()

bool evaluateParameters ( )

Evaluate all parameters.

Returns
true if success, otherwise false

◆ getParameterDataPtr()

void * getParameterDataPtr ( const HString & rName)

Returns a pointer directly to the parameter data variable.

Warning
Don't use this function unless YOU REALLY KNOW WHAT YOU ARE DOING

◆ getParameterValue()

void getParameterValue ( const HString & rName,
HString & rValue )

Get the value of specified parameter.

Parameters
[in]rNameThe parameter name to get value of
[out]rValueReference to the string variable that will contain the parameter value. The variable will be "" if parameter not found

◆ hasParameter()

bool hasParameter ( const HString & rName) const

Check if a parameter with given name exist among the parameters.

Parameters
[in]rNameThe name of the parameter to check for
Returns
true if found else false

◆ renameParameter()

bool renameParameter ( const HString & rOldName,
const HString & rNewName )

Rename a parameter (only useful for system parameters)

◆ setParameterValue()

bool setParameterValue ( const HString & rName,
const HString & rValue,
bool force = false )

Set the parameter value for an existing parameter.

Parameters
[in]rNameThe name of the parameter to be set
[in]rValueThe new value for the parameter
[in]forceShould we force the value to be set
Returns
true if success, otherwise false