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)
 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)

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 
)

Definition at line 14 of file Constraint_Interpreter.cpp.

References ACE_NEW_THROW_EX, 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 }

TAO_Constraint_Interpreter::TAO_Constraint_Interpreter ( TAO_Constraint_Validator validator,
const char *  constraints 
)

This constructor builds an expression tree representing the constraint specified in <constraints>, 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::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 }

TAO_Constraint_Interpreter::~TAO_Constraint_Interpreter ( void   ) 

Destructor.

Definition at line 61 of file Constraint_Interpreter.cpp.

00062 {
00063 }


Member Function Documentation

CORBA::Boolean TAO_Constraint_Interpreter::evaluate ( TAO_Constraint_Evaluator evaluator  ) 

Definition at line 73 of file Constraint_Interpreter.cpp.

References TAO_Constraint_Evaluator::evaluate_constraint().

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

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

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().

00067 {
00068   TAO_Trader_Constraint_Evaluator evaluator (offer);
00069   return evaluator.evaluate_constraint (this->root_);
00070 }


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:49:31 2010 for TAO_CosTrader by  doxygen 1.4.7