#include <Constraint_Interpreter.h>
Inheritance diagram for TAO_Constraint_Interpreter:
Public Member Functions | |
TAO_Constraint_Interpreter (const CosTradingRepos::ServiceTypeRepository::TypeStruct &ts, const char *constraints) | |
TAO_Constraint_Interpreter (TAO_Constraint_Validator &validator, const char *constraints) | |
~TAO_Constraint_Interpreter (void) | |
Destructor. | |
CORBA::Boolean | evaluate (CosTrading::Offer *offer) |
CORBA::Boolean | evaluate (TAO_Constraint_Evaluator &evaluator) |
TAO_Constraint_Interpreter will first build an expression tree representing the constraint expression using Lex and Yacc. Then, using a TAO_Constraint_Validator, it will validate the semantic correctness of the tree. When the evaluate method is invoked with an Offer, the TAO_Constraint_Interpreter will construct an EvaluationVisitor, which will evaluate the tree and decide whether the offer meets the constraints.
Definition at line 46 of file Constraint_Interpreter.h.
|
Definition at line 14 of file Constraint_Interpreter.cpp. References ACE_NEW_THROW_EX, TAO_Interpreter::build_tree(), TAO_Interpreter::is_empty_string(), and TAO_Constraint_Validator::validate().
00018 : TAO_Interpreter () 00019 { 00020 // @@ Throwing Exception from constructor is very nasty situation to 00021 // deal with. 00022 00023 TAO_Trader_Constraint_Validator type_checker (ts); 00024 00025 if (TAO_Interpreter::is_empty_string (constraints)) 00026 { 00027 ACE_NEW_THROW_EX (this->root_, 00028 TAO_Literal_Constraint ((CORBA::Boolean) 1), 00029 CORBA::NO_MEMORY ()); 00030 } 00031 else 00032 { 00033 if (this->build_tree (constraints) != 0) 00034 throw CosTrading::IllegalConstraint (constraints); 00035 00036 if (type_checker.validate (this->root_) == -1) 00037 throw CosTrading::IllegalConstraint (constraints); 00038 } 00039 } |
|
This constructor builds an expression tree representing the constraint specified in , and throws an Illegal Constraint exception if the constraint given has syntax errors or semantic errors, such as mismatched types. Definition at line 42 of file Constraint_Interpreter.cpp. References ACE_NEW_THROW_EX, TAO_Interpreter::build_tree(), TAO_Interpreter::is_empty_string(), and TAO_Constraint_Validator::validate().
00044 { 00045 if (TAO_Interpreter::is_empty_string (constraints)) 00046 { 00047 ACE_NEW_THROW_EX (this->root_, 00048 TAO_Literal_Constraint ((CORBA::Boolean) 1), 00049 CORBA::NO_MEMORY ()); 00050 } 00051 else 00052 { 00053 if (this->build_tree (constraints) != 0) 00054 throw CosTrading::IllegalConstraint (constraints); 00055 00056 if (validator.validate (this->root_) == -1) 00057 throw CosTrading::IllegalConstraint (constraints); 00058 } 00059 } |
|
Destructor.
Definition at line 61 of file Constraint_Interpreter.cpp.
00062 { 00063 } |
|
Definition at line 73 of file Constraint_Interpreter.cpp. References TAO_Constraint_Evaluator::evaluate_constraint().
00074 { 00075 return evaluator.evaluate_constraint (this->root_); 00076 } |
|
Definition at line 66 of file Constraint_Interpreter.cpp. References TAO_Constraint_Evaluator::evaluate_constraint(). Referenced by TAO_Lookup< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::lookup_one_type(), and TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::withdraw_using_constraint().
00067 { 00068 TAO_Trader_Constraint_Evaluator evaluator (offer); 00069 return evaluator.evaluate_constraint (this->root_); 00070 } |