TAO_Constraint_Interpreter Class Reference

TAO_Constraint_Interpreter will, given a constraint string whose syntax and semantics comply with the trader specification for the constraint language, determine if a CosTrading::Offer meets the constraints. More...

#include <Constraint_Interpreter.h>

Inheritance diagram for TAO_Constraint_Interpreter:

Inheritance graph
[legend]
Collaboration diagram for TAO_Constraint_Interpreter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Constraint_Interpreter (const CosTradingRepos::ServiceTypeRepository::TypeStruct &ts, const char *constraints) throw (CosTrading::IllegalConstraint, CORBA::NO_MEMORY)
 TAO_Constraint_Interpreter (TAO_Constraint_Validator &validator, const char *constraints) throw (CosTrading::IllegalConstraint, CORBA::NO_MEMORY)
 ~TAO_Constraint_Interpreter (void)
 Destructor.

CORBA::Boolean evaluate (CosTrading::Offer *offer)
CORBA::Boolean evaluate (TAO_Constraint_Evaluator &evaluator)

Detailed Description

TAO_Constraint_Interpreter will, given a constraint string whose syntax and semantics comply with the trader specification for the constraint language, determine if a CosTrading::Offer meets the constraints.

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.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Constraint_Interpreter::TAO_Constraint_Interpreter const CosTradingRepos::ServiceTypeRepository::TypeStruct ts,
const char *  constraints
throw (CosTrading::IllegalConstraint, CORBA::NO_MEMORY)
 

Definition at line 13 of file Constraint_Interpreter.cpp.

References ACE_CHECK, ACE_NEW_THROW_EX, ACE_THROW, TAO_Interpreter::is_empty_string(), and TAO_Constraint_Validator::validate().

00020   : TAO_Interpreter ()
00021 {
00022   // @@ Throwing Exception from constructor is very nasty situation to
00023   // deal with.
00024 
00025   TAO_Trader_Constraint_Validator type_checker (ts);
00026 
00027   if (TAO_Interpreter::is_empty_string (constraints))
00028     {
00029       ACE_NEW_THROW_EX (this->root_,
00030                         TAO_Literal_Constraint ((CORBA::Boolean) 1),
00031                         CORBA::NO_MEMORY ());
00032       ACE_CHECK;
00033     }
00034   else
00035     {
00036       if (this->build_tree (constraints) != 0)
00037         ACE_THROW (CosTrading::IllegalConstraint (constraints));
00038 
00039       if (type_checker.validate (this->root_) == -1)
00040         ACE_THROW (CosTrading::IllegalConstraint (constraints));
00041     }
00042 }

TAO_Constraint_Interpreter::TAO_Constraint_Interpreter TAO_Constraint_Validator validator,
const char *  constraints
throw (CosTrading::IllegalConstraint, CORBA::NO_MEMORY)
 

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 45 of file Constraint_Interpreter.cpp.

References ACE_CHECK, ACE_NEW_THROW_EX, ACE_THROW, and TAO_Interpreter::is_empty_string().

00050 {
00051   if (TAO_Interpreter::is_empty_string (constraints))
00052     {
00053       ACE_NEW_THROW_EX (this->root_,
00054                         TAO_Literal_Constraint ((CORBA::Boolean) 1),
00055                         CORBA::NO_MEMORY ());
00056       ACE_CHECK;
00057     }
00058   else
00059     {
00060       if (this->build_tree (constraints) != 0)
00061         ACE_THROW (CosTrading::IllegalConstraint (constraints));
00062 
00063       if (validator.validate (this->root_) == -1)
00064         ACE_THROW (CosTrading::IllegalConstraint (constraints));
00065     }
00066 }

TAO_Constraint_Interpreter::~TAO_Constraint_Interpreter void   ) 
 

Destructor.

Definition at line 68 of file Constraint_Interpreter.cpp.

00069 {
00070 }


Member Function Documentation

CORBA::Boolean TAO_Constraint_Interpreter::evaluate TAO_Constraint_Evaluator evaluator  ) 
 

Definition at line 80 of file Constraint_Interpreter.cpp.

References TAO_Constraint_Evaluator::evaluate_constraint().

00081 {
00082   return evaluator.evaluate_constraint (this->root_);
00083 }

CORBA::Boolean TAO_Constraint_Interpreter::evaluate CosTrading::Offer offer  ) 
 

Definition at line 73 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().

00074 {
00075   TAO_Trader_Constraint_Evaluator evaluator (offer);
00076   return evaluator.evaluate_constraint (this->root_);
00077 }


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 14:00:48 2006 for TAO_CosTrader by doxygen 1.3.6