TAO_CosTrader
2.0.8
|
TAO_Constraint_Evaluator traverse a constraint expression tree, and determines whether an offer fits the constraints represented by the tree. More...
#include <Constraint_Visitors.h>
Classes | |
class | Operand_Queue |
Public Member Functions | |
TAO_Constraint_Evaluator (void) | |
Constructor. | |
CORBA::Boolean | evaluate_constraint (TAO_Constraint *root) |
int | evaluate_preference (TAO_Constraint *root, TAO_Literal_Constraint &result) |
virtual int | visit_constraint (TAO_Unary_Constraint *constraint) |
virtual int | visit_with (TAO_Unary_Constraint *unary_with) |
virtual int | visit_min (TAO_Unary_Constraint *unary_min) |
virtual int | visit_max (TAO_Unary_Constraint *unary_max) |
virtual int | visit_first (TAO_Noop_Constraint *noop_first) |
virtual int | visit_random (TAO_Noop_Constraint *noop_random) |
virtual int | visit_and (TAO_Binary_Constraint *boolean_and) |
virtual int | visit_or (TAO_Binary_Constraint *boolean_or) |
virtual int | visit_not (TAO_Unary_Constraint *unary_not) |
Logically negates the value of the operand. | |
virtual int | visit_exist (TAO_Unary_Constraint *unary_exist) |
virtual int | visit_unary_minus (TAO_Unary_Constraint *unary_minus) |
Mathematically negates the return value the operand. | |
virtual int | visit_add (TAO_Binary_Constraint *boolean_add) |
Add the results of evaluating the left and right operands. | |
virtual int | visit_sub (TAO_Binary_Constraint *boolean_sub) |
Subtract the results of evaluating the left and right operands. | |
virtual int | visit_mult (TAO_Binary_Constraint *boolean_mult) |
Multiply the results of evaluating the left and right operands. | |
virtual int | visit_div (TAO_Binary_Constraint *boolean_div) |
Divide the results of evaluating the left and right operands. | |
virtual int | visit_twiddle (TAO_Binary_Constraint *binary_twiddle) |
Determines if the right operand is a substring of the left. | |
virtual int | visit_in (TAO_Binary_Constraint *binary_in) |
virtual int | visit_less_than (TAO_Binary_Constraint *boolean_lt) |
virtual int | visit_less_than_equal (TAO_Binary_Constraint *boolean_lte) |
virtual int | visit_greater_than (TAO_Binary_Constraint *boolean_gt) |
virtual int | visit_greater_than_equal (TAO_Binary_Constraint *boolean_gte) |
virtual int | visit_equal (TAO_Binary_Constraint *boolean_eq) |
virtual int | visit_not_equal (TAO_Binary_Constraint *boolean_neq) |
virtual int | visit_literal (TAO_Literal_Constraint *literal) |
Copy the value of the literal into the result container. | |
virtual int | visit_property (TAO_Property_Constraint *literal) |
Copy the value of the property into the result container. | |
Protected Attributes | |
TAO_Lookup_Table | props_ |
The map of property names to their values for a property. | |
Operand_Queue | queue_ |
The result of a non_boolean operation. | |
Private Member Functions | |
void | do_the_op (int operation) |
Method for performing a arithmetic or comparison operation. | |
int | visit_bin_op (TAO_Binary_Constraint *op, int operation) |
Method for evaluating a binary operation. | |
CORBA::Boolean | sequence_does_contain (CORBA::Any *sequence, TAO_Literal_Constraint &element) |
TAO_Constraint_Evaluator (const TAO_Constraint_Evaluator &) | |
Disallow copying. | |
TAO_Constraint_Evaluator & | operator= (const TAO_Constraint_Evaluator &) |
TAO_Constraint_Evaluator traverse a constraint expression tree, and determines whether an offer fits the constraints represented by the tree.
Using the Visitor pattern, the TAO_Constraint_Evaluator has each node of the expression tree call back to it with the method designated for its type. In that method, the visitor will evaluate its operands and perform the operation designated by that node's type, and return the result. Note: the TAO_Constraint_Evaluator assumes the tree is semantically correct, that is, the validate method on TAO_Constraint_Validator return true. The only possible evaluation time errors are a divide by a property whose value is zero and undefined properties.
TAO_Constraint_Evaluator::TAO_Constraint_Evaluator | ( | void | ) |
Constructor.
TAO_Constraint_Evaluator::TAO_Constraint_Evaluator | ( | const TAO_Constraint_Evaluator & | ) | [private] |
Disallow copying.
void TAO_Constraint_Evaluator::do_the_op | ( | int | operation | ) | [private] |
Method for performing a arithmetic or comparison operation.
CORBA::Boolean TAO_Constraint_Evaluator::evaluate_constraint | ( | TAO_Constraint * | root | ) |
Evaluate returns 1 if the offer satisfies the constraints represented by the the expression tree rooted at <root>, 0 if it doesn't. If an error occurs during process, the constraint automatically fails.
int TAO_Constraint_Evaluator::evaluate_preference | ( | TAO_Constraint * | root, |
TAO_Literal_Constraint & | result | ||
) |
The result of the preference evaluation is stored in result. The method returns 0 upon success, -1 upon failure.
TAO_Constraint_Evaluator& TAO_Constraint_Evaluator::operator= | ( | const TAO_Constraint_Evaluator & | ) | [private] |
CORBA::Boolean TAO_Constraint_Evaluator::sequence_does_contain | ( | CORBA::Any * | sequence, |
TAO_Literal_Constraint & | element | ||
) | [private] |
Determine if sequence contains element, a literal of the same simple type as <sequence_type>. Return true in this eventuality.
int TAO_Constraint_Evaluator::visit_add | ( | TAO_Binary_Constraint * | boolean_add | ) | [virtual] |
Add the results of evaluating the left and right operands.
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_and | ( | TAO_Binary_Constraint * | boolean_and | ) | [virtual] |
Takes the logical and of the results of both operands. Note that in the case where the left operand returns zero, the result is immediately known.
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_bin_op | ( | TAO_Binary_Constraint * | op, |
int | operation | ||
) | [private] |
Method for evaluating a binary operation.
int TAO_Constraint_Evaluator::visit_constraint | ( | TAO_Unary_Constraint * | constraint | ) | [virtual] |
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_div | ( | TAO_Binary_Constraint * | boolean_div | ) | [virtual] |
Divide the results of evaluating the left and right operands.
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_equal | ( | TAO_Binary_Constraint * | boolean_eq | ) | [virtual] |
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_exist | ( | TAO_Unary_Constraint * | unary_exist | ) | [virtual] |
The property exists if its name is bound to a value in the <props_> map.
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_first | ( | TAO_Noop_Constraint * | noop_first | ) | [virtual] |
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_greater_than | ( | TAO_Binary_Constraint * | boolean_gt | ) | [virtual] |
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_greater_than_equal | ( | TAO_Binary_Constraint * | boolean_gte | ) | [virtual] |
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_in | ( | TAO_Binary_Constraint * | binary_in | ) | [virtual] |
Determines if the sequence represented by the right operand contains the left operand.
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_less_than | ( | TAO_Binary_Constraint * | boolean_lt | ) | [virtual] |
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_less_than_equal | ( | TAO_Binary_Constraint * | boolean_lte | ) | [virtual] |
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_literal | ( | TAO_Literal_Constraint * | literal | ) | [virtual] |
Copy the value of the literal into the result container.
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_max | ( | TAO_Unary_Constraint * | unary_max | ) | [virtual] |
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_min | ( | TAO_Unary_Constraint * | unary_min | ) | [virtual] |
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_mult | ( | TAO_Binary_Constraint * | boolean_mult | ) | [virtual] |
Multiply the results of evaluating the left and right operands.
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_not | ( | TAO_Unary_Constraint * | unary_not | ) | [virtual] |
Logically negates the value of the operand.
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_not_equal | ( | TAO_Binary_Constraint * | boolean_neq | ) | [virtual] |
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_or | ( | TAO_Binary_Constraint * | boolean_or | ) | [virtual] |
Takes the logical or of the results of both operands. Note that in the case where the left operand returns one, the result is immediately known.
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_property | ( | TAO_Property_Constraint * | literal | ) | [virtual] |
Copy the value of the property into the result container.
Implements TAO_Constraint_Visitor.
Reimplemented in TAO_Trader_Constraint_Evaluator.
int TAO_Constraint_Evaluator::visit_random | ( | TAO_Noop_Constraint * | noop_random | ) | [virtual] |
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_sub | ( | TAO_Binary_Constraint * | boolean_sub | ) | [virtual] |
Subtract the results of evaluating the left and right operands.
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_twiddle | ( | TAO_Binary_Constraint * | binary_twiddle | ) | [virtual] |
Determines if the right operand is a substring of the left.
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_unary_minus | ( | TAO_Unary_Constraint * | unary_minus | ) | [virtual] |
Mathematically negates the return value the operand.
Implements TAO_Constraint_Visitor.
int TAO_Constraint_Evaluator::visit_with | ( | TAO_Unary_Constraint * | unary_with | ) | [virtual] |
Implements TAO_Constraint_Visitor.
TAO_Lookup_Table TAO_Constraint_Evaluator::props_ [protected] |
The map of property names to their values for a property.
Operand_Queue TAO_Constraint_Evaluator::queue_ [protected] |
The result of a non_boolean operation.