RAIN.Belief.ConditionalExpression Class Reference

ConditionalExpression represents a logical expression similar to a C++ or C# conditional. Conditionals 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 GT, LT, GE, LE, EQ, NEQ, APPROX, NAPPROX, NO_OP Nested expressions and expressions with variables are supported. (i.e., lhs and rhs can be any valid Expression) More...

List of all members.

Public Types

enum  ComparisonType {
  GT, LT, GE, LE,
  EQ, NEQ, APPROX, NAPPROX,
  NO_OP
}
 Comparison type enum. More...

Public Member Functions

 ConditionalExpression ()
 Default constructor.
 ConditionalExpression (Expression expr1, ComparisonType comparisonOperator, Expression expr2)
 Constructor including lhs, op, and rhs.
void SetInvalid ()
 Invalidate the ConditionalExpression.
void RenameVariable (string originalName, string newName)
 Rename a variable in all nested expressions.
void SetExpression (Expression expr1, ComparisonType comparisonOperator, Expression expr2)
 Reset the ConditionalExpression with a new rhs, operator, and lhs.
bool Evaluate (float deltaTime, ActionContext actionContext)
 Evaluate will calculate the true or false value of the conditional expression by evaluating the lhs and rhs, then comparing them using the operator. The current VariableContext will be used to bind values for any nested variables. If either lhs or rhs are missing, Evaluate returns false. If either lhs or rhs evaluate to NaN (not a number) Evaluate will return false.
override string ToString ()
 ToString() will return a string representation of the ConditionalExpression which may differ from the original text parsed to create this expression.

Properties

bool IsValid [get]
 Is the conditional expression valid and can it be evaluated successfully? Checks to ensure that the Conditional Expression is formed of valid lhs and rhs expressions, and that the comparison 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

ConditionalExpression represents a logical expression similar to a C++ or C# conditional. Conditionals 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 GT, LT, GE, LE, EQ, NEQ, APPROX, NAPPROX, NO_OP Nested expressions and expressions with variables are supported. (i.e., lhs and rhs can be any valid Expression)


Member Enumeration Documentation


Constructor & Destructor Documentation

RAIN.Belief.ConditionalExpression.ConditionalExpression ( )

Default constructor.

RAIN.Belief.ConditionalExpression.ConditionalExpression ( Expression  expr1,
ComparisonType  comparisonOperator,
Expression  expr2 
)

Constructor including lhs, op, and rhs.

Parameters:
expr1The left-hand-side expression
comparisonOperatorThe comparison operator
expr2The right-hand-side expression

Member Function Documentation

bool RAIN.Belief.ConditionalExpression.Evaluate ( float  deltaTime,
ActionContext  actionContext 
)

Evaluate will calculate the true or false value of the conditional expression by evaluating the lhs and rhs, then comparing them using the operator. The current VariableContext will be used to bind values for any nested variables. If either lhs or rhs are missing, Evaluate returns false. If either lhs or rhs evaluate to NaN (not a number) Evaluate will return false.

Parameters:
deltaTimetimestep to use when evaluating. this wlil replace the variable "t" in all expressions
Returns:
true if the expression evaluates to true, false otherwise
void RAIN.Belief.ConditionalExpression.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.ConditionalExpression.SetExpression ( Expression  expr1,
ComparisonType  comparisonOperator,
Expression  expr2 
)

Reset the ConditionalExpression with a new rhs, operator, and lhs.

Parameters:
expr1The left-hand-side expression
comparisonOperatorThe comparison operator
expr2The right-hand-side expression
void RAIN.Belief.ConditionalExpression.SetInvalid ( )

Invalidate the ConditionalExpression.

override string RAIN.Belief.ConditionalExpression.ToString ( )

ToString() will return a string representation of the ConditionalExpression 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.ConditionalExpression.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.ConditionalExpression.IsValid [get]

Is the conditional expression valid and can it be evaluated successfully? Checks to ensure that the Conditional Expression is formed of valid lhs and rhs expressions, and that the comparison operator is not a no-op.