AnimatLab
2
Test
|
Standard post fix evaluation class. More...
#include <StdPostFixEval.h>
Public Member Functions | |
CStdPostFixEval () | |
Default constructor. More... | |
virtual | ~CStdPostFixEval () |
Destructor. More... | |
void | AddVariable (std::string strVarName) |
Adds a variable. More... | |
void | Equation (std::string strVal) |
Sets the post-fix Equation. More... | |
std::string | Equation () |
Gets the post-fix equation. More... | |
void | SetVariable (std::string strVarName, double dblVal) |
Sets the value of a variable. More... | |
double | Solution () |
Gets the solution. More... | |
double | Solve () |
Solves the equation using the defined variable values. More... | |
Protected Member Functions | |
void | FillInVariables (CStdArray< std::string > &aryPostFix) |
Fill in variables. More... | |
CStdVariable * | FindVariable (std::string strVarName) |
Searches for the a variable with the specified name. More... | |
void | GetParams (double &dblLeft, double &dblRight, int iNumParams) |
Gets the parameters. More... | |
void | SavePostFixInArray (std::string &strEqu) |
Saves a post fix in array. More... | |
Protected Attributes | |
CStdArray< std::string > | m_aryPostFix |
internal array used to store the equation parts. | |
CStdStack< double > | m_aryStack |
Stack of equation parts. | |
CStdPtrArray< CStdVariable > | m_aryVariables |
Array of variables. | |
double | m_dblSolution |
The double solution value. | |
std::string | m_strEquation |
The post-fix equation. | |
Standard post fix evaluation class.
This evaluates a post-fix equation.
Definition at line 19 of file StdPostFixEval.h.
StdUtils::CStdPostFixEval::CStdPostFixEval | ( | ) |
Default constructor.
Definition at line 18 of file StdPostFixEval.cpp.
References m_dblSolution.
|
virtual |
void StdUtils::CStdPostFixEval::AddVariable | ( | std::string | strVarName | ) |
Adds a variable.
strVarName | Name of the variable. |
Definition at line 81 of file StdPostFixEval.cpp.
References FindVariable(), m_aryVariables, and StdUtils::CStdVariable::m_strVariable.
Referenced by AnimatSim::ExternalStimuli::CurrentStimulus::CurrentEquation(), AnimatSim::ExternalStimuli::MotorStimulus::Equation(), AnimatSim::ExternalStimuli::PropertyControlStimulus::Equation(), and AnimatSim::ExternalStimuli::ExternalInputStimulus::InputEquation().
void StdUtils::CStdPostFixEval::Equation | ( | std::string | strVal | ) |
Sets the post-fix Equation.
strVal | The new equation. |
Definition at line 64 of file StdPostFixEval.cpp.
References m_strEquation, SavePostFixInArray(), and StdUtils::Std_Replace().
Referenced by AnimatSim::ExternalStimuli::CurrentStimulus::CurrentEquation(), AnimatSim::ExternalStimuli::MotorStimulus::Equation(), AnimatSim::ExternalStimuli::PropertyControlStimulus::Equation(), and AnimatSim::ExternalStimuli::ExternalInputStimulus::InputEquation().
std::string StdUtils::CStdPostFixEval::Equation | ( | ) |
Gets the post-fix equation.
Definition at line 53 of file StdPostFixEval.cpp.
References m_strEquation.
|
protected |
Fill in variables.
[in,out] | aryPostFix | The post-fix array. |
Definition at line 142 of file StdPostFixEval.cpp.
References FindVariable(), and StdUtils::CStdVariable::m_dblValue.
Referenced by Solve().
|
protected |
Searches for the a variable with the specified name.
strVarName | Name of the variable. |
Definition at line 120 of file StdPostFixEval.cpp.
References m_aryVariables, and StdUtils::CStdVariable::m_strVariable.
Referenced by AddVariable(), FillInVariables(), and SetVariable().
|
protected |
Gets the parameters.
[in,out] | dblLeft | The double left. |
[in,out] | dblRight | The double right. |
iNumParams | Number of parameters. |
Definition at line 332 of file StdPostFixEval.cpp.
References m_aryStack.
Referenced by Solve().
|
protected |
Saves a post fix in array.
[in,out] | strEqu | The equation. |
Definition at line 297 of file StdPostFixEval.cpp.
References m_aryPostFix.
Referenced by Equation().
void StdUtils::CStdPostFixEval::SetVariable | ( | std::string | strVarName, |
double | dblVal | ||
) |
Sets the value of a variable.
strVarName | Name of the variable. |
dblVal | The new value. |
Definition at line 101 of file StdPostFixEval.cpp.
References FindVariable(), and StdUtils::CStdVariable::m_dblValue.
Referenced by AnimatSim::ExternalStimuli::CurrentStimulus::CurrentEquation(), AnimatSim::ExternalStimuli::CurrentStimulus::GetCurrentOn(), AnimatSim::ExternalStimuli::ExternalInputStimulus::StepSimulation(), AnimatSim::ExternalStimuli::MotorStimulus::StepSimulation(), AnimatSim::ExternalStimuli::PropertyControlStimulus::StepSimulation(), and AnimatSim::ExternalStimuli::ForceStimulus::StepSimulation().
double StdUtils::CStdPostFixEval::Solution | ( | ) |
Gets the solution.
Definition at line 42 of file StdPostFixEval.cpp.
References m_dblSolution.
double StdUtils::CStdPostFixEval::Solve | ( | ) |
Solves the equation using the defined variable values.
Definition at line 167 of file StdPostFixEval.cpp.
References FillInVariables(), GetParams(), m_aryPostFix, m_aryStack, and StdUtils::Std_DRand().
Referenced by AnimatSim::ExternalStimuli::CurrentStimulus::CurrentEquation(), AnimatSim::ExternalStimuli::CurrentStimulus::GetCurrentOn(), AnimatSim::ExternalStimuli::ExternalInputStimulus::StepSimulation(), AnimatSim::ExternalStimuli::MotorStimulus::StepSimulation(), AnimatSim::ExternalStimuli::PropertyControlStimulus::StepSimulation(), and AnimatSim::ExternalStimuli::ForceStimulus::StepSimulation().