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...
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. |
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)
Comparison type enum.
RAIN.Belief.ConditionalExpression.ConditionalExpression | ( | ) |
Default constructor.
RAIN.Belief.ConditionalExpression.ConditionalExpression | ( | Expression | expr1, |
ComparisonType | comparisonOperator, | ||
Expression | expr2 | ||
) |
Constructor including lhs, op, and rhs.
expr1 | The left-hand-side expression |
comparisonOperator | The comparison operator |
expr2 | The right-hand-side expression |
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.
deltaTime | timestep to use when evaluating. this wlil replace the variable "t" in all expressions |
void RAIN.Belief.ConditionalExpression.RenameVariable | ( | string | originalName, |
string | newName | ||
) |
Rename a variable in all nested expressions.
originalName | The name of the variable to rename |
newName | The 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.
expr1 | The left-hand-side expression |
comparisonOperator | The comparison operator |
expr2 | The 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.
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.