AURobotServers  4
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
UVarCalc Class Reference

#include <uvarcalc.h>

Inheritance diagram for UVarCalc:
Inheritance graph

Public Member Functions

double evaluateD (const char *line, const char *start, const char **end, bool *evaluated, bool syntaxCheck)
 Get value for the variable or function call with this name Variables and functions in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found. More...
 
bool evaluateParametersD (const char *sourceLine, const char **paramStart, double *paramValues, int *paramValuesCnt, char **paramStr, char *paramOrder, int maxParamCount, int maxParamStrCount, int maxParamStrLength)
 
bool evaluateParametersV (const char *sourceLine, const char **paramStart, char *paramOrder, UVariable *params[], int *paramsCnt, int maxParamsCnt)
 
bool evaluateToStringD (const char *sourceLine, const char *paramStart, const char **nextChar, char *dest, int destLength)
 
bool evaluateToStringV (const char *sourceLine, const char *paramStart, const char **nextChar, char *dest, int destLength)
 
double evaluateUnaryValD (const char *line, const char *start, const char **end, bool *evaluated, bool syntaxCheck)
 Evaluate an expression. More...
 
bool evaluateUnaryValV (const char *line, const char *start, const char **end, UVariable *value, bool syntaxCheck)
 
bool evaluateV (const char *line, const char *start, const char **end, UVariable *value, bool syntaxCheck)
 Evaluate an expression. More...
 
char * getErrorTxt ()
 
int getErrorTxtMaxCnt ()
 
bool getIdentifier (const char *id, int idCnt, const char *allowed, const char **oChar)
 
bool getValueAnyD (UVarPool *scope, const char *name, double *value, const char **params)
 Get value for the variable or function call with this name Variables and functions in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found. More...
 
bool getValueAnyV (UVarPool *scope, const char *name, UVariable *value, const char **params)
 Get value for the variable or function call with this name Variables and functions in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found. More...
 
bool getVariableAny (UVarPool *scope, const char *name, UVariable *value)
 Get the variable with this name in the specified scope (incl. math) Variables in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found. More...
 
bool getVariableRefAny (UVarPool *scope, const char *name, UVariable **found, int *nameIndex)
 Get reference to variable with this name in the specified scope (incl. math) Variables in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found. More...
 
bool isDefined (UVarPool *scope, const char *varName)
 Is this variable defined in the scope. The test is for variables and structures, and in the provided scope as well as any parent scope. further the math scope is tested too. More...
 
bool isRemark (const char *string)
 
bool setResource (UResBase *resource, bool remove)
 Called by server core when new resources are available. More...
 
 UVarCalc ()
 
virtual ~UVarCalc ()
 
- Public Member Functions inherited from UVarPool
int addMethod (UVarMethodImplement *implementor, const char *formalName, const char *paramTypes, const char *comment)
 
int addMethodV (UVarMethodImplement *implementor, const char *formalName, const char *paramTypes, const char *comment)
 
int addStruct (const char *name, UVarPool *varStruct)
 
int addStructLink (const char *name, UVarPool *toVarStruct)
 Add a link to another place in the var tree but do not change anything in the linked structure. More...
 
UVarPooladdStructLocal (const char *name, const char *note, bool copy)
 
UVariableaddVar (const char *name, const double initialValue, const char *type, const char *comment)
 
UVariableaddVar (const char *name, const double initialValue, UVariable::varType type, const char *comment, const char *attValue=NULL)
 
UVariableaddVar (const char *name, const UVariable *source, const char *comment)
 
UVariableaddVar (const char *name, const char *comment)
 
UVariableaddVarA (const char *name, const char *attValue, const char *type, const char *comment)
 
bool callGlobal (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct, int *returnStructCnt)
 Call a method in the root var pool. It may be in this structure or in any sub-structure that the 'name' indicate. More...
 
bool callGlobalV (const char *name, const char *paramOrder, UVariable **params, UDataBase **returnStruct, int *returnStructCnt)
 Call a method from the root var pool scope It may be in the structure direct (no '.') or in any sub-structure that the 'name.subname' indicate. More...
 
bool callLocal (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct, int *returnStructCnt)
 Call a method in this var pool. It may be in this structure or in any sub-structure that the 'name' indicate. More...
 
bool callLocalV (const char *name, const char *paramOrder, UVariable *params[], UDataBase **returnStruct, int *returnStructCnt)
 Call a method in this var pool (using UVariable parameters). It may be in this structure or in any sub-structure that the 'name' indicate. More...
 
bool callScope (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct, int *returnStructCnt)
 Call a method in this scope, i.e. try if it fits a call in any of the parent var pools. It may be in the structure direct (no '.') or in any sub-structure that the 'name.subname' indicate. More...
 
bool callScopeV (const char *name, const char *paramOrder, UVariable **params, UDataBase **returnStruct, int *returnStructCnt)
 Call a method in this scope - using UVariable parameters, i.e. try if it fits a call in any of the parent var pools. It may be in the structure direct (no '.') or in any sub-structure that the 'name.subname' indicate. More...
 
bool createVarSpace (const int varCnt, const int structCnt, const int methCnt, const char *note, bool copy)
 
void deleteAll ()
 
void deleteMethod (const char *name, const char *paramStr)
 
void deleteMethods (UVarMethodImplement *owner)
 
void deleteStruct (const char *name)
 
const char * getDescription ()
 
const char * getFullPreName (char *name, const int MNL)
 
const char * getFullPreName ()
 
bool getGlobalString (const char *name, const char **value)
 
bool getGlobalValue (const char *name, double *value)
 
bool getGlobalValue (const char *name, bool *value)
 
bool getGlobalValue (const char *name, UTime *value)
 
UVariablegetGlobalVariable (const char *name, int *element=NULL)
 get pointer to variable object NB! the returned pointer may be ilegal if module that owns the variable is unloaded so it must be used only while executing one command in main server core thread, if needed in a thread - like the sequencer, then get the value only - getValue(). More...
 
UVarMethodgetLocalMethod (const char *name, const char *paramList)
 
UVarPoolgetLocalMethod (const char *name, const char *paramList, UVarMethod **method)
 
UVarMethodgetLocalMethod (const int index)
 
int getLocalMethodIdx (const char *name, const char *paramList)
 Get index of this method in this var pool. More...
 
double getLocalValue (int idx, int element=0)
 
bool getLocalValue (const char *name, double *value)
 
bool getLocalValue (const char *name, bool *value)
 
bool getLocalValue (const char *name, UTime *value)
 
UPosition getLocalValue3D (int idx)
 
UPosRot getLocalValue6D (int idx)
 
bool getLocalValueBool (int idx)
 
int getLocalValueInt (int idx)
 
UPose getLocalValuePose (int idx)
 
URotation getLocalValueRot (int idx)
 
UTime getLocalValueTime (int idx)
 
UVariablegetLocalVar (int index)
 
UVariablegetLocalVariable (const char *name, int *element)
 get pointer to variable object in this variable tree More...
 
int getLocalVarIndex (const char *name, int *element)
 
ULogFilegetLogVar ()
 
ULockgetLogVarLock ()
 
int getMethodCnt ()
 
int getMethodMax ()
 
UVarPoolgetParentVarPool ()
 
UVarPoolgetParentVarPoolScope ()
 
const char * getPreName ()
 
UVarPoolgetRootVarPool ()
 
bool getScopeValue (const char *name, double *value)
 
UVarPoolgetStruct (const char *name)
 
UVarPoolgetStruct (const int idx)
 
int getStructCnt ()
 
UVarPoolgetStructDeep (const char *fullName, char *varName, const int varNameCnt)
 
UVarPoolgetStructDeep (const char *fullName, const bool mayAdd, char *varName, const int varNameCnt)
 
int getStructIdx (const char *name)
 
int getStructMax ()
 
const char * getVarDescription (int idx)
 
int getVarMax ()
 
char * getVarName (int index)
 
UVariable ** getVars ()
 
int getVarsCnt ()
 
bool isLogfileOpen ()
 
bool isVarPoolVerbose ()
 
void listVars (const char *preStr, char *buff, const int buffCnt, bool andStructs)
 
void setDescription (const char *note, bool copy)
 
bool setGlobalVar (const char *name, const double value, bool mayAdd)
 Assigns a value to a variable. The variable may be a part of a structure. More...
 
bool setLocalVar (const int index, const double value, const int element)
 
bool setLocalVar (const int index, UVariable *value)
 
bool setLocalVar (const char *name, const double value, bool mayAdd, UVariable::varType vartyp, const char *attValue=NULL)
 Assigns a value to a variable. The variable may be a part of a structure. More...
 
bool setLocalVar (const char *name, const char *value, bool mayAdd, const char *vartyp, UTime *updTime=NULL, bool *added=NULL)
 Assigns a value to a variable. The variable may be a part of a structure. More...
 
bool setLocalVar3D (int idx, UPosition *value)
 
bool setLocalVar6D (int idx, UPosRot *value)
 
bool setLocalVarAdd (const int index, const double value, const int element)
 
bool setLocalVarPose (int idx, UPose *value)
 
bool setLocalVarRot (int idx, URotation *value)
 
void setLogfile (ULogFile *fileHandle, ULock *fileLock)
 
void setParentVarPool (UVarPool *parent)
 
void setParentVarPoolScope (UVarPool *parent)
 
bool setPreName (const char *name)
 
bool setScopeVar (const char *name, const double value, bool mayAdd)
 
bool setScopeVar (const char *name, const UVariable *source, bool mayAdd)
 
void setVerbose (bool value)
 
 UVarPool ()
 
virtual ~UVarPool ()
 
- Public Member Functions inherited from ULock
bool lock ()
 
void lockInit ()
 
void post ()
 
bool tryLock ()
 
bool tryWait ()
 
 ULock ()
 
void unlock ()
 
bool wait ()
 
 ~ULock ()
 
- Public Member Functions inherited from UServerPush
int addPushCommand (UServerInMsg *msg)
 
virtual void callGotNewDataWithObject ()
 
bool doPushCall (UServerPushElement *pe, const char *value)
 
void flushClientCmds (int clientIdx)
 
UServerPushImplementgetImplementor ()
 
int getPushCmdCnt (int *cmdCnt, int *callCnt)
 
UServerPushQueuegetPushQueue ()
 
bool gotCmdExe ()
 
void gotNewData (void *pData)
 
bool isUpdated (int lastCnt, int *newCnt)
 
bool needNewData ()
 
void print (const char *preString)
 
void print (const char *preString, char *buff, int buffCnt)
 
void servicePendingPushCmds ()
 
void setCmdExe (UServerPushImplement *executor)
 
void setImplementor (UServerPushImplement *executor)
 
bool setResource (UResBase *resource, bool remove)
 
bool setUpdated (const char *value)
 Add watch object if needed. An image or other object is updated. set object as updated, with an extra qualifier, that may be used as a parameter in a push call. this push list is then added to the to the push list examined by the server thread. when server thread reach this push list it will call to get a possible associated data structure by a call to needNewData() whish is expected to call gotNewData(void * data_structure) - but now in the server thread. More...
 
 UServerPush ()
 
virtual ~UServerPush ()
 

Protected Member Functions

virtual bool getLocalScopeVaiable (const char *name, double *value)
 
- Protected Member Functions inherited from UVarPool
bool createFunctionStack (const int maxCount)
 
bool createVarPoolStack (const int maxCount)
 
bool createVarStack (const int maxCount)
 
virtual bool evaluateSystemFunction (const char *name, const double pars[], int parsCnt, double *value, bool syntaxCheck)
 

Protected Attributes

char errorTxt [MAX_ERROR_SIZE]
 
- Protected Attributes inherited from UVarPool
const char * description
 
ULogFilelogVar
 
ULocklogVarLock
 
UVarPool ** varPools
 
bool * varPoolsLocal
 
bool verbose
 

Detailed Description

Class to act as a calculator

Constructor & Destructor Documentation

UVarCalc::UVarCalc ( )

Constructor

UVarCalc::~UVarCalc ( )
virtual

Destructor

Member Function Documentation

double UVarCalc::evaluateD ( const char *  line,
const char *  start,
const char **  end,
bool *  evaluated,
bool  syntaxCheck 
)

Get value for the variable or function call with this name Variables and functions in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found.

Parameters
scopethe scope to be searched for value (normally just from 'getVarPool()')
valuethe found (double) value is returned here (if not NULL).
paramsat this position are the parameters for the function, if parameters are used (and can be evaluated) then the character position are modified to just passed the end bracket for the parameter. Evaluate an expression
lineis the source line
startis where the expression starts in the line
nextpoints to the first unused character after evaluation
Returns
a double, that may hold a boolean value.
Parameters
evaluatedreturns false if string fails to evaluate 'evaluated' (if not NULL)
syntaxCheckwhen true the evaluation is evaluated partially, as far as to the point where values or actions are initiated

References UVarCalcOper::evaluateD(), UVarCalcOper::evaluateOperator(), UVarCalcOper::getValue(), UVarCalcOper::insertOperator(), MAX_ERROR_SIZE, UVarCalcOper::parent, UVarCalcOper::right, and UVarCalcOper::setValue().

Referenced by UKeepItem::monitorTest().

bool UVarCalc::evaluateParametersD ( const char *  sourceLine,
const char **  paramStart,
double *  paramValues,
int *  paramValuesCnt,
char **  paramStr,
char *  paramOrder,
int  maxParamCount,
int  maxParamStrCount,
int  maxParamStrLength 
)

evaluate a single variable

Parameters
lineis full line that is evaluated upon.
startis where to start (on this line).
evaluatedis set true, if a value is found.
endis set to first unused character.
syntaxCheckis passed on to any expression of functionCall evaluation.
Returns
a variable with the result Evaluate a number [0..maxParamCount] of parameters – for a function call. The number of found parameters gets returned in length of 'paramStr', and the values are present in 'paramValues' and 'paramStr'. Eg: sourceLine: "phi = 23.7 + atan2(y * sin(h), (x - 0.1) * cos(h))", and paramStart: "(y * sin(h), (x - 0.1) * cos(h))" Return will be paramValues = 2, paramValue[0] and [1] will be assigned values, 'paramStart' will point at first character after parameter list - just after the ')' char
Parameters
sourceline is used when reporting syntax error only
paramStartis a pointer into the place in 'line' where the parameter analysis should start.
paramValuesis an array of doubles where the double sized parameters are returned, the size is in maxParamCount
paramValuesCntis a pointer to an interger where the found number of double parameters are returned.
paramStris a pointer to an array of string pointers. This is where the string parameters are returned. The number of strings available is in maxParamStrCount and the length of each string is in maxParamStrLength
paramOrderis a string where the sequence of parameters are returned, e.g. "dsd" means the first parameter is a double, returned in paramValue[0], the next is a string returned in paramStr[0] and the third parameter is a double returned in paramValue[1].
maxParamCountis the size of the paramOrder string AND the size of the paramValues array
maxParamStrCountmax number of string parameters allowed
maxParamStrLengthis the max length of evaluated string parameters (size of string buffer) true if not syntax error were found.

References UVarCalcOper::evaluateD(), and MAX_ERROR_SIZE.

bool UVarCalc::evaluateParametersV ( const char *  sourceLine,
const char **  paramStart,
char *  paramOrder,
UVariable params[],
int *  paramsCnt,
int  maxParamsCnt 
)

Evaluate a number [0..maxParamCount] of parameters – for a function call. The number of found parameters gets returned in length of 'paramStr', and the values are present in 'paramValues' and 'paramStr'. Eg: sourceLine: "phi = 23.7 + atan2(y * sin(h), (x - 0.1) * cos(h))", and paramStart: "(y * sin(h), (x - 0.1) * cos(h))" Return will be paramValues = 2, paramValue[0] and [1] will be assigned values, 'paramStart' will point at first character after parameter list - just after the ')' char

Parameters
sourceline is used when reporting syntax error only
paramStartis a pointer into the place in 'line' where the parameter analysis should start.
paramOrderis a string where the sequence of parameters are returned, e.g. "dsd" means the first parameter is a double, the next is a string and the third parameter is a double.
paramsis a pointer to an array of variables. The number of variable pointers available is in maxParamsCount. Assumed to be NULL pointers, an caller must delete variables created.
paramsCntis a pointer to an interger where the found number of parameters are returned.
maxParamsCountmax number of string parameters allowed true if not syntax error were found.

References UVarCalcOper::evaluateV(), MAX_ERROR_SIZE, and UVariable::setValues().

Referenced by UMisControl::execute(), UMisRuleState::initCall(), and UMisRuleState::runRuleCommands().

bool UVarCalc::evaluateToStringD ( const char *  sourceLine,
const char *  paramStart,
const char **  nextChar,
char *  dest,
int  destLength 
)

Evaluate a string of mixed unknown values and values to evaluate to a new evaluated string, that can be send to a subsystem - e.g. a SMRCL command. Uses evaluateD(...) to evaluate non-strings. If part of the command is in quotes ("), then it is not evaluated. e.g. 'turnr 1.2 ' calcH -0.1 ' "rad" @v' speed ":($odoth >" calcH ")" and speed=0.3 and calcH=0.5, then it is evaluated to: turnr 1.2 0.4 "rad" 0.3 :($odoth > 0.5)

Parameters
paramStartthe start position (in line) where to start the string extraction
nextCharreturns the first position after the string, e.g. a ',' or a ')'
destthe destination string
destLengthis the length of the string buffer true if evaluated and there is space in 'dest' string.

References UVarCalcOper::evaluateD(), MAX_ERROR_SIZE, and UVarCalcOper::value.

bool UVarCalc::evaluateToStringV ( const char *  sourceLine,
const char *  paramStart,
const char **  nextChar,
char *  dest,
int  destLength 
)

Evaluate a string of mixed unknown values and values to evaluate to a new evaluated string, that can be send to a subsystem - e.g. a SMRCL command. Uses evaluateV(...) to evaluate non-strings. If part of the command is in quotes ("), then it is not evaluated. e.g. 'turnr 1.2 ' calcH -0.1 ' "rad" @v' speed ":($odoth >" calcH ")" and speed=0.3 and calcH=0.5, then it is evaluated to: turnr 1.2 0.4 "rad" 0.3 :($odoth > 0.5)

Parameters
paramStartthe start position (in line) where to start the string extraction
nextCharreturns the first position after the string, e.g. a ',' or a ')'
destthe destination string
destLengthis the length of the string buffer true if evaluated and there is space in 'dest' string.

References UVarCalcOper::evaluateV(), UVariable::getValuesAsString(), MAX_ERROR_SIZE, and UVarCalcOper::value.

Referenced by UMisRuleState::runEnable().

double UVarCalc::evaluateUnaryValD ( const char *  line,
const char *  start,
const char **  end,
bool *  evaluated,
bool  syntaxCheck 
)

Evaluate an expression.

Parameters
lineis the source line
startis where the expression starts in the line
nextpoints to the first unused character after evaluation
evaluatedreturns false if string fails to evaluate 'evaluated' (if not NULL)
syntaxCheckwhen true the evaluation is evaluated partially, as far as to the point where values or actions are initiated
Returns
a pounter to a variable on the heap, receiver must delete. Evaluate an expression
Parameters
lineis the source line
startis where the expression starts in the line
nextpoints to the first unused character after evaluation
Returns
a double, that may hold a boolean value.
Parameters
evaluatedreturns false if string fails to evaluate 'evaluated' (if not NULL)
syntaxCheckwhen true the evaluation is evaluated partially, as far as to the point where values or actions are initiated Evaluate a single value, that may have a unary operator in front of the value. The syntax may be: ['not' | '-'] (symbol | constant | '(' expression ')' | functionCall ). Returns the value found, or 0 on error.
lineis full line that is evaluated upon.
startis where to start (on this line).
evaluatedis set true, if a value is found.
endis set to first unused character.
syntaxCheckis passed on to any expression of functionCall evaluation.
Returns
the result as a double

References UVarCalcOper::evaluateD(), MAX_ERROR_SIZE, MAX_VARIABLE_NAME_SIZE, and roundi().

bool UVarCalc::evaluateUnaryValV ( const char *  line,
const char *  start,
const char **  end,
UVariable value,
bool  syntaxCheck 
)

Evaluate a single value, that may have a unary operator in front of the value. The syntax may be: ['not' | '-'] (symbol | constant | '(' expression ')' | functionCall ). Returns the value found, or 0 on error.

Parameters
lineis full line that is evaluated upon.
startis where to start (on this line).
endis set to first unused character.
valueis the value found (if not NULL).
syntaxCheckis passed on to any expression of functionCall evaluation.
Returns
the true if a value is found

References UVarCalcOper::evaluateV(), UVariable::getValued(), UVariable::isString(), MAX_ERROR_SIZE, MAX_VARIABLE_NAME_SIZE, UVariable::negate(), roundi(), UVariable::setNot(), UVariable::setTypeChar(), UVariable::setValued(), UVariable::setValues(), and UVarCalcOper::value.

bool UVarCalc::evaluateV ( const char *  line,
const char *  start,
const char **  end,
UVariable value,
bool  syntaxCheck 
)

Evaluate an expression.

Parameters
lineis the source line
startis where the expression starts in the line
nextpoints to the first unused character after evaluation
valuereturns the resulting value here (if not NULL)
syntaxCheckwhen true the evaluation is evaluated partially, as far as to the point where values or actions are initiated
Returns
true is evaluated, false if syntax errors (description in errorTxt)

References UVariable::copy(), UVarCalcOper::evaluateOperator(), UVarCalcOper::evaluateV(), UVariable::getElementCnt(), UVarCalcOper::getVar(), UVarCalcOper::insertOperator(), UVariable::isString(), MAX_ERROR_SIZE, UVarCalcOper::num, UVarCalcOper::parent, UVarCalcOper::remVar(), UVarCalcOper::right, UVarCalcOper::setValue(), and UVariable::setValues().

Referenced by UMisRuleState::createParameterVar(), UMisLoop::evalCondition(), UMisControl::evaluateCondition(), UMisCaseSwitch::evaluateExpr(), UMisAssign::execute(), UMisIf::execute(), UFunctionVarPool::handleVarValues(), UMisRuleState::methodCall(), UMisRuleState::methodCallV(), and UMisRuleState::step().

char* UVarCalc::getErrorTxt ( )
inline

Get variable assignment as specified in this line.

Returns
true if variable is set with no syntax error.
Parameters
cmdLineThe line from where to start the evaluation (line is not changed) syntax error the errorText() is set with a description.. Get error text

Referenced by UMisControl::evaluateCondition(), UMisAssign::execute(), UMisControl::execute(), UFuncKeep::handleKeep(), UMisAssign::setLine(), UMisIf::setLine(), UMisBreak::setLine(), UMisLoop::setLine(), UMisCaseSwitch::setLine(), UMisCase::setLine(), and UMisCall::setLine().

int UVarCalc::getErrorTxtMaxCnt ( )
inline
bool UVarCalc::getIdentifier ( const char *  id,
int  idCnt,
const char *  allowed,
const char **  oChar 
)

Is the next n characters from 'var' a valid identifier. an identifier starts with a character and may continue with a sequence of characters, numbers or one of '_$'

Parameters
idpointer to the first character to be evaluated - assumed not to be zero terminated.
idCntmaximum number of characters to be evaluated.
allowedis any special characters allowed after initial alpha character - typical "_"
oCharis set to the first char not belonging to a identifier
Returns
true if 'id' starts with a valid identifier

Referenced by UMisRuleState::createParameterVar(), UMisAssign::setLine(), UMisBreak::setLine(), UMisCall::setLine(), and testCalc().

bool UVarCalc::getLocalScopeVaiable ( const char *  name,
double *  value 
)
protectedvirtual

Evaluate system specific functions - that need to know position of planner etc. The called function name is in 'name' the parameters in 'pars' and if the function returns a value it must be put in 'value' Get value from a local function variable (a parameter). true if a variable exist, and

Returns
the value in '*value'
bool UVarCalc::getValueAnyD ( UVarPool scope,
const char *  name,
double *  value,
const char **  params 
)

Get value for the variable or function call with this name Variables and functions in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found.

Parameters
scopethe scope to be searched for value (normally just from 'getVarPool()')
valuethe found (double) value is returned here (if not NULL).
paramsat this position are the parameters for the function, if parameters are used (and can be evaluated) then the character position are modified to just passed the end bracket for the parameter.

References UVarPool::callLocal(), UVarPool::getLocalValue(), UVarPool::getParentVarPoolScope(), UVarPool::getRootVarPool(), and UVarPool::getStruct().

bool UVarCalc::getValueAnyV ( UVarPool scope,
const char *  name,
UVariable value,
const char **  params 
)

Get value for the variable or function call with this name Variables and functions in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found.

Parameters
scopethe scope to be searched for value (normally just from 'getVarPool()')
valuethe found value is returned here (if not NULL).
paramsat this position are the parameters for the function, if parameters are used (and can be evaluated) then the character position are modified to just passed the end bracket for the parameter.

References UVarPool::callLocalV(), UVariable::copy(), UVarPool::getLocalVariable(), UVarPool::getParentVarPoolScope(), UVarPool::getRootVarPool(), UVarPool::getStruct(), UVariable::getValued(), UVariable::getValues(), UVariable::isString(), UVariable::setValued(), UVariable::setValues(), and UVarCalcOper::value.

bool UVarCalc::getVariableAny ( UVarPool scope,
const char *  name,
UVariable value 
)

Get the variable with this name in the specified scope (incl. math) Variables in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found.

Parameters
scopethe scope to be searched for value (normally just from 'getVarPool()')
nameis the name of the variable
valuethe found (double) value is returned here (if not NULL).

References UVariable::copy(), UVarPool::getLocalVariable(), UVarPool::getParentVarPoolScope(), UVarPool::getRootVarPool(), UVarPool::getStruct(), and UVarCalcOper::value.

bool UVarCalc::getVariableRefAny ( UVarPool scope,
const char *  name,
UVariable **  found,
int *  nameIndex 
)

Get reference to variable with this name in the specified scope (incl. math) Variables in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found.

Parameters
scopethe scope to be searched for value (normally just from 'getVarPool()')
nameis the name of the variable (may include index - is returned in nameIndex
foundthe found variable is returned here (if not NULL).
nameIndexis any optional index in the variable name string (if not NULL) if variable is found, but no index, then set to -1. if no variable, then not changed.

References UVarPool::getLocalVariable(), UVarPool::getParentVarPoolScope(), UVarPool::getRootVarPool(), and UVarPool::getStruct().

bool UVarCalc::isDefined ( UVarPool scope,
const char *  varName 
)

Is this variable defined in the scope. The test is for variables and structures, and in the provided scope as well as any parent scope. further the math scope is tested too.

Copy values of all variables to logfile The varPool has methods, and a call to one of these are needed. Do the call now and return (a double sized) result in 'value' and return true if the method call is allowed.

Parameters
scopethe scope variable pool at the deepest level.
varNamevariable name (or struct name) that may include a '.' for sub-structure.
Returns
true if found.

References UVarPool::getParentVarPoolScope(), UVarPool::getStruct(), and UVarPool::getStructDeep().

bool UVarCalc::isRemark ( const char *  string)

Returns a help string for general function 'index' and the number of general functions in 'count'. Get a (or try to) value from the connected MRC. Returns false if variable is unknown or MRC is not connected Is this string to be regarded as a remark line? Returns true if so. A remark line start with one of "%#;" or "//"

Referenced by UMisRuleState::runRuleCommands().

bool UVarCalc::setResource ( UResBase resource,
bool  remove 
)

Called by server core when new resources are available.

Add standard math methods

Parameters
resourceis the offered resource pointer
removeis true if the resource is unloaded and thuis no longer valid
Returns
true is resouurce is used Save a pointer to the resource as needed.

Referenced by UResRuleState::UResRuleState().

Member Data Documentation

char UVarCalc::errorTxt[MAX_ERROR_SIZE]
protected

The documentation for this class was generated from the following files: