RAIN.Belief.AssignmentExpression Class Reference

AssignmentExpression represents a variable assignment expression similar to a C++ or C# assignment. Assignments can be represented as a left-hand-side (lhs), right-hand-side (rhs) and an infix operator (op) as in (lhs op rhs). Operators supported are EQ, PLUSEQ, MINUSEQ, TIMESEQ, DIVIDEEQ Nested expressions and expressions with variables are supported. lhs must be a single variable name. More...

List of all members.

Public Types

enum  AssignmentType {
  EQ, PLUSEQ, MINUSEQ, TIMESEQ,
  DIVIDEEQ, NO_OP
}
 Comparison type enum. More...

Public Member Functions

 AssignmentExpression ()
 Default constructor.
 AssignmentExpression (string variable, AssignmentType assignmentOperator, Expression expr2)
 Constructor including variable, op, and rhs.
void SetInvalid ()
 Invalidate the AssignmentExpression.
void RenameVariable (string originalName, string newName)
 Rename a variable in all nested expressions.
void SetExpression (string variable, AssignmentType assignmentOperator, Expression expr2)
 Reset the AssignmentExpression with a new variable, operator, and lhs.
void Evaluate (float deltaTime, ActionContext actionContext)
 Evaluate will assign the variable to a new value based on evaluating the rhs expression. The result will be stored in the ActionContext.
void Evaluate (float deltaTime, float minValue, float maxValue, ActionContext fromContext, ActionContext toContext)
 Evaluate will assign the variable to a new value based on evaluating the rhs expression. The fromContext will be used for calculating the new value. The result will be stored in the toContext.
override string ToString ()
 ToString() will return a string representation of the AssignmentExpression which may differ from the original text parsed to create this expression.

Properties

string AssignedVariable [get]
bool IsValid [get]
 Is the expression valid and can it be evaluated successfully? Checks to ensure that the AssignemntExpression is formed of valid variable and rhs expressions, and that the assignment operator is not a no-op.
string ExpressionAsEntered [get, set]
 ExpressionAsEntered returns the text used to initially describe the ConditionalExpression, if the expression was created from parsing a script or manual entry. This is useful when supporting user editing of invalid expressions.

Detailed Description

AssignmentExpression represents a variable assignment expression similar to a C++ or C# assignment. Assignments can be represented as a left-hand-side (lhs), right-hand-side (rhs) and an infix operator (op) as in (lhs op rhs). Operators supported are EQ, PLUSEQ, MINUSEQ, TIMESEQ, DIVIDEEQ Nested expressions and expressions with variables are supported. lhs must be a single variable name.


Member Enumeration Documentation


Constructor & Destructor Documentation

RAIN.Belief.AssignmentExpression.AssignmentExpression ( )

Default constructor.

RAIN.Belief.AssignmentExpression.AssignmentExpression ( string  variable,
AssignmentType  assignmentOperator,
Expression  expr2 
)

Constructor including variable, op, and rhs.

Parameters:
variableThe variable to assign
assignmentOperatorThe assignment operator
expr2The right-hand-side expression

Member Function Documentation

void RAIN.Belief.AssignmentExpression.Evaluate ( float  deltaTime,
ActionContext  actionContext 
)

Evaluate will assign the variable to a new value based on evaluating the rhs expression. The result will be stored in the ActionContext.

Parameters:
deltaTimetimestep to use when evaluating. this wlil replace the variable "t" in all expressions
void RAIN.Belief.AssignmentExpression.Evaluate ( float  deltaTime,
float  minValue,
float  maxValue,
ActionContext  fromContext,
ActionContext  toContext 
)

Evaluate will assign the variable to a new value based on evaluating the rhs expression. The fromContext will be used for calculating the new value. The result will be stored in the toContext.

Parameters:
minValuea minimum value for the result
maxValuea maximum value for the result
deltaTimetimestep to use when evaluating. this wlil replace the variable "t" in all expressions
fromContextContext to use when evaluating
toContextContext to store the result
void RAIN.Belief.AssignmentExpression.RenameVariable ( string  originalName,
string  newName 
)

Rename a variable in all nested expressions.

Parameters:
originalNameThe name of the variable to rename
newNameThe new name to replace the original variable name
void RAIN.Belief.AssignmentExpression.SetExpression ( string  variable,
AssignmentType  assignmentOperator,
Expression  expr2 
)

Reset the AssignmentExpression with a new variable, operator, and lhs.

Parameters:
variableThe variable to assign
assignmentOperatorThe assignment operator
expr2The right-hand-side expression
void RAIN.Belief.AssignmentExpression.SetInvalid ( )

Invalidate the AssignmentExpression.

override string RAIN.Belief.AssignmentExpression.ToString ( )

ToString() will return a string representation of the AssignmentExpression which may differ from the original text parsed to create this expression.

Returns:
Returns a text representation of the ConditionalExpressoin

Property Documentation

string RAIN.Belief.AssignmentExpression.ExpressionAsEntered [get, set]

ExpressionAsEntered returns the text used to initially describe the ConditionalExpression, if the expression was created from parsing a script or manual entry. This is useful when supporting user editing of invalid expressions.

bool RAIN.Belief.AssignmentExpression.IsValid [get]

Is the expression valid and can it be evaluated successfully? Checks to ensure that the AssignemntExpression is formed of valid variable and rhs expressions, and that the assignment operator is not a no-op.

Returns:
true if the AssignemntExpression is valid, false otherwise