From 8c3acf83c6ebdb83436580b7ce4d30b9bb067e9d Mon Sep 17 00:00:00 2001 From: nobody Date: Mon, 15 Feb 1999 19:18:27 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'ACE-4_6_22'. --- .../orbsvcs/Trader/Constraint_Interpreter.cpp | 335 ---- .../orbsvcs/Trader/Constraint_Interpreter.h | 232 --- TAO/orbsvcs/orbsvcs/Trader/Constraint_Nodes.cpp | 904 ---------- TAO/orbsvcs/orbsvcs/Trader/Constraint_Nodes.h | 323 ---- TAO/orbsvcs/orbsvcs/Trader/Constraint_Tokens.h | 36 - TAO/orbsvcs/orbsvcs/Trader/Constraint_Visitors.cpp | 1257 ------------- TAO/orbsvcs/orbsvcs/Trader/Constraint_Visitors.h | 452 ----- TAO/orbsvcs/orbsvcs/Trader/Constraint_l.cpp | 1765 ------------------ TAO/orbsvcs/orbsvcs/Trader/Constraint_y.cpp | 898 ---------- TAO/orbsvcs/orbsvcs/Trader/Locking.h | 48 - TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp | 373 ---- TAO/orbsvcs/orbsvcs/Trader/Offer_Database.h | 197 -- TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators.cpp | 387 ---- TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators.h | 276 --- TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators_T.cpp | 107 -- TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators_T.h | 80 - .../orbsvcs/Trader/Service_Type_Repository.cpp | 650 ------- .../orbsvcs/Trader/Service_Type_Repository.h | 298 ---- TAO/orbsvcs/orbsvcs/Trader/Trader.cpp | 1102 ------------ TAO/orbsvcs/orbsvcs/Trader/Trader.h | 566 ------ TAO/orbsvcs/orbsvcs/Trader/Trader_Interfaces.cpp | 1872 -------------------- TAO/orbsvcs/orbsvcs/Trader/Trader_Interfaces.h | 1000 ----------- TAO/orbsvcs/orbsvcs/Trader/Trader_T.cpp | 337 ---- TAO/orbsvcs/orbsvcs/Trader/Trader_T.h | 260 --- TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.cpp | 1497 ---------------- TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.h | 772 -------- TAO/orbsvcs/orbsvcs/Trader/constraint.l | 131 -- TAO/orbsvcs/orbsvcs/Trader/constraint.y | 136 -- 28 files changed, 16291 deletions(-) delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Constraint_Interpreter.cpp delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Constraint_Interpreter.h delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Constraint_Nodes.cpp delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Constraint_Nodes.h delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Constraint_Tokens.h delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Constraint_Visitors.cpp delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Constraint_Visitors.h delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Constraint_l.cpp delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Constraint_y.cpp delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Locking.h delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Offer_Database.h delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators.cpp delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators.h delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators_T.cpp delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators_T.h delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.cpp delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.h delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Trader.cpp delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Trader.h delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Trader_Interfaces.cpp delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Trader_Interfaces.h delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Trader_T.cpp delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Trader_T.h delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.cpp delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.h delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/constraint.l delete mode 100644 TAO/orbsvcs/orbsvcs/Trader/constraint.y (limited to 'TAO/orbsvcs/orbsvcs/Trader') diff --git a/TAO/orbsvcs/orbsvcs/Trader/Constraint_Interpreter.cpp b/TAO/orbsvcs/orbsvcs/Trader/Constraint_Interpreter.cpp deleted file mode 100644 index 6c29d3f4c9c..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Constraint_Interpreter.cpp +++ /dev/null @@ -1,335 +0,0 @@ -// ======================================================================== -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Constraint_Interpreter.cpp -// -// = AUTHOR -// Seth Widoff -// -// ======================================================================== - -#include "ace/OS.h" -#include "Constraint_Interpreter.h" - -ACE_RCSID(Trader, Constraint_Interpreter, "$Id$") - - // ************************************************************* - // TAO_Interpreter - // ************************************************************* - -TAO_Interpreter::~TAO_Interpreter (void) -{ - delete root_; -} - -int -TAO_Interpreter::build_tree(const char* constraints) -{ - TAO_Lex_String_Input::reset((char*)constraints); - int return_value = 0; - - yyval.constraint_ = 0; - return_value = ::yyparse(); - - if (return_value == 0 && yyval.constraint_ != 0) - this->root_ = yyval.constraint_; - else - { - while (yylex() > 0) - ; - this->root_ = 0; - } - - return return_value; -} - - -int -TAO_Interpreter::is_empty_string(const char* str) -{ - int return_value = 0; - - if (str != 0) - { - int i = 0; - while (str[i] != '\0') - { - if (str[i] != ' ') - break; - - i++; - } - - if (str[i] == '\0') - return_value = 1; - } - - return return_value; -} - - // ************************************************************* - // TAO_Constraint_Interpreter - // ************************************************************* - -TAO_Constraint_Interpreter:: -TAO_Constraint_Interpreter (const CosTradingRepos::ServiceTypeRepository::TypeStruct& ts, - const char* constraints, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::IllegalConstraint)) - : TAO_Interpreter () -{ - TAO_Constraint_Validator type_checker (ts); - - if (TAO_Interpreter::is_empty_string (constraints)) - this->root_ = new TAO_Literal_Constraint ((CORBA::Boolean) 1); - else - { - if (this->build_tree (constraints) != 0) - TAO_THROW (CosTrading::IllegalConstraint (constraints)); - - if (type_checker.validate (this->root_) == -1) - TAO_THROW (CosTrading::IllegalConstraint (constraints)); - } -} - -TAO_Constraint_Interpreter:: -TAO_Constraint_Interpreter(TAO_Constraint_Validator& validator, - const char* constraints, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::IllegalConstraint)) -{ - if (TAO_Interpreter::is_empty_string (constraints)) - this->root_ = new TAO_Literal_Constraint ((CORBA::Boolean) 1); - else - { - if (this->build_tree (constraints) != 0) - TAO_THROW (CosTrading::IllegalConstraint (constraints)); - - if (validator.validate (this->root_) == -1) - TAO_THROW (CosTrading::IllegalConstraint (constraints)); - } -} - -TAO_Constraint_Interpreter::~TAO_Constraint_Interpreter (void) -{ -} - -CORBA::Boolean -TAO_Constraint_Interpreter::evaluate (CosTrading::Offer* offer) -{ - TAO_Constraint_Evaluator evaluator (offer); - return evaluator.evaluate_constraint (this->root_); -} - -CORBA::Boolean -TAO_Constraint_Interpreter::evaluate(TAO_Constraint_Evaluator& evaluator) -{ - return evaluator.evaluate_constraint (this->root_); -} - - // ************************************************************* - // TAO_Preference_Interpreter - // ************************************************************* - -TAO_Preference_Interpreter:: -TAO_Preference_Interpreter(const CosTradingRepos::ServiceTypeRepository::TypeStruct& ts, - const char* preference, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::Lookup::IllegalPreference)) - : TAO_Interpreter () -{ - TAO_Constraint_Validator type_checker (ts); - - if (TAO_Interpreter::is_empty_string (preference)) - this->root_ = new TAO_Noop_Constraint (TAO_FIRST); - else - { - if (this->build_tree (preference) != 0) - TAO_THROW (CosTrading::Lookup::IllegalPreference (preference)); - - if (type_checker.validate (this->root_) == -1) - TAO_THROW (CosTrading::Lookup::IllegalPreference (preference)); - } -} - -TAO_Preference_Interpreter:: -TAO_Preference_Interpreter(TAO_Constraint_Validator& validator, - const char* preference, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::Lookup::IllegalPreference)) - : TAO_Interpreter () -{ - if (TAO_Interpreter::is_empty_string (preference)) - this->root_ = new TAO_Noop_Constraint (TAO_FIRST); - else - { - if (this->build_tree (preference) != 0) - TAO_THROW (CosTrading::Lookup::IllegalPreference (preference)); - - if (validator.validate (this->root_) == -1) - TAO_THROW (CosTrading::Lookup::IllegalPreference (preference)); - } -} - -TAO_Preference_Interpreter::~TAO_Preference_Interpreter() -{ -} - -void -TAO_Preference_Interpreter:: -order_offer (CosTrading::Offer* offer, - CosTrading::OfferId offer_id) -{ - TAO_Constraint_Evaluator evaluator (offer); - this->order_offer (evaluator, offer, offer_id); -} - -void -TAO_Preference_Interpreter:: -order_offer (TAO_Constraint_Evaluator& evaluator, - CosTrading::Offer* offer, - CosTrading::OfferId offer_id) -{ - if (this->root_ != 0) - { - Preference_Info pref_info; - - pref_info.offer_ = offer; - pref_info.offer_id_ = offer_id; - pref_info.evaluated_ = 1; - - if (evaluator.evaluate_preference (this->root_, pref_info.value_) == 0) - { - // If the evaluation succeeds, insert the node into the - // correct place in the queue. - TAO_Expression_Type expr_type = this->root_->expr_type (); - - if (expr_type == TAO_FIRST || - (expr_type == TAO_WITH && - ! ACE_static_cast (CORBA::Boolean, pref_info.value_))) - this->offers_.enqueue_tail (pref_info); - else - this->offers_.enqueue_head (pref_info); - - if (expr_type == TAO_MIN || expr_type == TAO_MAX) - { - Ordered_Offers::ITERATOR offer_iter (this->offers_); - - // Push the new item down the list until the min/max - // criterion is satisfied. Observe the evaluation - // failed / evaluation suceeded partion in the list. - offer_iter.advance (); - for (int i = 1; - ! offer_iter.done (); - offer_iter.advance (), i++) - { - Preference_Info* current_offer; - offer_iter.next (current_offer); - - // Maintain the sorted order in the first partition. - if (current_offer->evaluated_ == 1 && - ((expr_type == TAO_MIN && - pref_info.value_ > current_offer->value_) || - (expr_type == TAO_MAX && - pref_info.value_ < current_offer->value_))) - { - // Swap the out of order pair - this->offers_.set (*current_offer, i - 1); - this->offers_.set (pref_info, i); - } - else - break; - } - } - } - else - { - // If the evaluation fails, just tack the sucker onto the - // end of the queue. - pref_info.evaluated_ = 0; - this->offers_.enqueue_tail (pref_info); - } - } -} - -int -TAO_Preference_Interpreter:: -remove_offer (CosTrading::Offer*& offer, - CosTrading::OfferId& offer_id) -{ - int return_value = -1; - Preference_Info pref_info; - - return_value = this->offers_.dequeue_head (pref_info); - - if (return_value == 0) - { - offer = pref_info.offer_; - offer_id = pref_info.offer_id_; - } - - return return_value; -} - -int -TAO_Preference_Interpreter:: -remove_offer (CosTrading::Offer*& offer) -{ - CosTrading::OfferId offer_id = 0; - return this->remove_offer (offer, offer_id); -} - - -int -TAO_Preference_Interpreter::num_offers (void) -{ - return this->offers_.size(); -} - - // ************************************************************* - // Ugly Lex/Yacc Stuff - // ************************************************************* - -char* TAO_Lex_String_Input::string_ = 0; -char* TAO_Lex_String_Input::current_ = 0; -char* TAO_Lex_String_Input::end_ = 0; - -// Routine to have Lex read its input from the constraint string. - -int -TAO_Lex_String_Input::copy_into(char* buf, int max_size) -{ - int chars_left = TAO_Lex_String_Input::end_ - TAO_Lex_String_Input::current_; - int n = (max_size > chars_left) ? chars_left : max_size; - - if (n > 0) - { - memcpy(buf, TAO_Lex_String_Input::current_, n); - TAO_Lex_String_Input::current_ += n; - } - - return n; -} - -void -TAO_Lex_String_Input::reset(char* input_string) -{ - TAO_Lex_String_Input::string_ = input_string; - TAO_Lex_String_Input::current_ = input_string; - TAO_Lex_String_Input::end_ = input_string + - ACE_OS::strlen(TAO_Lex_String_Input::string_); -} - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Node; -template class ACE_Unbounded_Queue; -template class ACE_Unbounded_Queue_Iterator; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Node -#pragma instantiate ACE_Unbounded_Queue -#pragma instantiate ACE_Unbounded_Queue_Iterator -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Constraint_Interpreter.h b/TAO/orbsvcs/orbsvcs/Trader/Constraint_Interpreter.h deleted file mode 100644 index 26a1fb12b91..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Constraint_Interpreter.h +++ /dev/null @@ -1,232 +0,0 @@ -/* -*- C++ -*- */ - -// ======================================================================== -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Constraint_Interpreter.h -// -// = AUTHOR -// Seth Widoff -// -// ======================================================================== - -#ifndef TAO_CONSTRAINT_INTERPRETER_H -#define TAO_CONSTRAINT_INTERPRETER_H - -#include "Constraint_Nodes.h" -#include "Constraint_Visitors.h" - -class TAO_Constraint_Evaluator; -class TAO_Constraint_Validator; - - // ************************************************************* - // TAO_Interpreter - // ************************************************************* - -class TAO_Interpreter -// = TITLE -// TAO_Interpreter is the superclass for all interpreters. Its -// build tree method invokes the yacc parser to parse a constraint -// or preference string. -{ -protected: - - TAO_Interpreter (void) : root_ (0) {} - - ~TAO_Interpreter (void); - - int build_tree (const char* preferences); - // Using the Yacc generated parser, construct an expression - // tree representing from the tokens returned by it. - - static int is_empty_string (const char* str); - - TAO_Constraint* root_; - // The root of the expression tree, not equal to null if build_tree - // successfully builds a tree from the constraints. -}; - - // ************************************************************* - // TAO_Constraint_Interpreter - // ************************************************************* - -class TAO_Constraint_Interpreter : public TAO_Interpreter -// -// = TITLE -// 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. -// -// = DESCRIPTION -// 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. -{ -public: - - TAO_Constraint_Interpreter (const CosTradingRepos::ServiceTypeRepository::TypeStruct& ts, - const char* constraints, - CORBA::Environment& env) - TAO_THROW_SPEC ((CosTrading::IllegalConstraint)); - - TAO_Constraint_Interpreter (TAO_Constraint_Validator& validator, - const char* constraints, - CORBA::Environment& env) - TAO_THROW_SPEC ((CosTrading::IllegalConstraint)); - // 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. - - ~TAO_Constraint_Interpreter (void); - // Destructor - - CORBA::Boolean evaluate (CosTrading::Offer* offer); - - CORBA::Boolean evaluate (TAO_Constraint_Evaluator& evaluator); - - // Determine whether an offer fits the constraints with which the - // tree was constructed. This method is thread safe (hopefully). -}; - - // ************************************************************* - // TAO_Preference_Interpreter - // ************************************************************* - -class TAO_Preference_Interpreter : public TAO_Interpreter -// = TITLE -// The TAO_Preference_Interpreter will, given a valid preference -// string and offers, will order the offers based on the offers' -// compliance with the preferences. -// -// = DESCRIPTION -// Each time the order_offer method is invoked, the -// TAO_Preference_Interpreter stores the offer reference in the -// order dictated by its evaluation of the preference string. After -// the TAO_Preference_Interpreter client has finished ordering all -// the offers, it will extract the offers in order using the -// remove_offer method. -{ -public: - - TAO_Preference_Interpreter (const CosTradingRepos::ServiceTypeRepository::TypeStruct& ts, - const char* preference, - CORBA::Environment& env) - TAO_THROW_SPEC ((CosTrading::Lookup::IllegalPreference)); - - TAO_Preference_Interpreter (TAO_Constraint_Validator& validator, - const char* preference, - CORBA::Environment& env) - TAO_THROW_SPEC ((CosTrading::Lookup::IllegalPreference)); - - // Parse the preference string, determining first if it's - // valid. Throw an IllegalPreference exception if the preference - // doesn't conform to the BNF grammar for preferences. - - ~TAO_Preference_Interpreter(void); - // Destructor - - void order_offer (CosTrading::Offer* offer, - CosTrading::OfferId offer_id = 0); - - void order_offer (TAO_Constraint_Evaluator& evaluator, - CosTrading::Offer* offer, - CosTrading::OfferId offer_id = 0); - // Evaluate the offer, and order it internally based on the results - // of the evaluation. - - int remove_offer (CosTrading::Offer*& offer, - CosTrading::OfferId& offer_id); - - int remove_offer (CosTrading::Offer*& offer); - // Remove the next offer. The offer returned will be the next in the - // ordering determined by the preference string. - - int num_offers (void); - // Return the number of offers remaining in the ordering. - - struct Preference_Info - { - CORBA::Boolean evaluated_; - // True if the preference evaluation didn't return an error for this offer. - - TAO_Literal_Constraint value_; - // The value of the preference evaluation. - - CosTrading::OfferId offer_id_; - // The offer id of this offer. - - CosTrading::Offer* offer_; - // A pointer to the offer. - }; - - typedef ACE_Unbounded_Queue Ordered_Offers; - -private: - - TAO_Preference_Interpreter (const TAO_Preference_Interpreter&); - TAO_Preference_Interpreter& operator= (const TAO_Preference_Interpreter&); - // Disallow copying. - - Ordered_Offers offers_; - // The ordered list of offers. -}; - - // ************************************************************* - // Ugly Lex/Yacc Stuff - // ************************************************************* - -// Functions we need for parsing. -extern int yyparse(void); -extern void yyrestart(FILE*); -extern int yylex(void); - -// Have yylex read from the constraint string, not from stdin. -#undef YY_INPUT -#define YY_INPUT(b, r, ms) (r = TAO_Lex_String_Input::copy_into(b, ms)) - -#undef yyerror -#define yyerror(x) - -class TAO_Lex_String_Input -// = TITLE -// Stupid hack to have Lex read from a string and not from -// stdin. Essentially, the interpreter needs to call yylex() until -// EOF, and call TAO_Lex_String_Input::reset() with the new string, -// prior to calling yyparse. -{ -public: - - static void reset(char* input_string); - // Reset the lex input. - - static int copy_into(char* buf, int max_size); - // Method lex will call to read from the input string. - -private: - - static char* string_; - static char* current_; - static char* end_; - // Pointers to keep track of the input string. -}; - -// The union used by lex and yacc to build the Abstract Syntax Tree. -typedef union -{ - TAO_Constraint* constraint_; -} YYSTYPE; - -extern YYSTYPE yylval; -extern YYSTYPE yyval; - -#endif /* TAO_CONSTRAINT_INTERPRETER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Constraint_Nodes.cpp b/TAO/orbsvcs/orbsvcs/Trader/Constraint_Nodes.cpp deleted file mode 100644 index db7b154891a..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Constraint_Nodes.cpp +++ /dev/null @@ -1,904 +0,0 @@ -// ===================================================================== -// $Id$ -// -// = LIBRARY -// Lookup -// -// = FILENAME -// Constraint_Nodes.cpp -// -// = AUTHOR -// Seth Widoff -// -// ===================================================================== - - -#include "Constraint_Nodes.h" -#include "Constraint_Visitors.h" - -ACE_RCSID(Trader, Constraint_Nodes, "$Id$") - -const CORBA::Long MAX_SIGNED_INTEGER = (~(CORBA::Long)0) >> 1; -const CORBA::Long MIN_SIGNED_INTEGER = ~(MAX_SIGNED_INTEGER); -const CORBA::ULong MAX_UNSIGNED_INTEGER = (~(CORBA::ULong)0); - -int -TAO_Noop_Constraint::accept (TAO_Constraint_Visitor* visitor) -{ - int return_value = -1; - switch (this->type_) - { - case TAO_FIRST: - return_value = visitor->visit_first (this); - break; - case TAO_RANDOM: - return_value = visitor->visit_random (this); - } - - return return_value; -} - -TAO_Binary_Constraint:: -TAO_Binary_Constraint (TAO_Expression_Type op_type, - TAO_Constraint* left, - TAO_Constraint* right) - : op_ (op_type), - left_ (left), - right_ (right) -{ -} - -TAO_Binary_Constraint::~TAO_Binary_Constraint () -{ - delete left_; - delete right_; -} - -// Dispatch table for the accept method -static int (*dispatch_table[]) (TAO_Constraint_Visitor*, - TAO_Binary_Constraint*)= -{ - TAO_Binary_Constraint::visit_greater_than, - TAO_Binary_Constraint::visit_greater_than_equal, - TAO_Binary_Constraint::visit_less_than, - TAO_Binary_Constraint::visit_less_than_equal, - TAO_Binary_Constraint::visit_equal, - TAO_Binary_Constraint::visit_not_equal, - 0, - TAO_Binary_Constraint::visit_and, - TAO_Binary_Constraint::visit_or, - 0, - TAO_Binary_Constraint::visit_in, - TAO_Binary_Constraint::visit_twiddle, - 0, - TAO_Binary_Constraint::visit_add, - TAO_Binary_Constraint::visit_sub, - TAO_Binary_Constraint::visit_mult, - TAO_Binary_Constraint::visit_div -}; - -// Simulate the fun of actual double dispatching. -int -TAO_Binary_Constraint::accept (TAO_Constraint_Visitor* visitor) -{ - int offset = this->op_ - TAO_GT, - return_value = -1; - - if (dispatch_table[offset] != 0) - return_value = dispatch_table[offset](visitor, this); - - return return_value; -} - -int -TAO_Binary_Constraint:: -visit_or (TAO_Constraint_Visitor* visitor, - TAO_Binary_Constraint* expr) -{ - return visitor->visit_or(expr); -} - -int -TAO_Binary_Constraint:: -visit_and (TAO_Constraint_Visitor* visitor, - TAO_Binary_Constraint* expr) -{ - return visitor->visit_and(expr); -} - -int -TAO_Binary_Constraint:: -visit_less_than (TAO_Constraint_Visitor* visitor, - TAO_Binary_Constraint* expr) -{ - return visitor->visit_less_than (expr); -} - -int -TAO_Binary_Constraint:: -visit_less_than_equal (TAO_Constraint_Visitor* visitor, - TAO_Binary_Constraint* expr) -{ - return visitor->visit_less_than_equal (expr); -} - -int -TAO_Binary_Constraint:: -visit_greater_than (TAO_Constraint_Visitor* visitor, - TAO_Binary_Constraint* expr) -{ - return visitor->visit_greater_than (expr); -} - -int -TAO_Binary_Constraint:: -visit_greater_than_equal (TAO_Constraint_Visitor* visitor, - TAO_Binary_Constraint* expr) -{ - return visitor->visit_greater_than_equal (expr); -} - -int -TAO_Binary_Constraint:: -visit_equal (TAO_Constraint_Visitor* visitor, - TAO_Binary_Constraint* expr) -{ - return visitor->visit_equal (expr); -} - -int -TAO_Binary_Constraint:: -visit_not_equal (TAO_Constraint_Visitor* visitor, - TAO_Binary_Constraint* expr) -{ - return visitor->visit_not_equal (expr); -} - -int -TAO_Binary_Constraint:: -visit_add (TAO_Constraint_Visitor* visitor, - TAO_Binary_Constraint* expr) -{ - return visitor->visit_add (expr); -} - -int -TAO_Binary_Constraint:: -visit_sub (TAO_Constraint_Visitor* visitor, - TAO_Binary_Constraint* expr) -{ - return visitor->visit_sub (expr); -} - -int -TAO_Binary_Constraint:: -visit_mult (TAO_Constraint_Visitor* visitor, - TAO_Binary_Constraint* expr) -{ - return visitor->visit_mult (expr); -} - -int -TAO_Binary_Constraint:: -visit_div (TAO_Constraint_Visitor* visitor, - TAO_Binary_Constraint* expr) -{ - return visitor->visit_div (expr); -} - -int -TAO_Binary_Constraint:: -visit_twiddle (TAO_Constraint_Visitor* visitor, - TAO_Binary_Constraint* expr) -{ - return visitor->visit_twiddle (expr); -} - -int -TAO_Binary_Constraint:: -visit_in (TAO_Constraint_Visitor* visitor, - TAO_Binary_Constraint* expr) -{ - return visitor->visit_in (expr); -} - - -TAO_Constraint* -TAO_Binary_Constraint::left_operand (void) const -{ - return this->left_; -} - -TAO_Constraint* -TAO_Binary_Constraint::right_operand (void) const -{ - return this->right_; -} - -TAO_Unary_Constraint:: -TAO_Unary_Constraint (TAO_Expression_Type op_type, - TAO_Constraint* operand) - : op_ (op_type), - operand_ (operand) -{ -} - -TAO_Unary_Constraint::~TAO_Unary_Constraint (void) -{ - delete operand_; -} - - -int -TAO_Unary_Constraint::accept (TAO_Constraint_Visitor* visitor) -{ - // Since there are only three unary operators, there's no need for a - // dispatch table. - int return_value = -1; - switch (this->op_) - { - case TAO_CONSTRAINT: - return_value = visitor->visit_constraint (this); - break; - case TAO_WITH: - return_value = visitor->visit_with (this); - break; - case TAO_MIN: - return_value = visitor->visit_min (this); - break; - case TAO_MAX: - return_value = visitor->visit_max (this); - break; - case TAO_NOT: - return_value = visitor->visit_not (this); - break; - case TAO_UMINUS: - return_value = visitor->visit_unary_minus (this); - break; - case TAO_EXIST: - return_value = visitor->visit_exist (this); - break; - } - - return return_value; -} - -TAO_Constraint* -TAO_Unary_Constraint::operand (void) -{ - return this->operand_; -} - -TAO_Property_Constraint:: -TAO_Property_Constraint (const char* name) - : name_ (CORBA::string_dup (name)) -{ -} - -TAO_Property_Constraint::~TAO_Property_Constraint (void) -{ - CORBA::string_free (this->name_); -} - -int -TAO_Property_Constraint::accept(TAO_Constraint_Visitor* visitor) -{ - return visitor->visit_property (this); -} - -const char* -TAO_Property_Constraint::name (void) const -{ - return name_; -} - -TAO_Literal_Constraint:: -TAO_Literal_Constraint (const TAO_Literal_Constraint& lit) -{ - this->copy (lit); -} - - -TAO_Literal_Constraint:: -TAO_Literal_Constraint (CORBA::Any* any) -{ - CORBA::Environment env; - CORBA::Any& any_ref = *any; - CORBA::TypeCode_var type = any_ref.type (); - CORBA::TCKind corba_type = type->kind (env); - TAO_CHECK_ENV_RETURN_VOID (env); - - this->type_ = TAO_Literal_Constraint::comparable_type (type.in ()); - switch(this->type_) - { - case TAO_SIGNED: - this->op_.integer_ = 0; - if (corba_type == CORBA::tk_short) - { - CORBA::Short sh; - any_ref >>= sh; - this->op_.integer_ = (CORBA::Long)sh; - } - else - any_ref >>= this->op_.integer_; - break; - case TAO_UNSIGNED: - this->op_.uinteger_ = 0; - if (corba_type == CORBA::tk_ushort) - { - CORBA::UShort sh; - any_ref >>= sh; - this->op_.uinteger_ = (CORBA::ULong)sh; - } - else - any_ref >>= this->op_.uinteger_; - break; - case TAO_DOUBLE: - if (corba_type == CORBA::tk_float) - { - CORBA::Float fl; - (*any) >>= fl; - this->op_.double_ = (CORBA::Double)fl; - } - else - (*any) >>= this->op_.double_; - break; - case TAO_BOOLEAN: - { - CORBA_Any::to_boolean tmp(this->op_.bool_); - (*any) >>= tmp; - } - break; - case TAO_STRING: - { - char* s; - any_ref >>= s; - this->op_.str_ = CORBA::string_dup (s); - } - break; - case TAO_SEQUENCE: - this->op_.any_ = any; - } -} - -TAO_Literal_Constraint::TAO_Literal_Constraint (CORBA::ULong uinteger) - : type_ (TAO_UNSIGNED) -{ - this->op_.uinteger_ = uinteger; -} - -TAO_Literal_Constraint::TAO_Literal_Constraint (CORBA::Long integer) - : type_ (TAO_SIGNED) -{ - this->op_.integer_ = integer; -} - -TAO_Literal_Constraint::TAO_Literal_Constraint (CORBA::Boolean boolean) - : type_ (TAO_BOOLEAN) -{ - this->op_.bool_ = boolean; -} - -TAO_Literal_Constraint::TAO_Literal_Constraint (CORBA::Double doub) - : type_ (TAO_DOUBLE) -{ - this->op_.double_ = doub; -} - -TAO_Literal_Constraint::TAO_Literal_Constraint (const char* str) - : type_ (TAO_STRING) -{ - this->op_.str_ = CORBA::string_dup (str); -} - -TAO_Literal_Constraint::~TAO_Literal_Constraint (void) -{ - if (this->type_ == TAO_STRING) - CORBA::string_free (this->op_.str_); -} - -int -TAO_Literal_Constraint::accept (TAO_Constraint_Visitor* visitor) -{ - return visitor->visit_literal(this); -} - -void -TAO_Literal_Constraint::operator= (const TAO_Literal_Constraint& co) -{ - this->copy (co); -} - -TAO_Literal_Constraint::operator CORBA::Boolean (void) const -{ - return (this->type_ == TAO_BOOLEAN) ? this->op_.bool_ : 0; -} - -TAO_Literal_Constraint::operator CORBA::ULong (void) const -{ - CORBA::ULong return_value = (CORBA::ULong)0; - - if (this->type_ == TAO_UNSIGNED) - return_value = this->op_.uinteger_; - else if (this->type_ == TAO_SIGNED) - return_value = - (this->op_.integer_ > 0) ? (CORBA::ULong)this->op_.integer_ : 0; - else if (this->type_ == TAO_DOUBLE) - return_value = - (this->op_.double_ > 0) ? - ((this->op_.double_ > MAX_UNSIGNED_INTEGER) ? - MAX_UNSIGNED_INTEGER : - (CORBA::ULong)this->op_.double_) - : 0; - - return return_value; -} - -TAO_Literal_Constraint::operator CORBA::Long (void) const -{ - CORBA::Long return_value = (CORBA::Long)0; - - if (this->type_ == TAO_SIGNED) - return_value = this->op_.integer_; - else if (this->type_ == TAO_UNSIGNED) - return_value = - (this->op_.uinteger_ > (CORBA::ULong) MAX_SIGNED_INTEGER) ? - MAX_SIGNED_INTEGER : (CORBA::Long) this->op_.uinteger_; - else if (this->type_ == TAO_DOUBLE) - return_value = - (this->op_.double_ > 0) ? - ((this->op_.double_ > MAX_SIGNED_INTEGER) ? - MAX_SIGNED_INTEGER : - (CORBA::Long)this->op_.double_) : - ((this->op_.double_ < MIN_SIGNED_INTEGER) ? - MIN_SIGNED_INTEGER : - (CORBA::Long)this->op_.double_); - - return return_value; -} - -TAO_Literal_Constraint::operator CORBA::Double (void) const -{ - CORBA::Double return_value = (CORBA::Double)0.0; - - if (this->type_ == TAO_DOUBLE) - return_value = this->op_.double_; - else if (this->type_ == TAO_SIGNED) - return_value = (CORBA::Double)this->op_.integer_; - else if (this->type_ == TAO_UNSIGNED) - return_value = (CORBA::Double)this->op_.uinteger_; - - return return_value; -} - -TAO_Literal_Constraint::operator const char* (void) const -{ - return (this->type_ == TAO_STRING) ? this->op_.str_ : 0; -} - -TAO_Literal_Constraint::operator const CORBA::Any* (void) const -{ - return (this->type_ == TAO_SEQUENCE) ? this->op_.any_ : 0; -} - -TAO_Expression_Type -TAO_Literal_Constraint::comparable_type (CORBA::TypeCode_ptr type) -{ - // Convert a CORBA::TCKind into a TAO_Literal_Type - CORBA::Environment env; - TAO_Expression_Type return_value = TAO_UNKNOWN; - CORBA::TCKind kind = type->kind (env); - TAO_CHECK_ENV_RETURN (env, return_value); - - switch (kind) - { - case CORBA::tk_ushort: - case CORBA::tk_ulong: - return_value = TAO_UNSIGNED; - break; - case CORBA::tk_long: - case CORBA::tk_short: - return_value = TAO_SIGNED; - break; - case CORBA::tk_boolean: - return_value = TAO_BOOLEAN; - break; - case CORBA::tk_float: - case CORBA::tk_double: - return_value = TAO_DOUBLE; - break; - case CORBA::tk_string: - return_value = TAO_STRING; - break; - case CORBA::tk_sequence: - return_value = TAO_SEQUENCE; - break; - case CORBA::tk_alias: - { - CORBA::TypeCode_ptr typecode = type->content_type (env); - TAO_CHECK_ENV_RETURN (env, return_value); - CORBA::TCKind kind = typecode->kind (env); - TAO_CHECK_ENV_RETURN (env, return_value); - - if (kind == CORBA::tk_sequence) - return_value = TAO_SEQUENCE; - } - break; - default: - return_value = TAO_UNKNOWN; - } - - return return_value; -} - -int -operator== (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right) -{ - int return_value = 0; - TAO_Expression_Type widest_type = - TAO_Literal_Constraint::widest_type(left, right); - - switch (widest_type) - { - case TAO_STRING: - return_value = (ACE_OS::strcmp((const char*)left, (const char*)right) == 0); - break; - case TAO_DOUBLE: - return_value = (CORBA::Double)left == (CORBA::Double)right; - break; - case TAO_SIGNED: - return_value = (CORBA::Long)left == (CORBA::Long)right; - break; - case TAO_UNSIGNED: - return_value = (CORBA::ULong)left == (CORBA::ULong)right; - break; - case TAO_BOOLEAN: - return_value = (CORBA::Boolean)left == (CORBA::Boolean)right; - break; - } - - return return_value; -} - - -int -operator!= (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right) -{ - int return_value = 0; - TAO_Expression_Type widest_type = - TAO_Literal_Constraint::widest_type(left, right); - - switch (widest_type) - { - case TAO_STRING: - return_value = (ACE_OS::strcmp((const char*)left, (const char*)right) != 0); - break; - case TAO_DOUBLE: - return_value = (CORBA::Double)left != (CORBA::Double)right; - break; - case TAO_SIGNED: - return_value = (CORBA::Long)left != (CORBA::Long)right; - break; - case TAO_UNSIGNED: - return_value = (CORBA::ULong)left != (CORBA::ULong)right; - break; - case TAO_BOOLEAN: - return_value = (CORBA::Boolean)left != (CORBA::Boolean)right; - break; - } - - return return_value; -} - -int -operator< (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right) -{ - int return_value = 0; - TAO_Expression_Type widest_type = - TAO_Literal_Constraint::widest_type(left, right); - - switch (widest_type) - { - case TAO_STRING: - return_value = (ACE_OS::strcmp((const char*)left, (const char*)right) < 0); - break; - case TAO_DOUBLE: - return_value = (CORBA::Double)left < (CORBA::Double)right; - break; - case TAO_SIGNED: - return_value = (CORBA::Long)left < (CORBA::Long)right; - break; - case TAO_UNSIGNED: - return_value = (CORBA::ULong)left < (CORBA::ULong)right; - break; - case TAO_BOOLEAN: - return_value = (CORBA::Boolean) left < (CORBA::Boolean) right; - break; - } - - return return_value; -} - -int -operator<= (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right) -{ - int return_value = 0; - TAO_Expression_Type widest_type = - TAO_Literal_Constraint::widest_type(left, right); - - switch (widest_type) - { - case TAO_STRING: - return_value = (ACE_OS::strcmp((const char*)left, (const char*)right) <= 0); - break; - case TAO_DOUBLE: - return_value = (CORBA::Double)left <= (CORBA::Double)right; - break; - case TAO_SIGNED: - return_value = (CORBA::Long)left <= (CORBA::Long)right; - break; - case TAO_UNSIGNED: - return_value = (CORBA::ULong)left <= (CORBA::ULong)right; - break; - } - - return return_value; -} - -int -operator> (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right) -{ - int return_value = 0; - TAO_Expression_Type widest_type = - TAO_Literal_Constraint::widest_type(left, right); - - switch (widest_type) - { - case TAO_STRING: - return_value = (ACE_OS::strcmp((const char*)left, (const char*)right) > 0); - break; - case TAO_DOUBLE: - return_value = (CORBA::Double)left > (CORBA::Double)right; - break; - case TAO_SIGNED: - return_value = (CORBA::Long)left > (CORBA::Long)right; - break; - case TAO_UNSIGNED: - return_value = (CORBA::ULong)left > (CORBA::ULong)right; - break; - } - - return return_value; -} - -int -operator>= (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right) -{ - int return_value = 0; - TAO_Expression_Type widest_type = - TAO_Literal_Constraint::widest_type(left, right); - - switch (widest_type) - { - case TAO_STRING: - return_value = (ACE_OS::strcmp((const char*)left, (const char*)right) >= 0); - break; - case TAO_DOUBLE: - return_value = (CORBA::Double)left >= (CORBA::Double)right; - break; - case TAO_SIGNED: - return_value = (CORBA::Long)left >= (CORBA::Long)right; - break; - case TAO_UNSIGNED: - return_value = (CORBA::ULong)left >= (CORBA::ULong)right; - break; - } - - return return_value; -} - - -int -operator== (CORBA::Double left, const TAO_Literal_Constraint& right) -{ - return (left == (CORBA::Double) right); -} - -int -operator== (const TAO_String_Manager& left, - const TAO_Literal_Constraint& right) -{ - int result = 0; - - if ((const char*)right != 0) - result = ACE_OS::strcmp ((const char*) left, - (const char*) right) == 0; - return result; -} - - -TAO_Literal_Constraint -operator+ (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right) -{ - TAO_Expression_Type widest_type = - TAO_Literal_Constraint::widest_type(left, right); - - switch (widest_type) - { - case TAO_DOUBLE: - { - CORBA::Double result = (CORBA::Double)left + (CORBA::Double)right; - return TAO_Literal_Constraint((CORBA::Double)result); - } - case TAO_SIGNED: - { - CORBA::Long result = (CORBA::Long)left + (CORBA::Long)right; - return TAO_Literal_Constraint((CORBA::Long)result); - } - case TAO_UNSIGNED: - { - CORBA::ULong result = (CORBA::ULong)left + (CORBA::ULong)right; - return TAO_Literal_Constraint((CORBA::ULong)result); - } - default: - return TAO_Literal_Constraint((CORBA::Long)0); - } -} - -TAO_Literal_Constraint -operator- (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right) -{ - TAO_Expression_Type widest_type = - TAO_Literal_Constraint::widest_type(left, right); - - switch (widest_type) - { - case TAO_DOUBLE: - { - CORBA::Double result = (CORBA::Double)left - (CORBA::Double)right; - return TAO_Literal_Constraint((CORBA::Double)result); - } - case TAO_SIGNED: - { - CORBA::Long result = (CORBA::Long)left - (CORBA::Long)right; - return TAO_Literal_Constraint((CORBA::Long)result); - } - case TAO_UNSIGNED: - { - CORBA::ULong result = (CORBA::ULong)left - (CORBA::ULong)right; - return TAO_Literal_Constraint((CORBA::ULong)result); - } - default: - return TAO_Literal_Constraint((CORBA::Long)0); - } -} - -TAO_Literal_Constraint -operator* (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right) -{ - TAO_Expression_Type widest_type = - TAO_Literal_Constraint::widest_type(left, right); - - switch (widest_type) - { - case TAO_DOUBLE: - { - CORBA::Double result = (CORBA::Double)left * (CORBA::Double)right; - return TAO_Literal_Constraint((CORBA::Double)result); - } - case TAO_SIGNED: - { - CORBA::Long result = (CORBA::Long)left * (CORBA::Long)right; - return TAO_Literal_Constraint((CORBA::Long)result); - } - case TAO_UNSIGNED: - { - CORBA::ULong result = (CORBA::ULong)left * (CORBA::ULong)right; - return TAO_Literal_Constraint((CORBA::ULong)result); - } - default: - return TAO_Literal_Constraint((CORBA::Long)0); - } -} - -TAO_Literal_Constraint -operator/ (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right) -{ - TAO_Expression_Type widest_type = - TAO_Literal_Constraint::widest_type(left, right); - - switch (widest_type) - { - case TAO_DOUBLE: - { - CORBA::Double result = (CORBA::Double)left / (CORBA::Double)right; - return TAO_Literal_Constraint((CORBA::Double)result); - } - case TAO_SIGNED: - { - CORBA::Long result = (CORBA::Long)left / (CORBA::Long)right; - return TAO_Literal_Constraint((CORBA::Long)result); - } - case TAO_UNSIGNED: - { - CORBA::ULong result = (CORBA::ULong)left / (CORBA::ULong)right; - return TAO_Literal_Constraint((CORBA::ULong)result); - } - default: - return TAO_Literal_Constraint((CORBA::Long)0); - } -} - -TAO_Literal_Constraint -operator- (const TAO_Literal_Constraint& operand) -{ - switch (operand.expr_type ()) - { - case TAO_DOUBLE: - { - CORBA::Double result = - (CORBA::Double)operand; - return TAO_Literal_Constraint((CORBA::Double)result); - } - case TAO_SIGNED: - { - CORBA::Long result = - (CORBA::Long)operand; - return TAO_Literal_Constraint((CORBA::Long)result); - } - case TAO_UNSIGNED: - { - CORBA::Long result = - (CORBA::Long)((CORBA::ULong)operand); - return TAO_Literal_Constraint((CORBA::ULong)result); - } - default: - return TAO_Literal_Constraint((CORBA::Long)0); - } -} - -TAO_Expression_Type -TAO_Literal_Constraint::widest_type (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right) -{ - TAO_Expression_Type left_type = left.expr_type (), - right_type = right.expr_type (), - return_value = right_type; - - if (right_type != left_type) - { - if (right_type > left_type) - return_value = right_type; - else - return_value = left_type; - } - - return return_value; -} - -void -TAO_Literal_Constraint::copy (const TAO_Literal_Constraint& lit) -{ - this->type_ = lit.type_; - if (this->type_ == TAO_STRING) - this->op_.str_ = CORBA::string_dup (lit.op_.str_); - else if (this->type_ == TAO_DOUBLE) - this->op_.double_ = lit.op_.double_; - else if (this->type_ == TAO_UNSIGNED) - this->op_.uinteger_ = lit.op_.uinteger_; - else if (this->type_ == TAO_SIGNED) - this->op_.integer_ = lit.op_.integer_; - else if (this->type_ == TAO_BOOLEAN) - this->op_.bool_ = lit.op_.bool_; - else if (this->type_ == TAO_SEQUENCE) - this->op_.any_ = lit.op_.any_; - else - type_ = TAO_UNKNOWN; -} diff --git a/TAO/orbsvcs/orbsvcs/Trader/Constraint_Nodes.h b/TAO/orbsvcs/orbsvcs/Trader/Constraint_Nodes.h deleted file mode 100644 index 0b953421d15..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Constraint_Nodes.h +++ /dev/null @@ -1,323 +0,0 @@ -/* -*- C++ -*- */ - -// ===================================================================== -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Constraint_Nodes.h -// -// = AUTHOR -// Seth Widoff -// -// ===================================================================== - -#ifndef TAO_CONSTRAINT_NODES_H -#define TAO_CONSTRAINT_NODES_H - -#include "Constraint_Tokens.h" -#include "orbsvcs/CosTradingC.h" - -#if defined(_MSC_VER) -#pragma warning (disable:4250) -#endif /* _MSC_VER */ - -class TAO_Constraint_Visitor; -typedef unsigned short TAO_Expression_Type; - -class TAO_Constraint -// -// = TITLE -// TAO_Constraint is the base class of all nodes on the -// constraint expression tree. -// -// = DESCRIPTION -// An TAO_Constraint knows what type of operation or entity -// it represents, and which method on TAO_Constraint_Visitor -// correlates to its type. When the accept method is invoked, a -// subclass dispatches the method on an TAO_Constraint_Visitor -// correlating to its type. -{ -public: - - virtual int accept (TAO_Constraint_Visitor* visitor) = 0; - // Implementing the pattern of double dispatching, each subclass of - // TAO_Constraint will call back on an InterpreterVisitor the - // method to handle a node of its ExpressionType. - - virtual TAO_Expression_Type expr_type (void) const = 0; - // Return the expression type represented by this node. - - virtual ~TAO_Constraint (void) {} -}; - -class TAO_Noop_Constraint : public TAO_Constraint -// = TITLE -// A node that represents an operation with no operands. -{ -public: - - TAO_Noop_Constraint (TAO_Expression_Type type) - : type_ (type) {} - - virtual int accept (TAO_Constraint_Visitor* visitor); - - virtual TAO_Expression_Type expr_type (void) const - { return this->type_; } - -private: - - TAO_Expression_Type type_; -}; - -class TAO_Binary_Constraint : public TAO_Constraint -// -// = TITLE -// TAO_Binary_Constraint represents an operation with left -// and right operands. -{ -public: - - TAO_Binary_Constraint (TAO_Expression_Type op_type, - TAO_Constraint* left, - TAO_Constraint* right); - - virtual int accept (TAO_Constraint_Visitor* visitor); - - virtual ~TAO_Binary_Constraint (void); - - virtual TAO_Expression_Type expr_type (void) const - { return this->op_; } - - TAO_Constraint* left_operand (void) const; - // Return the left operand of the binary expression - - TAO_Constraint* right_operand (void) const; - // Return the right operand of the binary expression - - // Allow double dispatching without creating an inundation of - // classes by using a dispatch table of static method pointers to - // invoke the correct visitor method as efficiently as a virtual - // method invocation. - static int visit_or (TAO_Constraint_Visitor*, TAO_Binary_Constraint*); - static int visit_and (TAO_Constraint_Visitor* , TAO_Binary_Constraint*); - static int visit_less_than (TAO_Constraint_Visitor* , TAO_Binary_Constraint*); - static int visit_less_than_equal (TAO_Constraint_Visitor* , TAO_Binary_Constraint*); - static int visit_greater_than (TAO_Constraint_Visitor* , TAO_Binary_Constraint*); - static int visit_greater_than_equal (TAO_Constraint_Visitor* , TAO_Binary_Constraint*); - static int visit_equal (TAO_Constraint_Visitor* , TAO_Binary_Constraint*); - static int visit_not_equal (TAO_Constraint_Visitor* , TAO_Binary_Constraint*); - static int visit_add (TAO_Constraint_Visitor* , TAO_Binary_Constraint*); - static int visit_sub (TAO_Constraint_Visitor* , TAO_Binary_Constraint*); - static int visit_mult (TAO_Constraint_Visitor* , TAO_Binary_Constraint*); - static int visit_div (TAO_Constraint_Visitor* , TAO_Binary_Constraint*); - static int visit_twiddle (TAO_Constraint_Visitor* , TAO_Binary_Constraint*); - static int visit_in (TAO_Constraint_Visitor* , TAO_Binary_Constraint*); - -private: - - TAO_Binary_Constraint (const TAO_Binary_Constraint&); - TAO_Binary_Constraint& operator= (const TAO_Binary_Constraint&); - - TAO_Expression_Type op_; - // The operator type - - TAO_Constraint* left_; - TAO_Constraint* right_; - // The operands of the expression -}; - -class TAO_Unary_Constraint : public TAO_Constraint -// -// = TITLE -// TAO_Unary_Constraint represents an operation with only -// one operand. -{ -public: - - TAO_Unary_Constraint (TAO_Expression_Type op_type, - TAO_Constraint* operand); - - virtual ~TAO_Unary_Constraint (void); - - virtual int accept (TAO_Constraint_Visitor* visitor); - - virtual TAO_Expression_Type expr_type (void) const - { return this->op_; } - - TAO_Constraint* operand (void); - -private: - - TAO_Unary_Constraint (const TAO_Unary_Constraint&); - TAO_Unary_Constraint& operator= (const TAO_Unary_Constraint&); - - TAO_Expression_Type op_; - // The operator type - - TAO_Constraint* operand_; - // The operand of the expression -}; - -class TAO_Property_Constraint : public TAO_Constraint -// -// = TITLE -// TAO_Property_Constraint represents a property whose -// value is determined by the offer being evaluated. -{ -public: - - TAO_Property_Constraint (const char* name); - - virtual ~TAO_Property_Constraint (void); - - virtual int accept (TAO_Constraint_Visitor* visitor); - - virtual TAO_Expression_Type expr_type (void) const - { return TAO_IDENT; } - - const char* name (void) const; - // Returns the name of the property. - -private: - - TAO_Property_Constraint (const TAO_Property_Constraint&); - TAO_Property_Constraint& operator= (const TAO_Property_Constraint&); - - char* name_; - // The name of the property. -}; - -class TAO_Literal_Constraint : public TAO_Constraint -// -// = TITLE -// TAO_Literal_Constraint represents a literal occuring in -// the constraint expression tree. -{ - public: - - TAO_Literal_Constraint (void) - : type_ (TAO_UNKNOWN) {} - - // = Constructors for each of the various types of literals. - - TAO_Literal_Constraint (CORBA::Any* any); - TAO_Literal_Constraint (CORBA::ULong uinteger); - TAO_Literal_Constraint (CORBA::Long integer); - TAO_Literal_Constraint (CORBA::Boolean boolean); - TAO_Literal_Constraint (CORBA::Double doub); - TAO_Literal_Constraint (const char* str); - - TAO_Literal_Constraint (const TAO_Literal_Constraint& lit); - // Copy constructor - - ~TAO_Literal_Constraint(void); - // Destructor. - - virtual int accept (TAO_Constraint_Visitor* visitor); - // Visitor accept methods. - - virtual TAO_Expression_Type expr_type (void) const - { return type_; } - - void operator= (const TAO_Literal_Constraint& co); - // Assignment operator. - - // Conversion routines. - operator CORBA::Boolean (void) const; - operator CORBA::ULong (void) const; - operator CORBA::Long (void) const; - operator CORBA::Double (void) const; - operator const char* (void) const; - operator const CORBA::Any* (void) const; - - // Return the type represented by this MysteryOperand. - - // = Comparison operators. - - friend int - operator< (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right); - - friend int - operator<= (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right); - - friend int - operator> (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right); - - friend int - operator>= (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right); - - friend int - operator== (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right); - - friend int - operator!= (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right); - - friend int - operator== (double left, - const TAO_Literal_Constraint& right); - - friend int - operator== (const TAO_String_Manager& left, - const TAO_Literal_Constraint& right); - - // = Arithmetic operators. - - friend TAO_Literal_Constraint - operator+ (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right); - - friend TAO_Literal_Constraint - operator- (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right); - - friend TAO_Literal_Constraint - operator* (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right); - - friend TAO_Literal_Constraint - operator/ (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right); - - friend TAO_Literal_Constraint - operator- (const TAO_Literal_Constraint& operand); - - static TAO_Expression_Type - widest_type (const TAO_Literal_Constraint& left, - const TAO_Literal_Constraint& right); - // Ensure both operands are of the same simple numeric type. - - static TAO_Expression_Type - comparable_type (CORBA::TypeCode_ptr type); - // Determine the comparable Expression Type from the CORBA type - - private: - - void copy (const TAO_Literal_Constraint& co); - // Private copy method. - - union - { - char* str_; - CORBA::Any_ptr any_; - CORBA::ULong uinteger_; - CORBA::Long integer_; - CORBA::Boolean bool_; - CORBA::Double double_; - } op_; - // Union of the possible literal types. - - TAO_Expression_Type type_; - // The actual types of the TAO_Literal_Constraint. - -}; - -#endif /* TAO_CONSTRAINT_NODES_H */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Constraint_Tokens.h b/TAO/orbsvcs/orbsvcs/Trader/Constraint_Tokens.h deleted file mode 100644 index c5001d91f08..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Constraint_Tokens.h +++ /dev/null @@ -1,36 +0,0 @@ -// $Id$ - -# define TAO_GT 257 -# define TAO_GE 258 -# define TAO_LT 259 -# define TAO_LE 260 -# define TAO_EQ 261 -# define TAO_NE 262 -# define TAO_EXIST 263 -# define TAO_AND 264 -# define TAO_OR 265 -# define TAO_NOT 266 -# define TAO_IN 267 -# define TAO_TWIDDLE 268 -# define TAO_BOOLEAN 269 -# define TAO_PLUS 270 -# define TAO_MINUS 271 -# define TAO_MULT 272 -# define TAO_DIV 273 -# define TAO_UMINUS 274 -# define TAO_NUMBER 275 -# define TAO_RPAREN 276 -# define TAO_LPAREN 277 -# define TAO_IDENT 278 -# define TAO_STRING 279 -# define TAO_UNKNOWN 280 -# define TAO_UNSIGNED 281 -# define TAO_SIGNED 282 -# define TAO_DOUBLE 283 -# define TAO_CONSTRAINT 284 -# define TAO_SEQUENCE 285 -# define TAO_WITH 286 -# define TAO_MAX 287 -# define TAO_MIN 288 -# define TAO_FIRST 289 -# define TAO_RANDOM 290 diff --git a/TAO/orbsvcs/orbsvcs/Trader/Constraint_Visitors.cpp b/TAO/orbsvcs/orbsvcs/Trader/Constraint_Visitors.cpp deleted file mode 100644 index ddffa05012b..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Constraint_Visitors.cpp +++ /dev/null @@ -1,1257 +0,0 @@ -// $Id$ - -// ======================================================================== -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Constraint_Visitors.cpp -// -// = AUTHOR -// Seth Widoff -// -// ======================================================================== - -#include "Constraint_Visitors.h" -#include "Constraint_Nodes.h" -#include "Trader_T.h" - -ACE_RCSID(Trader, Constraint_Visitors, "$Id$") - - // ************************************************************* - // TAO_Constraint_Evaluator - // ************************************************************* - -TAO_Constraint_Evaluator::Operand_Queue::Operand_Queue (void) -{ -} - -TAO_Literal_Constraint& -TAO_Constraint_Evaluator::Operand_Queue::get_left_operand (void) -{ - TAO_Literal_Constraint* left_operand = 0; - this->get (left_operand, 1); - return *left_operand; -} - -TAO_Literal_Constraint& -TAO_Constraint_Evaluator::Operand_Queue::get_right_operand (void) -{ - TAO_Literal_Constraint* right_operand = 0; - this->get (right_operand); - return *right_operand; -} - -TAO_Literal_Constraint& -TAO_Constraint_Evaluator::Operand_Queue::get_operand (void) -{ - TAO_Literal_Constraint* operand = 0; - this->get (operand); - return *operand; -} - -void -TAO_Constraint_Evaluator::Operand_Queue::dequeue_operand (void) -{ - TAO_Literal_Constraint operand; - this->dequeue_head (operand); -} - -TAO_Constraint_Evaluator:: -TAO_Constraint_Evaluator (CosTrading::Offer* offer, - CORBA::Boolean supports_dp) - : prop_eval_ (*offer, supports_dp) -{ - this->props_.close (); - this->props_.open (); - int length = offer->properties.length (); - - // Create a map of property names to their values. - for (int i = 0; i < length; i++) - { - TAO_String_Hash_Key name = (const char*) offer->properties[i].name; - this->props_.bind (name, i); - } -} - - -CORBA::Boolean -TAO_Constraint_Evaluator::evaluate_constraint (TAO_Constraint* root) -{ - CORBA::Boolean result = 0; - this->queue_.reset (); - - // Evaluate the offer according to the constraints in root_; - if (root != 0) - { - if ((root->accept (this) == 0) && - (! this->queue_.is_empty ())) - { - result = (CORBA::Boolean) this->queue_.get_operand(); - this->queue_.dequeue_operand (); - } - } - - // If a property couldn't be evaluated we must return 0. - return result; -} - -int -TAO_Constraint_Evaluator:: -evaluate_preference (TAO_Constraint* root, - TAO_Literal_Constraint& result) -{ - int return_value = -1; - while (! this->queue_.is_empty ()) - this->queue_.dequeue_operand (); - - // Evaluate the offer according to the constraints in root_; - if (root != 0) - { - if ((root->accept (this) == 0) && - (! this->queue_.is_empty ())) - { - result = this->queue_.get_operand (); - this->queue_.dequeue_operand (); - return_value = 0; - } - } - - return return_value; -} - -int -TAO_Constraint_Evaluator::visit_constraint(TAO_Unary_Constraint* constraint) -{ - TAO_Constraint* operand = constraint->operand (); - return operand->accept (this); -} - -int -TAO_Constraint_Evaluator::visit_with (TAO_Unary_Constraint* unary_with) -{ - TAO_Constraint* operand = unary_with->operand (); - return operand->accept (this); -} - -int -TAO_Constraint_Evaluator::visit_min (TAO_Unary_Constraint* unary_min) -{ - TAO_Constraint* operand = unary_min->operand (); - return operand->accept (this); -} - -int -TAO_Constraint_Evaluator::visit_max (TAO_Unary_Constraint* unary_max) -{ - TAO_Constraint* operand = unary_max->operand (); - return operand->accept (this); -} - -int -TAO_Constraint_Evaluator::visit_random (TAO_Noop_Constraint *) -{ - TAO_Literal_Constraint random ((CORBA::Long) (ACE_OS::rand ())); - this->queue_.enqueue_head (random); - return 0; -} - -int -TAO_Constraint_Evaluator::visit_first (TAO_Noop_Constraint *) -{ - TAO_Literal_Constraint first ((CORBA::Long) 0); - this->queue_.enqueue_head (first); - return 0; -} - -int -TAO_Constraint_Evaluator:: -visit_and (TAO_Binary_Constraint* boolean_and) -{ - int return_value = -1; - CORBA::Boolean result = (CORBA::Boolean) 0; - TAO_Constraint* left = boolean_and->left_operand (), - *right = boolean_and->right_operand (); - - // Short circuiting AND. - - if (left->accept (this) == 0) - { - result = (CORBA::Boolean) this->queue_.get_operand (); - this->queue_.dequeue_operand (); - - if (result) - { - if (right->accept(this) == 0) - { - result = (CORBA::Boolean) this->queue_.get_operand(); - this->queue_.dequeue_operand (); - - return_value = 0; - } - } - else - return_value = 0; - } - - if (return_value != -1) - this->queue_.enqueue_head (TAO_Literal_Constraint (result)); - - return return_value; -} - -int -TAO_Constraint_Evaluator:: -visit_or (TAO_Binary_Constraint* boolean_or) -{ - int return_value = -1; - CORBA::Boolean result = (CORBA::Boolean) 0; - TAO_Constraint* left = boolean_or->left_operand (), - *right = boolean_or->right_operand (); - - // Short-circuiting OR. - - if (left->accept (this) == 0) - { - result = (CORBA::Boolean) this->queue_.get_operand (); - this->queue_.dequeue_operand (); - - if (result == (CORBA::Boolean) 0) - { - if (right->accept (this) == 0) - { - result = (CORBA::Boolean) this->queue_.get_operand (); - this->queue_.dequeue_operand (); - return_value = 0; - } - } - else - return_value = 0; - } - - if (return_value != -1) - this->queue_.enqueue_head (TAO_Literal_Constraint (result)); - - return return_value; -} - -int -TAO_Constraint_Evaluator:: -visit_not (TAO_Unary_Constraint* unary_not) -{ - int return_value = -1; - TAO_Constraint* operand = unary_not->operand (); - - // Logical NOT. - - if (operand->accept (this) == 0) - { - CORBA::Boolean result = ! (CORBA::Boolean)this->queue_.get_operand (); - this->queue_.dequeue_operand (); - this->queue_.enqueue_head (TAO_Literal_Constraint (result)); - - return_value = 0; - } - - return return_value; -} - -int -TAO_Constraint_Evaluator:: -visit_exist (TAO_Unary_Constraint* unary_exist) -{ - TAO_Property_Constraint* operand = - (TAO_Property_Constraint*) unary_exist->operand (); - TAO_String_Hash_Key property_name ((const char*) operand->name ()); - - // Determine if a property is defined on this offer. - - CORBA::Boolean result = - (CORBA::Boolean) (this->props_.find (property_name) == 0); - - this->queue_.enqueue_head (TAO_Literal_Constraint (result)); - return 0; -} - -int -TAO_Constraint_Evaluator:: -visit_unary_minus (TAO_Unary_Constraint* unary_minus) -{ - int return_value = -1; - TAO_Constraint* operand = unary_minus->operand (); - - if (operand->accept (this) == 0) - { - TAO_Literal_Constraint result = - this->queue_.get_operand (); - this->queue_.dequeue_operand (); - this->queue_.enqueue_head (result); - - return_value = 0; - } - - return return_value; -} - -void -TAO_Constraint_Evaluator::do_the_op (int operation) -{ - TAO_Literal_Constraint& l_op = this->queue_.get_left_operand (); - TAO_Literal_Constraint& r_op = this->queue_.get_right_operand (); - - // Perform the listed bindary operation on the first two elements on - // the stack. - - TAO_Literal_Constraint result = - (operation <= TAO_NE) - ? - TAO_Literal_Constraint - ((CORBA::Boolean) - ((operation == TAO_GT) ? l_op > r_op : - (operation == TAO_GE) ? l_op >= r_op : - (operation == TAO_LT) ? l_op < r_op : - (operation == TAO_LE) ? l_op <= r_op : - (operation == TAO_NE) ? l_op != r_op : - (operation == TAO_EQ) ? l_op == r_op : 0)) - : - ((operation == TAO_PLUS) ? l_op + r_op : - (operation == TAO_MINUS) ? l_op - r_op : - (operation == TAO_MULT) ? l_op * r_op : - (operation == TAO_DIV) ? l_op / r_op : - TAO_Literal_Constraint ()); - - this->queue_.dequeue_operand (); - this->queue_.dequeue_operand (); - this->queue_.enqueue_head (result); -} - -int -TAO_Constraint_Evaluator::visit_bin_op (TAO_Binary_Constraint* op, - int operation) -{ - int return_value = -1; - TAO_Constraint* left = op->left_operand (); - TAO_Constraint* right = op->right_operand (); - - // Perform an operation on the results of evaluating the left and - // right branches of this subtree. - if (left->accept (this) == 0) - { - if (right->accept (this) == 0) - { - this->do_the_op (operation); - return_value = 0; - } - else - this->queue_.dequeue_operand (); - } - - return return_value; -} - -int -TAO_Constraint_Evaluator:: -visit_add(TAO_Binary_Constraint* boolean_add) -{ - return this->visit_bin_op (boolean_add, TAO_PLUS); -} - -int -TAO_Constraint_Evaluator:: -visit_sub (TAO_Binary_Constraint* boolean_sub) -{ - return this->visit_bin_op (boolean_sub, TAO_MINUS); -} - -int -TAO_Constraint_Evaluator:: -visit_mult (TAO_Binary_Constraint* boolean_mult) -{ - return this->visit_bin_op (boolean_mult, TAO_MULT); -} - -int -TAO_Constraint_Evaluator:: -visit_div (TAO_Binary_Constraint* boolean_div) -{ - return this->visit_bin_op (boolean_div, TAO_DIV); -} - -int -TAO_Constraint_Evaluator:: -visit_twiddle (TAO_Binary_Constraint* binary_twiddle) -{ - int return_value = -1; - TAO_Constraint* left = binary_twiddle->left_operand (), - *right = binary_twiddle->right_operand (); - - // Determine if the left operand is a subTAO_String_Hash_Key of the right. - - if (left->accept (this) == 0) - { - if (right->accept (this) == 0) - { - TAO_Literal_Constraint& left_operand = this->queue_.get_left_operand (); - TAO_Literal_Constraint& right_operand = this->queue_.get_right_operand (); - - CORBA::Boolean result = (CORBA::Boolean) - (ACE_OS::strstr ((const char*)left_operand, - (const char*)right_operand) != 0); - - this->queue_.dequeue_operand (); - this->queue_.dequeue_operand (); - this->queue_.enqueue_head (TAO_Literal_Constraint (result)); - return_value = 0; - } - else - this->queue_.dequeue_operand (); - } - - return return_value; -} - -int -TAO_Constraint_Evaluator:: -visit_in(TAO_Binary_Constraint* binary_in) -{ - int return_value = -1; - TAO_Constraint* left = binary_in->left_operand (), - *right = binary_in->right_operand (); - - // Determine if the left operand is contained in the right. - - if (left->accept (this) == 0) - { - if (this->visit_property ((TAO_Property_Constraint*) right) == 0) - { - TAO_Literal_Constraint& left_value = this->queue_.get_left_operand(); - const CORBA::Any* any = (const CORBA::Any*) this->queue_.get_right_operand(); - - if (any != 0) - { - CORBA::Boolean result = - this->sequence_does_contain ((CORBA::Any*) any, left_value); - - this->queue_.dequeue_operand (); - this->queue_.dequeue_operand (); - this->queue_.enqueue_head (TAO_Literal_Constraint (result)); - return_value = 0; - } - else - this->queue_.dequeue_operand (); - } - } - - return return_value; -} - -int -TAO_Constraint_Evaluator:: -visit_less_than (TAO_Binary_Constraint* boolean_lt) -{ - return this->visit_bin_op (boolean_lt, TAO_LT); -} - -int -TAO_Constraint_Evaluator:: -visit_less_than_equal (TAO_Binary_Constraint* boolean_lte) -{ - return this->visit_bin_op (boolean_lte, TAO_LE); -} - -int -TAO_Constraint_Evaluator:: -visit_greater_than (TAO_Binary_Constraint* boolean_gt) -{ - return this->visit_bin_op (boolean_gt, TAO_GT); -} - -int -TAO_Constraint_Evaluator:: -visit_greater_than_equal (TAO_Binary_Constraint* boolean_gte) -{ - return this->visit_bin_op (boolean_gte, TAO_GE); -} - -int -TAO_Constraint_Evaluator:: -visit_equal (TAO_Binary_Constraint* boolean_eq) -{ - return this->visit_bin_op (boolean_eq, TAO_EQ); -} - -int -TAO_Constraint_Evaluator:: -visit_not_equal (TAO_Binary_Constraint* boolean_neq) -{ - return this->visit_bin_op (boolean_neq, TAO_NE); -} - -int -TAO_Constraint_Evaluator:: -visit_literal (TAO_Literal_Constraint* literal) -{ - this->queue_.enqueue_head (*literal); - return 0; -} - -int -TAO_Constraint_Evaluator:: -visit_property (TAO_Property_Constraint* literal) -{ - int return_value = -1, prop_index = 0; - // Handle case where property is not, in fact, mapped to a value - TAO_String_Hash_Key prop_name ((const char*) literal->name ()); - - if (this->props_.find (prop_name, prop_index) == 0) - { - CORBA::Environment env; - // Retrieve the value of the property from the Property_Evaluator - - CORBA::Any* value = - this->prop_eval_.property_value (prop_index, env); - TAO_CHECK_ENV_RETURN (env, -1); - - if (value != 0) - { - this->queue_.enqueue_head (TAO_Literal_Constraint (value)); - return_value = 0; - } - } - - return return_value; -} - - -CORBA::Boolean -TAO_find_string (CosTradingSequences::StringSeq& sequence, - const char* element) -{ - int length = sequence.length (), - return_value = 0; - - for (int i = 0; i < length; i++) - { - if (ACE_OS::strcmp (sequence[i], element) == 0) - { - return_value = 1; - break; - } - } - - return (CORBA::Boolean) return_value; -} - -CORBA::Boolean -TAO_Constraint_Evaluator:: -sequence_does_contain (CORBA::Any* sequence, - TAO_Literal_Constraint& element) -{ - // Helper method to cast the void* value returned from the sequence - // any into a sequence type locally compiled from idl. The sequence - // wrapper uses the [] operator to locate the target element in the - // sequence. - - CORBA::Environment env; - CORBA::Boolean return_value = 0; - CORBA::TypeCode_var type = sequence->type (); - CORBA::TCKind sequence_type = - TAO_Sequence_Extracter_Base::sequence_type (type.in (), env); - TAO_CHECK_ENV_RETURN (env, return_value); - - if (sequence_type == CORBA::tk_void) - return return_value; - - switch (sequence_type) - { - case CORBA::tk_short: - { - CORBA::Long value = element; - return_value = ::TAO_find (*sequence, ACE_static_cast (CORBA::Short, value)); - } - break; - case CORBA::tk_ushort: - { - CORBA::ULong value = element; - return_value = ::TAO_find (*sequence, ACE_static_cast (CORBA::UShort, value)); - } - break; - case CORBA::tk_long: - { - CORBA::Long value = element; - return_value = ::TAO_find (*sequence, value); - } - break; - case CORBA::tk_ulong: - { - CORBA::ULong value = element; - return_value = ::TAO_find (*sequence, value); - } - break; - case CORBA::tk_float: - { - CORBA::Double value = element; - return_value = ::TAO_find (*sequence, ACE_static_cast (CORBA::Float, value)); - } - break; - case CORBA::tk_double: - { - CORBA::Double value = element; - return_value = ::TAO_find (*sequence, value); - } - break; - case CORBA::tk_boolean: - { - CORBA::Boolean value = element; - return_value = ::TAO_find (*sequence, value); - } - break; - case CORBA::tk_string: - { - const char* value = element; - return_value = ::TAO_find (*sequence, value); - } - break; - default: - break; - } - - return return_value; -} - -int -TAO_Element_Equal:: -operator () (TAO_DynSequence_i& dyn_any, - CORBA::Short element) const -{ - int return_value = 0; - TAO_TRY - { - CORBA::Short value = dyn_any.get_short (TAO_TRY_ENV); - TAO_CHECK_ENV; - return_value = (value == element); - } - TAO_CATCHANY {} TAO_ENDTRY; - return return_value; -} - -int -TAO_Element_Equal:: -operator () (TAO_DynSequence_i& dyn_any, - CORBA::UShort element) const -{ - int return_value = 0; - TAO_TRY - { - CORBA::UShort value = dyn_any.get_ushort (TAO_TRY_ENV); - TAO_CHECK_ENV; - return_value = (value == element); - } - TAO_CATCHANY {} TAO_ENDTRY; - return return_value; -} - -int -TAO_Element_Equal:: -operator () (TAO_DynSequence_i& dyn_any, - CORBA::Long element) const -{ - int return_value = 0; - TAO_TRY - { - CORBA::Long value = dyn_any.get_long (TAO_TRY_ENV); - TAO_CHECK_ENV; - return_value = (value == element); - } - TAO_CATCHANY {} TAO_ENDTRY; - return return_value; -} - -int -TAO_Element_Equal:: -operator () (TAO_DynSequence_i& dyn_any, - CORBA::ULong element) const -{ - int return_value = 0; - TAO_TRY - { - CORBA::ULong value = dyn_any.get_ulong (TAO_TRY_ENV); - TAO_CHECK_ENV; - return_value = (value == element); - } - TAO_CATCHANY {} TAO_ENDTRY; - return return_value; -} - -int -TAO_Element_Equal:: -operator () (TAO_DynSequence_i& dyn_any, - CORBA::Float element) const -{ - int return_value = 0; - TAO_TRY - { - CORBA::Float value = dyn_any.get_float (TAO_TRY_ENV); - TAO_CHECK_ENV; - return_value = (value == element); - } - TAO_CATCHANY {} TAO_ENDTRY; - return return_value; -} - -int -TAO_Element_Equal:: -operator () (TAO_DynSequence_i& dyn_any, - CORBA::Double element) const -{ - int return_value = 0; - TAO_TRY - { - CORBA::Double value = dyn_any.get_short (TAO_TRY_ENV); - TAO_CHECK_ENV; - return_value = (value == element); - } - TAO_CATCHANY {} TAO_ENDTRY; - return return_value; -} - -int -TAO_Element_Equal:: -operator () (TAO_DynSequence_i& dyn_any, - CORBA::Boolean element) const -{ - int return_value = 0; - TAO_TRY - { - CORBA::Boolean value = (CORBA::Boolean) dyn_any.get_short (TAO_TRY_ENV); - TAO_CHECK_ENV; - return_value = (value == element); - } - TAO_CATCHANY {} TAO_ENDTRY; - return return_value; -} - -int -TAO_Element_Equal:: -operator () (TAO_DynSequence_i& dyn_any, - const char* element) const -{ - int return_value = 0; - TAO_TRY - { - const char* value = dyn_any.get_string (TAO_TRY_ENV); - TAO_CHECK_ENV; - return_value = (ACE_OS::strcmp (value, element) == 0); - } - TAO_CATCHANY {} TAO_ENDTRY; - return return_value; -} - - -// ************************************************************* -// TAO_Constraint_Validator -// ************************************************************* - -TAO_Constraint_Validator:: -TAO_Constraint_Validator -(const CosTradingRepos::ServiceTypeRepository::TypeStruct& type_struct) -{ - const CosTradingRepos::ServiceTypeRepository::PropStructSeq& prop_seq = - type_struct.props; - int length = prop_seq.length (); - - // Create a map of the service type properties to their types. - for (int i = 0; i < length; i++) - { - CORBA::TypeCode_ptr corba_type = - CORBA::TypeCode::_duplicate (prop_seq[i].value_type.in ()); - - TAO_String_Hash_Key prop_name_str = (const char*) prop_seq[i].name; - this->type_map_.bind (prop_name_str, corba_type); - } -} - -TAO_Constraint_Validator::~TAO_Constraint_Validator (void) -{ - for (TAO_Typecode_Table::iterator type_iter (this->type_map_); - ! type_iter.done (); - type_iter++) - { - CORBA::TypeCode_ptr corba_type = (*type_iter).int_id_; - CORBA::release (corba_type); - } -} - -int -TAO_Constraint_Validator::validate (TAO_Constraint* root) -{ - return root->accept(this); -} - -int -TAO_Constraint_Validator::visit_constraint (TAO_Unary_Constraint* constraint) -{ - int return_value = -1; - TAO_Expression_Type type; - TAO_Constraint* operand = constraint->operand (); - this->extract_type (operand, type); - - if (this->expr_returns_boolean (type)) - return_value = operand->accept (this); - - return return_value; -} - -int -TAO_Constraint_Validator::visit_first (TAO_Noop_Constraint *) -{ - return 0; -} - -int -TAO_Constraint_Validator::visit_random (TAO_Noop_Constraint *) -{ - return 0; -} - -int -TAO_Constraint_Validator::visit_with (TAO_Unary_Constraint* unary_with) -{ - return this->visit_constraint (unary_with); -} - -int -TAO_Constraint_Validator::visit_min (TAO_Unary_Constraint* unary_min) -{ - return this->visit_unary_minus (unary_min); -} - -int -TAO_Constraint_Validator::visit_max (TAO_Unary_Constraint* unary_max) -{ - return this->visit_unary_minus (unary_max); -} - -int -TAO_Constraint_Validator:: -visit_and (TAO_Binary_Constraint* boolean_and) -{ - int return_value = -1; - TAO_Constraint* left = boolean_and->left_operand (), - *right = boolean_and->right_operand (); - TAO_Expression_Type left_type, right_type; - this->extract_type (left, left_type); - this->extract_type (right, right_type); - - // Can only "and" expressions that return a boolean value - if (this->expr_returns_boolean (left_type) && - this->expr_returns_boolean (right_type)) - { - if (left->accept (this) == 0 && - right->accept (this) == 0) - return_value = 0; - } - - return return_value; -} - -int -TAO_Constraint_Validator:: -visit_or(TAO_Binary_Constraint* boolean_or) -{ - // The types for or are the same as those for and. - return this->visit_and (boolean_or); -} - -int -TAO_Constraint_Validator:: -visit_not (TAO_Unary_Constraint* unary_not) -{ - int return_value = -1; - // Not can only negate an expression that returns a boolean. - TAO_Expression_Type type; - TAO_Constraint* operand = unary_not->operand (); - this->extract_type (operand, type); - - if (this->expr_returns_boolean (type)) - return_value = operand->accept (this); - - return return_value; -} - -int -TAO_Constraint_Validator:: -visit_exist (TAO_Unary_Constraint* unary_exist) -{ - // Exist simply requires that its operand be a property name - // included in the service type. - int return_value = -1; - TAO_Constraint* operand = unary_exist->operand (); - TAO_Expression_Type type = operand->expr_type (); - - if (type == TAO_IDENT) - return_value = operand->accept (this); - - return return_value; -} - -int -TAO_Constraint_Validator:: -visit_unary_minus (TAO_Unary_Constraint* unary_minus) -{ - // Unary minus can only negate a numeric operand. - int return_value = -1; - TAO_Expression_Type type; - TAO_Constraint* operand = unary_minus->operand (); - this->extract_type (operand, type); - - if (this->expr_returns_number (type)) - return_value = operand->accept (this); - - return return_value; -} - -int -TAO_Constraint_Validator:: -visit_add (TAO_Binary_Constraint* boolean_add) -{ - // All the mathematical operators require numeric operands. - int return_value = -1; - TAO_Constraint* left = boolean_add->left_operand (), - *right = boolean_add->right_operand (); - TAO_Expression_Type left_type, right_type; - this->extract_type (left, left_type); - this->extract_type (right, right_type); - - if (this->expr_returns_number (left_type) && - this->expr_returns_number (right_type)) - { - if (left->accept (this) == 0 && - right->accept (this) == 0) - return_value = 0; - } - - return return_value; -} - -int -TAO_Constraint_Validator:: -visit_sub (TAO_Binary_Constraint* boolean_sub) -{ - return this->visit_add (boolean_sub); -} - -int -TAO_Constraint_Validator:: -visit_mult (TAO_Binary_Constraint* boolean_mult) -{ - return this->visit_add (boolean_mult); -} - -int -TAO_Constraint_Validator:: -visit_div (TAO_Binary_Constraint* boolean_div) -{ - // Div not only requires that both of its operands be numeric, but - // also the the demoninator not be zero. However, since the - // denominator can be an expression who's value can only be - // determined while evaulating the constraint expression, this - // method detects only when the demoniator is a literal whose value - // is zero. - int return_value = -1; - TAO_Constraint* left = boolean_div->left_operand (), - *right = boolean_div->right_operand (); - TAO_Expression_Type left_type, right_type; - this->extract_type (left, left_type); - this->extract_type (right, right_type); - - if (this->expr_returns_number (left_type) && - this->expr_returns_number (right_type)) - { - // Prevent division by zero, a no no. - int right_isnt_zero = 1; - switch(right->expr_type ()) - { - case TAO_UNSIGNED: - right_isnt_zero = - ((CORBA::ULong) (*((TAO_Literal_Constraint*) right)) != 0); - break; - case TAO_SIGNED: - right_isnt_zero = - ((CORBA::Long) (*((TAO_Literal_Constraint*) right)) != 0); - break; - case TAO_DOUBLE: - right_isnt_zero = - ((CORBA::Double) (*((TAO_Literal_Constraint*) right)) != 0.0); - break; - } - - if (right_isnt_zero) - { - if (left->accept (this) == 0 && - right->accept (this) == 0) - return_value = 0; - } - } - - return return_value; -} - -int -TAO_Constraint_Validator:: -visit_twiddle (TAO_Binary_Constraint* binary_twiddle) -{ - // Twiddle requires that both of its operand be strings. - int return_value = -1; - TAO_Constraint* left = binary_twiddle->left_operand (), - *right = binary_twiddle->right_operand (); - TAO_Expression_Type left_type, right_type; - this->extract_type (left, left_type); - this->extract_type (right, right_type); - - if (this->expr_returns_string (left_type) && - this->expr_returns_string (right_type)) - { - if (left->accept (this) == 0 && - right->accept (this) == 0) - return_value = 0; - } - - return return_value; -} - -int -TAO_Constraint_Validator:: -visit_in (TAO_Binary_Constraint* binary_in) -{ - // In requires that the right operand be a sequence of a simple type - // and that its left operand be an expression that evaluates to a - // value of the same simple type. - int return_value = -1; - TAO_Expression_Type left_type, right_type; - TAO_Constraint - *left = binary_in->left_operand (), - *right = binary_in->right_operand (); - - CORBA::TypeCode* prop_type = this->extract_type (right, right_type); - this->extract_type (left, left_type); - - if (right_type == TAO_SEQUENCE) - { - CORBA::Environment env; - CORBA::Boolean types_match = 0; - CORBA::TCKind seq_type = - TAO_Sequence_Extracter_Base::sequence_type (prop_type, env); - TAO_CHECK_ENV_RETURN (env, return_value); - - if (seq_type != CORBA::tk_void) - { - if (this->expr_returns_number (left_type)) - { - types_match = (seq_type == CORBA::tk_short || - seq_type == CORBA::tk_ushort || - seq_type == CORBA::tk_long || - seq_type == CORBA::tk_ulong || - seq_type == CORBA::tk_float || - seq_type == CORBA::tk_double); - } - else if (this->expr_returns_boolean (left_type)) - types_match = (seq_type == CORBA::tk_boolean); - else if (this->expr_returns_string (left_type)) - types_match = (seq_type == CORBA::tk_string); - - if (types_match) - return_value = left->accept (this); - } - } - - return return_value; -} - -int -TAO_Constraint_Validator:: -visit_less_than(TAO_Binary_Constraint* boolean_lt) -{ - // Comparison operations require that both operands be of the same - // simple type. - int return_value = -1; - TAO_Constraint* left = boolean_lt->left_operand (), - *right = boolean_lt->right_operand (); - TAO_Expression_Type left_type, right_type; - this->extract_type (left, left_type); - this->extract_type (right, right_type); - - if ((this->expr_returns_number (left_type) && - this->expr_returns_number (right_type)) || - (this->expr_returns_string (left_type) && - this->expr_returns_string (right_type))) - { - if (left->accept (this) == 0 && - right->accept (this) == 0) - return_value = 0; - } - - return return_value; -} - -int -TAO_Constraint_Validator:: -visit_less_than_equal (TAO_Binary_Constraint* boolean_lte) -{ - return this->visit_less_than (boolean_lte); -} - -int -TAO_Constraint_Validator:: -visit_greater_than (TAO_Binary_Constraint* boolean_gt) -{ - return this->visit_less_than (boolean_gt); -} - -int -TAO_Constraint_Validator:: -visit_greater_than_equal (TAO_Binary_Constraint* boolean_gte) -{ - return this->visit_less_than(boolean_gte); -} - -int -TAO_Constraint_Validator:: -visit_equal (TAO_Binary_Constraint* boolean_eq) -{ - int return_value = -1; - TAO_Constraint* left = boolean_eq->left_operand (), - *right = boolean_eq->right_operand (); - TAO_Expression_Type left_type, right_type; - this->extract_type (left, left_type); - this->extract_type (right, right_type); - - if ((this->expr_returns_number (left_type) && - this->expr_returns_number (right_type)) || - (this->expr_returns_string (left_type) && - this->expr_returns_string (right_type)) || - (this->expr_returns_boolean (left_type) && - this->expr_returns_boolean (right_type))) - { - if (left->accept (this) == 0 && - right->accept (this) == 0) - return_value = 0; - } - - return return_value; -} - -int -TAO_Constraint_Validator:: -visit_not_equal (TAO_Binary_Constraint* boolean_neq) -{ - return this->visit_equal (boolean_neq); -} - -int -TAO_Constraint_Validator:: -visit_literal (TAO_Literal_Constraint *) -{ - return 0; -} - -int -TAO_Constraint_Validator:: -visit_property (TAO_Property_Constraint *) -{ - return 0; -} - -CORBA::TypeCode* -TAO_Constraint_Validator::extract_type (TAO_Constraint* expr, - TAO_Expression_Type& type) -{ - CORBA::TypeCode* return_value = 0; - - type = expr->expr_type (); - if (type == TAO_IDENT) - { - TAO_Property_Constraint* prop = (TAO_Property_Constraint*) expr; - TAO_String_Hash_Key prop_name (prop->name ()); - - if (this->type_map_.find (prop_name, return_value) == 0) - type = TAO_Literal_Constraint::comparable_type (return_value); - } - - return return_value; -} - -int -TAO_Constraint_Validator::expr_returns_boolean (TAO_Expression_Type expr_type) -{ - // If the expression is a boolean operations, a boolean literal, or - // a boolean property, return 1. - int return_value = 0; - - if (expr_type <= TAO_BOOLEAN) - return_value = 1; - - return return_value; -} - - -int -TAO_Constraint_Validator::expr_returns_number (TAO_Expression_Type expr_type) -{ - // If the expression is a number operation, a numeric literal, or a - // numeric property, return 1. - int return_value = 0; - - if ((expr_type >= TAO_PLUS && expr_type <= TAO_NUMBER) || - (expr_type >= TAO_UNSIGNED && expr_type <= TAO_DOUBLE)) - return_value = 1; - - return return_value; -} - -int -TAO_Constraint_Validator::expr_returns_string (TAO_Expression_Type expr_type) -{ - // If the expression is an operation with a string return value, a - // string literal, or a property whose type is string, return 1. - int return_value = 0; - - if (expr_type == TAO_STRING) - return_value = 1; - - return return_value; -} - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Node; -template class ACE_Unbounded_Queue; -template class ACE_Unbounded_Queue_Iterator; -template CORBA::Boolean TAO_find (const CORBA::Any &, const int &); -template CORBA::Boolean TAO_find (const CORBA::Any &, const unsigned char &); -#if !defined (ACE_LACKS_FLOATING_POINT) -template CORBA::Boolean TAO_find (const CORBA::Any &, const float &); -template CORBA::Boolean TAO_find (const CORBA::Any &, const double &); -#endif /* ACE_LACKS_FLOATING_POINT */ -template CORBA::Boolean TAO_find (const CORBA::Any &, const short &); -template CORBA::Boolean TAO_find (const CORBA::Any &, const char * const &); -template CORBA::Boolean TAO_find (const CORBA::Any &, const unsigned short &); -template CORBA::Boolean TAO_find (const CORBA::Any &, const unsigned int &); - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - -#pragma instantiate ACE_Node -#pragma instantiate ACE_Unbounded_Queue -#pragma instantiate ACE_Unbounded_Queue_Iterator - -#pragma instantiate CORBA::Boolean TAO_find (const CORBA::Any &, const int &) -#pragma instantiate CORBA::Boolean TAO_find (const CORBA::Any &, const unsigned char &) -#if !defined (ACE_LACKS_FLOATING_POINT) -#pragma instantiate CORBA::Boolean TAO_find (const CORBA::Any &, const float &) -#pragma instantiate CORBA::Boolean TAO_find (const CORBA::Any &, const double &) -#endif /* ACE_LACKS_FLOATING_POINT */ -#pragma instantiate CORBA::Boolean TAO_find (const CORBA::Any &, const short &) -#pragma instantiate CORBA::Boolean TAO_find (const CORBA::Any &, const char * const &) -#pragma instantiate CORBA::Boolean TAO_find (const CORBA::Any &, const unsigned short &) -#pragma instantiate CORBA::Boolean TAO_find (const CORBA::Any &, const unsigned int &) - -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Constraint_Visitors.h b/TAO/orbsvcs/orbsvcs/Trader/Constraint_Visitors.h deleted file mode 100644 index bf74dfdcb14..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Constraint_Visitors.h +++ /dev/null @@ -1,452 +0,0 @@ -/* -*- C++ -*- */ - -// ======================================================================== -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Constraint_Visitor.h -// -// = AUTHOR -// Seth Widoff -// -// ======================================================================== - -#ifndef TAO_CONSTRAINT_VISITOR_H -#define TAO_CONSTRAINT_VISITOR_H - -#include "Trader.h" - - // ************************************************************* - // TAO_Constraint_Visitor - // ************************************************************* - -class TAO_Constraint; -class TAO_Unary_Constraint; -class TAO_Binary_Constraint; -class TAO_Literal_Constraint; -class TAO_Property_Constraint; -class TAO_Noop_Constraint; - -class TAO_Constraint_Visitor -// -// = TITLE -// This is the base class for all visitors who wish to preform -// some operation from the state of the expression tree. Using -// double dispatching, subclasses of Constraint expression call -// back to the InterpreterVisitor subclass from the accept method. -// -// = DESCRIPTION -// Traversal of the expression tree uses the "Visitor" pattern. To -// "visit" a node, a client invokes the "accept" method on a -// subclass of ConstraintExpression, which, in turn, invokes the -// appropriate method on the visitor passed to it, based on its -// own type. So, the Constraint_Visitor has a method to deal with -// each possible type of node in an expression tree; one for each -// operator in the grammar. -{ -public: - - virtual ~TAO_Constraint_Visitor (void) {} - - virtual int visit_constraint (TAO_Unary_Constraint* constraint) = 0; - - virtual int visit_with (TAO_Unary_Constraint* unary_with) = 0; - virtual int visit_min (TAO_Unary_Constraint* unary_min) = 0; - virtual int visit_max (TAO_Unary_Constraint* unary_max) = 0; - virtual int visit_first (TAO_Noop_Constraint* noop_first) = 0; - virtual int visit_random (TAO_Noop_Constraint* noop_random) = 0; - - virtual int visit_and (TAO_Binary_Constraint* boolean_and) = 0; - virtual int visit_or (TAO_Binary_Constraint* boolean_or) = 0; - virtual int visit_not (TAO_Unary_Constraint* unary_not) = 0; - - virtual int visit_exist (TAO_Unary_Constraint* unary_exist) = 0; - virtual int visit_unary_minus (TAO_Unary_Constraint* unary_minus) = 0; - - virtual int visit_add (TAO_Binary_Constraint* boolean_add) = 0; - virtual int visit_sub (TAO_Binary_Constraint* boolean_sub) = 0; - virtual int visit_mult (TAO_Binary_Constraint* boolean_mult) = 0; - virtual int visit_div (TAO_Binary_Constraint* boolean_div) = 0; - - virtual int visit_twiddle (TAO_Binary_Constraint* binary_twiddle) = 0; - virtual int visit_in (TAO_Binary_Constraint* binary_in) = 0; - - virtual int visit_less_than (TAO_Binary_Constraint* boolean_lt) = 0; - virtual int visit_less_than_equal (TAO_Binary_Constraint* boolean_lte) = 0; - virtual int visit_greater_than (TAO_Binary_Constraint* boolean_gt) = 0; - virtual int visit_greater_than_equal (TAO_Binary_Constraint* boolean_gte) = 0; - virtual int visit_equal (TAO_Binary_Constraint* boolean_eq) = 0; - virtual int visit_not_equal (TAO_Binary_Constraint* boolean_neq) = 0; - - virtual int visit_literal (TAO_Literal_Constraint* literal) = 0; - virtual int visit_property (TAO_Property_Constraint* literal) = 0; -}; - - // ************************************************************* - // TAO_Constraint_Validator - // ************************************************************* - -#include "Constraint_Nodes.h" - -class TAO_Constraint_Validator : public TAO_Constraint_Visitor - // - // = TITLE - // TAO_Constraint_Validator ensures that in an expression tree - // passed to it, the operands of each operation match the - // correct types. - // - // = DESCRIPTION - // TAO_Constraint_Validator uses the visitor pattern to - // traverse all the nodes in an expression tree, checking that - // for each operator node the operands are of the proper data - // type it they're literals, or that they exist in the service - // type definition _and_ have the proper type, if they're - // property names. The algorithm for type - // checking is as follows: ensure that operand expression(s) - // return the correct types using expr_returns* methods. If they - // (or it) return the correct types, call accept - // on each operand until all return true or one returns false, - // at which point we can back out of the traversal and indicate - // failure. -{ -public: - - TAO_Constraint_Validator - (const CosTradingRepos::ServiceTypeRepository::TypeStruct& type_struct); - // The constructor creates a map of property names to their values - // from the Type Description retrieved from the - // ServiceTypeRepository. The ServiceTypeRepository throws - // exceptions when it's displeased with the type name provided to - // it. The map allows O(lg n) associative access, rather than the - // O(n) sequential lookup from the CORBA data structures. - - virtual ~TAO_Constraint_Validator (void); - // Desctructor. - - int validate (TAO_Constraint* root); - // Validate returns 1 if the expression tree whose root is - // makes semantic sense, in that the operands for each operation - // comply with each other and the types accepted by the operator. - - // = Visitor Methods - - 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); - // The two operands must return a boolean value. - - virtual int visit_not (TAO_Unary_Constraint* unary_not); - // The operand must return a boolean value. - - virtual int visit_exist (TAO_Unary_Constraint* unary_exist); - // The operand must return a valid (i.e., present in the service - // type description) property name. - - virtual int visit_unary_minus (TAO_Unary_Constraint* unary_minus); - // The operand must return a number to be negated. - - virtual int visit_add (TAO_Binary_Constraint* boolean_add); - virtual int visit_sub (TAO_Binary_Constraint* boolean_sub); - virtual int visit_mult (TAO_Binary_Constraint* boolean_mult); - virtual int visit_div (TAO_Binary_Constraint* boolean_div); - // Both operands must return numeric results. - - virtual int visit_twiddle (TAO_Binary_Constraint* binary_twiddle); - // Both operands must return strings. - - virtual int visit_in (TAO_Binary_Constraint* binary_in); - // The right operand must be a sequence of the same simple type as - // the left operand. - - 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); - // The left and right operands must both be of the same simple type. - - virtual int visit_literal (TAO_Literal_Constraint* literal); - virtual int visit_property (TAO_Property_Constraint* literal); - // The property must be defined in the service type description. - -private: - - TAO_Typecode_Table type_map_; - // A map gleaned from the ServiceTypeStruct, which correlates - // property names with their types. - - CORBA::TypeCode* extract_type (TAO_Constraint* expr_type, - TAO_Expression_Type& type); - - int expr_returns_boolean (TAO_Expression_Type expr_type); - // expr_returns_boolean returns 1 if , when evaluated, will - // return a boolean. - - int expr_returns_number (TAO_Expression_Type expr_type); - // expr_returns_boolean returns 1 if , when evaluated, will - // return a number. - - int expr_returns_string (TAO_Expression_Type expr_type); - // expr_returns_boolean returns 1 if , when evaluated, will - // return a string. - - TAO_Constraint_Validator (const TAO_Constraint_Validator&); - TAO_Constraint_Validator& operator= (const TAO_Constraint_Validator&); -}; - - // ************************************************************* - // TAO_Constraint_Evaluator - // ************************************************************* - -#include "Trader_Utils.h" - -class TAO_Constraint_Evaluator : public TAO_Constraint_Visitor -// -// = TITLE -// TAO_Constraint_Evaluator traverse a constraint expression tree, -// and determines whether an offer fits the constraints -// represented by the tree -// -// = DESCRIPTION -// 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. -{ -public: - - TAO_Constraint_Evaluator (CosTrading::Offer* offer, - CORBA::Boolean supports_dynamic_properties = 1); - - CORBA::Boolean evaluate_constraint (TAO_Constraint* root); - // Evaluate returns 1 if the offer satisfies the constraints - // represented by the the expression tree rooted at , 0 if it - // doesn't. If an error occurs during process, the constraint - // automatically fails. - - int 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. - - // = Visitor Methods - - 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); - // 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. - - virtual int visit_or (TAO_Binary_Constraint* boolean_or); - // 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. - - 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); - // The property exists if its name is bound to a value in the - // map. - - 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); - // Determines if the sequence represented by the right operand - // contains the left operand. - - // = Compare the results of evaluating left and right operands. - 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. - -private: - - class Operand_Queue : - public ACE_Unbounded_Queue - // = TITLE - // A queue adapter with methods to setting and getting operands - // from the expression evaluation results. - { - public: - - Operand_Queue (void); - - TAO_Literal_Constraint& get_left_operand (void); - // In a binary operation, obtain the left operand. - - TAO_Literal_Constraint& get_right_operand (void); - // In a binary operation, obtain the right operand. - - TAO_Literal_Constraint& get_operand (void); - // In a unary operation, obtain the only operand. - - void dequeue_operand (void); - // Remove an operand from the queue. - }; - - 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); - // Determine if sequence contains , a literal of the same - // simple type as . Return 1 in this eventuality. - - TAO_Constraint_Evaluator (const TAO_Constraint_Evaluator&); - TAO_Constraint_Evaluator& operator= (const TAO_Constraint_Evaluator&); - // Disallow copying. - - TAO_Lookup_Table props_; - // The map of property names to their values for a property. - - TAO_Property_Evaluator prop_eval_; - // Utility with which to evaluate the properties of an offer, be - // they dyanmic or static. - - Operand_Queue queue_; - // The result of a non_boolean operation. -}; - - // ************************************************************* - // Utilities - // ************************************************************* - -#include "tao/DynSequence_i.h" - -// Forward declaration -template class TAO_Element_Equal; - -class TAO_Element_Equal -{ -public: - int operator () (TAO_DynSequence_i& dyn_any, - CORBA::Short element) const; - // Calls the correct method on dyn_seq to extract the element type, then - // uses the appropriate form of equals comparison. - -}; - -class TAO_Element_Equal -{ -public: - int operator () (TAO_DynSequence_i& dyn_any, - CORBA::UShort element) const; - // Calls the correct method on dyn_seq to extract the element type, then - // uses the appropriate form of equals comparison. - -}; - -class TAO_Element_Equal -{ -public: - int operator () (TAO_DynSequence_i& dyn_any, - CORBA::Long element) const; - // Calls the correct method on dyn_seq to extract the element type, then - // uses the appropriate form of equals comparison. - -}; - -class TAO_Element_Equal -{ -public: - int operator () (TAO_DynSequence_i& dyn_any, - CORBA::ULong element) const; - // Calls the correct method on dyn_seq to extract the element type, then - // uses the appropriate form of equals comparison. - -}; - -class TAO_Element_Equal -{ -public: - int operator () (TAO_DynSequence_i& dyn_any, - CORBA::Float element) const; - // Calls the correct method on dyn_seq to extract the element type, then - // uses the appropriate form of equals comparison. - -}; - -class TAO_Element_Equal -{ -public: - int operator () (TAO_DynSequence_i& dyn_any, - CORBA::Double element) const; - // Calls the correct method on dyn_seq to extract the element type, then - // uses the appropriate form of equals comparison. - -}; - -class TAO_Element_Equal -{ -public: - int operator () (TAO_DynSequence_i& dyn_any, - CORBA::Boolean element) const; - // Calls the correct method on dyn_seq to extract the element type, then - // uses the appropriate form of equals comparison. - -}; - -class TAO_Element_Equal -{ -public: - int operator () (TAO_DynSequence_i& dyn_any, - const char* element) const; - // Calls the correct method on dyn_seq to extract the element type, then - // uses the appropriate form of equals comparison. - -}; - - -#endif /* CONSTRAINT_VISITORS_H */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Constraint_l.cpp b/TAO/orbsvcs/orbsvcs/Trader/Constraint_l.cpp deleted file mode 100644 index 7572d7eca87..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Constraint_l.cpp +++ /dev/null @@ -1,1765 +0,0 @@ -/* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - * $Header$ - */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 - -#include "ace/OS.h" - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#define YY_BUF_SIZE 16384 - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -extern int yyleng; -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yytext_ptr ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ -typedef unsigned int yy_size_t; - - -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - }; - -static YY_BUFFER_STATE yy_current_buffer = 0; - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; - -static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart YY_PROTO(( FILE *input_file )); - -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); -void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); -#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) - -YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); -YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); - -static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); -static void yy_flex_free YY_PROTO(( void * )); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) - -typedef unsigned char YY_CHAR; -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; -typedef int yy_state_type; -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 31 -#define YY_END_OF_BUFFER 32 -static yyconst short int yy_accept[81] = - { 0, - 0, 0, 32, 30, 31, 30, 30, 22, 23, 14, - 12, 13, 30, 15, 26, 16, 30, 18, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 11, 21, 0, 28, 0, 27, 0, 26, 17, 20, - 19, 29, 29, 29, 29, 29, 29, 10, 29, 29, - 29, 9, 29, 29, 0, 0, 29, 29, 8, 29, - 29, 2, 1, 7, 29, 29, 0, 27, 29, 24, - 29, 29, 29, 5, 25, 6, 3, 29, 4, 0 - } ; - -static yyconst int yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 3, 1, 1, 1, 1, 1, 4, 5, - 6, 7, 8, 1, 9, 10, 11, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 1, 1, 13, - 14, 15, 1, 1, 16, 17, 17, 17, 18, 19, - 17, 17, 17, 17, 17, 20, 17, 17, 17, 17, - 17, 21, 22, 23, 24, 17, 17, 17, 17, 17, - 1, 25, 1, 1, 26, 1, 27, 17, 17, 28, - - 29, 30, 17, 31, 32, 17, 17, 17, 33, 34, - 35, 17, 17, 36, 37, 38, 17, 17, 39, 40, - 17, 17, 1, 1, 1, 41, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst int yy_meta[42] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 1 - } ; - -static yyconst short int yy_base[83] = - { 0, - 0, 0, 104, 105, 105, 89, 38, 105, 105, 105, - 105, 105, 90, 105, 33, 87, 86, 85, 0, 82, - 76, 62, 55, 62, 59, 17, 57, 55, 63, 57, - 105, 105, 42, 105, 43, 36, 76, 40, 105, 105, - 105, 0, 67, 62, 57, 52, 47, 0, 42, 47, - 42, 0, 45, 40, 47, 47, 55, 58, 0, 38, - 34, 0, 0, 0, 42, 38, 54, 52, 44, 0, - 23, 22, 23, 0, 0, 0, 0, 24, 0, 105, - 72, 51 - } ; - -static yyconst short int yy_def[83] = - { 0, - 80, 1, 80, 80, 80, 80, 81, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 80, 80, 81, 80, 80, 80, 80, 80, 80, 80, - 80, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 81, 80, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 80, 80, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 0, - 80, 80 - } ; - -static yyconst short int yy_nxt[147] = - { 0, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 19, 19, 20, 19, - 19, 19, 21, 19, 4, 4, 22, 19, 23, 24, - 19, 25, 26, 27, 28, 29, 19, 19, 30, 19, - 31, 34, 37, 49, 38, 34, 55, 36, 50, 37, - 34, 38, 42, 56, 67, 67, 79, 78, 68, 77, - 76, 75, 35, 68, 56, 68, 35, 55, 74, 73, - 72, 35, 33, 33, 71, 70, 69, 66, 65, 64, - 63, 62, 61, 60, 59, 58, 57, 36, 54, 53, - 52, 51, 48, 47, 46, 45, 44, 43, 41, 40, - - 39, 36, 32, 80, 3, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80 - } ; - -static yyconst short int yy_chk[147] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 7, 15, 26, 15, 33, 35, 36, 26, 38, - 55, 38, 82, 36, 56, 56, 78, 73, 56, 72, - 71, 69, 7, 68, 36, 67, 33, 35, 66, 65, - 61, 55, 81, 81, 60, 58, 57, 54, 53, 51, - 50, 49, 47, 46, 45, 44, 43, 37, 30, 29, - 28, 27, 25, 24, 23, 22, 21, 20, 18, 17, - - 16, 13, 6, 3, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -#line 1 "Trader/constraint.l" -#define INITIAL 0 -#line 2 "Trader/constraint.l" -// $Id$ -// ======================================================================== -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// constraint.l -// -// = AUTHOR -// Seth Widoff -// -// ======================================================================== - -#include "Constraint_Interpreter.h" -#include "Constraint_Nodes.h" -#include "Constraint_Tokens.h" - -static TAO_Literal_Constraint* extract_string(const char*); - -#define TAO_YY_LEX_DEBUG - -#ifdef TAO_CONSTRAINT_DEBUG -#define TAO_YY_LEX_DEBUG ACE_OS::fprintf(stderr, "%s\n", yytext) -#endif /* TAO_CONSTRAINT_DEBUG */ - - -#line 448 "lex.yy.c" - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap YY_PROTO(( void )); -#else -extern int yywrap YY_PROTO(( void )); -#endif -#endif - -#if 0 -#ifndef YY_NO_UNPUT -static void yyunput YY_PROTO(( int c, char *buf_ptr )); -#endif -#endif /* 0 */ - -#ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen YY_PROTO(( yyconst char * )); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif -#endif - -#if YY_STACK_USED -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = 0; -#ifndef YY_NO_PUSH_STATE -static void yy_push_state YY_PROTO(( int new_state )); -#endif -#ifndef YY_NO_POP_STATE -static void yy_pop_state YY_PROTO(( void )); -#endif -#ifndef YY_NO_TOP_STATE -static int yy_top_state YY_PROTO(( void )); -#endif - -#else -#define YY_NO_PUSH_STATE 1 -#define YY_NO_POP_STATE 1 -#define YY_NO_TOP_STATE 1 -#endif - -#ifdef YY_MALLOC_DECL -YY_MALLOC_DECL -#else -#if __STDC__ -#ifndef __cplusplus -#include -#endif -#else -/* Just try to get by without declaring the routines. This will fail - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) - * or sizeof(void*) != sizeof(int). - */ -#endif -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ - -#ifndef TAO_TRADER_ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define TAO_TRADER_ECHO (void) fwrite( yytext, yyleng, 1, yyout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( yy_current_buffer->yy_is_interactive ) \ - { \ - int c = '*', n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ - && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL int yylex YY_PROTO(( void )) -#endif - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -YY_DECL - { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 42 "Trader/constraint.l" - - -#line 602 "lex.yy.c" - - if ( yy_init ) - { - yy_init = 0; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! yy_current_buffer ) - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yy_start; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 81 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 105 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - -do_action: /* This label is used only to access EOF actions. */ - - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 44 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_MIN; } - ACE_NOTREACHED (YY_BREAK) -case 2: -YY_RULE_SETUP -#line 45 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_MAX; } - ACE_NOTREACHED (YY_BREAK) -case 3: -YY_RULE_SETUP -#line 46 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_FIRST; } - ACE_NOTREACHED (YY_BREAK) -case 4: -YY_RULE_SETUP -#line 47 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_RANDOM; } - ACE_NOTREACHED (YY_BREAK) -case 5: -YY_RULE_SETUP -#line 48 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_WITH; } - ACE_NOTREACHED (YY_BREAK) -case 6: -YY_RULE_SETUP -#line 49 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_EXIST; } - ACE_NOTREACHED (YY_BREAK) -case 7: -YY_RULE_SETUP -#line 50 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_NOT; } - ACE_NOTREACHED (YY_BREAK) -case 8: -YY_RULE_SETUP -#line 51 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_AND; } - ACE_NOTREACHED (YY_BREAK) -case 9: -YY_RULE_SETUP -#line 52 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_OR; } - ACE_NOTREACHED (YY_BREAK) -case 10: -YY_RULE_SETUP -#line 53 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_IN; } - ACE_NOTREACHED (YY_BREAK) -case 11: -YY_RULE_SETUP -#line 54 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_TWIDDLE; } - ACE_NOTREACHED (YY_BREAK) -case 12: -YY_RULE_SETUP -#line 55 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_PLUS; } - ACE_NOTREACHED (YY_BREAK) -case 13: -YY_RULE_SETUP -#line 56 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_MINUS; } - ACE_NOTREACHED (YY_BREAK) -case 14: -YY_RULE_SETUP -#line 57 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_MULT; } - ACE_NOTREACHED (YY_BREAK) -case 15: -YY_RULE_SETUP -#line 58 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_DIV; } - ACE_NOTREACHED (YY_BREAK) -case 16: -YY_RULE_SETUP -#line 59 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_LT; } - ACE_NOTREACHED (YY_BREAK) -case 17: -YY_RULE_SETUP -#line 60 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_LE; } - ACE_NOTREACHED (YY_BREAK) -case 18: -YY_RULE_SETUP -#line 61 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_GT; } - ACE_NOTREACHED (YY_BREAK) -case 19: -YY_RULE_SETUP -#line 62 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_GE; } - ACE_NOTREACHED (YY_BREAK) -case 20: -YY_RULE_SETUP -#line 63 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_EQ; } - ACE_NOTREACHED (YY_BREAK) -case 21: -YY_RULE_SETUP -#line 64 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_NE; } - ACE_NOTREACHED (YY_BREAK) -case 22: -YY_RULE_SETUP -#line 65 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_LPAREN; } - ACE_NOTREACHED (YY_BREAK) -case 23: -YY_RULE_SETUP -#line 66 "Trader/constraint.l" -{ TAO_YY_LEX_DEBUG; return TAO_RPAREN; } - ACE_NOTREACHED (YY_BREAK) -case 24: -YY_RULE_SETUP -#line 67 "Trader/constraint.l" -{ - yylval.constraint_ = - new TAO_Literal_Constraint((CORBA::Boolean) 1); - TAO_YY_LEX_DEBUG; return TAO_BOOLEAN; - } - ACE_NOTREACHED (YY_BREAK) -case 25: -YY_RULE_SETUP -#line 72 "Trader/constraint.l" -{ - yylval.constraint_ = - new TAO_Literal_Constraint((CORBA::Boolean) 0); - TAO_YY_LEX_DEBUG; return TAO_BOOLEAN; - } - ACE_NOTREACHED (YY_BREAK) -case 26: -YY_RULE_SETUP -#line 77 "Trader/constraint.l" -{ - yylval.constraint_ = - new TAO_Literal_Constraint((CORBA::Long)atoi(yytext)); - TAO_YY_LEX_DEBUG; return TAO_NUMBER; - } - ACE_NOTREACHED (YY_BREAK) -case 27: -YY_RULE_SETUP -#line 82 "Trader/constraint.l" -{ - yylval.constraint_ = - new TAO_Literal_Constraint((CORBA::Double)atof(yytext)); - TAO_YY_LEX_DEBUG; return TAO_NUMBER; - } - ACE_NOTREACHED (YY_BREAK) -case 28: -YY_RULE_SETUP -#line 87 "Trader/constraint.l" -{ - yylval.constraint_ = extract_string(yytext); - TAO_YY_LEX_DEBUG; return TAO_STRING; - } - ACE_NOTREACHED (YY_BREAK) -case 29: -YY_RULE_SETUP -#line 91 "Trader/constraint.l" -{ - yylval.constraint_ = - new TAO_Property_Constraint(yytext); - TAO_YY_LEX_DEBUG; return TAO_IDENT; - } - ACE_NOTREACHED (YY_BREAK) -case 30: -YY_RULE_SETUP -#line 96 "Trader/constraint.l" -{ - TAO_YY_LEX_DEBUG; return TAO_UNKNOWN; - } - ACE_NOTREACHED (YY_BREAK) -case 31: -YY_RULE_SETUP -#line 99 "Trader/constraint.l" -TAO_TRADER_ECHO; - YY_BREAK -#line 865 "lex.yy.c" -case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between yy_current_buffer and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yy_n_chars = yy_current_buffer->yy_n_chars; - yy_current_buffer->yy_input_file = yyin; - yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of yylex */ - - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int yy_get_next_buffer() - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( yy_current_buffer->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_current_buffer->yy_n_chars = yy_n_chars = 0; - - else - { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; - - int yy_c_buf_p_offset = - (int) (yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = yy_current_buffer->yy_buf_size - - number_to_move - 1; -#endif - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; - - return ret_val; - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -static yy_state_type yy_get_previous_state() - { - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = yy_start; - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 81 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -yy_state_type yy_current_state; -#endif - { - register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 81 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 80); - - return yy_is_jam ? 0 : yy_current_state; - } - -#if 0 -#ifndef YY_NO_UNPUT -#ifdef YY_USE_PROTOS -static void yyunput( int c, register char *yy_bp ) -#else -static void yyunput( c, yy_bp ) -int c; -register char *yy_bp; -#endif - { - register char *yy_cp = yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yy_n_chars + 2; - register char *dest = &yy_current_buffer->yy_ch_buf[ - yy_current_buffer->yy_buf_size + 2]; - register char *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; - - while ( source > yy_current_buffer->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - yy_current_buffer->yy_n_chars = - yy_n_chars = yy_current_buffer->yy_buf_size; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - - yytext_ptr = yy_bp; - yy_hold_char = *yy_cp; - yy_c_buf_p = yy_cp; - } -#endif /* ifndef YY_NO_UNPUT */ -#endif /* 0 */ - -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#endif - { - int c; - - *yy_c_buf_p = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* This was really a NUL. */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yy_c_buf_p - yytext_ptr; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin ); - - /* fall through */ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - return EOF; - - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; - - - return c; - } - - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yy_load_buffer_state(); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file ); - - return b; - } - - -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - { - if ( ! b ) - return; - - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yy_flex_free( (void *) b->yy_ch_buf ); - - yy_flex_free( (void *) b ); - } - - - -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif - - - { - yy_flush_buffer( b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - - } - - -#ifdef YY_USE_PROTOS -void yy_flush_buffer( YY_BUFFER_STATE b ) -#else -void yy_flush_buffer( b ) -YY_BUFFER_STATE b; -#endif - - { - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == yy_current_buffer ) - yy_load_buffer_state(); - } - - -#ifndef YY_NO_SCAN_BUFFER -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) -#else -YY_BUFFER_STATE yy_scan_buffer( base, size ) -char *base; -yy_size_t size; -#endif - { - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b ); - - return b; - } -#endif - - -#ifndef YY_NO_SCAN_STRING -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) -#else -YY_BUFFER_STATE yy_scan_string( yy_str ) -yyconst char *yy_str; -#endif - { - int len; - for ( len = 0; yy_str[len]; ++len ) - ; - - return yy_scan_bytes( yy_str, len ); - } -#endif - - -#ifndef YY_NO_SCAN_BYTES -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) -#else -YY_BUFFER_STATE yy_scan_bytes( bytes, len ) -yyconst char *bytes; -int len; -#endif - { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) yy_flex_alloc( n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; - - buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; - } -#endif - - -#ifndef YY_NO_PUSH_STATE -#ifdef YY_USE_PROTOS -static void yy_push_state( int new_state ) -#else -static void yy_push_state( new_state ) -int new_state; -#endif - { - if ( yy_start_stack_ptr >= yy_start_stack_depth ) - { - yy_size_t new_size; - - yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yy_start_stack_depth * sizeof( int ); - - if ( ! yy_start_stack ) - yy_start_stack = (int *) yy_flex_alloc( new_size ); - - else - yy_start_stack = (int *) yy_flex_realloc( - (void *) yy_start_stack, new_size ); - - if ( ! yy_start_stack ) - YY_FATAL_ERROR( - "out of memory expanding start-condition stack" ); - } - - yy_start_stack[yy_start_stack_ptr++] = YY_START; - - BEGIN(new_state); - } -#endif - - -#ifndef YY_NO_POP_STATE -static void yy_pop_state() - { - if ( --yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(yy_start_stack[yy_start_stack_ptr]); - } -#endif - - -#ifndef YY_NO_TOP_STATE -static int yy_top_state() - { - return yy_start_stack[yy_start_stack_ptr - 1]; - } -#endif - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -#ifdef YY_USE_PROTOS -static void yy_fatal_error( yyconst char msg[] ) -#else -static void yy_fatal_error( msg ) -char msg[]; -#endif - { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); - } - - - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) - - -/* Internal utility routines. */ - -#ifndef yytext_ptr -#ifdef YY_USE_PROTOS -static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) -#else -static void yy_flex_strncpy( s1, s2, n ) -char *s1; -yyconst char *s2; -int n; -#endif - { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; - } -#endif - -#ifdef YY_NEED_STRLEN -#ifdef YY_USE_PROTOS -static int yy_flex_strlen( yyconst char *s ) -#else -static int yy_flex_strlen( s ) -yyconst char *s; -#endif - { - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; - } -#endif - - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { - return (void *) malloc( size ); - } - -#ifdef YY_USE_PROTOS -static void *yy_flex_realloc( void *ptr, yy_size_t size ) -#else -static void *yy_flex_realloc( ptr, size ) -void *ptr; -yy_size_t size; -#endif - { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); - } - -#ifdef YY_USE_PROTOS -static void yy_flex_free( void *ptr ) -#else -static void yy_flex_free( ptr ) -void *ptr; -#endif - { - free( ptr ); - } - -#if YY_MAIN -int main() - { - yylex(); - return 0; - } -#endif -#line 99 "Trader/constraint.l" - - -TAO_Literal_Constraint* -extract_string(const char* total) -{ - int prev_slash = 0, - ctr = 0; - char str[BUFSIZ], - *tmp = (char*) total + 1; - - while (*tmp != '\0') - { - if (*tmp == '\\') - { - if (prev_slash) - prev_slash = 0; - else - { - prev_slash = 1; - continue; - } - } - else if (*tmp == '\'') - prev_slash = 0; - - str[ctr++] = *tmp; - tmp++; - } - - str[ctr - 1] = '\0'; - return new TAO_Literal_Constraint(str); -} - -int -yywrap (void) -{ - return 1; -} diff --git a/TAO/orbsvcs/orbsvcs/Trader/Constraint_y.cpp b/TAO/orbsvcs/orbsvcs/Trader/Constraint_y.cpp deleted file mode 100644 index 08778372140..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Constraint_y.cpp +++ /dev/null @@ -1,898 +0,0 @@ - -# line 2 "Trader/constraint.y" - // $Id$ -// ======================================================================== -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// constraint.y -// -// = AUTHOR -// Seth Widoff -// -// ======================================================================== - -#include "ace/OS.h" -#include "Constraint_Interpreter.h" -#include "Constraint_Nodes.h" - -//#define YYDEBUG 1 -# define TAO_GT 257 -# define TAO_GE 258 -# define TAO_LT 259 -# define TAO_LE 260 -# define TAO_EQ 261 -# define TAO_NE 262 -# define TAO_EXIST 263 -# define TAO_AND 264 -# define TAO_OR 265 -# define TAO_NOT 266 -# define TAO_IN 267 -# define TAO_TWIDDLE 268 -# define TAO_BOOLEAN 269 -# define TAO_PLUS 270 -# define TAO_MINUS 271 -# define TAO_MULT 272 -# define TAO_DIV 273 -# define TAO_UMINUS 274 -# define TAO_NUMBER 275 -# define TAO_RPAREN 276 -# define TAO_LPAREN 277 -# define TAO_IDENT 278 -# define TAO_STRING 279 -# define TAO_UNKNOWN 280 -# define TAO_UNSIGNED 281 -# define TAO_SIGNED 282 -# define TAO_DOUBLE 283 -# define TAO_CONSTRAINT 284 -# define TAO_SEQUENCE 285 -# define TAO_WITH 286 -# define TAO_MAX 287 -# define TAO_MIN 288 -# define TAO_FIRST 289 -# define TAO_RANDOM 290 - -#ifdef __cplusplus - -#ifndef yyerror - void yyerror(const char *); -#endif - -#ifndef yylex -#ifdef __EXTERN_C__ - extern "C" { int yylex(void); } -#else - int yylex(void); -#endif -#endif - int yyparse(void); - -#endif -#define yyclearin yychar = -1 -#define yyerrok yyerrflag = 0 -extern int yychar; -extern int yyerrflag; -YYSTYPE yylval; -YYSTYPE yyval; -typedef int yytabelem; -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 150 -#endif -#if YYMAXDEPTH > 0 -int yy_yys[YYMAXDEPTH], *yys = yy_yys; -YYSTYPE yy_yyv[YYMAXDEPTH], *yyv = yy_yyv; -#else /* user does initial allocation */ -int *yys; -YYSTYPE *yyv; -#endif -static int yymaxdepth = YYMAXDEPTH; -# define YYERRCODE 256 - -# line 133 "Trader/constraint.y" - - -//extern int yydebug = 1; -yytabelem yyexca[] ={ --1, 1, - 0, -1, - -2, 0, - }; -# define YYNPROD 38 -# define YYLAST 93 -yytabelem yyact[]={ - - 19, 54, 44, 16, 45, 19, 24, 37, 22, 38, - 39, 24, 21, 22, 18, 20, 23, 21, 25, 18, - 20, 23, 36, 7, 6, 5, 8, 9, 19, 60, - 26, 16, 40, 41, 24, 25, 22, 38, 39, 15, - 21, 11, 18, 20, 23, 32, 33, 34, 35, 30, - 31, 14, 10, 17, 13, 12, 4, 3, 1, 2, - 0, 0, 0, 0, 0, 27, 28, 29, 0, 0, - 42, 0, 48, 49, 50, 51, 52, 53, 43, 47, - 58, 59, 46, 0, 0, 0, 0, 0, 0, 0, - 56, 57, 55 }; -yytabelem yypact[]={ - - -263,-10000000, -230,-10000000, -234, -235, -235, -235,-10000000,-10000000, --10000000, -212, -245, -261, -240,-10000000, -258,-10000000, -235, -276, --10000000,-10000000, -271,-10000000,-10000000, -235, -235, -230, -230, -230, - -235, -235, -235, -235, -235, -235, -277, -235, -235, -235, - -235, -235,-10000000, -247,-10000000,-10000000, -234,-10000000,-10000000,-10000000, --10000000,-10000000,-10000000,-10000000,-10000000, -233, -240, -240,-10000000,-10000000, --10000000 }; -yytabelem yypgo[]={ - - 0, 58, 57, 59, 56, 52, 41, 55, 54, 51, - 39, 53 }; -yytabelem yyr1[]={ - - 0, 1, 1, 2, 2, 2, 2, 2, 3, 3, - 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, - 6, 7, 7, 8, 8, 8, 9, 9, 9, 10, - 10, 11, 11, 11, 11, 11, 11, 11 }; -yytabelem yyr2[]={ - - 0, 3, 3, 5, 5, 5, 3, 3, 7, 3, - 7, 3, 7, 7, 7, 7, 7, 7, 3, 7, - 3, 7, 3, 7, 7, 3, 7, 7, 3, 5, - 3, 7, 5, 3, 3, 5, 3, 3 }; -yytabelem yychk[]={ - --10000000, -1, -3, -2, -4, 288, 287, 286, 289, 290, - -5, -6, -7, -8, -9, -10, 266, -11, 277, 263, - 278, 275, 271, 279, 269, 265, 264, -3, -3, -3, - 261, 262, 257, 258, 259, 260, 267, 268, 270, 271, - 272, 273, -11, -3, 278, 275, -4, -5, -6, -6, - -6, -6, -6, -6, 278, -8, -9, -9, -10, -10, - 276 }; -yytabelem yydef[]={ - - 0, -2, 1, 2, 9, 0, 0, 0, 6, 7, - 11, 18, 20, 22, 25, 28, 0, 30, 0, 0, - 33, 34, 0, 36, 37, 0, 0, 3, 4, 5, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 29, 0, 32, 35, 8, 10, 12, 13, - 14, 15, 16, 17, 19, 21, 23, 24, 26, 27, - 31 }; -typedef struct -#ifdef __cplusplus - yytoktype -#endif -{ char *t_name; int t_val; } yytoktype; -#ifndef YYDEBUG -# define YYDEBUG 0 /* don't allow debugging */ -#endif - -#if YYDEBUG - -yytoktype yytoks[] = -{ - "TAO_GT", 257, - "TAO_GE", 258, - "TAO_LT", 259, - "TAO_LE", 260, - "TAO_EQ", 261, - "TAO_NE", 262, - "TAO_EXIST", 263, - "TAO_AND", 264, - "TAO_OR", 265, - "TAO_NOT", 266, - "TAO_IN", 267, - "TAO_TWIDDLE", 268, - "TAO_BOOLEAN", 269, - "TAO_PLUS", 270, - "TAO_MINUS", 271, - "TAO_MULT", 272, - "TAO_DIV", 273, - "TAO_UMINUS", 274, - "TAO_NUMBER", 275, - "TAO_RPAREN", 276, - "TAO_LPAREN", 277, - "TAO_IDENT", 278, - "TAO_STRING", 279, - "TAO_UNKNOWN", 280, - "TAO_UNSIGNED", 281, - "TAO_SIGNED", 282, - "TAO_DOUBLE", 283, - "TAO_CONSTRAINT", 284, - "TAO_SEQUENCE", 285, - "TAO_WITH", 286, - "TAO_MAX", 287, - "TAO_MIN", 288, - "TAO_FIRST", 289, - "TAO_RANDOM", 290, - "-unknown-", -1 /* ends search */ -}; - -char * yyreds[] = -{ - "-no such reduction-", - "constraint : bool_or", - "constraint : preference", - "preference : TAO_MIN bool_or", - "preference : TAO_MAX bool_or", - "preference : TAO_WITH bool_or", - "preference : TAO_FIRST", - "preference : TAO_RANDOM", - "bool_or : bool_or TAO_OR bool_and", - "bool_or : bool_and", - "bool_and : bool_and TAO_AND bool_compare", - "bool_and : bool_compare", - "bool_compare : expr_in TAO_EQ expr_in", - "bool_compare : expr_in TAO_NE expr_in", - "bool_compare : expr_in TAO_GT expr_in", - "bool_compare : expr_in TAO_GE expr_in", - "bool_compare : expr_in TAO_LT expr_in", - "bool_compare : expr_in TAO_LE expr_in", - "bool_compare : expr_in", - "expr_in : expr_twiddle TAO_IN TAO_IDENT", - "expr_in : expr_twiddle", - "expr_twiddle : expr TAO_TWIDDLE expr", - "expr_twiddle : expr", - "expr : expr TAO_PLUS term", - "expr : expr TAO_MINUS term", - "expr : term", - "term : term TAO_MULT factor_not", - "term : term TAO_DIV factor_not", - "term : factor_not", - "factor_not : TAO_NOT factor", - "factor_not : factor", - "factor : TAO_LPAREN bool_or TAO_RPAREN", - "factor : TAO_EXIST TAO_IDENT", - "factor : TAO_IDENT", - "factor : TAO_NUMBER", - "factor : TAO_MINUS TAO_NUMBER", - "factor : TAO_STRING", - "factor : TAO_BOOLEAN", -}; -#endif /* YYDEBUG */ -# line 1 "/usr/ccs/bin/yaccpar" -/* - * Copyright (c) 1993 by Sun Microsystems, Inc. - */ - -//#pragma ident "@(#)yaccpar 6.12 93/06/07 SMI" - -/* -** Skeleton parser driver for yacc output -*/ - -/* -** yacc user known macros and defines -*/ -#define YYERROR goto yyerrlab -#define YYACCEPT return(0) -#define YYABORT return(1) -#define YYBACKUP( newtoken, newvalue )\ -{\ - if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\ - {\ - yyerror( "syntax error - cannot backup" );\ - goto yyerrlab;\ - }\ - yychar = newtoken;\ - yystate = *yyps;\ - yylval = newvalue;\ - goto yynewstate;\ -} -#define YYRECOVERING() (!!yyerrflag) -#define YYNEW(type) malloc(sizeof(type) * yynewmax) -#define YYCOPY(to, from, type) \ - (type *) memcpy(to, (char *) from, yynewmax * sizeof(type)) -#define YYENLARGE( from, type) \ - (type *) realloc((char *) from, yynewmax * sizeof(type)) -#ifndef YYDEBUG -# define YYDEBUG 1 /* make debugging available */ -#endif - -/* -** user known globals -*/ -int yydebug; /* set to 1 to get debugging */ - -/* -** driver internal defines -*/ -#define YYFLAG (-10000000) - -/* -** global variables used by the parser -*/ -YYSTYPE *yypv; /* top of value stack */ -int *yyps; /* top of state stack */ - -int yystate; /* current state */ -int yytmp; /* extra var (lasts between blocks) */ - -int yynerrs; /* number of errors */ -int yyerrflag; /* error recovery flag */ -int yychar; /* current input token number */ - - - -#ifdef YYNMBCHARS -#define YYLEX() yycvtok(yylex()) -/* -** yycvtok - return a token if i is a wchar_t value that exceeds 255. -** If i<255, i itself is the token. If i>255 but the neither -** of the 30th or 31st bit is on, i is already a token. -*/ -#if defined(__STDC__) || defined(__cplusplus) -int yycvtok(int i) -#else -int yycvtok(i) int i; -#endif -{ - int first = 0; - int last = YYNMBCHARS - 1; - int mid; - wchar_t j; - - if(i&0x60000000){/*Must convert to a token. */ - if( yymbchars[last].character < i ){ - return i;/*Giving up*/ - } - while ((last>=first)&&(first>=0)) {/*Binary search loop*/ - mid = (first+last)/2; - j = yymbchars[mid].character; - if( j==i ){/*Found*/ - return yymbchars[mid].tvalue; - }else if( j= 0; - yy_i++ ) - { - if ( yytoks[yy_i].t_val == yychar ) - break; - } - printf( "%s\n", yytoks[yy_i].t_name ); - } - } -#endif /* YYDEBUG */ - if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */ - { - /* - ** reallocate and recover. Note that pointers - ** have to be reset, or bad things will happen - */ - int yyps_index = (yy_ps - yys); - int yypv_index = (yy_pv - yyv); - int yypvt_index = (yypvt - yyv); - int yynewmax; -#ifdef YYEXPAND - yynewmax = YYEXPAND(yymaxdepth); -#else - yynewmax = 2 * yymaxdepth; /* double table size */ - if (yymaxdepth == YYMAXDEPTH) /* first time growth */ - { - char *newyys = (char *)YYNEW(int); - char *newyyv = (char *)YYNEW(YYSTYPE); - if (newyys != 0 && newyyv != 0) - { - yys = YYCOPY(newyys, yys, int); - yyv = YYCOPY(newyyv, yyv, YYSTYPE); - } - else - yynewmax = 0; /* failed */ - } - else /* not first time */ - { - yys = YYENLARGE(yys, int); - yyv = YYENLARGE(yyv, YYSTYPE); - if (yys == 0 || yyv == 0) - yynewmax = 0; /* failed */ - } -#endif - if (yynewmax <= yymaxdepth) /* tables not expanded */ - { - yyerror( "yacc stack overflow" ); - YYABORT; - } - yymaxdepth = yynewmax; - - yy_ps = yys + yyps_index; - yy_pv = yyv + yypv_index; - yypvt = yyv + yypvt_index; - } - *yy_ps = yy_state; - *++yy_pv = yyval; - - /* - ** we have a new state - find out what to do - */ - yy_newstate: - if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG ) - goto yydefault; /* simple state */ -#if YYDEBUG - /* - ** if debugging, need to mark whether new token grabbed - */ - yytmp = yychar < 0; -#endif - if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) ) - yychar = 0; /* reached EOF */ -#if YYDEBUG - if ( yydebug && yytmp ) - { - register int yy_i; - - printf( "Received token " ); - if ( yychar == 0 ) - printf( "end-of-file\n" ); - else if ( yychar < 0 ) - printf( "-none-\n" ); - else - { - for ( yy_i = 0; yytoks[yy_i].t_val >= 0; - yy_i++ ) - { - if ( yytoks[yy_i].t_val == yychar ) - break; - } - printf( "%s\n", yytoks[yy_i].t_name ); - } - } -#endif /* YYDEBUG */ - if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) ) - goto yydefault; - if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/ - { - yychar = -1; - yyval = yylval; - yy_state = yy_n; - if ( yyerrflag > 0 ) - yyerrflag--; - goto yy_stack; - } - - yydefault: - if ( ( yy_n = yydef[ yy_state ] ) == -2 ) - { -#if YYDEBUG - yytmp = yychar < 0; -#endif - if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) ) - yychar = 0; /* reached EOF */ -#if YYDEBUG - if ( yydebug && yytmp ) - { - register int yy_i; - - printf( "Received token " ); - if ( yychar == 0 ) - printf( "end-of-file\n" ); - else if ( yychar < 0 ) - printf( "-none-\n" ); - else - { - for ( yy_i = 0; - yytoks[yy_i].t_val >= 0; - yy_i++ ) - { - if ( yytoks[yy_i].t_val - == yychar ) - { - break; - } - } - printf( "%s\n", yytoks[yy_i].t_name ); - } - } -#endif /* YYDEBUG */ - /* - ** look through exception table - */ - { - register int *yyxi = yyexca; - - while ( ( *yyxi != -1 ) || - ( yyxi[1] != yy_state ) ) - { - yyxi += 2; - } - while ( ( *(yyxi += 2) >= 0 ) && - ( *yyxi != yychar ) ) - ; - if ( ( yy_n = yyxi[1] ) < 0 ) - YYACCEPT; - } - } - - /* - ** check for syntax error - */ - if ( yy_n == 0 ) /* have an error */ - { - /* no worry about speed here! */ - switch ( yyerrflag ) - { - case 0: /* new error */ - yyerror( "syntax error" ); - goto skip_init; - yyerrlab: - /* - ** get globals into registers. - ** we have a user generated syntax type error - */ - yy_pv = yypv; - yy_ps = yyps; - yy_state = yystate; - skip_init: - yynerrs++; - /* FALLTHRU */ - case 1: - case 2: /* incompletely recovered error */ - /* try again... */ - yyerrflag = 3; - /* - ** find state where "error" is a legal - ** shift action - */ - while ( yy_ps >= yys ) - { - yy_n = yypact[ *yy_ps ] + YYERRCODE; - if ( yy_n >= 0 && yy_n < YYLAST && - yychk[yyact[yy_n]] == YYERRCODE) { - /* - ** simulate shift of "error" - */ - yy_state = yyact[ yy_n ]; - goto yy_stack; - } - /* - ** current state has no shift on - ** "error", pop stack - */ -#if YYDEBUG -# define _POP_ "Error recovery pops state %d, uncovers state %d\n" - if ( yydebug ) - printf( _POP_, *yy_ps, - yy_ps[-1] ); -# undef _POP_ -#endif - yy_ps--; - yy_pv--; - } - /* - ** there is no state on stack with "error" as - ** a valid shift. give up. - */ - YYABORT; - case 3: /* no shift yet; eat a token */ -#if YYDEBUG - /* - ** if debugging, look up token in list of - ** pairs. 0 and negative shouldn't occur, - ** but since timing doesn't matter when - ** debugging, it doesn't hurt to leave the - ** tests here. - */ - if ( yydebug ) - { - register int yy_i; - - printf( "Error recovery discards " ); - if ( yychar == 0 ) - printf( "token end-of-file\n" ); - else if ( yychar < 0 ) - printf( "token -none-\n" ); - else - { - for ( yy_i = 0; - yytoks[yy_i].t_val >= 0; - yy_i++ ) - { - if ( yytoks[yy_i].t_val - == yychar ) - { - break; - } - } - printf( "token %s\n", - yytoks[yy_i].t_name ); - } - } -#endif /* YYDEBUG */ - if ( yychar == 0 ) /* reached EOF. quit */ - YYABORT; - yychar = -1; - goto yy_newstate; - } - }/* end if ( yy_n == 0 ) */ - /* - ** reduction by production yy_n - ** put stack tops, etc. so things right after switch - */ -#if YYDEBUG - /* - ** if debugging, print the string that is the user's - ** specification of the reduction which is just about - ** to be done. - */ - if ( yydebug ) - printf( "Reduce by (%d) \"%s\"\n", - yy_n, yyreds[ yy_n ] ); -#endif - yytmp = yy_n; /* value to switch over */ - yypvt = yy_pv; /* $vars top of value stack */ - /* - ** Look in goto table for next state - ** Sorry about using yy_state here as temporary - ** register variable, but why not, if it works... - ** If yyr2[ yy_n ] doesn't have the low order bit - ** set, then there is no action to be done for - ** this reduction. So, no saving & unsaving of - ** registers done. The only difference between the - ** code just after the if and the body of the if is - ** the goto yy_stack in the body. This way the test - ** can be made before the choice of what to do is needed. - */ - { - /* length of production doubled with extra bit */ - register int yy_len = yyr2[ yy_n ]; - - if ( !( yy_len & 01 ) ) - { - yy_len >>= 1; - yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ - yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + - *( yy_ps -= yy_len ) + 1; - if ( yy_state >= YYLAST || - yychk[ yy_state = - yyact[ yy_state ] ] != -yy_n ) - { - yy_state = yyact[ yypgo[ yy_n ] ]; - } - goto yy_stack; - } - yy_len >>= 1; - yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ - yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + - *( yy_ps -= yy_len ) + 1; - if ( yy_state >= YYLAST || - yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) - { - yy_state = yyact[ yypgo[ yy_n ] ]; - } - } - /* save until reenter driver code */ - yystate = yy_state; - yyps = yy_ps; - yypv = yy_pv; - } - /* - ** code supplied by user is placed in this switch - */ - switch( yytmp ) - { - -case 1: -# line 38 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Unary_Constraint(TAO_CONSTRAINT, yypvt[-0].constraint_); } break; -case 2: -# line 40 "Trader/constraint.y" -{ yyval.constraint_ = yypvt[-0].constraint_; } break; -case 3: -# line 44 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Unary_Constraint(TAO_MIN, yypvt[-0].constraint_); } break; -case 4: -# line 46 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Unary_Constraint(TAO_MAX, yypvt[-0].constraint_); } break; -case 5: -# line 48 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Unary_Constraint(TAO_WITH, yypvt[-0].constraint_); } break; -case 6: -# line 50 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Noop_Constraint(TAO_FIRST); } break; -case 7: -# line 52 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Noop_Constraint(TAO_RANDOM); } break; -case 8: -# line 56 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Binary_Constraint(TAO_OR, yypvt[-2].constraint_, yypvt[-0].constraint_); } break; -case 9: -# line 58 "Trader/constraint.y" -{ yyval.constraint_ = yypvt[-0].constraint_; } break; -case 10: -# line 62 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Binary_Constraint(TAO_AND, yypvt[-2].constraint_, yypvt[-0].constraint_); } break; -case 11: -# line 64 "Trader/constraint.y" -{ yyval.constraint_ = yypvt[-0].constraint_; } break; -case 12: -# line 68 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Binary_Constraint(TAO_EQ, yypvt[-2].constraint_, yypvt[-0].constraint_); } break; -case 13: -# line 70 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Binary_Constraint(TAO_NE, yypvt[-2].constraint_, yypvt[-0].constraint_); } break; -case 14: -# line 72 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Binary_Constraint(TAO_GT, yypvt[-2].constraint_, yypvt[-0].constraint_); } break; -case 15: -# line 74 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Binary_Constraint(TAO_GE, yypvt[-2].constraint_, yypvt[-0].constraint_); } break; -case 16: -# line 76 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Binary_Constraint(TAO_LT, yypvt[-2].constraint_, yypvt[-0].constraint_); } break; -case 17: -# line 78 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Binary_Constraint(TAO_LE, yypvt[-2].constraint_, yypvt[-0].constraint_); } break; -case 18: -# line 80 "Trader/constraint.y" -{ yyval.constraint_ = yypvt[-0].constraint_; } break; -case 19: -# line 84 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Binary_Constraint(TAO_IN, yypvt[-2].constraint_, yypvt[-0].constraint_); } break; -case 20: -# line 86 "Trader/constraint.y" -{ yyval.constraint_ = yypvt[-0].constraint_; } break; -case 21: -# line 90 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Binary_Constraint(TAO_TWIDDLE, yypvt[-2].constraint_, yypvt[-0].constraint_); } break; -case 22: -# line 92 "Trader/constraint.y" -{ yyval.constraint_ = yypvt[-0].constraint_; } break; -case 23: -# line 96 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Binary_Constraint(TAO_PLUS, yypvt[-2].constraint_, yypvt[-0].constraint_); } break; -case 24: -# line 98 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Binary_Constraint(TAO_MINUS, yypvt[-2].constraint_, yypvt[-0].constraint_); } break; -case 25: -# line 100 "Trader/constraint.y" -{ yyval.constraint_ = yypvt[-0].constraint_; } break; -case 26: -# line 104 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Binary_Constraint(TAO_MULT, yypvt[-2].constraint_, yypvt[-0].constraint_); } break; -case 27: -# line 106 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Binary_Constraint(TAO_DIV, yypvt[-2].constraint_, yypvt[-0].constraint_); } break; -case 28: -# line 108 "Trader/constraint.y" -{ yyval.constraint_ = yypvt[-0].constraint_; } break; -case 29: -# line 112 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Unary_Constraint(TAO_NOT, yypvt[-0].constraint_); } break; -case 30: -# line 114 "Trader/constraint.y" -{ yyval.constraint_ = yypvt[-0].constraint_; } break; -case 31: -# line 118 "Trader/constraint.y" -{ yyval.constraint_ = yypvt[-1].constraint_; } break; -case 32: -# line 120 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Unary_Constraint(TAO_EXIST, yypvt[-0].constraint_); } break; -case 33: -# line 122 "Trader/constraint.y" -{ yyval.constraint_ = yypvt[-0].constraint_; } break; -case 34: -# line 124 "Trader/constraint.y" -{ yyval.constraint_ = yypvt[-0].constraint_; } break; -case 35: -# line 126 "Trader/constraint.y" -{ yyval.constraint_ = new TAO_Unary_Constraint(TAO_UMINUS, yypvt[-0].constraint_); } break; -case 36: -# line 128 "Trader/constraint.y" -{ yyval.constraint_ = yypvt[-0].constraint_; } break; -case 37: -# line 130 "Trader/constraint.y" -{ yyval.constraint_ = yypvt[-0].constraint_; } break; -# line 532 "/usr/ccs/bin/yaccpar" - } - goto yystack; /* reset registers in driver code */ -} - diff --git a/TAO/orbsvcs/orbsvcs/Trader/Locking.h b/TAO/orbsvcs/orbsvcs/Trader/Locking.h deleted file mode 100644 index 0c79088727e..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Locking.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- C++ -*- */ - -// ========================================================================= -// $Id$ -// -// = LIBRARY -// Trading -// -// = FILENAME -// Locking.h -// -// = AUTHOR -// Marina Spivak -// Seth Widoff -// Irfan Pyarali -// -// ========================================================================== -#ifndef TAO_LOCKING_H -#define TAO_LOCKING_H - -#include "tao/corba.h" - -// Macros for obtaining read/write locks that are -// automatically released at the end of scope. -// In case of failure, CORBA::SystemException is thrown. - -#define TAO_WRITE_GUARD(MUTEX,OBJ,LOCK) \ -ACE_Write_Guard OBJ (LOCK); \ -if (OBJ.locked () == 0) \ - TAO_THROW (CORBA::UNKNOWN (CORBA::COMPLETED_NO)); - -#define TAO_READ_GUARD(MUTEX,OBJ,LOCK) \ -ACE_Read_Guard OBJ (LOCK); \ -if (OBJ.locked () == 0) \ - TAO_THROW (CORBA::UNKNOWN (CORBA::COMPLETED_NO)); - -#define TAO_WRITE_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \ -ACE_Write_Guard OBJ (LOCK); \ -if (OBJ.locked () == 0) \ - TAO_THROW_RETURN (CORBA::UNKNOWN (CORBA::COMPLETED_NO), RETURN); - -#define TAO_READ_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \ -ACE_Read_Guard OBJ (LOCK); \ -if (OBJ.locked () == 0) \ - TAO_THROW_RETURN (CORBA::UNKNOWN (CORBA::COMPLETED_NO), RETURN); - -#endif /* TAO_LOCKING_H */ - diff --git a/TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp b/TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp deleted file mode 100644 index caa2c2c2a3c..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp +++ /dev/null @@ -1,373 +0,0 @@ -// $Id$ - -#ifndef TAO_OFFER_DATABASE_C -#define TAO_OFFER_DATABASE_C - -#include "Offer_Database.h" - -ACE_RCSID(Trader, Offer_Database, "$Id$") - -template -TAO_Offer_Database::TAO_Offer_Database (void) -{ -} - -template -TAO_Offer_Database::~TAO_Offer_Database (void) -{ - ACE_WRITE_GUARD (LOCK_TYPE, ace_mon, this->db_lock_); - - for (ACE_TYPENAME Offer_Database::iterator type_iter (this->offer_db_); - ! type_iter.done (); - type_iter++) - { - Offer_Map_Entry* offer_map_entry = (*type_iter).int_id_; - - { - // Artificial scope, so the guard will release the lock before - // we delete the lock along with the offer_map_entry. - ACE_WRITE_GUARD (LOCK_TYPE, ace_mon, offer_map_entry->lock_); - - for (TAO_Offer_Map::iterator offer_iter (*offer_map_entry->offer_map_); - ! offer_iter.done (); - offer_iter++) - { - // Delete all the offers in the offer map. - CosTrading::Offer* offer = (*offer_iter).int_id_; - delete offer; - } - - delete offer_map_entry->offer_map_; - } - - delete offer_map_entry; - } -} - -template CosTrading::OfferId -TAO_Offer_Database:: -insert_offer (const char* type, CosTrading::Offer* offer) -{ - CosTrading::OfferId return_value = 0; - ACE_TYPENAME Offer_Database::ENTRY* database_entry = 0; - TAO_String_Hash_Key service_type (type); - - ACE_READ_GUARD_RETURN (LOCK_TYPE, ace_mon, this->db_lock_, 0); - - if (this->offer_db_.find (service_type, database_entry) == -1) - { - // If there's no entry for the service type, create one. - - Offer_Map_Entry* new_offer_map_entry = 0; - ACE_NEW_RETURN (new_offer_map_entry, Offer_Map_Entry, 0); - ACE_NEW_RETURN (new_offer_map_entry->offer_map_, TAO_Offer_Map, 0); - new_offer_map_entry->counter_ = 1; - - if (this->db_lock_.release () == -1) - return 0; - else - { - // Add the new entry; upgrade lock. - ACE_WRITE_GUARD_RETURN (LOCK_TYPE, ace_mon, this->db_lock_, 0); - this->offer_db_.bind (service_type, new_offer_map_entry, database_entry); - } - - if (this->db_lock_.acquire_read () == -1) - return 0; - } - - Offer_Map_Entry* offer_map_entry = database_entry->int_id_; - ACE_WRITE_GUARD_RETURN (LOCK_TYPE, ace_mon2, offer_map_entry->lock_, 0); - - // Add the offer to the service offer table for this service type. - offer_map_entry->offer_map_->bind (offer_map_entry->counter_, offer); - return_value = this->generate_offer_id (type, offer_map_entry->counter_); - offer_map_entry->counter_++; - - return return_value; -} - -template int -TAO_Offer_Database:: -remove_offer (const char* type, CORBA::ULong id) -{ - ACE_READ_GUARD_RETURN (LOCK_TYPE, ace_mon, this->db_lock_, -1); - - int return_value = -1; - ACE_TYPENAME Offer_Database::ENTRY* db_entry = 0; - TAO_String_Hash_Key service_type (type); - - if (this->offer_db_.find (service_type, db_entry) == 0) - { - CosTrading::Offer* offer = 0; - Offer_Map_Entry* offer_map_entry = db_entry->int_id_; - - if (offer_map_entry->lock_.acquire_write () == -1) - return -1; - - return_value = offer_map_entry->offer_map_->unbind (id, offer); - delete offer; - - // If the service type has no more offers, free the map, lest - // the memory forever persist. - if (offer_map_entry->offer_map_->current_size () == 0) - { - if (this->db_lock_.release () == -1) - return -1; - else - { - // Promote the database lock. Will be released by - // guard. - if (this->db_lock_.acquire_write () == -1) - return -1; - - // Unbind the service type from the database. - this->offer_db_.unbind (service_type); - - // Now that the type has been removed, we can release - // its lock. - if (offer_map_entry->lock_.release () == -1) - return -1; - - // Delete the database resources for this type. - delete offer_map_entry->offer_map_; - delete offer_map_entry; - } - } - else if (offer_map_entry->lock_.release () == -1) - return -1; - } - - return return_value; -} - -template int -TAO_Offer_Database:: -remove_offer (const CosTrading::OfferId offer_id, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId)) -{ - char* stype = 0; - CORBA::ULong index; - - this->parse_offer_id (offer_id, stype, index, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, -1); - - if (this->remove_offer (stype, index) == -1) - TAO_THROW_RETURN (CosTrading::UnknownOfferId (offer_id), -1); - - return 0; -} - -template CosTrading::Offer* -TAO_Offer_Database:: -lookup_offer (const CosTrading::OfferId offer_id, - char*& type_name, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId)) -{ - CORBA::ULong index; - CosTrading::Offer* offer = 0; - this->parse_offer_id (offer_id, type_name, index, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, offer); - - if ((offer = this->lookup_offer (type_name, index)) == 0) - TAO_THROW_RETURN (CosTrading::UnknownOfferId (offer_id), offer); - - return offer; -} - - -template CosTrading::Offer* -TAO_Offer_Database:: -lookup_offer (const CosTrading::OfferId offer_id, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId)) -{ - char* type_name; - CORBA::ULong index; - CosTrading::Offer* offer = 0; - - this->parse_offer_id (offer_id, type_name, index, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, offer); - - if ((offer = this->lookup_offer (type_name, index)) == 0) - TAO_THROW_RETURN (CosTrading::UnknownOfferId (offer_id), offer); - - return offer; -} - -template CosTrading::Offer* -TAO_Offer_Database:: -lookup_offer (const char* type, CORBA::ULong id) -{ - ACE_READ_GUARD_RETURN (LOCK_TYPE, ace_mon, this->db_lock_, 0); - - CosTrading::Offer* return_value = 0; - ACE_TYPENAME Offer_Database::ENTRY* db_entry = 0; - TAO_String_Hash_Key service_type (type); - - if (this->offer_db_.find (service_type, db_entry) == 0) - { - Offer_Map_Entry* offer_map_entry = db_entry->int_id_; - ACE_READ_GUARD_RETURN (LOCK_TYPE, ace_mon, offer_map_entry->lock_, 0); - - TAO_Offer_Map::ENTRY* offer_entry_ptr = 0; - offer_map_entry->offer_map_->find (id, offer_entry_ptr); - - return_value = offer_entry_ptr->int_id_; - } - - return return_value; -} - -template TAO_Offer_Id_Iterator* -TAO_Offer_Database::retrieve_all_offer_ids (void) -{ - // Fill an TAO_Offer_Id_Iterator with the offer_ids of all offers - // exported to the TAO_Offer_Database. Iterates through the entire - // map, cramming offer_id strings into a newly constructed - // TAO_Offer_Id_Iterator. - TAO_Offer_Id_Iterator* id_iterator = new TAO_Offer_Id_Iterator (); - ACE_READ_GUARD_RETURN (LOCK_TYPE, ace_mon, this->db_lock_, 0); - - for (ACE_TYPENAME Offer_Database::iterator type_iter (this->offer_db_); - ! type_iter.done (); - type_iter++) - { - const char* type_name = (*type_iter).ext_id_; - Offer_Map_Entry* offer_map_entry = (*type_iter).int_id_; - - ACE_READ_GUARD_RETURN (LOCK_TYPE, ace_mon, offer_map_entry->lock_, 0); - - for (TAO_Offer_Map::iterator offer_iter (*offer_map_entry->offer_map_); - ! offer_iter.done (); - offer_iter++) - { - CORBA::ULong offer_index = (*offer_iter).ext_id_; - CosTrading::OfferId offer_id = - this->generate_offer_id (type_name, offer_index); - - id_iterator->insert_id (offer_id); - } - } - - return id_iterator; -} - -template void -TAO_Offer_Database:: -parse_offer_id (const CosTrading::OfferId offer_id, - char*&service_type, - CORBA::ULong& id, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::IllegalOfferId)) -{ - // Get service type: it is everything from 17th character to the end. - service_type = (char *) offer_id + 16; - - // Get id: temporarily put the end of string character where the service - // type starts, convert to number, replace the character back. - char* start_of_type = (char *) (offer_id + 16); - char temp = *start_of_type; - *start_of_type = '\0'; - id = ACE_OS::atoi (offer_id); - - *start_of_type = temp; - - if (! TAO_Trader_Base::is_valid_identifier_name (service_type)) - TAO_THROW (CosTrading::IllegalOfferId (offer_id)); -} - -template CosTrading::OfferId -TAO_Offer_Database:: -generate_offer_id (const char *service_type_name, CORBA::ULong id) -{ - // holds final id string. - int total_size = 16 + ACE_OS::strlen (service_type_name); - - // hold portions of id string. - CosTrading::OfferId offer_id = CORBA::string_alloc (total_size); - char* return_value = 0; - ACE_OS::sprintf (offer_id, "%016u%s", (CORBA::ULong) id, service_type_name); - - return_value = CORBA::string_dup (offer_id); - delete [] offer_id; - - return return_value; -} - - -template -TAO_Service_Offer_Iterator:: -TAO_Service_Offer_Iterator (const char* type, - TAO_Offer_Database& offer_database) - : stm_ (offer_database), - lock_ (0), - offer_iter_ (0), - type_ (type) -{ - TAO_String_Hash_Key service_type (type); - - if (this->stm_.db_lock_.acquire_read () == -1) - return; - - ACE_TYPENAME TAO_Offer_Database::Offer_Map_Entry* entry = 0; - if (this->stm_.offer_db_.find (service_type, entry) == -1) - return; - else - { - this->lock_ = &entry->lock_; - if (this->lock_->acquire_read () == -1) - return; - - ACE_NEW (offer_iter_, - TAO_Offer_Map::iterator (*entry->offer_map_)); - } -} - -template -TAO_Service_Offer_Iterator::~TAO_Service_Offer_Iterator (void) -{ - this->stm_.db_lock_.release (); - - if (this->lock_ != 0) - { - this->lock_->release (); - delete this->offer_iter_; - } -} - -template CosTrading::OfferId -TAO_Service_Offer_Iterator::get_id (void) -{ - return (this->offer_iter_ != 0) - ? TAO_Offer_Database::generate_offer_id (this->type_, (**this->offer_iter_).ext_id_) - : 0; -} - -template int -TAO_Service_Offer_Iterator::has_more_offers (void) -{ - return (this->offer_iter_ != 0) ? ! this->offer_iter_->done () : 0; -} - - -template CosTrading::Offer* -TAO_Service_Offer_Iterator::get_offer (void) -{ - return (this->offer_iter_ != 0) ? (**this->offer_iter_).int_id_ : 0; -} - -template void -TAO_Service_Offer_Iterator::next_offer (void) -{ - if (this->offer_iter_ != 0) - this->offer_iter_->advance (); -} - -#endif /* TAO_OFFER_DATABASE_C */ - diff --git a/TAO/orbsvcs/orbsvcs/Trader/Offer_Database.h b/TAO/orbsvcs/orbsvcs/Trader/Offer_Database.h deleted file mode 100644 index b79ecffe98a..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Offer_Database.h +++ /dev/null @@ -1,197 +0,0 @@ -/* -*- C++ -*- */ - -// ======================================================================== -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Offer_Database.h -// -// = AUTHOR -// Seth Widoff -// -// ======================================================================== - -#ifndef TAO_OFFER_DATABASE_H -#define TAO_OFFER_DATABASE_H - -#include "Trader.h" -#include "Offer_Iterators.h" - -template class TAO_Service_Offer_Iterator; - -template -class TAO_Offer_Database -// = DESCRIPTION -// The TAO_Offer_Database encapsulates the mapping of service -// types to those offers exported with that service types. The -// underlying structure is a map of maps. The first maps maps the -// service type name to a map of exported offers. The second map -// maps the identifying index for that offer within the service -// types. So a service type name and an index uniquely identifies an -// exported offer. In fact, when the register export interface -// returns a CosTrading::OfferId, it's returning no more than a -// simple string concatenation of these two values. In addition to -// all these wonderful things, the TAO_Offer_Database has built-in -// locking, one reader/writer-style lock for modifying the top-level -// map and a reader/writer-style for each of the offer -// maps. Needless to say the locks are acquired when the -// TAO_Offer_Database performs operations on the structures they -// guard. -// -// NOTE: TAO_Offer_Database needs to be parameterized by a -// READER/WRITER LOCK, a RECURSIVE MUTEX, or a NULL MUTEX, not a -// simple binary mutex! Mutexes will cause deadlock when you try to -// contruct an iterator (which acquires a read lock on the map under -// an existing read lock). Just don't do it, ok? -{ - friend class TAO_Service_Offer_Iterator; -public: - - // Traits - typedef TAO_Service_Offer_Iterator offer_iterator; - - TAO_Offer_Database (void); - // No arg constructor. - - ~TAO_Offer_Database (void); - - CosTrading::OfferId insert_offer (const char* type, - CosTrading::Offer* offer); - // Add an offer of type and generate a CosTrading::OfferId - // for it. Returns 0 on failure. - - int remove_offer (const CosTrading::OfferId offer_id, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId)); - - CosTrading::Offer* lookup_offer (const CosTrading::OfferId offer_id, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId)); - // Lookup an offer whose offer_id is , and return - // it. Otherwise, throw the appropriate exception. - - CosTrading::Offer* lookup_offer (const CosTrading::OfferId offer_id, - char*& type_name, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId)); - // Lookup an offer whose OfferId is and return in - // the type name of the object. Type name is just a - // pointer to a location in offer_id, so DON'T DELETE IT. - - TAO_Offer_Id_Iterator* retrieve_all_offer_ids (void); - // Return an iterator that will traverse and return all the offer - // ids in the service type map. - - struct Offer_Map_Entry - { - TAO_Offer_Map* offer_map_; - CORBA::ULong counter_; - LOCK_TYPE lock_; - }; - - typedef ACE_Hash_Map_Manager - < - TAO_String_Hash_Key, - Offer_Map_Entry*, - ACE_Null_Mutex - > - Offer_Database; - -private: - - // The internal id is a pointer here, not only to avoid copying, - // since we would only copy on insertion, and we only insert once - // --- with an empty Offer_Map_Entry --- but also since most locks - // have unimplemented copy constructors. - - CosTrading::Offer* lookup_offer (const char* type, - CORBA::ULong id); - // Lookup an offer whose type is and id, . Return 0 on - // failure. - - int remove_offer (const char* type, CORBA::ULong id); - // Remove an offers whose id is . Returns 0 on success, -1 - // on failure, and throws a CosTrading::IllegalOfferId if it can't - // parse the CosTrading::OfferId. - - static CosTrading::OfferId generate_offer_id (const char *type_name, - CORBA::ULong id); - // Take in a service type name for the offer the current value of - // of the counter and generate an offer id. - - static void parse_offer_id (const CosTrading::OfferId offer_id, - char* &service_type, - CORBA::ULong& id, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CosTrading::IllegalOfferId)); - // Take in a previously generated offer id and return the type - // and id that were used to generate the offer id. - - // = Disallow these operations. - ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Offer_Database &)) - ACE_UNIMPLEMENTED_FUNC (TAO_Offer_Database (const TAO_Offer_Database &)) - - LOCK_TYPE db_lock_; - - Offer_Database offer_db_; - // The protected data structure. -}; - -template -class TAO_Service_Offer_Iterator -// = TITLE -// TAO_Service_Offer_Iterator iterates over the set of exported -// offers for a given type. Handily, it takes care of all the -// necessary locking, acquiring them in the constructor, and -// releasing them in the destructor. -{ - public: - - typedef TAO_Offer_Database Offer_Database; - - TAO_Service_Offer_Iterator (const char* type, - TAO_Offer_Database& offer_database); - - ~TAO_Service_Offer_Iterator (void); - // Release all the locks acquired. - - int has_more_offers (void); - // Returns 1 if there are more offers, 0 otherwise. - - CosTrading::OfferId get_id (void); - // Get the id for the current offer. - - CosTrading::Offer* get_offer (void); - // Returns the next offer in the series. - - void next_offer (void); - // Advances the iterator 1. - - private: - // Protected constructor. - - TAO_Offer_Database& stm_; - // Lock the top_level map. - - LOCK_TYPE* lock_; - // Lock for the internal map. - - TAO_Offer_Map::iterator* offer_iter_; - // Iterator over the actual offer map. - - const char* type_; - // The name of the type. Used for constructing offer ids. -}; - - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "Offer_Database.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#endif /* TAO_SERVICE_TYPE_MAP_H */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators.cpp b/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators.cpp deleted file mode 100644 index e96619bcf75..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators.cpp +++ /dev/null @@ -1,387 +0,0 @@ -// ======================================================================== -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Offer_Iterators.cpp -// -// = AUTHOR -// Marina Spivak -// Seth Widoff -// -// ======================================================================== - -#include "Offer_Iterators.h" - -ACE_RCSID(Trader, Offer_Iterators, "$Id$") - - // ************************************************************* - // TAO_Offer_Iterator - // ************************************************************* - -TAO_Offer_Iterator::TAO_Offer_Iterator (const TAO_Property_Filter& pfilter) - : pfilter_ (pfilter) -{ -} - -TAO_Offer_Iterator::~TAO_Offer_Iterator (void) -{ -} - -void -TAO_Offer_Iterator::destroy (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - // Remove self from POA - // - // Note that there is no real error checking here as we can't do - // much about errors here anyway - // - - TAO_TRY - { - PortableServer::POA_var poa = this->_default_POA (TAO_TRY_ENV); - TAO_CHECK_ENV; - - PortableServer::ObjectId_var id = poa->servant_to_id (this, TAO_TRY_ENV); - TAO_CHECK_ENV; - - poa->deactivate_object (id.in (), TAO_TRY_ENV); - } - TAO_CATCHANY - { - } - TAO_ENDTRY; - - delete this; -} - - // ************************************************************* - // TAO_Query_Only_Offer_Iterator - // ************************************************************* - -TAO_Query_Only_Offer_Iterator:: -TAO_Query_Only_Offer_Iterator(const TAO_Property_Filter& pfilter) - : TAO_Offer_Iterator (pfilter) -{ -} - -TAO_Query_Only_Offer_Iterator::~TAO_Query_Only_Offer_Iterator(void) -{ -} - -void -TAO_Query_Only_Offer_Iterator::add_offer (CosTrading::OfferId offer_id, - const CosTrading::Offer* offer) -{ - this->offers_.enqueue_tail ((CosTrading::Offer*) offer); - CORBA::string_free (offer_id); -} - -CORBA::ULong -TAO_Query_Only_Offer_Iterator::max_left (CORBA::Environment &) - TAO_THROW_SPEC((CORBA::SystemException, - CosTrading::UnknownMaxLeft)) -{ - return this->offers_.size (); -} - -CORBA::Boolean -TAO_Query_Only_Offer_Iterator::next_n (CORBA::ULong n, - CosTrading::OfferSeq_out offers, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - offers = new CosTrading::OfferSeq; - - CORBA::ULong sequence_size = this->offers_.size (); - CORBA::ULong offers_in_sequence = (n < sequence_size) ? n : sequence_size; - offers->length (offers_in_sequence); - - // populate the sequence. - for (CORBA::ULong i = 0; i < offers_in_sequence; i++) - { - - CosTrading::Offer *source = 0; - this->offers_.dequeue_head (source); - this->pfilter_.filter_offer (source, offers[i]); - } - - return offers_in_sequence != 0; -} - - // ************************************************************* - // TAO_Offer_Iterator_Collection - // ************************************************************* - -TAO_Offer_Iterator_Collection::TAO_Offer_Iterator_Collection (void) -{ -} - -TAO_Offer_Iterator_Collection::~TAO_Offer_Iterator_Collection (void) -{ - while (! this->iters_.is_empty ()) - { - CosTrading::OfferIterator* offer_iter; - this->iters_.dequeue_head (offer_iter); - - TAO_TRY - { - offer_iter->destroy (TAO_TRY_ENV); - TAO_CHECK_ENV; - - CORBA::release (offer_iter); - } - TAO_CATCHANY {} - TAO_ENDTRY; - } -} - -void -TAO_Offer_Iterator_Collection:: -add_offer_iterator (CosTrading::OfferIterator_ptr offer_iter) -{ - if (! CORBA::is_nil (offer_iter)) - this->iters_.enqueue_tail (offer_iter); -} - -CORBA::Boolean -TAO_Offer_Iterator_Collection::next_n (CORBA::ULong n, - CosTrading::OfferSeq_out offers, - CORBA::Environment &env) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::ULong offers_left = n; - CORBA::Boolean return_value = 1; - CosTrading::OfferSeq_var out_offers; - - ACE_NEW_RETURN (offers, CosTrading::OfferSeq, return_value); - while (offers_left > 0 && ! this->iters_.is_empty ()) - { - CORBA::ULong offset = 0; - CORBA::Boolean any_left = 0; - CosTrading::OfferIterator* iter = 0; - this->iters_.dequeue_head (iter); - - // Determine how many offers we should retrieve from this - // iterator. - - TAO_TRY - { - // Retrieve the set of offers. - any_left = - iter->next_n (offers_left, - CosTrading::OfferSeq_out (out_offers.out ()), - TAO_TRY_ENV); - TAO_CHECK_ENV; - - // If we've exhausted this iterator, destroy it. - if (any_left == 0) - { - iter->destroy (env); - CORBA::release (iter); - } - else - this->iters_.enqueue_head (iter); - - // Merge it with the passed set. - offset = offers->length (); - offers->length (out_offers->length () + offset); - for (int j = out_offers->length () - 1; j >= 0; j--) - offers[j + offset] = out_offers[j]; - - offers_left -= out_offers->length (); - } - TAO_CATCHANY - { - } - TAO_ENDTRY; - } - - // Determine if we have anything left to offer. - if (this->iters_.is_empty ()) - return_value = 0; - - return return_value; -} - -void -TAO_Offer_Iterator_Collection::destroy (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - // Destroy all iterators in the collection. - for (Offer_Iters::ITERATOR iters_iter (this->iters_); - ! iters_iter.done (); - iters_iter.advance ()) - { - CosTrading::OfferIterator** iter = 0; - - iters_iter.next (iter); - (*iter)->destroy (TAO_IN_ENV); - } - - // Remove self from POA - // - // Note that there is no real error checking here as we can't do - // much about errors here anyway - // - - TAO_TRY - { - PortableServer::POA_var poa = this->_default_POA (TAO_TRY_ENV); - TAO_CHECK_ENV; - PortableServer::ObjectId_var id = - poa->servant_to_id (this, TAO_TRY_ENV); - TAO_CHECK_ENV; - - poa->deactivate_object (id.in (), TAO_TRY_ENV); - } - TAO_CATCHANY - { - } - TAO_ENDTRY; - - delete this; -} - -CORBA::ULong -TAO_Offer_Iterator_Collection::max_left (CORBA::Environment &TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::UnknownMaxLeft)) -{ - TAO_THROW_RETURN (CosTrading::UnknownMaxLeft(), 0); -} - - // ************************************************************* - // TAO_Offer_Id_Iterator - // ************************************************************* - - -TAO_Offer_Id_Iterator::TAO_Offer_Id_Iterator (void) -{ -} - -TAO_Offer_Id_Iterator::~TAO_Offer_Id_Iterator (void) -{ - int return_value = 0; - - do - { - CosTrading::OfferId offer_id = 0; - - return_value = this->ids_.dequeue_head (offer_id); - if (return_value == 0) - CORBA::string_free (offer_id); - } - while (return_value == 0); -} - -CORBA::ULong -TAO_Offer_Id_Iterator::max_left (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::UnknownMaxLeft)) -{ - return this->ids_.size (); -} - -void -TAO_Offer_Id_Iterator::destroy (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - // Remove self from POA - // - // Note that there is no real error checking here as we can't do - // much about errors here anyway - // - - TAO_TRY - { - PortableServer::POA_var poa = this->_default_POA (TAO_TRY_ENV); - TAO_CHECK_ENV; - - PortableServer::ObjectId_var id = poa->servant_to_id (this, TAO_TRY_ENV); - TAO_CHECK_ENV; - - poa->deactivate_object (id.in (), TAO_TRY_ENV); - } - TAO_CATCHANY - { - } - TAO_ENDTRY; - - delete this; -} - -CORBA::Boolean -TAO_Offer_Id_Iterator::next_n (CORBA::ULong n, - CosTrading::OfferIdSeq_out _ids, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - // Calculate the number of Ids to be returned in this. - int items_left = this->ids_.size(), - difference = items_left - n, - returnable_items = (difference >= 0) ? n : items_left; - CORBA::Boolean return_value = (CORBA::Boolean) (difference > 0); - - if (returnable_items == 0) - { - ACE_NEW_RETURN (_ids, CosTrading::OfferIdSeq, return_value); - } - else - { - // Allocate space for the returned OfferIds. - CosTrading::OfferId* id_buf = - CosTrading::OfferIdSeq::allocbuf (returnable_items); - - if (id_buf != 0) - { - // Copy in those ids! - for (int i = 0; i < returnable_items; i++) - { - CosTrading::OfferId offer_id = 0; - - this->ids_.dequeue_head (offer_id); - id_buf[i] = offer_id; - } - - // Place them into an OfferIdSeq. - ACE_NEW_RETURN (_ids, - CosTrading::OfferIdSeq (returnable_items, - returnable_items, - id_buf, - 1), - return_value); - } - else - ACE_NEW_RETURN (_ids, CosTrading::OfferIdSeq, return_value); - } - - // Return true only if there are items left to be returned in - // subsequent calls. - return return_value; -} - -void -TAO_Offer_Id_Iterator::insert_id (CosTrading::OfferId new_id) -{ - this->ids_.enqueue_tail (new_id); -} - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Node ; -template class ACE_Unbounded_Queue ; -template class ACE_Unbounded_Queue_Iterator ; -template class ACE_Node ; -template class ACE_Unbounded_Queue ; -template class ACE_Unbounded_Queue_Iterator ; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Node -#pragma instantiate ACE_Unbounded_Queue -#pragma instantiate ACE_Unbounded_Queue_Iterator -#pragma instantiate ACE_Node -#pragma instantiate ACE_Unbounded_Queue -#pragma instantiate ACE_Unbounded_Queue_Iterator -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators.h b/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators.h deleted file mode 100644 index 64a080a00e7..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators.h +++ /dev/null @@ -1,276 +0,0 @@ -/* -*- C++ -*- */ - -// ============================================================================ -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Offer_Iterators.h -// -// = AUTHOR -// Marina Spivak -// Seth Widoff -// -// ============================================================================ - -#ifndef TAO_OFFER_ITERATORS_H -#define TAO_OFFER_ITERATORS_H - -#include "Trader_Utils.h" - - // ************************************************************* - // TAO_Offer_Iterator - // ************************************************************* - -class TAO_Offer_Iterator : public POA_CosTrading::OfferIterator -{ - // = TITLE - // This class implements CosTrading::OfferIterator IDL - // interface. - - // = DESCRIPTION - // This is an abstract base class to allow for different - // implementations of OfferIterator. - // BEGIN SPEC - // The OfferIterator interface is used to return a set of service - // offers from the query operation by enabling the service offers - // to be extracted by successive operations on the OfferIterator - // interface. - // END SPEC -public: - // = Initialization and termination methods. - - TAO_Offer_Iterator (const TAO_Property_Filter& property_filter); - - virtual ~TAO_Offer_Iterator (void); - - virtual void destroy (CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException)); - // BEGIN SPEC - // The destroy operation destroys the iterator. No further - // operations can be invoked on an iterator after it has been - // destroyed. - // END SPEC - - virtual void add_offer (CosTrading::OfferId offer_id, - const CosTrading::Offer* offer) = 0; - // Add an offer to the collection of offers the iterator will - // iterate over. - - virtual CORBA::ULong max_left (CORBA::Environment &env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::UnknownMaxLeft)) = 0; - - // BEGIN SPEC - // The max_left operation returns the number of service offers - // remaining in the iterator. The exception UnknownMaxLeft is raised - // if the iterator cannot determine the remaining number of service - // offers (e.g., if the iterator determines its set of service - // offers through lazy evaluation). - // END SPEC - - virtual CORBA::Boolean next_n (CORBA::ULong n, - CosTrading::OfferSeq_out offers, - CORBA::Environment &env) - TAO_THROW_SPEC ((CORBA::SystemException)) = 0; - // BEGIN SPEC - // The next_n operation returns a set of service offers in the - // output parameter "offers." The operation returns n service offers - // if there are at least n service offers remaining in the - // iterator. If there are fewer than n service offers in the - // iterator, then all remaining service offers are returned. The - // actual number of service offers returned can be determined from - // the length of the "offers" sequence. The next_n operation returns - // TRUE if there are further service offers to be extracted from the - // iterator. It returns FALSE if there are no further service offers - // to be extracted. - // END SPEC - protected: - - TAO_Offer_Iterator (TAO_Offer_Iterator &) {} - // To satisfy g++'s insane lust for copy constructors... - - TAO_Offer_Iterator& operator=(const TAO_Offer_Iterator&); - - TAO_Property_Filter pfilter_; - // The filter through which each returned offer must pass. Used to - // strip offers of undesirable properties. -}; - - // ************************************************************* - // TAO_Query_Only_Offer_Iterator - // ************************************************************* - -class TAO_Query_Only_Offer_Iterator - : public TAO_Offer_Iterator - // = TITLE - // An implementation of the CosTrading::OfferIterator IDL - // interface that takes advantage of the fact that the trader is - // Query Only, and therefore its service offers are not being - // changed or removed. - // - // = DESCRIPTION - // The iterator stores pointers to Offers to be iterated over, - // and later accesses the Offers directly through the pointers. - // -{ -public: - // = Initialization and termination methods. - - TAO_Query_Only_Offer_Iterator (const TAO_Property_Filter& pfilter); - - virtual ~TAO_Query_Only_Offer_Iterator (void); - - virtual CORBA::Boolean next_n (CORBA::ULong n, - CosTrading::OfferSeq_out offers, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException)); - // Deposit at maximum n offers into the return sequence and return 1, - // or return 0 if the iterator is done and no offers are returned. - - virtual CORBA::ULong max_left (CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::UnknownMaxLeft)); - // Return the number of items left in the iterator. - - void add_offer (CosTrading::OfferId offer_id, - const CosTrading::Offer* offer); - // Add an offer the iterator should iterate over. - -private: - - TAO_Query_Only_Offer_Iterator (const TAO_Query_Only_Offer_Iterator&); - TAO_Query_Only_Offer_Iterator& operator=(const TAO_Query_Only_Offer_Iterator&); - - ACE_Unbounded_Queue offers_; - // Structure that stores pointers to offers - // to iterate over. -}; - - // ************************************************************* - // TAO_Offer_Iterator_Collection - // ************************************************************* - -class TAO_Offer_Iterator_Collection : public POA_CosTrading::OfferIterator -// = TITLE -// A collection of offer iterator to query in turn. -// -// = DESCRIPTION -// Since a query could conceivable query several other traders, it -// needs a way to merge the results into a single set of results -// suitable for being returned to the user. And since all the query -// method can return to the user is a sequence and an iterator, and -// the size of the sequence is constrained, there needs to be some -// way to collect all the returned offer_iterators into a single -// offer_iterator. This is that collection. The results of -// collecting all the iterators in this way is a distributed tree of -// iterators, which could conceivably become hugely inefficient if -// the trader graph is deep enough. -{ -public: - - // = Constructors. - - TAO_Offer_Iterator_Collection (void); - - virtual ~TAO_Offer_Iterator_Collection (void); - - virtual CORBA::Boolean next_n (CORBA::ULong n, - CosTrading::OfferSeq_out offers, - CORBA::Environment &env) - TAO_THROW_SPEC ((CORBA::SystemException)); - // Retrieve n offers from the set of iterators. - - virtual void destroy (CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException)); - // Destroy the collection of iterators. - - virtual CORBA::ULong max_left (CORBA::Environment &env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::UnknownMaxLeft)); - // Determine how many offers are left in the collection. - - void add_offer_iterator (CosTrading::OfferIterator_ptr offer_iter); - // Add an iterator to the collection. - -private: - - TAO_Offer_Iterator_Collection (const TAO_Offer_Iterator_Collection&); - TAO_Offer_Iterator_Collection& operator= (const TAO_Offer_Iterator_Collection&); - - typedef ACE_Unbounded_Queue Offer_Iters; - - Offer_Iters iters_; - // The iterator collection. -}; - - // ************************************************************* - // TAO_Offer_Id_Iterator - // ************************************************************* - -class TAO_Offer_Id_Iterator : public POA_CosTrading::OfferIdIterator -// = TITLE -// Silly little iterator that contains the overflow of offer ids -// from the Admin list_offers method. -// -// = DESCRIPTION -// -// BEGIN SPEC -// The OfferIdIterator interface is used to return a set of offer -// identifiers from the list_offers operation and the list_proxies -// operation in the Admin interface by enabling the offer identifiers -// to be extracted by successive operations on the OfferIdIterator -// interface. -// END SPEC -{ - public: - - TAO_Offer_Id_Iterator(void); - // No op constructor - - ~TAO_Offer_Id_Iterator (void); - - virtual CORBA::ULong max_left(CORBA::Environment& env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::UnknownMaxLeft)); - // The max_left operation returns the number of offer identifiers - // remaining in the iterator. The exception UnknownMaxLeft is raised - // if the iterator cannot determine the remaining number of offer - // identifiers (e.g., if the iterator determines its set of offer - // identifiers through lazy evaluation). - - virtual void destroy(CORBA::Environment& env) - TAO_THROW_SPEC ((CORBA::SystemException)); - // The destroy operation destroys the iterator. No further - // operations can be invoked on an iterator after it has been - // destroyed. - - virtual CORBA::Boolean next_n(CORBA::ULong _n, - CosTrading::OfferIdSeq_out _ids, - CORBA::Environment& env) - TAO_THROW_SPEC ((CORBA::SystemException)); - // The next_n operation returns a set of offer identifiers in the - // output parameter "ids." The operation returns n offer identifiers - // if there are at least n offer identifiers remaining in the - // iterator. If there are fewer than n offer identifiers in the - // iterator, then all remaining offer identifiers are returned. The - // actual number of offer identifiers returned can be determined - // from the length of the "ids" sequence. The next_n operation - // returns TRUE if there are further offer identifiers to be - // extracted from the iterator. It returns FALSE if there are no - // further offer identifiers to be extracted. - - void insert_id(CosTrading::OfferId new_id); - // Insert a into the contents of the iterator. - - private: - - TAO_Offer_Id_Iterator (const TAO_Offer_Id_Iterator&); - TAO_Offer_Id_Iterator& operator= (TAO_Offer_Id_Iterator&); - - TAO_String_Queue ids_; -}; - -#endif /* TAO_OFFER_ITERATOR */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators_T.cpp b/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators_T.cpp deleted file mode 100644 index 7c6a5cd6daa..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators_T.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// ============================================================================ -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Offer_Iterators_T.cpp -// -// = AUTHOR -// Marina Spivak -// Seth Widoff -// Irfan Pyarali -// ============================================================================ - -#ifndef TAO_OFFER_ITERATORS_T_C -#define TAO_OFFER_ITERATORS_T_C - -#include "Offer_Iterators_T.h" - -ACE_RCSID(Trader, Offer_Iterators_T, "$Id$") - -template -TAO_Register_Offer_Iterator:: -TAO_Register_Offer_Iterator (TAO_Offer_Database &db, - const TAO_Property_Filter& pfilter) - : TAO_Offer_Iterator (pfilter), - db_ (db) -{ -} - -template -TAO_Register_Offer_Iterator:: -~TAO_Register_Offer_Iterator (void) -{ - while (! this->offer_ids_.is_empty ()) - { - CosTrading::OfferId offer_id = 0; - this->offer_ids_.dequeue_head (offer_id); - - CORBA::string_free (offer_id); - } -} - -template void -TAO_Register_Offer_Iterator:: -add_offer (CosTrading::OfferId id, - const CosTrading::Offer* offer) -{ - this->offer_ids_.enqueue_tail (id); -} - -template CORBA::ULong -TAO_Register_Offer_Iterator:: -max_left (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::UnknownMaxLeft)) -{ - return this->offer_ids_.size (); -} - -template CORBA::Boolean -TAO_Register_Offer_Iterator:: -next_n (CORBA::ULong n, - CosTrading::OfferSeq_out offers, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::ULong ret_offers = 0; - - CORBA::ULong max_possible_offers_in_sequence = - (n < this->offer_ids_.size ()) ? n : this->offer_ids_.size (); - - ACE_NEW_RETURN (offers, CosTrading::OfferSeq, 0); - offers->length (max_possible_offers_in_sequence); - - // While there are entries left and we haven't filled - // with requested number. - while (! this->offer_ids_.is_empty () - && n > ret_offers) - { - // If offer is found, put it into the sequence. - // remove this id irrespective of whether the offer is found - // or not. - CosTrading::OfferId id; - this->offer_ids_.dequeue_head (id); - - TAO_TRY - { - CosTrading::OfferId_var offerid_var (id); - CosTrading::Offer* offer = this->db_.lookup_offer (id, TAO_TRY_ENV); - TAO_CHECK_ENV; - - if (offer != 0) - this->pfilter_.filter_offer (offer, offers[ret_offers++]); - } - TAO_CATCHANY {} - TAO_ENDTRY; - } - - // Reset the length to the correct value - offers->length (ret_offers); - - return ACE_static_cast (CORBA::Boolean, ret_offers != 0); -} - -#endif /* TAO_REGISTER_OFFER_ITERATOR_C */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators_T.h b/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators_T.h deleted file mode 100644 index beae59855fd..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterators_T.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- C++ -*- */ - -// ======================================================================== -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Offer_Iterators_T.h -// -// = AUTHOR -// Marina Spivak -// Seth Widoff -// -// ======================================================================== - -#ifndef TAO_REGISTER_OFFER_ITERATOR_H -#define TAO_REGISTER_OFFER_ITERATOR_H - -#include "Offer_Iterators.h" -#include "Offer_Database.h" - -template -class TAO_Register_Offer_Iterator : public TAO_Offer_Iterator -{ - // = TITLE - // An implementation of CosTrading::OfferIterator IDL interface - // appropriate when trader has Register functionality. - // - // = DESCRIPTION - // Stores ids of offers to be iterated over. Before returning - // an offer, checks if the offer is still there (since it may - // have been removed by the Register). -public: - - // = Initialization and termination methods. - - TAO_Register_Offer_Iterator (TAO_Offer_Database &db, - const TAO_Property_Filter& pfilter); - // Takes service type and trader reference in order to - // later locate offers using their ids. - - virtual ~TAO_Register_Offer_Iterator (void); - // destructor. - - virtual CORBA::Boolean next_n (CORBA::ULong n, - CosTrading::OfferSeq_out offers, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - // Deposit at maximum n offers into the return sequence and return 1, - // or return 0 if the iterator is done and no offers are returned. - - virtual CORBA::ULong max_left (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::UnknownMaxLeft)); - // Throws CosTrading::UnknownMaxLeft since with the presence of - // "Register" functionality, the iterator cannot guarantee that - // the trader will have all the offers it has now when the time - // to return them comes. - - void add_offer (CosTrading::OfferId id, - const CosTrading::Offer *); - // Add an offer the iterator should iterate over. - -private: - - TAO_Offer_Database &db_; - // A reference to the trader is needed for access to the map of offers. - - TAO_String_Queue offer_ids_; - // Offer ids of offers to iterate over. -}; - - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "Offer_Iterators_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#endif /* TAO_REGISTER_OFFER_ITERATOR_H */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.cpp b/TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.cpp deleted file mode 100644 index 6ef9a11c184..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.cpp +++ /dev/null @@ -1,650 +0,0 @@ -// ======================================================================== -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Service_Type_Repository.cpp -// -// = AUTHOR -// Marina Spivak -// Seth Widoff -// -// ======================================================================== - -#include "Locking.h" -#include "Service_Type_Repository.h" - -ACE_RCSID(Trader, Service_Type_Repository, "$Id$") - -TAO_Service_Type_Repository:: -TAO_Service_Type_Repository (ACE_Lock* lock) - : lock_ (lock) -{ - this->incarnation_.low = 0; - this->incarnation_.high = 0; - - // If a lock wasn't provided, let's assume the user doesn't want any - // kind of lock at all. - if (this->lock_ == 0) - ACE_NEW (this->lock_, ACE_Lock_Adapter ()); -} - - -TAO_Service_Type_Repository::~TAO_Service_Type_Repository (void) -{ - { - ACE_WRITE_GUARD (ACE_Lock, ace_mon, *this->lock_); - - for (Service_Type_Map::iterator service_map_iterator (this->type_map_); - ! service_map_iterator.done (); - service_map_iterator++) - { - Type_Info* type_info = (*service_map_iterator).int_id_; - delete type_info; - } - } - - delete this->lock_; -} - - -CosTradingRepos::ServiceTypeRepository::IncarnationNumber -TAO_Service_Type_Repository::incarnation (CORBA::Environment &) -{ - CosTradingRepos::ServiceTypeRepository::IncarnationNumber inc_num; - if (this->lock_->acquire_read () == -1) - { - inc_num = this->incarnation_; - this->lock_->release (); - } - else - { - inc_num.high = 0; - inc_num.low = 0; - } - - return inc_num; -} - - -CosTradingRepos::ServiceTypeRepository::IncarnationNumber -TAO_Service_Type_Repository:: -add_type (const char * name, - const char * if_name, - const CosTradingRepos::ServiceTypeRepository::PropStructSeq& props, - const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq& super_types, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTradingRepos::ServiceTypeRepository::ServiceTypeExists, - CosTradingRepos::ServiceTypeRepository::InterfaceTypeMismatch, - CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName, - CosTradingRepos::ServiceTypeRepository::ValueTypeRedefinition, - CosTrading::UnknownServiceType, - CosTradingRepos::ServiceTypeRepository::DuplicateServiceTypeName)) -{ - Prop_Map prop_map; - Service_Type_Map super_map; - CosTradingRepos::ServiceTypeRepository::IncarnationNumber inc_num; - - inc_num.low = 0; - inc_num.high = 0; - ACE_UNUSED_ARG (inc_num); // With exceptions enabled, inc_num isn't used. - TAO_WRITE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, inc_num); - - // make sure Type name is valid - if (! TAO_Trader_Base::is_valid_identifier_name (name)) - TAO_THROW_RETURN (CosTrading::IllegalServiceType (name), - this->incarnation_); - - // check if the service type already exists. - TAO_String_Hash_Key type_name (name); - if (this->type_map_.find (type_name) == 0) - TAO_THROW_RETURN (CosTradingRepos::ServiceTypeRepository::ServiceTypeExists (), - this->incarnation_); - - // make sure all property names are valid and appear only once. - this->validate_properties (prop_map, props, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, this->incarnation_); - - // check that all super_types exist, and none are duplicated. - this->validate_supertypes (super_map, super_types, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, this->incarnation_); - - // NOTE: I don't really know a way to do this without an Interface - // Repository, since the Interface Repository IDs don't contain - // information about supertypes. - // - // make sure interface name is legal. - // this->validate_interface (if_name, super_types, TAO_IN_ENV); - // TAO_CHECK_ENV_RETURN(TAO_IN_ENV, this->incarnation); - // - // Instead, we do this: - // - if (if_name == 0) - TAO_THROW_RETURN (CosTradingRepos::ServiceTypeRepository::InterfaceTypeMismatch (), - this->incarnation_); - - // collect and make sure that properties of all supertypes and this type - // are compatible. We can use prop_map and super_types_map for the job. - this->validate_inheritance (prop_map, super_types, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, this->incarnation_); - - // we can now use prop_map to construct a sequence of all properties the - // this type. - this->update_type_map (name, - if_name, - props, - super_types, - prop_map, - super_map); - - CosTradingRepos::ServiceTypeRepository::IncarnationNumber return_value = - this->incarnation_; - - // increment incarnation number - this->incarnation_.low++; - // if we wrapped around in lows... - if (this->incarnation_.low == 0) - this->incarnation_.high++; - - return return_value; -} - - -void -TAO_Service_Type_Repository::remove_type (const char * name, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTradingRepos::ServiceTypeRepository::HasSubTypes)) -{ - if (! TAO_Trader_Base::is_valid_identifier_name (name)) - TAO_THROW (CosTrading::IllegalServiceType (name)); - - TAO_WRITE_GUARD (ACE_Lock, ace_mon, *this->lock_); - - // Check if the type exists. - Service_Type_Map::ENTRY* type_entry = 0; ; - if (this->type_map_.find (name, type_entry) == -1) - TAO_THROW (CosTrading::UnknownServiceType (name)); - - // Check if it has any subtypes. - Type_Info* type_info = type_entry->int_id_; - if (type_info->has_subtypes_) - TAO_THROW (CosTradingRepos::ServiceTypeRepository::HasSubTypes (name, "")); - - // remove the type from the map. - this->type_map_.unbind (type_entry); - delete type_info; -} - -CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq* -TAO_Service_Type_Repository:: -list_types (const CosTradingRepos::ServiceTypeRepository::SpecifiedServiceTypes& which_types, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - TAO_READ_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); - - CORBA::ULong i = 0, - length = this->type_map_.current_size (); - CosTrading::ServiceTypeName* types = - CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq::allocbuf (length); - - if (types == 0) - return 0; - - int all = (which_types._d () == CosTradingRepos::ServiceTypeRepository::all); - CosTradingRepos::ServiceTypeRepository::IncarnationNumber num = - which_types.incarnation (); - - for (Service_Type_Map::iterator itr (this->type_map_); - ! itr.done (); - itr++) - { - Type_Info* type_info = (*itr).int_id_; - const char* type_name = (const char*) (*itr).ext_id_; - - if (all || num < type_info->type_struct_.incarnation) - types[i++] = CORBA::string_dup (type_name); - } - - return new CosTradingRepos::ServiceTypeRepository:: - ServiceTypeNameSeq (length, i, types, 1); -} - - - -CosTradingRepos::ServiceTypeRepository::TypeStruct* -TAO_Service_Type_Repository:: -describe_type (const char * name, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType)) -{ - if (! TAO_Trader_Base::is_valid_identifier_name (name)) - TAO_THROW_RETURN - (CosTrading::IllegalServiceType (name), - (CosTradingRepos::ServiceTypeRepository::TypeStruct*) 0); - - TAO_READ_GUARD_RETURN - (ACE_Lock, - ace_mon, - *this->lock_, - (CosTradingRepos::ServiceTypeRepository::TypeStruct*) 0); - - // make sure the type exists. - TAO_String_Hash_Key type_name (name); - Service_Type_Map::ENTRY* type_entry = 0; - if (this->type_map_.find (type_name, type_entry) == -1) - TAO_THROW_RETURN (CosTrading::UnknownServiceType (name), - (CosTradingRepos::ServiceTypeRepository::TypeStruct*) 0); - - // return appropriate information about the type. - CosTradingRepos::ServiceTypeRepository::TypeStruct* descr = 0; - ACE_NEW_RETURN (descr, CosTradingRepos::ServiceTypeRepository::TypeStruct, 0); - CosTradingRepos::ServiceTypeRepository::TypeStruct & s = - type_entry->int_id_->type_struct_; - - descr->if_name = s.if_name; - descr->masked = s.masked; - descr->incarnation = s.incarnation; - descr->super_types = s.super_types; - descr->props = s.props; - /* - CORBA::ULong length = s.props.length (); - CosTradingRepos::ServiceTypeRepository::PropStruct* pstructs = - s.props.get_buffer (0); - descr->props.replace (length, length, pstructs, 0); - */ - return descr; -} - - -CosTradingRepos::ServiceTypeRepository::TypeStruct* -TAO_Service_Type_Repository:: -fully_describe_type (const char * name, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType)) -{ - if (! TAO_Trader_Base::is_valid_identifier_name (name)) - TAO_THROW_RETURN (CosTrading::IllegalServiceType (name), 0); - - TAO_READ_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); - - // make sure the type exists. - TAO_String_Hash_Key type_name (name); - Service_Type_Map::ENTRY* type_entry = 0; - if (this->type_map_.find (type_name, type_entry) == -1) - TAO_THROW_RETURN (CosTrading::UnknownServiceType (name), 0); - - // return appropriate information about the type. - CosTradingRepos::ServiceTypeRepository::TypeStruct* descr = 0; - ACE_NEW_RETURN (descr, CosTradingRepos::ServiceTypeRepository::TypeStruct, 0); - CosTradingRepos::ServiceTypeRepository::TypeStruct & s = - type_entry->int_id_->type_struct_; - - // Aggregate the Properties of this type and all its supertypes. - // Compute the transitive closure of all supertypes. - this->fully_describe_type_i (s, descr->props, descr->super_types); - - // We do the explicit copy, since otherwise we'd have excessive - // properties copying. - descr->if_name = s.if_name; - descr->masked = s.masked; - descr->incarnation = s.incarnation; - - return descr; -} - - -void -TAO_Service_Type_Repository:: -mask_type (const char * name, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTradingRepos::ServiceTypeRepository::AlreadyMasked)) -{ - if (! TAO_Trader_Base::is_valid_identifier_name (name)) - TAO_THROW (CosTrading::IllegalServiceType (name)); - - TAO_WRITE_GUARD (ACE_Lock, ace_mon, *this->lock_); - - // make sure the type exists. - TAO_String_Hash_Key type_name (name); - Service_Type_Map::ENTRY* type_entry = 0; - if (this->type_map_.find (type_name, type_entry) != -1) - TAO_THROW (CosTrading::UnknownServiceType (name)); - - // make sure the type is unmasked. - CORBA::Boolean& mask = type_entry->int_id_->type_struct_.masked; - - if (mask == 1) - TAO_THROW (CosTradingRepos::ServiceTypeRepository::AlreadyMasked (name)); - else - mask = 1; -} - - -void -TAO_Service_Type_Repository:: -unmask_type (const char * name, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTradingRepos::ServiceTypeRepository::NotMasked)) -{ - if (! TAO_Trader_Base::is_valid_identifier_name (name)) - TAO_THROW (CosTrading::IllegalServiceType (name)); - - TAO_WRITE_GUARD (ACE_Lock, ace_mon, *this->lock_); - - // make sure the type exists. - TAO_String_Hash_Key type_name (name); - Service_Type_Map::ENTRY* type_entry = 0; - if (this->type_map_.find (type_name, type_entry) != -1) - TAO_THROW (CosTrading::UnknownServiceType (name)); - - // make sure the type is masked. - CORBA::Boolean& mask = type_entry->int_id_->type_struct_.masked; - if (mask == 0) - TAO_THROW (CosTradingRepos::ServiceTypeRepository::AlreadyMasked (name)); - else - mask = 0; -} - -void -TAO_Service_Type_Repository:: -fully_describe_type_i (const CosTradingRepos::ServiceTypeRepository::TypeStruct& type_struct, - CosTradingRepos::ServiceTypeRepository::PropStructSeq& props, - CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq& super_types) -{ - TAO_String_Queue service_type_queue; - this->collect_inheritance_hierarchy (type_struct, service_type_queue); - - // Count the total number of properties. - CORBA::ULong num_props = 0, - num_types = service_type_queue.size (); - - TAO_String_Queue::ITERATOR iterator (service_type_queue); - for (; ! iterator.done (); iterator.advance ()) - { - char** next_type_name = 0; - Service_Type_Map::ENTRY* type_entry = 0; - - iterator.next (next_type_name); - TAO_String_Hash_Key hash_key (ACE_const_cast (const char*, *next_type_name)); - this->type_map_.find (hash_key, type_entry); - - CosTradingRepos::ServiceTypeRepository::TypeStruct& tstruct = - type_entry->int_id_->type_struct_; - num_props += tstruct.props.length (); - } - - num_props += type_struct.props.length (); - props.length (num_props); - super_types.length (num_types); - - // Copy in all properties. - int i = 0; - CORBA::ULong prop_index = 0, type_index = 0; - for (i = type_struct.props.length () - 1; i >= 0; i--) - props[prop_index++] = type_struct.props[i]; - - for (iterator.first (); ! iterator.done (); iterator.advance ()) - { - char** next_type_name = 0; - Service_Type_Map::ENTRY* type_entry = 0; - - iterator.next (next_type_name); - TAO_String_Hash_Key hash_key (ACE_const_cast (const char*, *next_type_name)); - this->type_map_.find (hash_key, type_entry); - - // Should never be zero. - if (type_entry != 0) - { - CosTradingRepos::ServiceTypeRepository::TypeStruct& tstruct = - type_entry->int_id_->type_struct_; - for (i = tstruct.props.length () - 1; i >= 0; i--) - props[prop_index++] = tstruct.props[i]; - - super_types[type_index++] = hash_key.in (); - } - } -} - -void -TAO_Service_Type_Repository:: -collect_inheritance_hierarchy (const CosTradingRepos::ServiceTypeRepository::TypeStruct& type_struct, - TAO_String_Queue& target) -{ - // Recurse for each super_type - for (int i = type_struct.super_types.length () - 1; i >= 0; i--) - { - Service_Type_Map::ENTRY* next_type_entry = 0; - TAO_String_Hash_Key next_type_name (type_struct.super_types[i]); - - //ACE_DEBUG ((LM_DEBUG, "%s\n", next_type_name.in ())); - if (this->type_map_.find (next_type_name, next_type_entry) != -1) - { - CosTradingRepos::ServiceTypeRepository::TypeStruct& - next_type_struct = next_type_entry->int_id_->type_struct_; - - const char* type_name = type_struct.super_types[i]; - target.enqueue_tail (ACE_const_cast (char*, type_name)); - - this->collect_inheritance_hierarchy (next_type_struct, target); - } - } -} - - -void -TAO_Service_Type_Repository:: -validate_properties (Prop_Map& prop_map, - const CosTradingRepos::ServiceTypeRepository::PropStructSeq& props, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName)) -{ - for (CORBA::ULong i = 0; i < props.length (); i++) - { - const char* n = props[i].name; - if (! TAO_Trader_Base::is_valid_identifier_name (n)) - TAO_THROW (CosTrading::IllegalPropertyName (n)); - else - { - TAO_String_Hash_Key prop_name (n); - CosTradingRepos::ServiceTypeRepository::PropStruct* prop_val = - (CosTradingRepos::ServiceTypeRepository::PropStruct*) &props[i]; - - if (prop_map.bind (prop_name, prop_val) == 1) - TAO_THROW (CosTrading::DuplicatePropertyName (n)); - } - } -} - -void -TAO_Service_Type_Repository:: -validate_supertypes (Service_Type_Map& super_map, - const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq& super_types, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTrading::DuplicatePropertyName)) -{ - for (CORBA::ULong i = 0; i < super_types.length (); i++) - { - const char* type = super_types[i]; - // ACE_DEBUG ((LM_DEBUG, "%s\n", type)); - - if (! TAO_Trader_Base::is_valid_identifier_name (type)) - TAO_THROW (CosTrading::IllegalServiceType (type)); - else - { - TAO_String_Hash_Key s_type (type); - Service_Type_Map::ENTRY* type_entry = 0; - if (this->type_map_.find (s_type, type_entry) == -1) - TAO_THROW (CosTrading::UnknownServiceType (type)); - else - { - if (super_map.bind (s_type, type_entry->int_id_) == 1) - TAO_THROW (CosTradingRepos::ServiceTypeRepository::DuplicateServiceTypeName (type)); - } - } - } -} - -void -TAO_Service_Type_Repository:: -validate_inheritance (Prop_Map& prop_map, - const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq& super_types, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTradingRepos::ServiceTypeRepository::ValueTypeRedefinition)) -{ - CORBA::ULong num_super_types = super_types.length (); - - for (CORBA::ULong i = 0; i < num_super_types; i++) - { - Service_Type_Map::ENTRY* super_type_entry = 0; - TAO_String_Hash_Key super_type (super_types[i]); - CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq place_holder; - CosTradingRepos::ServiceTypeRepository::PropStructSeq super_props; - - this->type_map_.find (super_type, super_type_entry); - - // super_type_entry should never be zero. - if (super_type_entry != 0) - { - this->fully_describe_type_i (super_type_entry->int_id_->type_struct_, - super_props, - place_holder); - } - else - continue; - - CORBA::ULong num_props = super_props.length (); - for (CORBA::ULong j = 0; j < num_props; j++) - { - Prop_Map::ENTRY* existing_prop = 0; - TAO_String_Hash_Key prop_name (super_props[j].name); - - if (prop_map.bind (prop_name, &super_props[j], existing_prop) == 1) - { - // if already there, check that it is compatible with - // properties of other types. Value Types have to be the - // same. - const CosTradingRepos::ServiceTypeRepository::PropStruct& - property_in_map = *existing_prop->int_id_; - - CORBA::TypeCode_ptr prop_type = property_in_map.value_type.in (); - if (! super_props[j].value_type->equal (prop_type, TAO_IN_ENV) || - super_props[j].mode > property_in_map.mode) - { - TAO_THROW (CosTradingRepos::ServiceTypeRepository::ValueTypeRedefinition - (super_props[j].name, - super_props[j], - property_in_map.name, - property_in_map)); - } - } - } - } -} - -void -TAO_Service_Type_Repository:: -update_type_map (const char* name, - const char * if_name, - const CosTradingRepos::ServiceTypeRepository::PropStructSeq& props, - const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq& super_types, - Prop_Map &, - Service_Type_Map& super_map) -{ - // update entries for all supertypes to include this type as a subtype. - // we can use the super_types_map we have constructed. - - for (Service_Type_Map::iterator super_map_iterator (super_map); - ! super_map_iterator.done (); - super_map_iterator++) - { - Type_Info* super_type_info = (*super_map_iterator).int_id_; - super_type_info->has_subtypes_ = 0; - } - - // all parameters are valid, create an entry for this service type - // in the this->type_map_. - Type_Info* type = 0; - ACE_NEW (type, Type_Info); - - type->type_struct_.props = props; - type->type_struct_.if_name = if_name; - type->type_struct_.super_types = super_types; - type->type_struct_.incarnation = this->incarnation_; - type->type_struct_.masked = 0; - type->has_subtypes_ = 0; - - // Move the prop struct sequences and super type names from the in - // params to the internal storage. - /* - CORBA::ULong pslength = props.length (); - CosTradingRepos::ServiceTypeRepository::PropStructSeq* pstructs = - ACE_const_cast (CosTradingRepos::ServiceTypeRepository::PropStructSeq*, - &props); - CosTradingRepos::ServiceTypeRepository::PropStruct* psbuf = - pstructs->get_buffer (1); - type->type_struct_.props.replace (pslength, - pslength, - psbuf, - 1); - */ - TAO_String_Hash_Key type_name (name); - this->type_map_.bind (type_name, type); -} - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Hash_Map_Entry; -template class ACE_Hash_Map_Manager; -template class ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator; -template class ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator; -template class ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Entry; -template class ACE_Hash_Map_Manager; -template class ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator; -template class ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator; -template class ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Hash_Map_Entry -#pragma instantiate ACE_Hash_Map_Manager -#pragma instantiate ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator -#pragma instantiate ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Entry -#pragma instantiate ACE_Hash_Map_Manager -#pragma instantiate ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator -#pragma instantiate ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.h b/TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.h deleted file mode 100644 index 62ab4388ae2..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.h +++ /dev/null @@ -1,298 +0,0 @@ -/* -*- C++ -*- */ - -// ======================================================================== -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Service_Type_Repository.h -// -// = AUTHOR -// Marina Spivak -// Seth Widoff -// -// ======================================================================== - -#ifndef TAO_SERVICE_TYPE_REPOSITORY_H -#define TAO_SERVICE_TYPE_REPOSITORY_H - -#include "Trader.h" - -class TAO_ORBSVCS_Export TAO_Service_Type_Repository : - public POA_CosTradingRepos::ServiceTypeRepository - // - // = TITLE - // This class implements CosTradingRepos::ServiceTypeRepository - // IDL interface. -{ -public: - - TAO_Service_Type_Repository (ACE_Lock* lock = 0); - // Parameterize the Service_Type_Repository with a lock to serialize - // access to the type repository map. A reader/writer lock is - // probably best. The Service_Type_Repository assumes control of the - // lock. - - ~TAO_Service_Type_Repository (void); - - virtual CosTradingRepos::ServiceTypeRepository::IncarnationNumber - incarnation (CORBA::Environment& _env); - - virtual CosTradingRepos::ServiceTypeRepository::IncarnationNumber - add_type (const char * name, - const char * if_name, - const CosTradingRepos::ServiceTypeRepository::PropStructSeq& props, - const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq& super_types, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTradingRepos::ServiceTypeRepository::ServiceTypeExists, - CosTradingRepos::ServiceTypeRepository::InterfaceTypeMismatch, - CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName, - CosTradingRepos::ServiceTypeRepository::ValueTypeRedefinition, - CosTrading::UnknownServiceType, - CosTradingRepos::ServiceTypeRepository::DuplicateServiceTypeName)); - - // BEGIN SPEC - // The add_type operation enables the creation of new service types - // in the service type repository. The caller supplies the "name" - // for the new type, the identifier for the interface associated - // with instances of this service type, the properties definitions - // for this service type, and the service type names of the - // immediate super-types to this service type. - - // If the type creation is successful, an incarnation number is - // returned as the value of the operation. Incarnation numbers are - // opaque values that are assigned to each modification to the - // repository's state. An incarnation number can be quoted when - // invoking the list_types operation to retrieve all changes to the - // service repository since a particular logical time. (Note: - // IncarnationNumber is currently declared as a struct consisting of - // two unsigned longs; what we really want here is an unsigned hyper - // [64-bit integer]. A future revision task force should modify this - // when CORBA systems support IDL 64-bit integers.) - - // If the "name" parameter is malformed, then the - // CosTrading::IllegalServiceType exception is raised. ° If the type - // already exists, then the ServiceTypeExists exception is raised. ° - // If the "if_name" parameter is not a sub-type of the interface - // associated with a service type from which this service type is - // derived, such that substitutability would be violated, then the - // InterfaceTypeMismatch exception is raised. ° If a property name - // supplied in the "props" parameter is malformed, the - // CosTrading::IllegalPropertyName exception is raised. ° If the - // same property name appears two or more times in the "props" - // parameter, the CosTrading::DuplicatePropertyName exception is - // raised. ° If a property value type associated with this service - // type illegally modifies the value type of a super-type's - // property, or if two super-types incompatibly declare value types - // for the same property name, then the ValueTypeRedefinition - // exception is raised. ° If one of the ServiceTypeNames in - // "super_types" is malformed, then the - // CosTrading::IllegalServiceType exception is raised. If one of the - // ServiceTypeNames in "super_types" does not exist, then the - // CosTrading::UnknownServiceType exception is raised. ° If the same - // service type name is included two or more times in this - // parameter, the DuplicateServiceTypeName exception is raised. - // END SPEC - - - virtual void remove_type (const char * name, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTradingRepos::ServiceTypeRepository::HasSubTypes)); - - // BEGIN SPEC - // The remove_type operation removes the named type from the service - // type repository. ° If "name" is malformed, then the - // CosTrading::IllegalServiceType exception is raised. ° If "name" - // does not exist within the repository, then the - // CosTrading::UnknownServiceType exception is raised. ° If "name" - // has a service type which has been derived from it, then the - // HasSubTypes exception is raised. - // END SPEC - - virtual CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq* - list_types (const CosTradingRepos::ServiceTypeRepository::SpecifiedServiceTypes& which_types, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException)); - - // BEGIN SPEC - // The list_types operation permits a client to obtain the names of - // service types which are in the repository. The "which_types" - // parameter permits the client to specify one of two possible - // values: ° all types known to the repository ° all types - // added/modified since a particular incarnation number The names of - // the requested types are returned by the operation for subsequent - // querying via the describe_type or the fully_describe_type - // operation. - // END SPEC - - virtual CosTradingRepos::ServiceTypeRepository::TypeStruct* - describe_type (const char * name, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType)); - // BEGIN SPEC - // The describe_type operation permits a client to obtain the - // details for a particular service type. ° If "name" is malformed, - // then the CosTrading::IllegalServiceType exception is raised. ° If - // "name" does not exist within the repository, then the - // CosTrading::UnknownServiceType exception is raised. - // END SPEC - - virtual CosTradingRepos::ServiceTypeRepository::TypeStruct* - fully_describe_type (const char * name, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType)); - // BEGIN SPEC - // The fully_describe_type operation permits a client to obtain the - // details for a particular service type. The property sequence - // returned in the TypeStruct includes all properties inherited from - // the transitive closure of its super types; the sequence of super - // types in the TypeStruct contains the names of the types in the - // transitive closure of the super type relation. ° If "name" is - // malformed, then the CosTrading::IllegalServiceType exception is - // raised. ° If "name" does not exist within the repository, then - // the CosTrading::UnknownServiceType exception is raised. - // END SPEC - - virtual void mask_type (const char * name, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTradingRepos::ServiceTypeRepository::AlreadyMasked)); - // BEGIN SPEC - // The mask_type operation permits the deprecation of a particular - // type (i.e., after being masked, exporters will no longer be able - // to advertise offers of that particular type). The type continues - // to exist in the service repository due to other service types - // being derived from it. ° If "name" is malformed, then the - // CosTrading::IllegalServiceType exception is raised. ° If "name" - // does not exist within the repository, then the - // CosTrading::UnknownServiceType exception is raised. ° If the type - // is currently in the masked state, then the AlreadyMasked - // exception is raised. - // END SPEC - - virtual void unmask_type (const char * name, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTradingRepos::ServiceTypeRepository::NotMasked)); - // BEGIN SPEC - // The unmask_type undeprecates a type (i.e., after being unmasked, - // exporters will be able to resume advertisement of offers of that - // particular type). ° If "name" is malformed, then the - // CosTrading::IllegalServiceType exception is raised. ° If "name" - // does not exist within the repository, then the - // CosTrading::UnknownServiceType exception is raised. ° If the type - // is not currently in the masked state, then the NotMasked - // exception is raised. - // END SPEC - -public: - - struct Type_Info - { - // storage structure for information pertinent to the type. - CosTradingRepos::ServiceTypeRepository::TypeStruct type_struct_; - // standard type info. - - CORBA::Boolean has_subtypes_; - // names of subtypes. - }; - - typedef ACE_Hash_Map_Manager - < - TAO_String_Hash_Key, - CosTradingRepos::ServiceTypeRepository::PropStruct*, - ACE_Null_Mutex - > - Prop_Map; - - typedef ACE_Hash_Map_Manager - < - TAO_String_Hash_Key, - Type_Info*, - ACE_Null_Mutex - > - Service_Type_Map; - - void fully_describe_type_i (const CosTradingRepos::ServiceTypeRepository::TypeStruct& type_struct, - CosTradingRepos::ServiceTypeRepository::PropStructSeq& props, - CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq& super_types); - // Build a sequence aggregating the property names from all - // supertypes of the type, and a sequence representing the - // transitive closure of the super type relation. - - void collect_inheritance_hierarchy (const CosTradingRepos::ServiceTypeRepository::TypeStruct& type_struct, - TAO_String_Queue& target); - - void validate_properties (Prop_Map& prop_map, - const CosTradingRepos::ServiceTypeRepository::PropStructSeq& props, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName)); - // Confirm that the properties in props have valid names, and aren't - // duplicated. Cram those properties into the prop_map. - - void validate_supertypes (Service_Type_Map& super_map, - const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq& super_types, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTrading::DuplicatePropertyName)); - // Confirm that the each super type exists, and cram them into super_map. - - void validate_inheritance (Prop_Map& prop_map, - const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq& super_types, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CosTradingRepos::ServiceTypeRepository::ValueTypeRedefinition)); - // Ensure that properties of a super_type aren't having their types - // or retstrictions redefined. - - // void validate_interface (const char* if_name, - // Service_Type_Map& super_map, - // CORBA::Environment& _env) - // TAO_THROW_SPEC ((CosTradingRepos::ServiceTypeRepository::InterfaceTypeMismatch)); - // Ensure that the interface type derives from its superclasses'. - - void update_type_map (const char* name, - const char * if_name, - const CosTradingRepos::ServiceTypeRepository::PropStructSeq& props, - const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq& super_types, - Prop_Map& prop_map, - Service_Type_Map& super_map); - // Update the type map with the information contained in the - // TypeStruct, prop_map, and super_map. - - TAO_Service_Type_Repository (const TAO_Service_Type_Repository&); - TAO_Service_Type_Repository& operator= (const TAO_Service_Type_Repository&); - - ACE_Lock* lock_; - // Lock with which to serialize access to the service type map. - - Service_Type_Map type_map_; - // Stores information for each service type in the repository. - // This is a mapping from service type name to a Type_Info struct - // which serves as a storage for various information for the given type. - - CosTradingRepos::ServiceTypeRepository::IncarnationNumber incarnation_; - // incarnation number to be used for the next modification to the repository. -}; - -// This are temporary functions, until the format of the incarnation number -// will be changed in the spec. - -#endif /* TAO_SERVICE_TYPE_REPOSITORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Trader.cpp b/TAO/orbsvcs/orbsvcs/Trader/Trader.cpp deleted file mode 100644 index 4c51b257702..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Trader.cpp +++ /dev/null @@ -1,1102 +0,0 @@ -// ============================================================================ -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Trader_Base.cpp -// -// = AUTHOR -// Irfan Pyarali -// Seth Widoff -// -// ============================================================================ - -#include "Trader.h" -#include "Offer_Iterators_T.h" - -// The following #include is needed only for the instantiation pragmas. -#include "Trader_Interfaces.h" - -ACE_RCSID(Trader, Trader, "$Id$") - - // ************************************************************* - // TAO_Trader_Base - // ************************************************************* - -TAO_Trader_Base::TAO_Trader_Base (void) - : trading_components_ (*this), - import_attributes_ (*this), - support_attributes_ (*this), - link_attributes_ (*this) -{ -} - -TAO_Trader_Base::~TAO_Trader_Base (void) -{ -} - -TAO_Import_Attributes_i & -TAO_Trader_Base::import_attributes (void) -{ - return this->import_attributes_; -} - -const TAO_Import_Attributes_i & -TAO_Trader_Base::import_attributes (void) const -{ - return this->import_attributes_; -} - -TAO_Support_Attributes_i & -TAO_Trader_Base::support_attributes (void) -{ - return this->support_attributes_; -} - -const TAO_Support_Attributes_i & -TAO_Trader_Base::support_attributes (void) const -{ - return this->support_attributes_; -} - -TAO_Link_Attributes_i & -TAO_Trader_Base::link_attributes (void) -{ - return this->link_attributes_; -} - -const TAO_Link_Attributes_i & -TAO_Trader_Base::link_attributes (void) const -{ - return this->link_attributes_; -} - -TAO_Trading_Components_i & -TAO_Trader_Base::trading_components (void) -{ - return this->trading_components_; -} - -const TAO_Trading_Components_i & -TAO_Trader_Base::trading_components (void) const -{ - return this->trading_components_; -} - -CORBA::Boolean -TAO_Trader_Base::is_valid_identifier_name (const char* ident) -{ - int return_value = 0; - - if (ident == 0) - return return_value; - - int length = ACE_OS::strlen (ident); - if (length >= 1 && isalpha (ident[0])) - { - return_value = 1; - for (int i = 0; i < length; i++) - { - if (! (isalnum (ident[i]) || ident[i] == '_')) - { - return_value = 0; - break; - } - } - } - - return return_value; -} - - // ************************************************************* - // Attribute Classes - // ************************************************************* - -TAO_Support_Attributes_i:: -TAO_Support_Attributes_i (TAO_Lockable &locker) - : locker_ (locker), - supports_modifiable_properties_ (1), - supports_dynamic_properties_ (1), - supports_proxy_offers_ (0), - type_repos_ (CosTrading::TypeRepository::_nil ()), - service_type_repos_ (CosTradingRepos::ServiceTypeRepository::_nil ()) -{ -} - -TAO_Support_Attributes_i::~TAO_Support_Attributes_i (void) -{ -} - -CORBA::Boolean -TAO_Support_Attributes_i::supports_modifiable_properties (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), - 0); - return this->supports_modifiable_properties_; -} - -void -TAO_Support_Attributes_i:: -supports_modifiable_properties (CORBA::Boolean new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - this->supports_modifiable_properties_ = new_value; -} - -CORBA::Boolean -TAO_Support_Attributes_i::supports_dynamic_properties (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), - 0); - - return this->supports_dynamic_properties_; -} - -void -TAO_Support_Attributes_i:: -supports_dynamic_properties (CORBA::Boolean new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - this->supports_dynamic_properties_ = new_value; -} - -CORBA::Boolean -TAO_Support_Attributes_i::supports_proxy_offers (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), - 0); - - return this->supports_proxy_offers_; -} - -void -TAO_Support_Attributes_i:: -supports_proxy_offers (CORBA::Boolean new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - this->supports_proxy_offers_ = new_value; -} - -CosTrading::TypeRepository_ptr -TAO_Support_Attributes_i::type_repos (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), - CosTrading::TypeRepository::_nil ()); - return this->type_repos_.ptr (); -} - -void -TAO_Support_Attributes_i:: -type_repos (CosTrading::TypeRepository_ptr new_value) -{ - CORBA::Environment TAO_IN_ENV; - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - - this->type_repos_ = new_value; - this->service_type_repos_ = - CosTradingRepos::ServiceTypeRepository::_narrow (new_value, TAO_IN_ENV); -} - -CosTradingRepos::ServiceTypeRepository_ptr -TAO_Support_Attributes_i::service_type_repos (void) const -{ - return this->service_type_repos_.ptr (); -} - - -TAO_Import_Attributes_i:: -TAO_Import_Attributes_i (TAO_Lockable &locker) - : locker_ (locker), - def_search_card_ (10), - max_search_card_ (100), - def_match_card_ (10), - max_match_card_ (100), - def_return_card_ (10), - max_return_card_ (100), - max_list_ (0), - def_hop_count_ (5), - max_hop_count_ (5), - def_follow_policy_ (CosTrading::if_no_local), - max_follow_policy_ (CosTrading::always) -{ -} - - -TAO_Import_Attributes_i::~TAO_Import_Attributes_i (void) -{ -} - -CORBA::ULong -TAO_Import_Attributes_i::def_search_card (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10); - return this->def_search_card_; -} - -void -TAO_Import_Attributes_i::def_search_card (CORBA::ULong new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - - if (new_value > this->max_search_card_) - this->def_search_card_ = this->max_search_card_; - else - this->def_search_card_ = new_value; -} - -CORBA::ULong -TAO_Import_Attributes_i::max_search_card (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10); - return this->max_search_card_; -} - -void -TAO_Import_Attributes_i::max_search_card (CORBA::ULong new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - - this->max_search_card_ = new_value; - - if (this->def_search_card_ > this->max_search_card_) - this->def_search_card_ = this->max_search_card_; -} - -CORBA::ULong -TAO_Import_Attributes_i::def_match_card (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10); - return this->def_match_card_; -} - -void -TAO_Import_Attributes_i::def_match_card (CORBA::ULong new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - - if (new_value > this->max_match_card_) - this->def_match_card_ = this->max_match_card_; - else - this->def_match_card_ = new_value; -} - -CORBA::ULong -TAO_Import_Attributes_i::max_match_card (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10); - return this->max_match_card_; -} - -void -TAO_Import_Attributes_i::max_match_card (CORBA::ULong new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - this->max_match_card_ = new_value; - - if (this->def_match_card_ > this->max_match_card_) - this->def_match_card_ = this->max_match_card_; -} - -CORBA::ULong -TAO_Import_Attributes_i::def_return_card (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10); - return this->def_return_card_; -} - -void -TAO_Import_Attributes_i::def_return_card (CORBA::ULong new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - - if (new_value > this->max_return_card_) - this->def_return_card_ = this->max_return_card_; - else - this->def_return_card_ = new_value; -} - -CORBA::ULong -TAO_Import_Attributes_i::max_return_card (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10); - return this->max_return_card_; -} - -void -TAO_Import_Attributes_i::max_return_card (CORBA::ULong new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - this->max_return_card_ = new_value; - - if (this->def_return_card_ > this->max_return_card_) - this->def_return_card_ = this->max_return_card_; -} - -CORBA::ULong -TAO_Import_Attributes_i::max_list (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 0); - return this->max_list_; -} - -void -TAO_Import_Attributes_i::max_list (CORBA::ULong new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - this->max_list_ = new_value; -} - -CORBA::ULong -TAO_Import_Attributes_i::def_hop_count (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 0); - return this->def_hop_count_; -} - -void -TAO_Import_Attributes_i::def_hop_count (CORBA::ULong new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - - if (new_value > this->max_hop_count_) - this->def_hop_count_ = this->max_hop_count_; - else - this->def_hop_count_ = new_value; -} - -CORBA::ULong -TAO_Import_Attributes_i::max_hop_count (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 0); - return this->max_hop_count_; -} - -void -TAO_Import_Attributes_i::max_hop_count (CORBA::ULong new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - this->max_hop_count_ = new_value; - - if (this->def_hop_count_ > this->max_hop_count_) - this->def_hop_count_ = this->max_hop_count_; -} - -CosTrading::FollowOption -TAO_Import_Attributes_i::def_follow_policy (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), CosTrading::local_only); - return this->def_follow_policy_; -} - -void -TAO_Import_Attributes_i::def_follow_policy (CosTrading::FollowOption new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - - if (new_value > this->max_follow_policy_) - this->def_follow_policy_ = this->max_follow_policy_; - else - this->def_follow_policy_ = new_value; -} - -CosTrading::FollowOption -TAO_Import_Attributes_i::max_follow_policy (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), CosTrading::local_only); - return this->max_follow_policy_; -} - -void -TAO_Import_Attributes_i::max_follow_policy (CosTrading::FollowOption new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - this->max_follow_policy_ = new_value; - - if (this->def_follow_policy_ > this->max_follow_policy_) - this->def_follow_policy_ = this->max_follow_policy_; -} - - -TAO_Trading_Components_i::TAO_Trading_Components_i (TAO_Lockable &locker) - : locker_ (locker), - lookup_ (CosTrading::Lookup::_nil ()), - register_ (CosTrading::Register::_nil ()), - link_ (CosTrading::Link::_nil ()), - proxy_ (CosTrading::Proxy::_nil ()), - admin_ (CosTrading::Admin::_nil ()) -{ -} - -TAO_Trading_Components_i::~TAO_Trading_Components_i (void) -{ -} - -CosTrading::Lookup_ptr -TAO_Trading_Components_i::lookup_if (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), - CosTrading::Lookup::_nil ()); - return this->lookup_.ptr (); -} - -void -TAO_Trading_Components_i::lookup_if (CosTrading::Lookup_ptr new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - this->lookup_ = new_value; -} - -CosTrading::Register_ptr -TAO_Trading_Components_i::register_if (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), - CosTrading::Register::_nil ()); - return this->register_.ptr (); -} - -void -TAO_Trading_Components_i::register_if (CosTrading::Register_ptr new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - this->register_ = new_value; -} - -CosTrading::Link_ptr -TAO_Trading_Components_i::link_if (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), - CosTrading::Link::_nil ()); - return this->link_.ptr (); -} - -void -TAO_Trading_Components_i::link_if (CosTrading::Link_ptr new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - this->link_ = new_value; -} - -CosTrading::Proxy_ptr -TAO_Trading_Components_i::proxy_if (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), - CosTrading::Proxy::_nil ()); - return this->proxy_.ptr (); -} - -void -TAO_Trading_Components_i::proxy_if (CosTrading::Proxy_ptr new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - this->proxy_ = new_value; -} - -CosTrading::Admin_ptr -TAO_Trading_Components_i::admin_if (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), - CosTrading::Admin::_nil ()); - return this->admin_.ptr (); -} - -void -TAO_Trading_Components_i::admin_if (CosTrading::Admin_ptr new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - this->admin_ = new_value; -} - - -TAO_Link_Attributes_i::TAO_Link_Attributes_i (TAO_Lockable &locker) - :locker_ (locker), - max_link_follow_policy_ (CosTrading::local_only) -{ -} - -TAO_Link_Attributes_i::~TAO_Link_Attributes_i (void) -{ -} - -CosTrading::FollowOption -TAO_Link_Attributes_i::max_link_follow_policy (void) const -{ - ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), - CosTrading::local_only); - return this->max_link_follow_policy_; -} - -void -TAO_Link_Attributes_i::max_link_follow_policy (CosTrading::FollowOption new_value) -{ - ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ()); - this->max_link_follow_policy_ = new_value; -} - - -// = Methods to deal with ACE_Hash_Map_Manager. - -TAO_String_Hash_Key::TAO_String_Hash_Key (void) -{ -} - -TAO_String_Hash_Key::TAO_String_Hash_Key (char * name) - : CORBA_String_var (name) -{ -} - -TAO_String_Hash_Key::TAO_String_Hash_Key (const char * name) - : CORBA_String_var (name) -{ -} - -TAO_String_Hash_Key::TAO_String_Hash_Key (const CORBA::String_var &src) - : CORBA_String_var (src) -{ -} - -int -TAO_String_Hash_Key::operator == (const TAO_String_Hash_Key &hash_key) const -{ - return ACE_OS::strcmp (this->in (), hash_key.in ()) == 0; -} - -int -operator < (const TAO_String_Hash_Key &left, - const TAO_String_Hash_Key &right) -{ - return ACE_OS::strcmp (left.in (), right.in ()) < 0; -} - - -u_long -TAO_String_Hash_Key::hash (void) const -{ - u_long ret = ACE::hash_pjw (this->in ()); - return ret; -} - -TAO_String_Hash_Key::~TAO_String_Hash_Key (void) -{ -} - -int -operator< (const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &l, - const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &r) -{ - if (l.high < r.high) - return 1; - else if (l.high == r.high) - return (l.low < r.low); - else - return 0; -} - -int -operator> (const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &l, - const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &r) -{ - return (r < l); -} - -int -operator== (const CosTrading::Admin::OctetSeq& left, - const CosTrading::Admin::OctetSeq& right) -{ - int return_value = 0; - CORBA::ULong left_length = left.length (), - right_length = right.length (); - - if (left_length == right_length) - { - return_value = 1; - for (CORBA::ULong i = 0; i < left_length; i++) - { - if (left[i] != right[i]) - { - return_value = 0; - break; - } - } - } - - return return_value; -} - - // ************************************************************* - // TAO_Trader_Factory - // ************************************************************* - -#include "ace/Arg_Shifter.h" -#include "Trader_T.h" - -TAO_Trader_Factory::TAO_TRADER* -TAO_Trader_Factory::create_trader (int& argc, char** argv) -{ - TAO_Trader_Factory trader_factory (argc, argv); - return trader_factory.manufacture_trader (); -} - -TAO_Trader_Factory::TAO_Trader_Factory (int& argc, char** argv) - : conformance_ (TAO_TRADER_LINKED), - threadsafe_ (0), - supports_dynamic_properties_ (1), - supports_modifiable_properties_ (1), - def_search_card_ (20), - max_search_card_ (50), - def_match_card_ (20), - max_match_card_ (50), - def_return_card_ (20), - max_return_card_ (50), - def_hop_count_ (5), - max_hop_count_ (10), - def_follow_policy_ (CosTrading::if_no_local), - max_follow_policy_ (CosTrading::always) -{ - this->parse_args (argc, argv); -} - -TAO_Trader_Factory::TAO_TRADER* -TAO_Trader_Factory::manufacture_trader (void) -{ - typedef TAO_Trader TRADER; - -#if defined ACE_HAS_THREADS - typedef TAO_Trader MT_TRADER; -#else - typedef TAO_Trader MT_TRADER; -#endif /* ACE_HAS_THREADS */ - - TAO_TRADER* return_value = 0; - int components = ACE_static_cast (int, TAO_Trader_Base::LOOKUP); - - if (this->conformance_ >= TAO_TRADER_SIMPLE) - components |= ACE_static_cast (int, TAO_Trader_Base::REGISTER); - - if (this->conformance_ >= TAO_TRADER_STANDALONE) - components |= ACE_static_cast (int, TAO_Trader_Base::ADMIN); - - if (this->conformance_ >= TAO_TRADER_LINKED) - components |= ACE_static_cast (int, TAO_Trader_Base::LINK); - - if (this->threadsafe_) - { - ACE_NEW_RETURN (return_value, - MT_TRADER (ACE_static_cast (TAO_Trader_Base::Trader_Components, - components)), - 0); - } - else - { - ACE_NEW_RETURN (return_value, - TRADER (ACE_static_cast (TAO_Trader_Base::Trader_Components, - components)), - 0); - } - - TAO_Import_Attributes_i import_attributes = - return_value->import_attributes (); - TAO_Support_Attributes_i support_attributes = - return_value->support_attributes (); - - import_attributes.def_search_card (this->def_search_card_); - import_attributes.max_search_card (this->max_search_card_); - import_attributes.def_match_card (this->def_match_card_); - import_attributes.max_match_card (this->max_match_card_); - import_attributes.def_return_card (this->def_return_card_); - import_attributes.max_return_card (this->max_return_card_); - import_attributes.def_hop_count (this->def_hop_count_); - import_attributes.max_hop_count (this->max_hop_count_); - import_attributes.def_follow_policy (this->def_follow_policy_); - import_attributes.max_follow_policy (this->max_follow_policy_); - support_attributes.supports_modifiable_properties (this->supports_modifiable_properties_); - support_attributes.supports_dynamic_properties (this->supports_dynamic_properties_); - - return return_value; -} - -void -TAO_Trader_Factory::parse_args (int& argc, char** argv) -{ - ACE_Arg_Shifter arg_shifter (argc, argv); - - while (arg_shifter.is_anything_left ()) - { - char *current_arg = arg_shifter.get_current (); - - if (ACE_OS::strcmp (current_arg, "-TSthreadsafe") == 0) - { - arg_shifter.consume_arg (); - this->threadsafe_ = 1; - } - else if (ACE_OS::strcmp (current_arg, "-TSconformance") == 0) - { - arg_shifter.consume_arg (); - if (arg_shifter.is_parameter_next ()) - { - char* conformance_str = arg_shifter.get_current (); - - if (ACE_OS::strcasecmp (conformance_str, "Linked") == 0) - this->conformance_ = TAO_TRADER_LINKED; - else if (ACE_OS::strcasecmp (conformance_str, "Query") == 0) - this->conformance_ = TAO_TRADER_QUERY; - else if (ACE_OS::strcasecmp (conformance_str, "Simple") == 0) - this->conformance_ = TAO_TRADER_SIMPLE; - else if (ACE_OS::strcasecmp (conformance_str, "Standalone") == 0) - this->conformance_ = TAO_TRADER_STANDALONE; - - arg_shifter.consume_arg (); - } - } - else if (ACE_OS::strcmp (current_arg, "-TSsupports_dynamic_properties") == 0) - { - arg_shifter.consume_arg (); - if (arg_shifter.is_parameter_next ()) - { - char* arg_str = arg_shifter.get_current (); - - if (ACE_OS::strcasecmp (arg_str, "true") == 0) - this->supports_dynamic_properties_ = 1; - else if (ACE_OS::strcasecmp (arg_str, "false") == 0) - this->supports_dynamic_properties_ = 0; - - arg_shifter.consume_arg (); - } - - } - else if (ACE_OS::strcmp (current_arg, "-TSsupports_modifiable_properties") == 0) - { - arg_shifter.consume_arg (); - if (arg_shifter.is_parameter_next ()) - { - char* arg_str = arg_shifter.get_current (); - - if (ACE_OS::strcasecmp (arg_str, "true") == 0) - this->supports_modifiable_properties_ = 1; - else if (ACE_OS::strcasecmp (arg_str, "false") == 0) - this->supports_modifiable_properties_ = 0; - - arg_shifter.consume_arg (); - } - } - else if (ACE_OS::strcmp (current_arg, "-TSdef_search_card") == 0 || - ACE_OS::strcmp (current_arg, "-TSmax_search_card") == 0 || - ACE_OS::strcmp (current_arg, "-TSdef_match_card") == 0 || - ACE_OS::strcmp (current_arg, "-TSmax_match_card") == 0 || - ACE_OS::strcmp (current_arg, "-TSdef_return_card") == 0 || - ACE_OS::strcmp (current_arg, "-TSmax_return_card") == 0 || - ACE_OS::strcmp (current_arg, "-TSdef_hop_count") == 0 || - ACE_OS::strcmp (current_arg, "-TSmax_hop_count") == 0) - { - arg_shifter.consume_arg (); - if (arg_shifter.is_parameter_next ()) - { - CORBA::ULong value = - ACE_static_cast (CORBA::ULong, - ACE_OS::atoi (arg_shifter.get_current ())); - arg_shifter.consume_arg (); - - if (ACE_OS::strstr (current_arg, "card")) - { - if (ACE_OS::strstr (current_arg, "max")) - { - if (ACE_OS::strstr (current_arg, "search")) - this->max_search_card_ = value; - else if (ACE_OS::strstr (current_arg, "match")) - this->max_match_card_ = value; - else - this->max_return_card_ = value; - } - else - { - if (ACE_OS::strstr (current_arg, "search")) - this->def_search_card_ = value; - else if (ACE_OS::strstr (current_arg, "match")) - this->def_match_card_ = value; - else - this->def_return_card_ = value; - } - } - else - { - if (ACE_OS::strstr (current_arg, "max")) - this->max_hop_count_ = value; - else - this->def_hop_count_ = value; - } - } - } - else if (ACE_OS::strcmp (current_arg, "-TSdef_follow_policy") == 0 || - ACE_OS::strcmp (current_arg, "-TSmax_follow_policy") == 0) - { - arg_shifter.consume_arg (); - if (arg_shifter.is_parameter_next ()) - { - char* arg_str = arg_shifter.get_current (); - CosTrading::FollowOption follow_option; - - if (ACE_OS::strcasecmp (arg_str, "always") == 0) - follow_option = CosTrading::always; - else if (ACE_OS::strcasecmp (arg_str, "if_no_local") == 0) - follow_option = CosTrading::if_no_local; - else if (ACE_OS::strcasecmp (arg_str, "local_only") == 0) - follow_option = CosTrading::local_only; - else if (ACE_OS::strstr (current_arg, "def")) - follow_option = this->def_follow_policy_; - else - follow_option = this->max_follow_policy_; - - if (ACE_OS::strstr (current_arg, "def")) - this->def_follow_policy_ = follow_option; - else - this->max_follow_policy_ = follow_option; - - arg_shifter.consume_arg (); - } - } - else - arg_shifter.ignore_arg (); - } -} - - // ************************************************************* - // TAO_Sequence_Extracter_Base - // ************************************************************* - -CORBA::TCKind -TAO_Sequence_Extracter_Base:: -sequence_type (CORBA::TypeCode* type_code, - CORBA::Environment& env) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::TCKind return_value = CORBA::tk_void, - type_kind = type_code->kind (env); - - if (type_kind == CORBA::tk_alias || type_kind == CORBA::tk_sequence) - { - CORBA::TypeCode_ptr base = type_code; - - while (base->kind (env) == CORBA::tk_alias) - base = base->content_type (env); - - if (base->kind (env) == CORBA::tk_sequence) - { - base = base->content_type (env); - TAO_CHECK_ENV_RETURN (env, return_value); - - return_value = base->kind (env); - } - } - - return return_value; -} - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) -template class TAO_Offer_Database; -template class TAO_Service_Offer_Iterator; -template class TAO_Trader; -template class TAO_Lookup; -template class TAO_Register; -template class TAO_Admin; -template class TAO_Link; -template class TAO_Proxy; -template class TAO_Register_Offer_Iterator; -template class ACE_Hash_Map_Manager; -template class ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_RW_Thread_Mutex>; -template class ACE_Hash_Map_Iterator; -template class ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_RW_Thread_Mutex>; -template class ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_RW_Thread_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator; -template class ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_RW_Thread_Mutex>; -template class ACE_Hash_Map_Entry::Offer_Map_Entry*>; -template class ACE_Hash_Map_Manager::Offer_Map_Entry*,ACE_Null_Mutex>; -template class ACE_Hash_Map_Manager_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator::Offer_Map_Entry*,ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator::Offer_Map_Entry*,ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Base_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; -#endif /* ACE_MT_SAFE */ -template class TAO_Offer_Database; -template class TAO_Service_Offer_Iterator; -template class TAO_Register_Offer_Iterator; -template class TAO_Trader_Components; -template class TAO_Support_Attributes; -template class TAO_Import_Attributes; -template class TAO_Trader_Components; -template class TAO_Support_Attributes; -template class TAO_Trader_Components; -template class TAO_Support_Attributes; -template class TAO_Import_Attributes; -template class TAO_Link_Attributes; -template class TAO_Trader_Components; -template class TAO_Support_Attributes; -template class TAO_Link_Attributes; -template class TAO_Trader_Components; -template class TAO_Support_Attributes; -template class TAO_Trader; -template class TAO_Lookup; -template class TAO_Register; -template class TAO_Admin; -template class TAO_Link; -template class TAO_Proxy; -# if defined (ACE_HAS_MOSTLY_UNICODE_APIS) - // These aren't needed unless ACE_HAS_MOSTLY_UNICODE_APIS. - // Otherwise, they're in ace/ARGV.cpp. - template class ACE_Node; - template class ACE_Unbounded_Queue; - template class ACE_Unbounded_Queue_Iterator; -#endif /* ACE_HAS_MOSTLY_UNICODE_APIS */ -template class ACE_Node; -template class ACE_Unbounded_Queue; -template class ACE_Unbounded_Queue_Iterator; -template class ACE_Node; -template class ACE_Unbounded_Set; -template class ACE_Unbounded_Set_Iterator; -template class ACE_Hash_Map_Entry; -template class ACE_Hash_Map_Manager; -template class ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator; -template class ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator; -template class ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Entry; -template class ACE_Hash_Map_Manager; -template class ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator; -template class ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator; -template class ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Entry; -template class ACE_Hash_Map_Manager; -template class ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator; -template class ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator; -template class ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Entry; -template class ACE_Hash_Map_Manager; -template class ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator; -template class ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator; -template class ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Entry::Offer_Map_Entry*>; -template class ACE_Hash_Map_Manager::Offer_Map_Entry*,ACE_Null_Mutex>; -template class ACE_Hash_Map_Manager_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator::Offer_Map_Entry*,ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator::Offer_Map_Entry*,ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Base_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) -#pragma instantiate TAO_Register_Offer_Iterator -#pragma instantiate TAO_Offer_Database -#pragma instantiate TAO_Service_Offer_Iterator -#pragma instantiate TAO_Trader -#pragma instantiate TAO_Lookup -#pragma instantiate TAO_Register -#pragma instantiate TAO_Admin -#pragma instantiate TAO_Link -#pragma instantiate TAO_Proxy -#pragma instantiate ACE_Hash_Map_Entry -#pragma instantiate ACE_Hash_Map_Manager -#pragma instantiate ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_RW_Thread_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator -#pragma instantiate ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_RW_Thread_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_RW_Thread_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_RW_Thread_Mutex> -#pragma instantiate ACE_Hash_Map_Entry::Offer_Map_Entry*> -#pragma instantiate ACE_Hash_Map_Manager::Offer_Map_Entry*,ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Manager_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator::Offer_Map_Entry*,ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator::Offer_Map_Entry*,ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> -#endif /* ACE_MT_SAFE */ -#pragma instantiate TAO_Offer_Database -#pragma instantiate TAO_Service_Offer_Iterator -#pragma instantiate TAO_Register_Offer_Iterator -#pragma instantiate TAO_Trader_Components -#pragma instantiate TAO_Support_Attributes -#pragma instantiate TAO_Import_Attributes -#pragma instantiate TAO_Trader_Components -#pragma instantiate TAO_Support_Attributes -#pragma instantiate TAO_Trader_Components -#pragma instantiate TAO_Support_Attributes -#pragma instantiate TAO_Import_Attributes -#pragma instantiate TAO_Link_Attributes -#pragma instantiate TAO_Trader_Components -#pragma instantiate TAO_Support_Attributes -#pragma instantiate TAO_Link_Attributes -#pragma instantiate TAO_Trader_Components -#pragma instantiate TAO_Support_Attributes -#pragma instantiate TAO_Trader -#pragma instantiate TAO_Lookup -#pragma instantiate TAO_Register -#pragma instantiate TAO_Admin -#pragma instantiate TAO_Link -#pragma instantiate TAO_Proxy -# if defined (ACE_HAS_MOSTLY_UNICODE_APIS) - // These aren't needed unless ACE_HAS_MOSTLY_UNICODE_APIS. - // Otherwise, they're in ace/ARGV.cpp. -# pragma instantiate ACE_Node -# pragma instantiate ACE_Unbounded_Queue -# pragma instantiate ACE_Unbounded_Queue_Iterator -# endif /* ACE_HAS_MOSTLY_UNICODE_APIS */ -#pragma instantiate ACE_Node -#pragma instantiate ACE_Unbounded_Queue -#pragma instantiate ACE_Unbounded_Queue_Iterator -#pragma instantiate ACE_Node -#pragma instantiate ACE_Unbounded_Set -#pragma instantiate ACE_Unbounded_Set_Iterator -#pragma instantiate ACE_Hash_Map_Entry -#pragma instantiate ACE_Hash_Map_Manager -#pragma instantiate ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator -#pragma instantiate ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Entry -#pragma instantiate ACE_Hash_Map_Manager -#pragma instantiate ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator -#pragma instantiate ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Entry -#pragma instantiate ACE_Hash_Map_Manager -#pragma instantiate ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator -#pragma instantiate ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Entry -#pragma instantiate ACE_Hash_Map_Manager -#pragma instantiate ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator -#pragma instantiate ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Entry::Offer_Map_Entry*> -#pragma instantiate ACE_Hash_Map_Manager::Offer_Map_Entry*,ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Manager_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator::Offer_Map_Entry*,ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator::Offer_Map_Entry*,ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex::Offer_Map_Entry*, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Trader.h b/TAO/orbsvcs/orbsvcs/Trader/Trader.h deleted file mode 100644 index 03dae79a92c..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Trader.h +++ /dev/null @@ -1,566 +0,0 @@ -/* -*- C++ -*- */ - -// ============================================================================ -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Trader_Base.h -// -// = AUTHOR -// Marina Spivak -// Seth Widoff -// Irfan Pyarali -// -// Contents: -// -// TAO_Trader_Factory -// TAO_Trader_Base -// TAO_Support_Attributes_i -// TAO_Trading_Components_i -// TAO_Link_Attributes_i -// TAO_Import_Attributes_i -// TAO_Sequence_Extracter_Base -// -// ============================================================================ - -#ifndef TAO_TRADER_BASE_H -#define TAO_TRADER_BASE_H - -#include "ace/Hash_Map_Manager.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Containers.h" - -#include "orbsvcs/CosTradingS.h" -#include "orbsvcs/orbsvcs_export.h" - -#if defined(_MSC_VER) -#pragma warning (disable:4250) -#endif /* _MSC_VER */ - -// Forward Declaration. -class TAO_Trader_Base; - - // ************************************************************* - // TAO_Trader_Factory - // ************************************************************* - -class TAO_ORBSVCS_Export TAO_Trader_Factory -// = TITLE -// Uses command line arguments to construct a trader instance with -// the correct interface support, locking, and policy settings. -{ -public: - - typedef TAO_Trader_Base TAO_TRADER; - - static TAO_TRADER* create_trader (int& argc, char** argv); - // Creates an instance of the trader according to parameters whose - // default values can be overrided with the following command line - // arguments: - // - // -TSthreadsafe, default is not thread-safe - // -TSconformance {query, simple, stand-alone, linked}, default is linked - // -TSsupports_dynamic_properties {true, false}, default is true - // -TSsupports_modifiable_propertise {true, false}, default is true - // -TSdef_search_card {integer}, default is 20 - // -TSmax_search_card {integer}, default is 50 - // -TSdef_match_card {integer}, default is 20 - // -TSmax_match_card {integer}, default is 50 - // -TSdef_return_card {integer}, default is 20 - // -TSmax_return_card {integer}, default is 50 - // -TSdef_hop_count {integer}, default is 5, - // -TSmax_hop_count {integer}, default is 10 - // -TSdef_follow_policy {always,if_no_local,local_only}, default is if_no_local, - // -TSmax_follow_policy {always,if_no_local,local_only}, default is always - -protected: - - TAO_Trader_Factory (int& argc, char** argv); - -private: - - enum Conformance { TAO_TRADER_QUERY, - TAO_TRADER_SIMPLE, - TAO_TRADER_STANDALONE, - TAO_TRADER_LINKED }; - - TAO_TRADER* manufacture_trader (void); - - void parse_args (int& argc, char** argv); - - TAO_Trader_Factory& operator= (const TAO_Trader_Factory&); - TAO_Trader_Factory (const TAO_Trader_Factory&); - - // = Command line configurable parameters. - - Conformance conformance_; - CORBA::Boolean threadsafe_; - CORBA::Boolean supports_dynamic_properties_; - CORBA::Boolean supports_modifiable_properties_; - CORBA::ULong def_search_card_; - CORBA::ULong max_search_card_; - CORBA::ULong def_match_card_; - CORBA::ULong max_match_card_; - CORBA::ULong def_return_card_; - CORBA::ULong max_return_card_; - CORBA::ULong def_hop_count_; - CORBA::ULong max_hop_count_; - CosTrading::FollowOption def_follow_policy_; - CosTrading::FollowOption max_follow_policy_; -}; - - // ************************************************************* - // Attribute Classes - // ************************************************************* - -class TAO_Lockable -// = DESCRIPTION -// Class used to remove the circular dependencies between the -// Attribute classes and the Trader class. -{ -public: - - virtual ACE_Lock& lock (void) = 0; -}; - - -class TAO_ORBSVCS_Export TAO_Support_Attributes_i - // = TITLE - // This class stores, allows access to and modification of - // trader's support attributes. - // - // = DESCRIPTION - // Contains a reference to the trader from which it is - // used so it can use trader's lock. -{ -public: - // = Initialization and termination methods. - TAO_Support_Attributes_i (TAO_Lockable &locker); - ~TAO_Support_Attributes_i (); - - // = Accessor methods. - CORBA::Boolean supports_modifiable_properties (void) const; - void supports_modifiable_properties (CORBA::Boolean); - - CORBA::Boolean supports_dynamic_properties (void) const; - void supports_dynamic_properties (CORBA::Boolean); - - CORBA::Boolean supports_proxy_offers (void) const; - void supports_proxy_offers (CORBA::Boolean); - - CosTrading::TypeRepository_ptr type_repos (void) const; - void type_repos (CosTrading::TypeRepository_ptr); - - CosTradingRepos::ServiceTypeRepository_ptr service_type_repos (void) const; - -private: - - TAO_Lockable &locker_; - // A reference to the trader (needed for obtaining the lock.) - - CORBA::Boolean supports_modifiable_properties_; - // Indicator of whether the trader supports property modification. - - CORBA::Boolean supports_dynamic_properties_; - // Indicator of whether the trader supports dynamic properties. - - CORBA::Boolean supports_proxy_offers_; - // Indicator of whether the trader supports proxy offers. - - CORBA::Object_var type_repos_; - // A reference to the TypeRepostitory used by the trader. - - CosTradingRepos::ServiceTypeRepository_var service_type_repos_; - // Already narrowed reference to the ServiceTypeRepository. -}; - -class TAO_ORBSVCS_Export TAO_Link_Attributes_i - // = TITLE - // This class stores, allows access to and modification of - // trader's link attributes. - // - // = DESCRIPTION - // Contains a reference to the trader from which it is - // used so it can use trader's lock. -{ -public: - // = Initialization and termination methods. - - TAO_Link_Attributes_i (TAO_Lockable &locker); - ~TAO_Link_Attributes_i (); - - // = Accessor methods. - - CosTrading::FollowOption max_link_follow_policy (void) const; - void max_link_follow_policy (CosTrading::FollowOption); - -private: - - TAO_Lockable &locker_; - // A reference to the trader (needed for obtaining the lock.) - - CosTrading::FollowOption max_link_follow_policy_; - // -}; - -class TAO_ORBSVCS_Export TAO_Import_Attributes_i - // = TITLE - // This class stores, allows access to and modification of - // trader's import attributes. - // - // = DESCRIPTION - // Contains a reference to the trader from which it is - // used so it can use trader's lock. -{ -public: - // = Initialization and termination methods. - - TAO_Import_Attributes_i (TAO_Lockable &locker); - - ~TAO_Import_Attributes_i (void); - - // = Accessor methods. - - CORBA::ULong def_search_card (void) const; - void def_search_card (CORBA::ULong); - - CORBA::ULong max_search_card (void) const; - void max_search_card (CORBA::ULong); - - CORBA::ULong def_match_card (void) const; - void def_match_card (CORBA::ULong); - - CORBA::ULong max_match_card (void) const; - void max_match_card (CORBA::ULong); - - CORBA::ULong def_return_card (void) const; - void def_return_card (CORBA::ULong); - - CORBA::ULong max_return_card (void) const; - void max_return_card (CORBA::ULong); - - CORBA::ULong max_list (void) const; - void max_list (CORBA::ULong); - - CORBA::ULong def_hop_count (void) const; - void def_hop_count (CORBA::ULong); - - CORBA::ULong max_hop_count (void) const; - void max_hop_count (CORBA::ULong); - - CosTrading::FollowOption def_follow_policy (void) const; - void def_follow_policy (CosTrading::FollowOption); - - CosTrading::FollowOption max_follow_policy (void) const; - void max_follow_policy (CosTrading::FollowOption); - -private: - - TAO_Lockable &locker_; - - CORBA::ULong def_search_card_; - // Upper bound of offers to be searched if - // is not specified. - - CORBA::ULong max_search_card_; - // Maximum upper bound of offers to be searched. - - CORBA::ULong def_match_card_; - // Upper bound of matched offers to be ordered if - // is not specified). - - CORBA::ULong max_match_card_; - // Maximum upper bound of matched offers to be ordered. - - CORBA::ULong def_return_card_; - // Upper bound of ordered offers to be returned if - // is not specified. - - CORBA::ULong max_return_card_; - // Maximum upper bound of ordered offers to be returned. - - CORBA::ULong max_list_; - // Upper bound of depth - - CORBA::ULong def_hop_count_; - // Upper bound of depth of links to be traversed if is - // not specified. - - CORBA::ULong max_hop_count_; - // Maximum upper bound of depth of links to be traversed. - - CosTrading::FollowOption def_follow_policy_; - // Default link follow policy for a particular trader. - - CosTrading::FollowOption max_follow_policy_; - // Limiting link follow policy for all links of the trader - - // overrides both link and importer policies. -}; - -class TAO_ORBSVCS_Export TAO_Trading_Components_i - // - // = TITLE - // Set/get methods for references to various - // interfaces of the trader. - // - // = DESCRIPTION - // Note, this class is for use in local address space only and is NOT a - // direct implementation of IDL methods. (Implementation of - // IDL methods in CosTrading::Trader_Components would need - // add a _duplicate call for each get method). -{ -public: - - // = Initialization and termination methods. - TAO_Trading_Components_i (TAO_Lockable &locker); - ~TAO_Trading_Components_i (void); - - // = CosTrading::TraderComponents methods. - - CosTrading::Lookup_ptr lookup_if (void) const; - // Returns an object reference to the Lookup interface of the trader. - // Returns nil if the trader does not support Lookup interface. - - void lookup_if (CosTrading::Lookup_ptr); - // Set the reference to the Lookup interface. - - CosTrading::Register_ptr register_if (void) const; - // Returns object reference for the Register interface of the trader. - // Returns nil if the trader does not support Register interface. - - void register_if (CosTrading::Register_ptr); - // Set the reference to the Register interface of the trader. - - CosTrading::Link_ptr link_if (void) const; - // Returns object reference for the Link interface of the trader. - // Returns nil if the trader does not support Link interface. - - void link_if (CosTrading::Link_ptr); - // Set the reference to the Link interface of the trader. - - CosTrading::Proxy_ptr proxy_if (void) const; - // Returns object reference to the Proxy interface of the trader. - // Returns nil if the trader does not support Proxy interface. - - void proxy_if (CosTrading::Proxy_ptr); - // Set the reference to the Proxy interface of the trader. - - CosTrading::Admin_ptr admin_if (void) const; - // Returns object reference for the Admin interface of the trader. - // Returns nil if the trader does not support Admin interface. - - void admin_if (CosTrading::Admin_ptr); - // Set the reference to the Admin interface of the trader. - -private: - - TAO_Lockable &locker_; - - CosTrading::Lookup_var lookup_; - CosTrading::Register_var register_; - CosTrading::Link_var link_; - CosTrading::Proxy_var proxy_; - CosTrading::Admin_var admin_; -}; - - // ************************************************************* - // TAO_Trader_Base - // ************************************************************* - -class TAO_ORBSVCS_Export TAO_Trader_Base : public TAO_Lockable - // - // = TITLE - // TAO_Trader inherits from this "helper" class. - // The sole purpose of this class is to factor some of TAO_Trader's - // data members out, so that they would not have to be templatized - // and be be aware of the type of lock they use. - // - // = DESCRIPTION - // TAO_Trader is a template class. And while we want - // , , and - // use a lock contained in TAO_Trader, we do not - // want all these classes to be templatized. TAO_Trader_Base class solves - // this problem. -{ -public: - - enum Trader_Components - { - LOOKUP = 0x001, - REGISTER = 0x002, - LINK = 0x004, - PROXY = 0x008, - ADMIN = 0x010 - }; - - virtual ~TAO_Trader_Base (void); - - // = Accessors for objects that manage trader's configuration. - - TAO_Trading_Components_i &trading_components (void); - - const TAO_Trading_Components_i &trading_components (void) const; - - TAO_Import_Attributes_i &import_attributes (void); - - const TAO_Import_Attributes_i &import_attributes (void) const; - - TAO_Support_Attributes_i &support_attributes (void); - - const TAO_Support_Attributes_i &support_attributes (void) const; - - TAO_Link_Attributes_i &link_attributes (void); - - const TAO_Link_Attributes_i &link_attributes (void) const; - - // = Accessor for trader's lock. - - static CORBA::Boolean is_valid_identifier_name (const char* ident); - // Determine whether the identifier is a valid one (i.e., if the - // first character is a letter, and the subsequent ones letter, - // numbers, or underscores.) - -protected: - // = Objects determining current configuration of a trader. - - TAO_Trading_Components_i trading_components_; - // Stores and allows lookup of trader's components. - - TAO_Import_Attributes_i import_attributes_; - // Stores and allows access/modification of trader's import attributes. - - TAO_Support_Attributes_i support_attributes_; - // Stores and allows access/modification of trader's support attributes. - - TAO_Link_Attributes_i link_attributes_; - // Stores and allows access/modification of trader's link attributes. - - protected: - - TAO_Trader_Base (void); - // Implemented. - - private: - - TAO_Trader_Base (const TAO_Trader_Base& TAO_Trader_Base); - TAO_Trader_Base& operator= (const TAO_Trader_Base&); - // Unimplemented. -}; - - -// = Classes to deal with the ACE_Hash_Map_Manager. - -class TAO_String_Hash_Key : public CORBA::String_var -{ - // = TITLE - // Key for the Hash Table. The EXT_ID of the - // ACE_Hash_Map_Manager. -public: - // = Initialization and termination methods. - TAO_String_Hash_Key (void); - // Default constructor. - - TAO_String_Hash_Key (char * name); - // Constructor from a const string. - - TAO_String_Hash_Key (const char * name); - // Constructor from a const string. - - TAO_String_Hash_Key (const CORBA::String_var &hash_key); - // Copy constructor. - - ~TAO_String_Hash_Key (void); - // Destructor. - - int operator == (const TAO_String_Hash_Key &hash_key) const; - // The operator for hash binding and "find"ing. - - friend int operator < (const TAO_String_Hash_Key &left, - const TAO_String_Hash_Key &right); - // The operator for hash binding and "find"ing. - - u_long hash (void) const; - // The function that computes a hash value. -}; - -class TAO_Hashable_ULong -// = TITLE -// Helper class using hashable integers in the -// ACE_Hash_Map_Manager. The right way to do this would probably be -// template specialization of the Hash Map Manager, but compilers have -// a difficult enough time with the Trading Service as it is. -{ -public: - - TAO_Hashable_ULong (void) - : number_ (0) {} - - TAO_Hashable_ULong (CORBA::ULong number) - : number_ (number) {} - - u_long hash (void) const { return number_; } - - TAO_Hashable_ULong& operator= (const TAO_Hashable_ULong& number) - { - this->number_ = number.number_; - return *this; - } - - operator CORBA::ULong (void) const { return number_; } - - friend int operator== (const TAO_Hashable_ULong& left, - const TAO_Hashable_ULong& right) - { return left.number_ == right.number_; } - -private: - - CORBA::ULong number_; -}; - -// Helpful typedefs -// Should probably be private to TAO_Offer_Database, but g++ has a -// hard time with it like that when compiling TAO_Service_Offer_Iterator. -typedef ACE_Hash_Map_Manager TAO_Offer_Map; -typedef ACE_Hash_Map_Manager TAO_Lookup_Table; -typedef ACE_Unbounded_Set TAO_String_Set; -typedef ACE_Hash_Map_Manager TAO_Typecode_Table; -typedef ACE_Unbounded_Queue TAO_String_Queue; - - // ************************************************************* - // TAO_Sequence_Extracter_Base - // ************************************************************* - -class TAO_Sequence_Extracter_Base -// = TITLE -// Static methods used by the TAO_Sequence_Extracter class. -{ -public: - - static CORBA::TCKind sequence_type (CORBA::TypeCode* code, - CORBA::Environment& env) - TAO_THROW_SPEC ((CORBA::SystemException)); - // Return the sequence element type for the sequence whose typecode - // is . -}; - -// = Helpful operators. - -int -operator> (const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &l, - const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &r); - -int -operator< (const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &l, - const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &r); - -int operator== (const CosTrading::Admin::OctetSeq& left, - const CosTrading::Admin::OctetSeq& right); - -#endif /* TAO_TRADER_BASE_H */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Trader_Interfaces.cpp b/TAO/orbsvcs/orbsvcs/Trader/Trader_Interfaces.cpp deleted file mode 100644 index d39c7815ff9..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Trader_Interfaces.cpp +++ /dev/null @@ -1,1872 +0,0 @@ -// ======================================================================== -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Trader_Interfaces.cpp -// -// = AUTHOR -// Marina Spivak -// Seth Widoff -// -// ======================================================================== - -#if !defined (TAO_TRADER_INTERFACES_C) -#define TAO_TRADER_INTERFACES_C - -#include "Trader_Interfaces.h" -#include "Trader_T.h" - -ACE_RCSID(Trader, Trader_Interfaces, "$Id$") - - // ************************************************************* - // TAO_Lookup - // ************************************************************* - -template -TAO_Lookup:: -TAO_Lookup (TAO_Trader &trader) - : TAO_Trader_Components (trader.trading_components ()), - TAO_Support_Attributes (trader.support_attributes ()), - TAO_Import_Attributes (trader.import_attributes ()), - IDS_SAVED (100), - trader_ (trader) -{ -} - -template -TAO_Lookup::~TAO_Lookup (void) -{ - ACE_GUARD (TRADER_LOCK_TYPE, trader_mon, this->lock_); - for (Request_Ids::ITERATOR riter (this->request_ids_); - ! riter.done (); - riter.advance ()) - { - CosTrading::Admin::OctetSeq** old_seq = 0; - riter.next (old_seq); - delete *old_seq; - } -} - -template void -TAO_Lookup:: -query (const char *type, - const char *constraint, - const char *preferences, - const CosTrading::PolicySeq &in_policies, - const CosTrading::Lookup::SpecifiedProps &desired_props, - CORBA::ULong how_many, - CosTrading::OfferSeq_out returned_offers, - CosTrading::OfferIterator_out returned_offer_iterator, - CosTrading::PolicyNameSeq_out returned_limits_applied, - CORBA::Environment& env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTrading::IllegalConstraint, - CosTrading::Lookup::IllegalPreference, - CosTrading::Lookup::IllegalPolicyName, - CosTrading::Lookup::PolicyTypeMismatch, - CosTrading::Lookup::InvalidPolicyValue, - CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName, - CosTrading::DuplicatePolicyName)) -{ - // Instantiate a class to help interpret query policies. - TAO_Policies policies (this->trader_, in_policies, env); - TAO_CHECK_ENV_RETURN_VOID (env); - - // If a federated query returns to us, ignore it to prevent - // redundant results and infinite loops. - CosTrading::Admin::OctetSeq* request_id = 0; - if (this->seen_request_id (policies, request_id, env)) - return; - TAO_CHECK_ENV_RETURN_VOID (env); - - // The presence of a link interface determines whether we should - // attempt to forward or propagate queries. - CosTrading::Link_ptr link_if = - this->trader_.trading_components ().link_if (); - - // If the importer has specified a starting trader, foward the - // query. - CosTrading::TraderName* trader_name = policies.starting_trader (env); - TAO_CHECK_ENV_RETURN_VOID (env); - - if (! CORBA::is_nil (link_if) && trader_name != 0) - { - CosTrading::PolicySeq policies_to_forward; - policies.copy_to_forward (policies_to_forward, *trader_name); - const char* next_hop = (*trader_name)[0]; - this->forward_query (next_hop, - type, - constraint, - preferences, - policies_to_forward, - desired_props, - how_many, - returned_offers, - returned_offer_iterator, - returned_limits_applied, - env); - TAO_CHECK_ENV_RETURN_VOID (env); - return; - } - - // Retrieve the type description struct from the Service Type Repos. - const TAO_Support_Attributes_i& support_attrs = - this->trader_.support_attributes (); - CosTradingRepos::ServiceTypeRepository_ptr rep = - support_attrs.service_type_repos (); - CosTradingRepos::ServiceTypeRepository::TypeStruct_var type_struct = - rep->fully_describe_type (type, env); - TAO_CHECK_ENV_RETURN_VOID (env); - - ACE_NEW (returned_offers, CosTrading::OfferSeq); - - // Obtain a reference to the offer database. - TAO_Offer_Database& offer_database = this->trader_.offer_database (); - - // TAO_Offer_Filter -- ensures that we don't consider offers with - // modifiable or dynamic properties if the Trader doesn't support - // them, or the importer has turned them off using policies. - // TAO_Constraint_Validator -- validates the constraint with the - // property types in the supplied type. - // TAO_Constraint_Interpreter -- parses the constraint string, and - // determines whether an offer meets those constraints. - // TAO_Preference_Interpreter -- parses the preference string and - // orders offers according to those constraints. - TAO_Offer_Filter offer_filter (policies, env); - TAO_CHECK_ENV_RETURN_VOID (env); - TAO_Constraint_Validator validator (type_struct.in ()); - TAO_Constraint_Interpreter constr_inter (validator, constraint, env); - TAO_CHECK_ENV_RETURN_VOID (env); - TAO_Preference_Interpreter pref_inter (validator, preferences, env); - TAO_CHECK_ENV_RETURN_VOID (env); - - // Try to find the map of offers of desired service type. - offer_filter.configure_type (type_struct.ptr ()); - this->lookup_one_type (type, - offer_database, - constr_inter, - pref_inter, - offer_filter); - - if (! policies.exact_type_match (env)) - { - // If the importer hasn't demanded an exact match search, we search - // all the subtypes of the supplied type. NOTE: Only the properties - // belonging to the provided type are considered on - // subtypes. Additional properties on the subtype are generally - // ignored. This is as it should be, consistent with the notions of - // type inheritence. - TAO_CHECK_ENV_RETURN_VOID (env); - this->lookup_all_subtypes (type, - type_struct->incarnation, - offer_database, - rep, - constr_inter, - pref_inter, - offer_filter); - } - TAO_CHECK_ENV_RETURN_VOID (env); - - // Take note of the limits applied in this query. - returned_limits_applied = offer_filter.limits_applied (); - - // Fill the return sequence and iterator with the bountiful results. - CORBA::ULong offers_returned = - this->fill_receptacles (type, - how_many, - desired_props, - policies, - pref_inter, - *returned_offers.ptr (), - returned_offer_iterator, - env); - TAO_CHECK_ENV_RETURN_VOID (env); - - // The following steps are only appropriate for a linked trader. - if (! CORBA::is_nil (link_if)) - { - // Determine if we should perform a federated query, and if so - // construct a sequence of links to follow. - CosTrading::LinkNameSeq_var links; - CORBA::Boolean should_follow = - this->retrieve_links (policies, - offers_returned, - CosTrading::LinkNameSeq_out (links.out ()), - env); - TAO_CHECK_ENV_RETURN_VOID (env); - - if (should_follow && links->length () != 0) - { - // Query those links we've accumulated! - this->federated_query (links.in (), - policies, - *request_id, - pref_inter, - type, - constraint, - preferences, - desired_props, - how_many, - *returned_offers.ptr (), - returned_offer_iterator.ptr (), - *returned_limits_applied.ptr (), - env); - TAO_CHECK_ENV_RETURN_VOID (env); - } - } -} - -template -void -TAO_Lookup:: -lookup_one_type (const char* type, - TAO_Offer_Database& offer_database, - TAO_Constraint_Interpreter& constr_inter, - TAO_Preference_Interpreter& pref_inter, - TAO_Offer_Filter& offer_filter) -{ - // Retrieve an iterator over the offers for a given type. - // @@ Would have used Offer_Database::offer_iterator for less - // coupling between TAO_Lookup and Offer_Database, but g++ barfs on - // that. -#if defined(_MSC_VER) - TAO_Offer_Database::offer_iterator - offer_iter (type, offer_database); -#else - // MSVC won't grok this for some reason, but it's necessary for the - // HP compiler, which seriously requires the typename keyword - // here. I apologize if this ifdef offends some ACE users' - // sensibilities --- it certainly offends mine. - ACE_TYPENAME TAO_Offer_Database::offer_iterator - offer_iter (type, offer_database); -#endif - - while (offer_filter.ok_to_consider_more () && - offer_iter.has_more_offers ()) - { - // For each offer in the iterator, attempt to match it with - // the constraints passed to the Query method. If it matches - // the constraint, use the TAO_Preference_Interpreter to - // order the matched offers with respect to the preference - // string passed to the method. All the while the offer - // filter ensures we don't exceed the match cardinality - // constraints. - CosTrading::Offer* offer = offer_iter.get_offer (); - - TAO_Constraint_Evaluator evaluator (offer); - if (offer_filter.ok_to_consider (offer) && - constr_inter.evaluate (evaluator)) - { - // Shove the offer and its id into the preference - // ordering object, pref_inter. - CosTrading::OfferId offer_id = offer_iter.get_id (); - pref_inter.order_offer (evaluator, offer, offer_id); - offer_filter.matched_offer (); - } - - offer_iter.next_offer (); - } -} - -template -void -TAO_Lookup:: -lookup_all_subtypes (const char* type, - CosTradingRepos::ServiceTypeRepository::IncarnationNumber& inc_num, - TAO_Offer_Database& offer_database, - CosTradingRepos::ServiceTypeRepository_ptr rep, - TAO_Constraint_Interpreter& constr_inter, - TAO_Preference_Interpreter& pref_inter, - TAO_Offer_Filter& offer_filter) -{ - // BEGIN SPEC - // The trader may return a service offer of a subtype of the "type" - // requested. Sub-typing of service types is discussed in "Service - // Types" on page 16-4. A service subtype can be described by the - // properties of its supertypes. This ensures that a well-formed query - // for the "type" is also a well-formed query with respect to any - // subtypes. However, if the importer specifies the policy of - // exact_type_match = TRUE, then only offers with the exact (no - // subtype) service type requested are returned. - // END SPEC - - CosTradingRepos::ServiceTypeRepository::SpecifiedServiceTypes sst; - CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq_var all_types; - - // Optimization: Since a subtype can't have a higher incarnation - // number than a supertype, we don't need to consider those - // types with lower incarnation numbers. - sst.incarnation (inc_num); - - // TAO_TRY - // { - CORBA::Environment env; - all_types = rep->list_types (sst, env); - // TAO_CHECK_ENV; - // } - // TAO_CATCHANY { return; } - // TAO_ENDTRY; - - // Scan all types inserted after the super types. If the transitive - // closure of a type's super type relation includes the super type - // being considered, then perform a search on that type. - CORBA::ULong num_types = all_types->length (); - CosTradingRepos::ServiceTypeRepository::TypeStruct_var type_struct; - for (CORBA::ULong i = 0; - i < num_types && offer_filter.ok_to_consider_more (); - i++) - { - TAO_TRY - { - // Obtain a description of the prospective type. - type_struct = rep->fully_describe_type (all_types[i], TAO_TRY_ENV); - TAO_CHECK_ENV; - - CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq& - super_types = type_struct->super_types; - CORBA::ULong num_super_types = super_types.length (); - - for (CORBA::ULong j = 0; j < num_super_types; j++) - { - if (ACE_OS::strcmp (type_struct->super_types[j], type) == 0) - { - // Egads, a subtype! This type has the type passed - // to query in its list of super_types. - offer_filter.configure_type (type_struct.ptr ()); - this->lookup_one_type (all_types[i], - offer_database, - constr_inter, - pref_inter, - offer_filter); - break; - } - } - } - TAO_CATCHANY - { - } - TAO_ENDTRY; - } -} - - -template -int -TAO_Lookup:: -fill_receptacles (const char* type, - CORBA::ULong how_many, - const CosTrading::Lookup::SpecifiedProps& desired_props, - TAO_Policies& policies, - TAO_Preference_Interpreter& pref_inter, - CosTrading::OfferSeq& offers, - CosTrading::OfferIterator_ptr& offer_itr, - CORBA::Environment& env) - TAO_THROW_SPEC ((CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName)) -{ - // BEGIN SPEC - // The returned offers are passed back in one of two ways (or a - // combination of both). ° The "offers" return result conveys a list - // of offers and the "offer_itr" is a reference to an interface at - // which offers can be obtained. ° The "how_many" parameter states - // how many offers are to be returned via the "offers" result, any - // remaining offers are available via the iterator interface. If the - // "how_many" exceeds the number of offers to be returned, then the - // "offer_itr" will be nil. - // END SPEC - - TAO_Property_Filter prop_filter (desired_props, env); - TAO_CHECK_ENV_RETURN (env, 0); - - // RETURNING: Calculate how many offers go into the sequence - // Calculate how many go into the iterator - - CORBA::ULong return_card = policies.return_card (env); - TAO_CHECK_ENV_RETURN (env, 0); - - CORBA::ULong i = 0; - CORBA::ULong size = pref_inter.num_offers (); - CORBA::ULong offers_in_sequence = (how_many < size) ? how_many : size; - CORBA::ULong offers_in_iterator = size - offers_in_sequence; - - // Ensure the total number of offers returned doesn't exceed return_card. - offers_in_sequence = - (offers_in_sequence > return_card) ? return_card : offers_in_sequence; - - return_card -= offers_in_sequence; - - offers_in_iterator = - (offers_in_iterator > return_card) ? return_card : offers_in_iterator; - - CORBA::ULong total_offers = offers_in_sequence + offers_in_iterator; - offers.length (offers_in_sequence); - - // Add to the sequence, filtering out the undesired properties. - for (i = 0; i < offers_in_sequence; i++) - { - CosTrading::Offer* offer = 0; - CosTrading::OfferId offer_id = 0; - - // Pull the next ordered offer out of the preference interpreter. - pref_inter.remove_offer (offer, offer_id); - - // Filter out the undesired properties. - prop_filter.filter_offer (offer, offers[i]); - CORBA::string_free (offer_id); - } - - // Any remaining offers under the return_card go into iterator - if (offers_in_iterator > 0) - { - // Create an iterator implementation - TAO_Offer_Iterator *oi = this->create_offer_iterator (prop_filter); - - // Register it with the POA. - offer_itr = oi->_this (env); - TAO_CHECK_ENV_RETURN (env, total_offers - offers_in_iterator); - - // Add to the iterator - for (i = 0; i < offers_in_iterator; i++) - { - CosTrading::Offer* offer = 0; - CosTrading::OfferId offer_id = 0; - - // Pull the next ordered offer out of the preference - // intrerpreter and add it to the offer iterator. - pref_inter.remove_offer (offer, offer_id); - oi->add_offer (offer_id, offer); - } - } - - // Clear the preference intrerpreter of superfluous items. - CORBA::ULong num_offers = pref_inter.num_offers (); - for (i = 0; i < num_offers; i++) - { - CosTrading::Offer* offer = 0; - CosTrading::OfferId offer_id = 0; - - pref_inter.remove_offer (offer, offer_id); - CORBA::string_free (offer_id); - } - - return total_offers; -} - -template -TAO_Offer_Iterator * -TAO_Lookup:: -create_offer_iterator (const TAO_Property_Filter& pfilter) -{ - // This is the factory method that creates the appropriate type of - // offer iterator. If there's no Register interface, then we can - // just stick the offers directly into an iterator, since these - // offers will never be removed from the Trader. If there's a - // Register interface, then there's a chance that by the time the - // importer calls the next_n method on the iterator that the offer - // will have been withdrawn. So the Register_Offer_Iterator retains only - // the offer ids, and will recognize when an offer id no longer - // identifies an offer in the trader. - - // We pass the property filter to the iterators, so when the iterators - // return the offers, they can remove the undesirable properties - // from those offers. - TAO_Offer_Iterator* iterator = 0; - - if (CORBA::is_nil (this->trader_.trading_components ().register_if ())) - iterator = new TAO_Query_Only_Offer_Iterator (pfilter); - else - { - iterator = - new TAO_Register_Offer_Iterator (this->trader_.offer_database (), - pfilter); - } - - return iterator; -} - -template -CORBA::Boolean -TAO_Lookup:: -retrieve_links (TAO_Policies& policies, - CORBA::ULong offers_returned, - CosTrading::LinkNameSeq_out links, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::Lookup::PolicyTypeMismatch)) -{ - CORBA::Boolean should_follow = 0; - CosTrading::FollowOption follow_rule = policies.link_follow_rule (TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, should_follow); - - // Determine whether or not a federated query is warranted. A query - // is waranted if the follow_rule governing this query is 'always' - // or if_no_local and the local query returned nothing. - if ((follow_rule == CosTrading::always || - (follow_rule == CosTrading::if_no_local && offers_returned == 0)) - && policies.hop_count (TAO_IN_ENV) > 0) - should_follow = 1; - - if (should_follow) - { - // Grab the names of all the links in the trader, and push - // the suitable ones onto . - CosTrading::Link_ptr link_if = - this->trader_.trading_components ().link_if (); - - links = link_if->list_links (TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, 0); - - // Determine which of the links registered with the Link - // interface are suitable to follow. - CORBA::ULong i = 0, j = 0, - length = links->length (); - - for (i = 0; i < length; i++) - { - // Grab the link information. - CosTrading::Link::LinkInfo_var - link_info (link_if->describe_link (links[i], TAO_IN_ENV)); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, should_follow); - - // Compute the link follow rule. - CosTrading::FollowOption link_rule = - policies.link_follow_rule (link_info.in (), TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, should_follow); - - // Determine if the link follow rule applies. - if (link_rule == CosTrading::always || - (link_rule == CosTrading::if_no_local && - offers_returned == 0)) - { - // Add the link to the list of links to follow. - if (i > j) - links[j] = links[i]; - - j++; - } - } - - links->length (j); - } - - return should_follow; -} - - -template -void -TAO_Lookup:: -federated_query (const CosTrading::LinkNameSeq& links, - const TAO_Policies& policies, - const CosTrading::Admin::OctetSeq& request_id, - TAO_Preference_Interpreter& pref_inter, - const char *type, - const char *constr, - const char *pref, - const CosTrading::Lookup::SpecifiedProps& desired_props, - CORBA::ULong how_many, - CosTrading::OfferSeq& offers, - CosTrading::OfferIterator_ptr& offer_iter, - CosTrading::PolicyNameSeq& limits, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTrading::IllegalConstraint, - CosTrading::Lookup::IllegalPreference, - CosTrading::Lookup::IllegalPolicyName, - CosTrading::Lookup::PolicyTypeMismatch, - CosTrading::Lookup::InvalidPolicyValue, - CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName, - CosTrading::DuplicatePolicyName)) -{ - // The general idea here is this: We've assembled a number of links - // to follow, and we'll query each of them in turn. On each query we - // adjust the policies for the new trader by reducing the hop_count, - // changing the link_follow_rule etc..., and merge the results from - // the new query with the results from the previous queries. - - // We'll need the link and admin interfaces for this part of the - // federated query. It's ok to get the admin interface without - // checking if it's nil, becase the conformance criteria dictate - // that a trader can't implement the link interface without the - // admin interface. - CosTrading::Link_ptr link_interface - = this->trader_.trading_components ().link_if (); - - // Begin collecting all the various offer_iterators into a - // collection. The end result is a distributed tree of offer - // iterators, which if traversed in its entirety is probably hugely - // inefficient, but oh well, I can't think of a better solution. - TAO_Offer_Iterator_Collection* offer_iter_collection; - ACE_NEW (offer_iter_collection, TAO_Offer_Iterator_Collection); - offer_iter_collection->add_offer_iterator (offer_iter); - - CosTrading::PolicySeq policies_to_pass; - policies.copy_to_pass (policies_to_pass, request_id); - - for (int i = links.length () - 1; i >= 0; i--) - { - CosTrading::OfferSeq_ptr out_offers = 0; - CosTrading::OfferIterator_ptr out_offer_iter = 0; - CosTrading::PolicyNameSeq_ptr out_limits = 0; - - TAO_TRY - { - // Obtain information about the link we're traversing. - CosTrading::Link::LinkInfo_var link_info = - link_interface->describe_link (links[i], TAO_TRY_ENV); - TAO_CHECK_ENV; - - // Set the link follow policy for the query over the link. - policies.copy_in_follow_option (policies_to_pass, - link_info.in (), - TAO_TRY_ENV); - TAO_CHECK_ENV; - - CosTrading::Lookup_var remote_lookup = - CosTrading::Lookup::_duplicate (link_info->target.in ()); - - // Perform the federated query. - remote_lookup->query (type, - constr, - pref, - policies_to_pass, - desired_props, - how_many - offers.length (), - CosTrading::OfferSeq_out (out_offers), - CosTrading::OfferIterator_out (out_offer_iter), - CosTrading::PolicyNameSeq_out (out_limits), - TAO_TRY_ENV); - TAO_CHECK_ENV; - - CORBA::ULong j = 0; - CosTrading::OfferSeq_var out_offers_var (out_offers); - CosTrading::PolicyNameSeq_var out_limits_var (out_limits); - - // Add another iterator to the collection. - if (! CORBA::is_nil (out_offer_iter)) - offer_iter_collection->add_offer_iterator (out_offer_iter); - - // Concatenate the limits applied. - CORBA::ULong source_length = out_limits->length (), - target_length = limits.length (), - total_length = source_length + target_length; - - limits.length (total_length); - for (j = 0; j < source_length; j++) - limits[j + target_length] = out_limits_var[j]; - - // Concatenate the sequence offers. - source_length = out_offers->length (); - target_length = offers.length (); - total_length = source_length + target_length; - - offers.length (total_length); - for (j = 0; j < source_length; j++) - offers[j + target_length] = out_offers_var[j]; - } - TAO_CATCHANY - { - // Ah, well, this query failed, move on to the next one. - } - TAO_ENDTRY; - } - - // Sort the sequence in preference order. - this->order_merged_sequence (pref_inter, offers); - - // Return the collection of offer iterators. - offer_iter = offer_iter_collection->_this (TAO_IN_ENV); -} - -template -void -TAO_Lookup:: -order_merged_sequence (TAO_Preference_Interpreter& pref_inter, - CosTrading::OfferSeq& offers) -{ - CORBA::ULong j = 0; - CORBA::ULong length = offers.length (); - - // Grab ownership of the offers already in the target sequence. - CosTrading::Offer* target_buf = offers.get_buffer (1); - - // Order the sequence. - for (j = 0; j < length; j++) - pref_inter.order_offer (&target_buf[j]); - //pref_inter.order_offer (&offers[j]); - - // Reallocate the sequence. - offers.length (length); - - // CosTrading::OfferSeq copy; - // copy.length (length); - - // Copy in the ordered offers. - for (j = 0; j < length; j++) - { - CosTrading::Offer* offer = 0; - pref_inter.remove_offer (offer); - //copy[j] = *offer; - offers[j] = *offer; - } - - // Release the orphaned memory. - CosTrading::OfferSeq::freebuf (target_buf); - // offers = copy -} - -template -void -TAO_Lookup:: -forward_query (const char* next_hop, - const char *type, - const char *constr, - const char *pref, - const CosTrading::PolicySeq& policy_seq, - const CosTrading::Lookup::SpecifiedProps& desired_props, - CORBA::ULong how_many, - CosTrading::OfferSeq_out offers, - CosTrading::OfferIterator_out offer_itr, - CosTrading::PolicyNameSeq_out limits_applied, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTrading::IllegalConstraint, - CosTrading::Lookup::IllegalPreference, - CosTrading::Lookup::IllegalPolicyName, - CosTrading::Lookup::PolicyTypeMismatch, - CosTrading::Lookup::InvalidPolicyValue, - CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName, - CosTrading::DuplicatePolicyName)) -{ - // Forward this query to the next link in the starting_trader sequence. - CosTrading::Link_ptr link_interface - = this->trader_.trading_components ().link_if (); - - TAO_TRY - { - CosTrading::Link::LinkInfo_var link_info = - link_interface->describe_link (next_hop, TAO_TRY_ENV); - TAO_CHECK_ENV; - - CosTrading::Lookup_var remote_lookup = - CosTrading::Lookup::_duplicate (link_info->target.in ()); - - CORBA::Object_var us = this->_this (TAO_TRY_ENV); - TAO_CHECK_ENV; - - CORBA::Boolean self_loop = - remote_lookup->_is_equivalent (us.in (), TAO_TRY_ENV); - TAO_CHECK_ENV; - - if (! self_loop) - { - // Perform forwarding query. - remote_lookup->query (type, - constr, - pref, - policy_seq, - desired_props, - how_many, - offers, - offer_itr, - limits_applied, - TAO_IN_ENV); - TAO_CHECK_ENV_RETURN_VOID (TAO_IN_ENV); - } - else - { - this->query (type, - constr, - pref, - policy_seq, - desired_props, - how_many, - offers, - offer_itr, - limits_applied, - TAO_IN_ENV); - TAO_CHECK_ENV_RETURN_VOID (TAO_IN_ENV); - } - } - TAO_CATCHANY - { - CosTrading::Policy policy; - policy.name = TAO_Policies::POLICY_NAMES[TAO_Policies::STARTING_TRADER]; - policy.value <<= next_hop; - TAO_THROW (CosTrading::Lookup::InvalidPolicyValue (policy)); - } - TAO_ENDTRY; -} - -template -CORBA::Boolean -TAO_Lookup:: -seen_request_id (TAO_Policies& policies, - CosTrading::Admin::OctetSeq*& seq, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::Lookup::PolicyTypeMismatch)) -{ - CORBA::Boolean return_value = 0; - - seq = policies.request_id (TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, 1); - - if (seq == 0) - { - CosTrading::Admin_ptr admin_if = - this->trader_.trading_components ().admin_if (); - seq = admin_if->request_id_stem (TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, 1); - } - else - { - // Allocate memory so memory mangement is the same for both - // cases. - ACE_NEW_RETURN (seq, - CosTrading::Admin::OctetSeq (*seq), - 0); - } - - if (seq == 0) - TAO_THROW_RETURN (CORBA::NO_MEMORY (CORBA::COMPLETED_NO), 1); - - ACE_GUARD_RETURN (TRADER_LOCK_TYPE, trader_mon, this->lock_, 1); - for (Request_Ids::ITERATOR riter (this->request_ids_); - ! riter.done (); - riter.advance ()) - { - CosTrading::Admin::OctetSeq** old_seq = 0; - riter.next (old_seq); - - if (**old_seq == *seq) - { - return_value = 1; - break; - } - } - - if (return_value == 0) - { - if (this->request_ids_.size () == IDS_SAVED) - { - CosTrading::Admin::OctetSeq* octet_seq = 0; - this->request_ids_.dequeue_head (octet_seq); - delete octet_seq; - } - - this->request_ids_.enqueue_tail (seq); - } - - return return_value; -} - - // ************************************************************* - // TAO_Register - // ************************************************************* - -template -TAO_Register::TAO_Register (TAO_Trader &trader) - : TAO_Trader_Components (trader.trading_components ()), - TAO_Support_Attributes (trader.support_attributes ()), - trader_ (trader) -{ -} - -template -TAO_Register::~TAO_Register (void) -{ -} - -template -CosTrading::OfferId -TAO_Register:: -export (CORBA::Object_ptr reference, - const char *type, - const CosTrading::PropertySeq &properties, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::Register::InvalidObjectRef, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTrading::Register::InterfaceTypeMismatch, - CosTrading::IllegalPropertyName, - CosTrading::PropertyTypeMismatch, - CosTrading::ReadonlyDynamicProperty, - CosTrading::MissingMandatoryProperty, - CosTrading::DuplicatePropertyName)) -{ - // For robustness purposes -- - if (CORBA::is_nil (reference)) - TAO_THROW_RETURN (CosTrading::Register::InvalidObjectRef (), 0); - - // Get service type map - TAO_Offer_Database &offer_database = this->trader_.offer_database (); - - CosTrading::Offer* offer = 0; - TAO_Support_Attributes_i& support_attrs = - this->trader_.support_attributes (); - CosTradingRepos::ServiceTypeRepository_ptr rep = - support_attrs.service_type_repos (); - - // Yank our friend, the type struct, and confirm that the given - // properties match the type definition. - CosTradingRepos::ServiceTypeRepository::TypeStruct_var type_struct = - rep->fully_describe_type (type, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, 0); - - // Oops the type is masked, we shouldn't let exporters know the type - // exists. - if (type_struct->masked) - TAO_THROW_RETURN (CosTrading::UnknownServiceType (type), 0); - - // TAO-specific way to determine if an object is derived from or is - // an interface type. - if (! reference->_is_a (type_struct->if_name, TAO_IN_ENV)) - TAO_THROW_RETURN (CosTrading::Register:: - InterfaceTypeMismatch (type, reference), 0); - - // Validate that the properties defined for this offer are correct - // to their types and strength. - this->validate_properties (type, type_struct.ptr (), properties, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, 0); - - // CORBA::ULong plength = properties.length (); - ACE_NEW_RETURN (offer, CosTrading::Offer, 0); - - // No copying, no memory leaks. Violates the "in" parameter semantics - // when this object is colocated with the client, however. - // CosTrading::PropertySeq* hack_seq = - // ACE_const_cast (CosTrading::PropertySeq*, &properties); - // CosTrading::Property* pbuf = hack_seq->get_buffer (1); - - // CosTrading::PropertySeq* hack_seq = - // ACE_const_cast (CosTrading::PropertySeq*, &properties); - // CosTrading::Property* pbuf = hack_seq->get_buffer (0); - // offer->properties.replace (plength, plength, pbuf, 0); - // offer->properties._allocate_buffer (plength); - offer->properties = properties; - offer->reference = reference->_duplicate (reference); - - // Insert the offer into the underlying type map. - CosTrading::OfferId id = offer_database.insert_offer (type, offer); - - return id; -} - -template -void -TAO_Register::withdraw (const char *id, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId, - CosTrading::Register::ProxyOfferId)) -{ - // Get service type map. - TAO_Offer_Database &offer_database = this->trader_.offer_database (); - offer_database.remove_offer ((CosTrading::OfferId) id, TAO_IN_ENV); -} - -template -CosTrading::Register::OfferInfo * -TAO_Register:: -describe (const char *id, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId, - CosTrading::Register::ProxyOfferId)) -{ - // Get service type map. - char* type = 0; - TAO_Offer_Database &offer_database = this->trader_.offer_database (); - - // Perform a lookup to find the offer. - CosTrading::Offer* offer = - offer_database.lookup_offer ((CosTrading::OfferId) id, type, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, (CosTrading::Register::OfferInfo *) 0); - - CosTrading::Register::OfferInfo *offer_info = 0; - ACE_NEW_RETURN (offer_info, CosTrading::Register::OfferInfo, 0); - - offer_info->reference = CORBA::Object::_duplicate (offer->reference.in ()); - offer_info->type = CORBA::string_dup (type); - - // Let the offer_info prop_seq "borrow" the sequence of properties. - //CORBA::ULong length = offer->properties.length (); - // CosTrading::Property* prop_buf = offer->properties.get_buffer (); - offer_info->properties = offer->properties; - - return offer_info; -} - -template -void -TAO_Register:: -modify (const char *id, - const CosTrading::PropertyNameSeq& del_list, - const CosTrading::PropertySeq& modify_list, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::NotImplemented, - CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId, - CosTrading::Register::ProxyOfferId, - CosTrading::IllegalPropertyName, - CosTrading::Register::UnknownPropertyName, - CosTrading::PropertyTypeMismatch, - CosTrading::ReadonlyDynamicProperty, - CosTrading::Register::MandatoryProperty, - CosTrading::Register::ReadonlyProperty, - CosTrading::DuplicatePropertyName)) -{ - // Throw an exception if the trader is not configured - // to support properties modification. - if (! this->supports_modifiable_properties (TAO_IN_ENV)) - TAO_THROW (CosTrading::NotImplemented ()); - - char* type = 0; - TAO_Support_Attributes_i& support_attrs = - this->trader_.support_attributes (); - CosTradingRepos::ServiceTypeRepository_ptr rep = - support_attrs.service_type_repos (); - TAO_Offer_Database &offer_database = this->trader_.offer_database (); - - CosTrading::Offer* offer = offer_database. - lookup_offer (ACE_const_cast (CosTrading::OfferId, id), type, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN_VOID (TAO_IN_ENV); - - if (offer != 0) - { - // Yank our friend, the type struct. - CosTradingRepos::ServiceTypeRepository::TypeStruct_var type_struct = - rep->fully_describe_type (type, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN_VOID (TAO_IN_ENV); - TAO_Offer_Modifier offer_mod (type, type_struct.in (), offer); - - // Delete, add, and change properties of the offer. - offer_mod.delete_properties (del_list, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN_VOID (TAO_IN_ENV); - - offer_mod.merge_properties (modify_list, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN_VOID (TAO_IN_ENV); - - // Alter our reference to the offer. We do this last, since the - // spec says: modify either suceeds completely or fails - // completely. - offer_mod.affect_change (modify_list); - } -} - -template -void -TAO_Register:: -withdraw_using_constraint (const char *type, - const char *constr, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTrading::IllegalConstraint, - CosTrading::Register::NoMatchingOffers)) -{ - TAO_Support_Attributes_i& - support_attrs = this->trader_.support_attributes (); - CosTradingRepos::ServiceTypeRepository_ptr rep = - support_attrs.service_type_repos (); - TAO_Offer_Database &offer_database = this->trader_.offer_database (); - CORBA::Boolean dp_support = support_attrs.supports_dynamic_properties (); - TAO_String_Queue ids; - - // Retrieve the type struct - CosTradingRepos::ServiceTypeRepository::TypeStruct_var type_struct = - rep->fully_describe_type (type, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN_VOID (TAO_IN_ENV); - - // Try to find the map of offers of desired service type. - // @@ Again, should be Offer_Database::offer_iterator - { -#if defined(_MSC_VER) - TAO_Offer_Database::offer_iterator - offer_iter (type, offer_database); -#else - // MSVC won't grok this for some reason, but it's necessary for the - // HP compiler, which seriously requires the typename keyword - // here. I apologize if this ifdef offends some ACE users' - // sensibilities --- it certainly offends mine. - ACE_TYPENAME TAO_Offer_Database::offer_iterator - offer_iter (type, offer_database); -#endif - - TAO_Constraint_Validator validator (type_struct.in ()); - TAO_Constraint_Interpreter constr_inter (validator, constr, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN_VOID (TAO_IN_ENV); - - while (offer_iter.has_more_offers ()) - { - CosTrading::Offer* offer = offer_iter.get_offer (); - // Add offer if it matches the constraints - - TAO_Constraint_Evaluator evaluator (offer, dp_support); - if (constr_inter.evaluate (evaluator)) - ids.enqueue_tail (offer_iter.get_id ()); - - offer_iter.next_offer (); - } - } - - if (ids.size () != 0) - { - while (! ids.is_empty ()) - { - char* offer_id = 0; - - ids.dequeue_head (offer_id); - offer_database.remove_offer (offer_id, TAO_IN_ENV); - CORBA::string_free (offer_id); - } - } - else - TAO_THROW (CosTrading::Register::NoMatchingOffers (constr)); -} - -template -CosTrading::Register_ptr -TAO_Register:: -resolve (const CosTrading::TraderName &name, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::Register::IllegalTraderName, - CosTrading::Register::UnknownTraderName, - CosTrading::Register::RegisterNotSupported)) -{ - // Determine if the first link is a legal link name. - if (! TAO_Trader_Base::is_valid_identifier_name (name[0])) - TAO_THROW_RETURN (CosTrading::Register::IllegalTraderName (name), - CosTrading::Register::_nil ()); - - // Grab a reference to the link interface, and get a link description. - CosTrading::Link_ptr link_if = - this->trader_.trading_components ().link_if (); - - // Ensure that the link interface is supported. - if (! CORBA::is_nil (link_if)) - return CosTrading::Register::_nil (); - - CosTrading::Link::LinkInfo_var link_info; - CosTrading::Register_var remote_reg; - - TAO_TRY - { - // Ensure that the link to the next trader exists. - link_info = link_if->describe_link (name[0], TAO_TRY_ENV); - TAO_CHECK_ENV; - - remote_reg = - CosTrading::Register::_narrow (link_info->target_reg.in (), TAO_TRY_ENV); - TAO_CHECK_ENV; - } - TAO_CATCHANY - { - TAO_THROW_RETURN (CosTrading::Register::UnknownTraderName (name), - CosTrading::Register::_nil ()); - } - TAO_ENDTRY; - - // Ensure that the register pointer isn't nil. - if (! CORBA::is_nil (remote_reg.in ())) - TAO_THROW_RETURN (CosTrading::Register::RegisterNotSupported (name), - CosTrading::Register::_nil ()); - - CosTrading::Register_ptr return_value = remote_reg.in (); - - if (name.length () > 1) - { - // Create a new Trader Name with the first link removed. - CosTrading::TraderName trader_name (name.length () - 1); - for (int i = trader_name.length () - 1; i >= 0; i--) - trader_name[i] = name[i + 1]; - - return_value = remote_reg->resolve (trader_name, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, CosTrading::Register::_nil ()); - } - - return return_value; -} - -template -void -TAO_Register:: -validate_properties (const char* type, - const CosTradingRepos::ServiceTypeRepository::TypeStruct* type_struct, - const CosTrading::PropertySeq& properties, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::IllegalPropertyName, - CosTrading::PropertyTypeMismatch, - CosTrading::ReadonlyDynamicProperty, - CosTrading::MissingMandatoryProperty, - CosTrading::DuplicatePropertyName)) -{ - CORBA::ULong length = properties.length (); - const CosTradingRepos::ServiceTypeRepository::PropStructSeq& - prop_types = type_struct->props; - TAO_Property_Evaluator_By_Name prop_eval (properties, TAO_IN_ENV); - TAO_CHECK_ENV_RETURN_VOID (TAO_IN_ENV); - - // Perform property validation - length = prop_types.length (); - for (CORBA::ULong i = 0; i < length; i++) - { - const CosTradingRepos::ServiceTypeRepository::PropStruct& - prop_struct = prop_types[i]; - const char* prop_name = prop_struct.name; - - // Obtain the type of the exported property. - CORBA::TypeCode_var prop_type = prop_eval.property_type (prop_name); - - if (CORBA::is_nil (prop_type.in ())) - { - // Offer cannot have a missing mandatory property. - if (prop_types[i].mode == - CosTradingRepos::ServiceTypeRepository::PROP_MANDATORY) - TAO_THROW (CosTrading::MissingMandatoryProperty (type, prop_name)); - } - else - { - if (! prop_type->equal (prop_struct.value_type.in (), TAO_IN_ENV)) - { - // Offer cannot redefine the type of an property. - const CosTrading::Property* prop = prop_eval.get_property (prop_name); - TAO_THROW (CosTrading::PropertyTypeMismatch (type, *prop)); - } - else if (prop_struct.mode == - CosTradingRepos::ServiceTypeRepository::PROP_READONLY && - prop_eval.is_dynamic_property (prop_name)) - TAO_THROW (CosTrading::ReadonlyDynamicProperty (type, prop_name)); - } - } -} - - // ************************************************************* - // TAO_Admin - // ************************************************************* - -template -TAO_Admin:: -TAO_Admin (TAO_Trader &trader) - : TAO_Trader_Components (trader.trading_components ()), - TAO_Support_Attributes (trader.support_attributes ()), - TAO_Import_Attributes (trader.import_attributes ()), - TAO_Link_Attributes (trader.link_attributes ()), - trader_ (trader), - sequence_number_ (0) -{ - // A random 4-bytes will prefix the sequence number space for each - // trader, making it extremely unlikely that the sequence spaces for - // two traders will over lap. - // @@ TODO: This is a bad way to generate pseudo random numbers. - size_t time_value = ACE_OS::time (); - ACE_RANDR_TYPE seed = ACE_static_cast(ACE_RANDR_TYPE, time_value); - - this->stem_id_.length (8); - this->stem_id_[0] = ACE_static_cast (CORBA::Octet, ACE_OS::rand_r (seed) % 256); - this->stem_id_[1] = ACE_static_cast (CORBA::Octet, ACE_OS::rand_r (seed) % 256); - this->stem_id_[2] = ACE_static_cast (CORBA::Octet, ACE_OS::rand_r (seed) % 256); - this->stem_id_[3] = ACE_static_cast (CORBA::Octet, ACE_OS::rand_r (seed) % 256); -} - -template -TAO_Admin::~TAO_Admin (void) -{ -} - -template -CosTrading::Admin::OctetSeq * -TAO_Admin::request_id_stem (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - ACE_GUARD_RETURN (TRADER_LOCK_TYPE, trader_mon, this->lock_, 0); - - // Add one to the sequence_number and concatenate it to the unique - // prefix. The sequence number is four octets long, the unique - // prefix, also 4 bytes long. - - this->stem_id_[4] = this->sequence_number_ & 0xff; - this->stem_id_[5] = (this->sequence_number_ >> 8) & 0xff; - this->stem_id_[6] = (this->sequence_number_ >> 16) & 0xff; - this->stem_id_[7] = (this->sequence_number_ >> 24) & 0xff; - - // Increment the sequence number and return a copy of the stem_id. - this->sequence_number_++; - return new CosTrading::Admin::OctetSeq (this->stem_id_); -} - -template -CORBA::ULong -TAO_Admin:: -set_def_search_card (CORBA::ULong value, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::ULong return_value = - this->trader_.import_attributes ().def_search_card (); - - this->trader_.import_attributes ().def_search_card (value); - return return_value; -} - -template -CORBA::ULong -TAO_Admin:: -set_max_search_card (CORBA::ULong value, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::ULong return_value = - this->trader_.import_attributes ().max_search_card (); - - this->trader_.import_attributes ().max_search_card (value); - return return_value; -} - -template -CORBA::ULong -TAO_Admin:: -set_def_match_card (CORBA::ULong value, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::ULong return_value = - this->trader_.import_attributes ().def_match_card (); - - this->trader_.import_attributes ().def_match_card (value); - return return_value; -} - -template -CORBA::ULong -TAO_Admin:: -set_max_match_card (CORBA::ULong value, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::ULong return_value = - this->trader_.import_attributes ().max_match_card (); - - this->trader_.import_attributes ().max_match_card (value); - return return_value; -} - -template -CORBA::ULong -TAO_Admin:: -set_def_return_card (CORBA::ULong value, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::ULong return_value = - this->trader_.import_attributes ().def_return_card (); - - this->trader_.import_attributes ().def_return_card (value); - return return_value; -} - -template -CORBA::ULong -TAO_Admin:: -set_max_return_card (CORBA::ULong value, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::ULong return_value = - this->trader_.import_attributes ().max_return_card (); - - this->trader_.import_attributes ().max_return_card (value); - return return_value; -} - -template -CORBA::ULong -TAO_Admin:: -set_max_list (CORBA::ULong value, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::ULong return_value = - this->trader_.import_attributes ().max_list (); - - this->trader_.import_attributes ().max_list (value); - return return_value; -} - -template -CORBA::Boolean -TAO_Admin:: -set_supports_modifiable_properties (CORBA::Boolean value, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::Boolean return_value = - this->trader_.support_attributes ().supports_modifiable_properties (); - - this->trader_.support_attributes ().supports_modifiable_properties (value); - return return_value; -} - -template -CORBA::Boolean -TAO_Admin:: -set_supports_dynamic_properties (CORBA::Boolean value, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::Boolean return_value = - this->trader_.support_attributes ().supports_dynamic_properties (); - - this->trader_.support_attributes ().supports_dynamic_properties (value); - return return_value; -} - -template -CORBA::Boolean -TAO_Admin:: -set_supports_proxy_offers (CORBA::Boolean value, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::Boolean return_value = - this->trader_.support_attributes ().supports_proxy_offers (); - - this->trader_.support_attributes ().supports_proxy_offers (value); - return return_value; -} - -template -CORBA::ULong -TAO_Admin:: -set_def_hop_count (CORBA::ULong value, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::ULong return_value = - this->trader_.import_attributes ().def_hop_count (); - - this->trader_.import_attributes ().def_hop_count (value); - return return_value; -} - -template -CORBA::ULong -TAO_Admin:: -set_max_hop_count (CORBA::ULong value, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::ULong return_value = - this->trader_.import_attributes ().max_hop_count (); - - this->trader_.import_attributes ().max_hop_count (value); - return return_value; -} - -template -CosTrading::FollowOption -TAO_Admin:: -set_def_follow_policy (CosTrading::FollowOption policy, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CosTrading::FollowOption return_value = - this->trader_.import_attributes ().def_follow_policy (); - - this->trader_.import_attributes ().def_follow_policy (policy); - return return_value; -} - -template -CosTrading::FollowOption -TAO_Admin:: -set_max_follow_policy (CosTrading::FollowOption policy, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CosTrading::FollowOption return_value = - this->trader_.import_attributes ().max_follow_policy (); - - this->trader_.import_attributes ().max_follow_policy (policy); - return return_value; -} - -template -CosTrading::FollowOption -TAO_Admin:: -set_max_link_follow_policy (CosTrading::FollowOption policy, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CosTrading::FollowOption return_value = - this->trader_.link_attributes ().max_link_follow_policy (); - - this->trader_.link_attributes ().max_link_follow_policy (policy); - return return_value; -} - -template -CosTrading::TypeRepository_ptr -TAO_Admin:: -set_type_repos (CosTrading::TypeRepository_ptr repository, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - CosTrading::TypeRepository_ptr return_value = - this->trader_.support_attributes ().type_repos (); - - this->trader_.support_attributes ().type_repos (repository); - return return_value; -} - -template -CosTrading::Admin::OctetSeq* -TAO_Admin:: -set_request_id_stem (const CosTrading::Admin::OctetSeq& stem, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - ACE_GUARD_RETURN (TRADER_LOCK_TYPE, trader_mon, this->lock_, &this->stem_id_); - this->stem_id_ = stem; - return &this->stem_id_; -} - -template -void -TAO_Admin:: -list_offers (CORBA::ULong how_many, - CosTrading::OfferIdSeq_out ids, - CosTrading::OfferIdIterator_out id_itr, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, CosTrading::NotImplemented)) -{ - // This method only applies when the register interface is implemented - if (CORBA::is_nil (this->trader_.trading_components().register_if())) - TAO_THROW (CosTrading::NotImplemented()); - - TAO_Offer_Database& type_map = this->trader_.offer_database (); - TAO_Offer_Id_Iterator* offer_id_iter = type_map.retrieve_all_offer_ids (); - - id_itr = CosTrading::OfferIdIterator::_nil (); - if (how_many > 0) - { - if (offer_id_iter->next_n (how_many, ids, TAO_IN_ENV) == 1) - { - id_itr = offer_id_iter->_this (TAO_IN_ENV); - TAO_CHECK_ENV_RETURN_VOID (TAO_IN_ENV); - } - else - delete offer_id_iter; - } - else - ids = new CosTrading::OfferIdSeq (0); -} - -template -void -TAO_Admin:: -list_proxies (CORBA::ULong how_many, - CosTrading::OfferIdSeq_out ids, - CosTrading::OfferIdIterator_out id_itr, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::NotImplemented)) -{ - TAO_THROW (CosTrading::NotImplemented ()); -} - - // ************************************************************* - // TAO_Link - // ************************************************************* - -template -TAO_Link::TAO_Link (TAO_Trader &trader) - : TAO_Trader_Components (trader.trading_components ()), - TAO_Support_Attributes (trader.support_attributes ()), - TAO_Link_Attributes (trader.link_attributes ()), - trader_ (trader) -{ -} - -template -TAO_Link::~TAO_Link (void) -{ -} - -template -void -TAO_Link:: -add_link (const char *name, - CosTrading::Lookup_ptr target, - CosTrading::FollowOption def_pass_on_follow_rule, - CosTrading::FollowOption limiting_follow_rule, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::Link::IllegalLinkName, - CosTrading::Link::DuplicateLinkName, - CosTrading::InvalidLookupRef, - CosTrading::Link::DefaultFollowTooPermissive, - CosTrading::Link::LimitingFollowTooPermissive)) -{ - // Ensure the link name is valid. - if (! TAO_Trader_Base::is_valid_identifier_name (name)) - TAO_THROW (CosTrading::Link::IllegalLinkName (name)); - - // Ensure this isn't a duplicate link name. - TAO_String_Hash_Key link_name (name); - if (this->links_.find (link_name) == 0) - TAO_THROW (CosTrading::Link::DuplicateLinkName (name)); - - // Ensure the lookup_ptr isn't nil. - if (CORBA::is_nil (target)) - TAO_THROW (CosTrading::InvalidLookupRef (target)); - - // Ensure that the default link behavior isn't stronger than the - // limiting link behavior. - if (def_pass_on_follow_rule > limiting_follow_rule) - TAO_THROW (CosTrading::Link::DefaultFollowTooPermissive - (def_pass_on_follow_rule, limiting_follow_rule)); - - // Ensure that the limiting link behavior for this link doesn't - // exceed the maximum allowed for a link. - if (limiting_follow_rule < this->max_link_follow_policy (TAO_IN_ENV)) - TAO_THROW (CosTrading::Link::LimitingFollowTooPermissive - (limiting_follow_rule, this->max_link_follow_policy (TAO_IN_ENV))); - - // Create a link info structure for this link of the federation. - CosTrading::Link::LinkInfo link_info; - - link_info.target = CosTrading::Lookup::_duplicate (target); - - link_info.def_pass_on_follow_rule = def_pass_on_follow_rule; - link_info.limiting_follow_rule = limiting_follow_rule; - TAO_CHECK_ENV_RETURN_VOID (TAO_IN_ENV); - - // Insert this link into the collection of links. - this->links_.bind (link_name, link_info); -} - -template -void -TAO_Link:: -remove_link (const char *name, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::Link::IllegalLinkName, - CosTrading::Link::UnknownLinkName)) -{ - // Ensure the link name is valid. - if (! TAO_Trader_Base::is_valid_identifier_name (name)) - TAO_THROW (CosTrading::Link::IllegalLinkName (name)); - - // Ensure this isn't a duplicate link name. - TAO_String_Hash_Key link_name (name); - if (this->links_.find (link_name) == -1) - TAO_THROW (CosTrading::Link::UnknownLinkName (name)); - - // Erase the link state from the map. - this->links_.unbind (link_name); -} - -template -CosTrading::Link::LinkInfo * -TAO_Link::describe_link (const char *name, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::Link::IllegalLinkName, - CosTrading::Link::UnknownLinkName)) -{ - // Ensure the link name is valid. - if (! TAO_Trader_Base::is_valid_identifier_name (name)) - TAO_THROW_RETURN (CosTrading::Link::IllegalLinkName (name), 0); - - // Ensure this isn't a duplicate link name. - ACE_TYPENAME Links::ENTRY* link_entry = 0; - TAO_String_Hash_Key link_name (name); - if (this->links_.find (link_name, link_entry) == -1) - TAO_THROW_RETURN (CosTrading::Link::UnknownLinkName (name), 0); - - // Build a new Link Info structure. - CosTrading::Link::LinkInfo* new_link_info = 0; - CosTrading::Link::LinkInfo& old_link_info = link_entry->int_id_; - - ACE_NEW_RETURN (new_link_info, CosTrading::Link::LinkInfo, 0); - - new_link_info->def_pass_on_follow_rule = old_link_info.def_pass_on_follow_rule; - new_link_info->limiting_follow_rule = old_link_info.limiting_follow_rule; - - new_link_info->target = old_link_info.target; - - // Delayed retrieval of register interface. - // This avoids the nested upcall that would occur were we to invoke - // this method in the add_link method. - - new_link_info->target_reg = old_link_info.target->register_if (TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, new_link_info); - - // return the link information for this link name. - return new_link_info; -} - -template -CosTrading::LinkNameSeq* -TAO_Link::list_links (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - // Allocate space for the link names. - CORBA::ULong size = this->links_.current_size (), i = 0; - CosTrading::LinkName* link_seq = - CosTrading::LinkNameSeq::allocbuf (size); - - // Copy the link names into the buffer. - for (ACE_TYPENAME Links::iterator links_iter (this->links_); - ! links_iter.done (); - links_iter++) - link_seq[i++] = CORBA::string_dup ((*links_iter).ext_id_.in ()); - - // Return a sequence of the buf names. - return new CosTrading::LinkNameSeq (i, i, link_seq, 1); -} - -template -void -TAO_Link:: -modify_link (const char *name, - CosTrading::FollowOption def_pass_on_follow_rule, - CosTrading::FollowOption limiting_follow_rule, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::Link::IllegalLinkName, - CosTrading::Link::UnknownLinkName, - CosTrading::Link::DefaultFollowTooPermissive, - CosTrading::Link::LimitingFollowTooPermissive)) -{ - // Ensure the link name is valid. - if (! TAO_Trader_Base::is_valid_identifier_name (name)) - TAO_THROW (CosTrading::Link::IllegalLinkName (name)); - - // Ensure this isn't a duplicate link name. - ACE_TYPENAME Links::ENTRY* link_entry = 0; - TAO_String_Hash_Key link_name (name); - if (this->links_.find (link_name, link_entry) == -1) - TAO_THROW (CosTrading::Link::UnknownLinkName (name)); - - // Ensure that the default link behavior isn't stronger than the - // limiting link behavior. - if (def_pass_on_follow_rule > limiting_follow_rule) - TAO_THROW (CosTrading::Link::DefaultFollowTooPermissive - (def_pass_on_follow_rule, limiting_follow_rule)); - - // Ensure that the limiting link behavior for this link doesn't - // exceed the maximum allowed for a link. - if (limiting_follow_rule < this->max_link_follow_policy (TAO_IN_ENV)) - TAO_THROW (CosTrading::Link::LimitingFollowTooPermissive - (limiting_follow_rule, this->max_link_follow_policy (TAO_IN_ENV))); - - // Adjust the link settings - CosTrading::Link::LinkInfo& link_info = link_entry->int_id_; - link_info.def_pass_on_follow_rule = def_pass_on_follow_rule; - link_info.limiting_follow_rule = limiting_follow_rule; -} - - // ************************************************************* - // TAO_Proxy - // ************************************************************* - -template -TAO_Proxy:: -TAO_Proxy (TAO_Trader &trader) - : TAO_Trader_Components (trader.trading_components ()), - TAO_Support_Attributes (trader.support_attributes ()), - trader_ (trader) -{ -} - -template -TAO_Proxy::~TAO_Proxy (void) -{ -} - -template -CosTrading::OfferId -TAO_Proxy:: -export_proxy (CosTrading::Lookup_ptr target, - const char *type, - const CosTrading::PropertySeq& properties, - CORBA::Boolean if_match_all, - const char * recipe, - const CosTrading::PolicySeq& policies_to_pass_on, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTrading::InvalidLookupRef, - CosTrading::IllegalPropertyName, - CosTrading::PropertyTypeMismatch, - CosTrading::ReadonlyDynamicProperty, - CosTrading::MissingMandatoryProperty, - CosTrading::Proxy::IllegalRecipe, - CosTrading::DuplicatePropertyName, - CosTrading::DuplicatePolicyName)) -{ - TAO_THROW_RETURN (CORBA::UNKNOWN (CORBA::COMPLETED_NO), 0); -} - -template -void -TAO_Proxy:: -withdraw_proxy (const char *id, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId, - CosTrading::Proxy::NotProxyOfferId)) -{ - TAO_THROW (CORBA::UNKNOWN (CORBA::COMPLETED_NO)); -} - -template -CosTrading::Proxy::ProxyInfo * -TAO_Proxy:: -describe_proxy (const char *id, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId, - CosTrading::Proxy::NotProxyOfferId)) -{ - TAO_THROW_RETURN (CORBA::UNKNOWN (CORBA::COMPLETED_NO), 0); -} - -template -void -TAO_Proxy:: -list_proxies (CORBA::ULong how_many, - CosTrading::OfferIdSeq*& ids, - CosTrading::OfferIdIterator_ptr& id_itr, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::NotImplemented)) -{ - TAO_THROW (CORBA::UNKNOWN (CORBA::COMPLETED_NO)); -} - -#endif /* TAO_TRADER_INTERFACES_C */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Trader_Interfaces.h b/TAO/orbsvcs/orbsvcs/Trader/Trader_Interfaces.h deleted file mode 100644 index 4e8086f8d96..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Trader_Interfaces.h +++ /dev/null @@ -1,1000 +0,0 @@ -/* -*- C++ -*- */ - -// ======================================================================== -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Trader_Interfaces.h -// -// = AUTHOR -// Marina Spivak -// Seth Widoff -// Irfan Pyarali -// -// ======================================================================== - -#ifndef TAO_TRADER_INTERFACES_H -#define TAO_TRADER_INTERFACES_H - -#include "Trader_Utils.h" -#include "Constraint_Interpreter.h" -#include "Offer_Iterators_T.h" - -// Hack because g++ forced this inane circular dependecy! - -class TAO_Constraint_Interpreter; -class TAO_Constraint_Evaluator; -class TAO_Constraint_Validator; -class TAO_Preference_Interpreter; - -template class TAO_Lookup; -template class TAO_Register; -template class TAO_Admin; -template class TAO_Proxy; -template class TAO_Link; - -#include "Trader_T.h" - - // ************************************************************* - // TAO_Lookup - // ************************************************************* - -template -class TAO_Lookup : - public TAO_Trader_Components, - public TAO_Support_Attributes, - public TAO_Import_Attributes -// -// = TITLE -// This class implements CosTrading::Lookup IDL interface. -{ -public: - - TAO_Lookup (TAO_Trader &trader); - - ~TAO_Lookup (void); - - virtual void - query (const char *type, - const char *constr, - const char *pref, - const CosTrading::PolicySeq& policies, - const CosTrading::Lookup::SpecifiedProps& desired_props, - CORBA::ULong how_many, - CosTrading::OfferSeq_out offers, - CosTrading::OfferIterator_out offer_itr, - CosTrading::PolicyNameSeq_out limits_applied, - CORBA::Environment& env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTrading::IllegalConstraint, - CosTrading::Lookup::IllegalPreference, - CosTrading::Lookup::IllegalPolicyName, - CosTrading::Lookup::PolicyTypeMismatch, - CosTrading::Lookup::InvalidPolicyValue, - CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName, - CosTrading::DuplicatePolicyName)); - - // BEGIN SPEC - // The query operation is the means by which an object can obtain - // references to other objects that provide services meeting its - // requirements. - - // The "type" parameter conveys the required service type. It is key - // to the central purpose of trading: to perform an introduction for - // future type safe interactions between importer and exporter. By - // stating a service type, the importer implies the desired interface - // type and a domain of discourse for talking about properties of the - // service. - - // The trader may return a service offer of a subtype of the "type" - // requested. Sub-typing of service types is discussed in "Service - // Types" on page 16-4. A service subtype can be described by the - // properties of its supertypes. This ensures that a well-formed - // query for the "type" is also a well-formed query with respect to - // any subtypes. However, if the importer specifies the policy of - // exact_type_match = TRUE, then only offers with the exact (no - // subtype) service type requested are returned. - - // The constraint "constr" is the means by which the importer states - // those requirements of a service that are not captured in the - // signature of the interface. These requirements deal with the - // computational behavior of the desired service, non-functional - // aspects, and non-computational aspects (such as the organization - // owning the objects that provide the service). An importer is - // always guaranteed that any returned offer satisfies the matching - // constraint at the time of import. If the "constr" does not obey - // the syntax rules for a legal constraint expression, then an - // IllegalConstraint exception is raised. - - // The "pref" parameter is also used to order those offers that - // match the "constr" so that the offers returned by the trader are - // in the order of greatest interest to the importer. If "pref" does - // not obey the syntax rules for a legal preference expression, then - // an IllegalPreference exception is raised. - - // The "policies" parameter allows the importer to specify how the - // search should be performed as opposed to what sort of services - // should be found in the course of the search. This can be viewed - // as parameterizing the algorithms within the trader - // implementation. The "policies" are a sequence of name-value - // pairs. The names available to an importer depend on the - // implementation of the trader. However, some names are - // standardized where they effect the interpretation of other - // parameters or where they may impact linking and federation of - // traders. - - // The "desired_props" parameter defines the set of properties - // describing returned offers that are to be returned with the - // object reference. There are three possibilities, the importer - // wants one of the properties, all of the properties (but without - // having to name them), or some properties (the names of which are - // provided). - - // The desired_props parameter does not affect whether or not a - // service offer is returned. To avoid "missing" desired properties, - // the importer should specify "exists prop_name" in the - // constraint. - - // The returned offers are passed back in one of two ways (or a - // combination of both). °The "offers" return result conveys a list - // of offers and the "offer_itr" is a reference to an interface at - // which offers can be obtained. The "how_many" parameter states - // how many offers are to be returned via the "offers" result, any - // remaining offers are available via the iterator interface. If the - // "how_many" exceeds the number of offers to be returned, then the - // "offer_itr" will be nil. - - // If any cardinality or other limits were applied by one or more - // traders in responding to a particular query, then the - // "limits_applied" parameter will contain the names of the policies - // which limited the query. The sequence of names returned in - // "limits_applied" from any federated or proxy queries must be - // concatenated onto the names of limits applied locally and - // returned. - // END SPEC - -private: - - TAO_Offer_Iterator* create_offer_iterator (const TAO_Property_Filter&); - // Factory method for creating an appropriate Offer Iterator based - // on the presence of the Register Interface. - - void lookup_all_subtypes (const char* type, - CosTradingRepos::ServiceTypeRepository::IncarnationNumber& inc_num, - TAO_Offer_Database& offer_database, - CosTradingRepos::ServiceTypeRepository_ptr rep, - TAO_Constraint_Interpreter& constr_inter, - TAO_Preference_Interpreter& pref_inter, - TAO_Offer_Filter& offer_filter); - // Traverse the type hierarchy to pull the matching offers from all - // subtypes of the root type. - - void lookup_one_type (const char* type, - TAO_Offer_Database& offer_database, - TAO_Constraint_Interpreter& constr_inter, - TAO_Preference_Interpreter& pref_inter, - TAO_Offer_Filter& offer_filter); - // Check if offers of a type fit the constraints and order them - // according to the preferences submitted. - - int fill_receptacles (const char *, - CORBA::ULong how_many, - const CosTrading::Lookup::SpecifiedProps& desired_props, - TAO_Policies& policies, - TAO_Preference_Interpreter& pref_inter, - CosTrading::OfferSeq& offers, - CosTrading::OfferIterator_ptr& offer_itr, - CORBA::Environment& env) - TAO_THROW_SPEC ((CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName)); - // This method takes the list of ordered offers and places a number - // of them in the sequence of returned offers and the rest into thr - // iterator. In addition, fill_receptacles uses the - // TAO_Property_Filter to ensure the returned offers contain the - // properties specified in the desired_props in parameter. - - void forward_query (const char* next_hop, - const char *type, - const char *constr, - const char *pref, - const CosTrading::PolicySeq& policy_seq, - const CosTrading::Lookup::SpecifiedProps& desired_props, - CORBA::ULong how_many, - CosTrading::OfferSeq_out offers, - CosTrading::OfferIterator_out offer_itr, - CosTrading::PolicyNameSeq_out limits_applied, - CORBA::Environment& env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTrading::IllegalConstraint, - CosTrading::Lookup::IllegalPreference, - CosTrading::Lookup::IllegalPolicyName, - CosTrading::Lookup::PolicyTypeMismatch, - CosTrading::Lookup::InvalidPolicyValue, - CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName, - CosTrading::DuplicatePolicyName)); - // If a starting_trader policy was specfied, foward the query to the - // next link in the sequence. - - CORBA::Boolean retrieve_links (TAO_Policies& policies, - CORBA::ULong offer_returned, - CosTrading::LinkNameSeq_out links, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::Lookup::PolicyTypeMismatch)); - // Assemble a sequence of links that the federate_query method - // should follow. Use the starting_trader policy, if one's provided, - // otherwise use the Link interface to determine which of the - // registered links should be followed in this query. - - void federated_query (const CosTrading::LinkNameSeq& links, - const TAO_Policies& policies, - const CosTrading::Admin::OctetSeq& request_id, - TAO_Preference_Interpreter& pref_inter, - const char *type, - const char *constr, - const char *pref, - const CosTrading::Lookup::SpecifiedProps& desired_props, - CORBA::ULong how_many, - CosTrading::OfferSeq& offers, - CosTrading::OfferIterator_ptr& offer_itr, - CosTrading::PolicyNameSeq& limits_applied, - CORBA::Environment& env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTrading::IllegalConstraint, - CosTrading::Lookup::IllegalPreference, - CosTrading::Lookup::IllegalPolicyName, - CosTrading::Lookup::PolicyTypeMismatch, - CosTrading::Lookup::InvalidPolicyValue, - CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName, - CosTrading::DuplicatePolicyName)); - // Perform and pass on a query over a set of links. Merge the - // results of the federated queries into a single set of results - // suitable for returning to the user. - - void order_merged_sequence (TAO_Preference_Interpreter& pref_inter, - CosTrading::OfferSeq& offers); - // Merge the results from a federated query into the collected results. - - CORBA::Boolean seen_request_id (TAO_Policies& policies, - CosTrading::Admin::OctetSeq*& seq, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::Lookup::PolicyTypeMismatch)); - - // = Disallow these operations. - ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Lookup &)) - ACE_UNIMPLEMENTED_FUNC (TAO_Lookup (const TAO_Lookup &)) - - const unsigned int IDS_SAVED; - - TAO_Trader &trader_; - // A reference to the trader for obtaining offer maps. - - typedef ACE_Unbounded_Queue Request_Ids; - - Request_Ids request_ids_; - // A list of recent request_id_stems - - TRADER_LOCK_TYPE lock_; - // Lock to secure the set of request ids. -}; - - - // ************************************************************* - // TAO_Register - // ************************************************************* - -template -class TAO_Register : - public TAO_Trader_Components, - public TAO_Support_Attributes - // - // = TITLE - // This class implements CosTrading::Register IDL interface. -{ -public: - - TAO_Register (TAO_Trader &trader); - - virtual ~TAO_Register (void); - - virtual CosTrading::OfferId export (CORBA::Object_ptr reference, - const char *type, - const CosTrading::PropertySeq& properties, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::Register::InvalidObjectRef, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTrading::Register::InterfaceTypeMismatch, - CosTrading::IllegalPropertyName, - CosTrading::PropertyTypeMismatch, - CosTrading::ReadonlyDynamicProperty, - CosTrading::MissingMandatoryProperty, - CosTrading::DuplicatePropertyName)); - - // BEGIN SPEC - // The export operation is the means by which a service is - // advertised, via a trader, to a community of potential - // importers. The OfferId returned is the handle with which the - // exporter can identify the exported offer when attempting to - // access it via other operations. The OfferId is only meaningful in - // the context of the trader that generated it. - - // The "reference" parameter is the information that enables a client - // to interact with a remote server. If a trader implementation chooses - // to consider certain types of object references (e.g., a nil object - // reference) to be unexportable, then it may return the InvalidObjectRef - // exception in such cases. - - // The "type" parameter - // identifies the service type, which contains the interface type of - // the "reference" and a set of named property types that may be - // used in further describing this offer (i.e., it restricts what is - // acceptable in the properties parameter). ° - - // If the string - // representation of the "type" does not obey the rules for - // identifiers, then an IllegalServiceType exception is raised. ° If - // the "type" is correct syntactically but a trader is able to - // unambiguously determine that it is not a recognized service type, - // then an UnknownServiceType exception is raised. ° - - // If the trader - // can determine that the interface type of the "reference" - // parameter is not a subtype of the interface type specified in - // "type," then an InterfaceTypeMismatch exception is raised. The - // "properties" parameter is a list of named values that conform to - // the property value types defined for those names. They describe - // the service being offered. This description typically covers - // behavioral, non-functional, and non-computational aspects of the - // service. ° - - // If any of the property names do not obey the syntax - // rules for PropertyNames, then an IllegalPropertyName exception is - // raised. ° - - // If the type of any of the property values is not the - // same as the declared type (declared in the service type), then a - // PropertyTypeMismatch exception is raised. - - // ° If an attempt is made to assign a dynamic property value to a - // readonly property, then the ReadonlyDynamicProperty exception is - // raised. ° If the "properties" parameter omits any property - // declared in the service type with a mode of mandatory, then a - // MissingMandatoryProperty exception is raised. ° If two or more - // properties with the same property name are included in this - // parameter, the DuplicatePropertyName exception is raised. - // END SPEC - - virtual void withdraw (const char *id, CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId, - CosTrading::Register::ProxyOfferId)); - - // BEGIN SPEC - // The withdraw operation removes the service offer from the trader - // (i.e., after withdraw the offer can no longer be returned as the - // result of a query). The offer is identified by the "id" parameter - // which was originally returned by export. ° If the string - // representation of "id" does not obey the rules for offer - // identifiers, then an IllegalOfferId exception is raised. ° If the - // "id" is legal but there is no offer within the trader with that - // "id," then an UnknownOfferId exception is raised. ° If the "id" - // identifies a proxy offer rather than an ordinary offer, then a - // ProxyOfferId exception is raised. - // END SPEC - - virtual CosTrading::Register::OfferInfo* - describe (const char * id, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId, - CosTrading::Register::ProxyOfferId)); - - // BEGIN SPEC - // The describe operation returns the information about an offered - // service that is held by the trader. It comprises the "reference" - // of the offered service, the "type" of the service offer, and the - // "properties" that describe this offer of service. The offer is - // identified by the "id" parameter which was originally returned by - // export. ° If the string representation of "id" does not obey the - // rules for object identifiers, then an IllegalOfferId exception is - // raised. ° If the "id" is legal but there is no offer within the - // trader with that "id," then an UnknownOfferId exception is - // raised. ° If the "id" identifies a proxy offer rather than an - // ordinary offer, then a ProxyOfferId exception is raised. - // END SPEC - - virtual void modify (const char * id, - const CosTrading::PropertyNameSeq& del_list, - const CosTrading::PropertySeq& modify_list, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::NotImplemented, - CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId, - CosTrading::Register::ProxyOfferId, - CosTrading::IllegalPropertyName, - CosTrading::Register::UnknownPropertyName, - CosTrading::PropertyTypeMismatch, - CosTrading::ReadonlyDynamicProperty, - CosTrading::Register::MandatoryProperty, - CosTrading::Register::ReadonlyProperty, - CosTrading::DuplicatePropertyName)); - - // BEGIN SPEC - // The modify operation is used to change the description of a - // service as held within a service offer. The object reference and - // the service type associated with the offer cannot be - // changed. This operation may: ° add new (non-mandatory) properties - // to describe an offer, ° change the values of some existing (not - // readonly) properties, or ° delete existing (neither mandatory nor - // readonly) properties. - - // The modify operation either succeeds completely or it fails - // completely. The offer is identified by the "id" parameter which - // was originally returned by export. ° If the string representation - // of "id" does not obey the rules for offer identifiers, then an - // IllegalOfferId exception is raised. ° If the "id" is legal but - // there is no offer within the trader with that "id," then an - // UnknownOfferId exception is raised. ° If the "id" identifies a - // proxy offer rather than an ordinary offer, then a ProxyOfferId - // exception is raised. - - // The "del_list" parameter gives the names of the properties that - // are no longer to be recorded for the identified offer. Future - // query and describe operations will not see these properties. ° If - // any of the names within the "del_list" do not obey the rules for - // PropertyName's, then an IllegalPropertyName exception is - // raised. ° If a "name" is legal but there is no property for the - // offer with that "name," then an UnknownPropertyName exception is - // raised. ° If the list includes a property that has a mandatory - // mode, then the MandatoryProperty exception is raised. ° If the - // same property name is included two or more times in this - // parameter, the DuplicatePropertyName exception is raised. - - // The "modify_list" parameter gives the names and values of - // properties to be changed. If the property is not in the offer, - // then the modify operation adds it. The modified (or added) - // property values are returned in future query and describe - // operations in place of the original values. ° If any of the names - // within the "modify_list" do not obey the rules for - // PropertyName's, then an IllegalPropertyName exception is - // raised. ° If the list includes a property that has a readonly - // mode, then the ReadonlyProperty exception is raised unless that - // readonly property is not currently recorded for the offer. The - // ReadonlyDynamicProperty exception is raised if an attempt is made - // to assign a dynamic property value to a readonly property. ° If - // the value of any modified property is of a type that is not the - // same as the type expected, then the PropertyTypeMismatch - // exception is raised. ° If two or more properties with the same - // property name are included in this argument, the - // DuplicatePropertyName exception is raised. - - // The NotImplemented exception shall be raised if and only if the - // supports_modifiable_properties attribute yields FALSE. - // END SPEC - - virtual void withdraw_using_constraint (const char *type, - const char *constr, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTrading::IllegalConstraint, - CosTrading::Register::NoMatchingOffers)); - - // BEGIN SPEC - // The withdraw_using_constraint operation withdraws a set of offers - // from within a single trader. This set is identified in the same - // way that a query operation identifies a set of offers to be - // returned to an importer. - - // The "type" parameter conveys the required service type. Each - // offer of the specified type will have the constraint expression - // applied to it. If it matches the constraint expression, then the - // offer will be withdrawn.° If "type" does not obey the rules for - // service types, then an IllegalServiceType exception is raised. ° - // If the "type" is correct syntactically but is not recognized as a - // service type by the trader, then an UnknownServiceType exception - // is raised. - - // The constraint "constr" is the means by which the client - // restricts the set of offers to those that are intended for - // withdrawal. ° If "constr" does not obey the syntax rules for a - // constraint then an IllegalConstraint exception is raised. ° If - // the constraint fails to match with any offer of the specified - // service type, then a NoMatchingOffers exception is raised. - // END SPEC - - virtual CosTrading::Register_ptr - resolve (const CosTrading::TraderName &name, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::Register::IllegalTraderName, - CosTrading::Register::UnknownTraderName, - CosTrading::Register::RegisterNotSupported)); - - // BEGIN SPEC - // This operation is used to resolve a context relative name for - // another trader. In particular, it is used when exporting to a - // trader that is known by a name rather than by an object - // reference. The client provides the name, which will be a sequence - // of name components. ° If the content of the parameter cannot - // yield legal syntax for the first component, then the - // IllegalTraderName exception is raised. Otherwise, the first name - // component is compared against the name held in each link. ° If no - // match is found, or the trader does not support links, the - // UnknownTraderName exception is raised. Otherwise, the trader - // obtains the register_if held as part of the matched link. ° If - // the Register interface is not nil, then the trader binds to the - // Register interface and invokes resolve but passes the TraderName - // with the first component removed; if it is nil, then the - // RegisterNotSupported exception is raised. When a trader is able - // to match the first name component leaving no residual name, that - // trader returns the reference for the Register interface for that - // linked trader. In unwinding the recursion, intermediate traders - // return the Register interface reference to their client (another - // trader). - // END SPEC - - protected: - - void validate_properties (const char* type, - const CosTradingRepos::ServiceTypeRepository::TypeStruct* type_struct, - const CosTrading::PropertySeq& properties, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CosTrading::IllegalPropertyName, - CosTrading::PropertyTypeMismatch, - CosTrading::ReadonlyDynamicProperty, - CosTrading::MissingMandatoryProperty, - CosTrading::DuplicatePropertyName)); - - // = Disallow these operations. - ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Register &)) - ACE_UNIMPLEMENTED_FUNC (TAO_Register (const TAO_Register &)) - - private: - - TAO_Trader &trader_; -}; - - // ************************************************************* - // TAO_Admin - // ************************************************************* - -template -class TAO_Admin : - public TAO_Trader_Components , - public TAO_Support_Attributes , - public TAO_Import_Attributes , - public TAO_Link_Attributes -// -// = TITLE -// This class implements CosTrading::Admin IDL interface. -// -// = DESCRIPTION (FROM SPEC) -// -// The admin interface enables the values of the trader attributes to -// be read and written. All attributes are defined as readonly in -// either SupportAttributes, ImportAttributes, LinkAttributes, or -// Admin. To set the trader "attribute" to a new value, -// set_ operations are defined in Admin. Each of these -// set operations returns the previous value of the attribute as its -// function value. If the admin interface operation -// set_support_proxy_offers is invoked with a value set to FALSE in a -// trader which supports the proxy interface, the -// set_support_proxy_offer value does not affect the function of -// operations in the proxy interface. However, in this case, it does -// have the effect of making any proxy offers exported via the proxy -// interface for that trader unavailable to satisfy queries on that -// trader's lookup interface. -{ -public: - - TAO_Admin (TAO_Trader &trader); - - ~TAO_Admin (void); - - // = Importing Parameters (used by the Lookup Interface) - - virtual CORBA::ULong set_def_search_card (CORBA::ULong value, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - virtual CORBA::ULong set_max_search_card (CORBA::ULong value, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - // search card is the cardinality of the offers searched for - // constraint compliance. - - - virtual CORBA::ULong set_def_match_card (CORBA::ULong value, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - virtual CORBA::ULong set_max_match_card (CORBA::ULong value, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - // match card is the cardinality of offers found compliant with the - // constraints. - - virtual CORBA::ULong set_def_return_card (CORBA::ULong value, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - virtual CORBA::ULong set_max_return_card (CORBA::ULong value, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - // return card is the cardinality of the offers returned from - // Lookup. - - virtual CORBA::ULong set_max_list (CORBA::ULong value, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - virtual CORBA::Boolean - set_supports_modifiable_properties (CORBA::Boolean value, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - virtual CORBA::Boolean - set_supports_dynamic_properties (CORBA::Boolean value, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - virtual CORBA::Boolean - set_supports_proxy_offers (CORBA::Boolean value, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - // Types of offers available for consideration. Ween out those - // offers with modifiable properties - - // = Link Interface parameters - - virtual CORBA::ULong set_def_hop_count (CORBA::ULong value, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - virtual CORBA::ULong set_max_hop_count (CORBA::ULong value, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - virtual CosTrading::FollowOption - set_def_follow_policy (CosTrading::FollowOption policy, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - virtual CosTrading::FollowOption - set_max_follow_policy (CosTrading::FollowOption policy, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - virtual CosTrading::FollowOption - set_max_link_follow_policy (CosTrading::FollowOption policy, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - // = Set Type Repository - - virtual CosTrading::TypeRepository_ptr - set_type_repos (CosTrading::TypeRepository_ptr repository, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - virtual CosTrading::Admin::OctetSeq* - request_id_stem (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - virtual CosTrading::Admin::OctetSeq* - set_request_id_stem (const CosTrading::Admin::OctetSeq& stem, - CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - virtual void list_offers (CORBA::ULong how_many, - CosTrading::OfferIdSeq_out ids, - CosTrading::OfferIdIterator_out id_itr, - CORBA::Environment& env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::NotImplemented)); - - - // BEGIN SPEC - // The list_offers operation allows the administrator of a trader to - // perform housekeeping by obtaining a handle on each of the offers - // within a trader (e.g., for garbage collection etc.). Only the - // identifiers of ordinary offers are returned, identifiers of proxy - // offers are not returned via this operation. If the trader does - // not support the Register interface, the NotImplemented exception - // is raised. The returned identifiers are passed back in one of two - // ways (or a combination of both). ° The "ids" return result - // conveys a list of offer identifiers and the "id_itr" is a - // reference to an interface at which additional offer identities - // can be obtained. ° The "how_many" parameter states how many - // identifiers are to be returned via the "ids" result; any - // remaining are available via the iterator interface. If the - // "how_many" exceeds the number of offers held in the trader, then - // the "id_itr" is nil. - // END SPEC - - virtual void list_proxies (CORBA::ULong, - CosTrading::OfferIdSeq_out, - CosTrading::OfferIdIterator_out, - CORBA::Environment& env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::NotImplemented)); - -private: - - // = Disallow these operations. - ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Admin &)) - ACE_UNIMPLEMENTED_FUNC (TAO_Admin (const TAO_Admin &)) - - TAO_Trader &trader_; - - CosTrading::Admin::OctetSeq stem_id_; - // Unique prefix to create a sequence number space. - - CORBA::ULong sequence_number_; - // Current sequence number. - - TRADER_LOCK_TYPE lock_; -}; - - // ************************************************************* - // TAO_Link - // ************************************************************* - -template -class TAO_Link : - public TAO_Trader_Components , - public TAO_Support_Attributes , - public TAO_Link_Attributes -{ -public: - - TAO_Link (TAO_Trader &trader); - - ~TAO_Link (void); - - virtual void add_link (const char *name, - CosTrading::Lookup_ptr target, - CosTrading::FollowOption def_pass_on_follow_rule, - CosTrading::FollowOption limiting_follow_rule, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::Link::IllegalLinkName, - CosTrading::Link::DuplicateLinkName, - CosTrading::InvalidLookupRef, - CosTrading::Link::DefaultFollowTooPermissive, - CosTrading::Link::LimitingFollowTooPermissive)); - // BEGIN SPEC - // The add_link operation allows a trader subsequently to use the - // service of another trader in the performance of its own trading - // service operations. - - // The "name" parameter is used in subsequent link management - // operations to identify the intended link. If the parameter is not - // legally formed, then the IllegalLinkName exception is raised. An - // exception of DuplicateLinkName is raised if the link name already - // exists. The link name is also used as a component in a sequence - // of name components in naming a trader for resolving or forwarding - // operations. The sequence of context relative link names provides - // a path to a trader. - - // The "target" parameter identifies the Lookup interface at which - // the trading service provided by the target trader can be - // accessed. Should the Lookup interface parameter be nil, then an - // exception of InvalidLookupRef is raised. The target interface is - // used to obtain the associated Register interface, which will be - // subsequently returned as part of a describe_link operation and - // invoked as part of a resolve operation. - - // The "def_pass_on_follow_rule" parameter specifies the default - // link behavior for the link if no link behavior is specified on an - // importer's query request. If the "def_pass_on_follow_rule" - // exceeds the "limiting_follow_rule" specified in the next - // parameter, then a DefaultFollowTooPermissive exception is - // raised. - - // The "limiting_follow_rule" parameter specifies the most - // permissive link follow behavior that the link is willing to - // tolerate. The exception LimitingFollowTooPermissive is raised if - // this parameter exceeds the trader's attribute of - // "max_link_follow_policy" at the time of the link's creation. Note - // it is possible for a link's "limiting_follow_rule" to exceed the - // trader's "max_link_follow_policy" later in the life of a link, as - // it is possible that the trader could set its - // "max_link_follow_policy" to a more restrictive value after the - // creation of the link. - // END SPEC - - virtual void remove_link (const char *name, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::Link::IllegalLinkName, - CosTrading::Link::UnknownLinkName)); - - // BEGIN SPEC - // The remove_link operation removes all knowledge of the target - // trader. The target trader cannot be used subsequently to resolve, - // forward, or propagate trading operations from this trader. - - // The "name" parameter identifies the link to be removed. The - // exception IllegalLinkName is raised if the link is formed poorly - // and the UnknownLinkName exception is raised if the named link is - // not in the trader. - // END SPEC - - virtual CosTrading::Link::LinkInfo* describe_link (const char *name, - CORBA::Environment&) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::Link::IllegalLinkName, - CosTrading::Link::UnknownLinkName)); - - // BEGIN SPEC - // The describe_link operation returns information on a link held in - // the trader. - - // The "name" parameter identifies the link whose description is - // required. For a malformed link name, the exception - // IllegalLinkName is raised. An UnknownLinkName exception is raised - // if the named link is not found in the trader. - - // The operation returns a LinkInfo structure comprising: ° the - // Lookup interface of the target trading service, ° the Register - // interface of the target trading service, and ° the default, as - // well as the limiting follow behavior of the named link. - - // If the target service does not support the Register interface, - // then that field of the LinkInfo structure is nil. Given the - // description of the Register::resolve() operation in "Resolve - // Operation" on page 16-45, most implementations will opt for - // determining the Register interface when add_link is called and - // storing that information statically with the rest of the link - // state. - // END SPEC - - virtual CosTrading::LinkNameSeq* list_links (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - // BEGIN SPEC - // The list_links operation returns a list of the names of all - // trading links within the trader. The names can be used - // subsequently for other management operations, such as - // describe_link or remove_link. - // END SPEC - - virtual void modify_link (const char *name, - CosTrading::FollowOption def_pass_on_follow_rule, - CosTrading::FollowOption limiting_follow_rule, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CosTrading::Link::IllegalLinkName, - CosTrading::Link::UnknownLinkName, - CosTrading::Link::DefaultFollowTooPermissive, - CosTrading::Link::LimitingFollowTooPermissive)); - - // BEGIN SPEC - // The modify_link operation is used to change the existing link - // follow behaviors of an identified link. The Lookup interface - // reference of the target trader and the name of the link cannot be - // changed. - - // The "name" parameter identifies the link whose follow behaviors - // are to be changed. A poorly formed "name" raises the - // IllegalLinkName exception. An UnknownLinkName exception is raised - // if the link name is not known to the trader. - - // The "def_pass_on_follow_rule" parameter specifies the new default - // link behavior for this link. If the "def_pass_on_follow_rule" - // exceeds the "limiting_follow_rule" specified in the next - // parameter, then a DefaultFollowTooPermissive exception is - // raised. - - // The "limiting_follow_rule" parameter specifies the new limit for - // the follow behavior of this link. The exception - // LimitingFollowTooPermissive is raised if the value exceeds the - // current "max_link_follow_policy" of the trader. - // END SPEC - -private: - - // = Disallow these operations. - ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Link &)) - ACE_UNIMPLEMENTED_FUNC (TAO_Link (const TAO_Link &)) - - typedef ACE_Hash_Map_Manager - < - TAO_String_Hash_Key, - CosTrading::Link::LinkInfo, - MAP_LOCK_TYPE - > - Links; - - Links links_; - // The collection of link connecting this trader to others in the - // federation. - - TAO_Trader &trader_; -}; - - // ************************************************************* - // TAO_Proxy - // ************************************************************* - -template -class TAO_Proxy : - public TAO_Trader_Components , - public TAO_Support_Attributes -{ -public: - - TAO_Proxy (TAO_Trader &trader); - - ~TAO_Proxy (void); - - virtual CosTrading::OfferId - export_proxy (CosTrading::Lookup_ptr, - const char *, - const CosTrading::PropertySeq &, - CORBA::Boolean if_match_all, - const char *, - const CosTrading::PolicySeq &, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalServiceType, - CosTrading::UnknownServiceType, - CosTrading::InvalidLookupRef, - CosTrading::IllegalPropertyName, - CosTrading::PropertyTypeMismatch, - CosTrading::ReadonlyDynamicProperty, - CosTrading::MissingMandatoryProperty, - CosTrading::Proxy::IllegalRecipe, - CosTrading::DuplicatePropertyName, - CosTrading::DuplicatePolicyName)); - - virtual void withdraw_proxy (const char *, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId, - CosTrading::Proxy::NotProxyOfferId)); - - virtual CosTrading::Proxy::ProxyInfo * - describe_proxy (const char *, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId, - CosTrading::Proxy::NotProxyOfferId)); - - // = CosTrading::TraderComponents methods. - - virtual void list_proxies (CORBA::ULong, - CosTrading::OfferIdSeq *&, - CosTrading::OfferIdIterator_ptr &, - CORBA::Environment& env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTrading::NotImplemented)); - -private: - - // = Disallow these operations. - ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Proxy &)) - ACE_UNIMPLEMENTED_FUNC (TAO_Proxy (const TAO_Proxy &)) - - - TAO_Trader& trader_; -}; - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "Trader_Interfaces.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#endif /* TAO_TRADER_INTERFACES_H */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Trader_T.cpp b/TAO/orbsvcs/orbsvcs/Trader/Trader_T.cpp deleted file mode 100644 index d00d2767c9b..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Trader_T.cpp +++ /dev/null @@ -1,337 +0,0 @@ -// ============================================================================ -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Trader.cpp -// -// = AUTHOR -// Marina Spivak -// Seth Widoff -// Irfan Pyarali -// -// ============================================================================ - -#ifndef TAO_TRADER_C -#define TAO_TRADER_C - -#include "Trader_T.h" -#include "Trader_Interfaces.h" - -ACE_RCSID(Trader, Trader_T, "$Id$") - - // ************************************************************* - // TAO_Trader - // ************************************************************* - -template -TAO_Trader:: -TAO_Trader (TAO_Trader_Base::Trader_Components components) -{ - CORBA::Environment env; - for (int i = LOOKUP_IF; i <= LINK_IF; i++) - this->ifs_[i] = 0; - - if (ACE_BIT_ENABLED (components, LOOKUP)) - { - TAO_Lookup* lookup = - new TAO_Lookup (*this); - this->trading_components ().lookup_if (lookup->_this (env)); - this->ifs_[LOOKUP_IF] = lookup; - } - if (ACE_BIT_ENABLED (components, REGISTER)) - { - TAO_Register* reg = - new TAO_Register (*this); - this->trading_components ().register_if (reg->_this (env)); - this->ifs_[REGISTER_IF] = reg; - } - if (ACE_BIT_ENABLED (components, ADMIN)) - { - TAO_Admin* admin = - new TAO_Admin (*this); - this->trading_components ().admin_if (admin->_this (env)); - this->ifs_[ADMIN_IF] = admin; - } - if (ACE_BIT_ENABLED (components, PROXY)) - { - TAO_Proxy* proxy = - new TAO_Proxy (*this); - this->trading_components ().proxy_if (proxy->_this (env)); - this->ifs_[PROXY_IF] = proxy; - } - if (ACE_BIT_ENABLED (components, LINK)) - { - TAO_Link* link = - new TAO_Link (*this); - this->trading_components ().link_if (link->_this (env)); - this->ifs_[LINK_IF] = link; - } -} - -template -TAO_Trader::~TAO_Trader (void) -{ - // Remove Trading Components from POA - // - // Note that there is no real error checking here as we can't do - // much about errors here anyway - // - - for (int i = LOOKUP_IF; i <= LINK_IF; i++) - { - if (this->ifs_[i] != 0) - { - TAO_TRY - { - PortableServer::POA_var poa = - this->ifs_[i]->_default_POA (TAO_TRY_ENV); - TAO_CHECK_ENV; - PortableServer::ObjectId_var id = - poa->servant_to_id (this->ifs_[i], TAO_TRY_ENV); - TAO_CHECK_ENV; - poa->deactivate_object (id.in (), TAO_TRY_ENV); - } - TAO_CATCHANY - { - } - TAO_ENDTRY; - - delete this->ifs_[i]; - } - } -} - -template -TAO_Offer_Database& -TAO_Trader::offer_database (void) -{ - return this->offer_database_; -} - -template ACE_Lock & -TAO_Trader::lock (void) -{ - return this->lock_; -} - - // ************************************************************* - // Template Attribute Classes - // ************************************************************* - -template -TAO_Trader_Components:: -TAO_Trader_Components (const TAO_Trading_Components_i& comps) - : comps_ (comps) -{ -} - -template CosTrading::Lookup_ptr -TAO_Trader_Components::lookup_if (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return CosTrading::Lookup::_duplicate (this->comps_.lookup_if ()); -} - -template CosTrading::Register_ptr -TAO_Trader_Components::register_if (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return CosTrading::Register::_duplicate (this->comps_.register_if ()); -} - -template CosTrading::Admin_ptr -TAO_Trader_Components::admin_if (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return CosTrading::Admin::_duplicate (this->comps_.admin_if ()); -} - -template CosTrading::Proxy_ptr -TAO_Trader_Components::proxy_if (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return CosTrading::Proxy::_duplicate (this->comps_.proxy_if ()); -} - -template CosTrading::Link_ptr -TAO_Trader_Components::link_if (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return CosTrading::Link::_duplicate (this->comps_.link_if ()); -} -template -TAO_Support_Attributes:: -TAO_Support_Attributes (const TAO_Support_Attributes_i& attrs) - : attrs_ (attrs) -{ -} - -template CORBA::Boolean -TAO_Support_Attributes::supports_modifiable_properties (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.supports_modifiable_properties (); -} - -template CORBA::Boolean -TAO_Support_Attributes::supports_dynamic_properties (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.supports_dynamic_properties (); -} - -template CORBA::Boolean -TAO_Support_Attributes::supports_proxy_offers (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.supports_proxy_offers (); -} - -template CosTrading::TypeRepository_ptr -TAO_Support_Attributes::type_repos (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return CosTrading::TypeRepository::_duplicate (this->attrs_.type_repos ()); -} - -template -TAO_Import_Attributes:: -TAO_Import_Attributes (const TAO_Import_Attributes_i& attrs) - : attrs_ (attrs) -{ -} - -template CORBA::ULong -TAO_Import_Attributes::def_search_card (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.def_search_card (); -} - -template CORBA::ULong -TAO_Import_Attributes::max_search_card (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.max_search_card (); -} - -template CORBA::ULong -TAO_Import_Attributes::def_match_card (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.def_match_card (); -} - -template CORBA::ULong -TAO_Import_Attributes::max_match_card (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.max_match_card (); -} - -template CORBA::ULong -TAO_Import_Attributes::def_return_card (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.def_return_card (); -} - -template CORBA::ULong -TAO_Import_Attributes::max_return_card (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.max_return_card (); -} - -template CORBA::ULong -TAO_Import_Attributes::max_list (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.max_list (); -} - -template CORBA::ULong -TAO_Import_Attributes::def_hop_count (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.def_hop_count (); -} - -template CORBA::ULong -TAO_Import_Attributes::max_hop_count (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.max_hop_count (); -} - -template CosTrading::FollowOption -TAO_Import_Attributes::def_follow_policy (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.def_follow_policy (); -} - -template CosTrading::FollowOption -TAO_Import_Attributes::max_follow_policy (CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.max_follow_policy (); -} - -template -TAO_Link_Attributes:: -TAO_Link_Attributes (const TAO_Link_Attributes_i& attrs) - : attrs_ (attrs) -{ -} - -template CosTrading::FollowOption -TAO_Link_Attributes::max_link_follow_policy (CORBA::Environment &env) - TAO_THROW_SPEC ((CORBA::SystemException)) -{ - return this->attrs_.max_link_follow_policy (); -} - - - // ************************************************************* - // TAO_Sequence_Extracter - // ************************************************************* - -template CORBA::Boolean -TAO_find (const CORBA::Any& sequence, const OPERAND_TYPE& element) -{ - CORBA::Boolean return_value = 0; - TAO_Element_Equal functor; - TAO_DynSequence_i dyn_seq (sequence); - - TAO_TRY - { - CORBA::ULong length = dyn_seq.length (TAO_TRY_ENV); - TAO_CHECK_ENV; - - for (CORBA::ULong i = 0; i < length && ! return_value; i++) - { - if (functor (dyn_seq, element)) - { - //ACE_DEBUG ((LM_DEBUG, "TAO_find::success\n")); - return_value = 1; - } - } - } - TAO_CATCHANY {} TAO_ENDTRY; - - return return_value; -} - -template int -TAO_Element_Equal:: -operator () (TAO_DynSequence_i& dyn_any, - const ELEMENT_TYPE& element) -{ - return 1; -} - -#endif /* TAO_TRADER_C */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Trader_T.h b/TAO/orbsvcs/orbsvcs/Trader/Trader_T.h deleted file mode 100644 index 9e2b672755d..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Trader_T.h +++ /dev/null @@ -1,260 +0,0 @@ -/* -*- C++ -*- */ - -// ======================================================================== -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Trader.h -// -// = AUTHOR -// Marina Spivak -// Seth Widoff -// Irfan Pyarali -// -// ======================================================================== - -#ifndef TAO_TRADER_H -#define TAO_TRADER_H - -#include "Trader.h" -#include "Offer_Database.h" -#include "tao/DynSequence_i.h" - - // ************************************************************* - // TAO_Trader - // ************************************************************* - -template -class TAO_Trader : public TAO_Trader_Base - // - // = TITLE - // This class packages together all the various pieces that - // provide functionality specified in COS Trading specification. - // - // = DESCRIPTION - // TAO_Trader contains all the components that together represent - // a single trader. Based on its constructor arguments, - // TAO_Trader creates instances of appropriate interface - // implementations as well as instances of objects common to - // more than one interface (offers, attributes, etc.). - // TAO_Trader also enforces the proper order on all - // initializations. TAO_Trader acts like a "glue" class that - // creates appropriate components, holds everything together, - // and enforces order. TAO_Trader is parameterized by two types - // of locks: one for its service service offers, one for its - // state (configuration). -{ -public: - - // The desired combination of interfaces to be passed to the - // TAO_Trader constructor. - - typedef TAO_Offer_Database Offer_Database; - // Offer Database Trait. - - TAO_Trader (Trader_Components components = LOOKUP); - // Constructor which based on its arguments will create - // a particular type of trader (e.g. Query trader, Simple trader, etc.) - // The argument is a bitwise OR of desired Trader_Components as listed - // in enumerated type above. - - virtual ~TAO_Trader (void); - // destructor. - - Offer_Database& offer_database (void); - // Accessor for the structure with all the service offers. - - ACE_Lock &lock (void); - // returns the trader - -protected: - - typedef TAO_Trader TRADER_SELF; - - Offer_Database offer_database_; - - ACE_Lock_Adapter lock_; - // lock that guards the state of the trader (its configuration). - - enum { LOOKUP_IF, REGISTER_IF, ADMIN_IF, PROXY_IF, LINK_IF }; - - PortableServer::ServantBase* ifs_[5]; - -private: - - // = Disallow these operations. - ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Trader &)) -}; - - // ************************************************************* - // Template Attribute Classes - // ************************************************************* - -template -class TAO_Trader_Components : public virtual IF -{ -public: - - TAO_Trader_Components (const TAO_Trading_Components_i& comps); - - // = CosTrading::TraderComponents methods. - virtual CosTrading::Lookup_ptr lookup_if (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - // Returns an object reference to the Lookup interface of the trader. - // Returns nil if the trader does not support Lookup interface. - - virtual CosTrading::Register_ptr register_if (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - // Returns object reference for the Register interface of the trader. - // Returns nil if the trader does not support Register interface. - - virtual CosTrading::Link_ptr link_if (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - // Returns object reference for the Link interface of the trader. - // Returns nil if the trader does not support Link interface. - - virtual CosTrading::Proxy_ptr proxy_if (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - // Returns object reference to the Proxy interface of the trader. - // Returns nil if the trader does not support Proxy interface. - - virtual CosTrading::Admin_ptr admin_if (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - // Returns object reference for the Admin interface of the trader. - // Returns nil if the trader does not support Admin interface. - -private: - - const TAO_Trading_Components_i& comps_; -}; - -template -class TAO_Support_Attributes : public virtual IF -{ -public: - - TAO_Support_Attributes (const TAO_Support_Attributes_i& attrs); - - // = CosTrading::SupportAttributes methods. - - virtual CORBA::Boolean supports_modifiable_properties (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - virtual CORBA::Boolean supports_dynamic_properties (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - virtual CORBA::Boolean supports_proxy_offers (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - virtual CosTrading::TypeRepository_ptr type_repos (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - -private: - - const TAO_Support_Attributes_i& attrs_; -}; - -template -class TAO_Import_Attributes : public virtual IF -{ -public: - - TAO_Import_Attributes (const TAO_Import_Attributes_i& attrs); - - // = CosTrading::ImportAttributes methods. - - virtual CORBA::ULong def_search_card (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - virtual CORBA::ULong max_search_card (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - // Search cardinality determines the maximum number of offers searched - // before not considering other offers. - - virtual CORBA::ULong def_match_card (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - virtual CORBA::ULong max_match_card (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - // Match cardinality determines the maximum number of offers - // matched to the constraints before not considering other offers.. - - virtual CORBA::ULong def_return_card (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - virtual CORBA::ULong max_return_card (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - // Return cardinality determines the maximum number of offers marked - // to return before not considering other offers. - - - virtual CORBA::ULong max_list (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - virtual CORBA::ULong def_hop_count (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - virtual CORBA::ULong max_hop_count (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - virtual CosTrading::FollowOption def_follow_policy (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - virtual CosTrading::FollowOption max_follow_policy (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - - -private: - - const TAO_Import_Attributes_i& attrs_; -}; - -template -class TAO_Link_Attributes : public virtual IF -{ -public: - - TAO_Link_Attributes (const TAO_Link_Attributes_i& attrs); - - // = CosTrading::LinkAttributes methods - virtual CosTrading::FollowOption max_link_follow_policy (CORBA::Environment &) - TAO_THROW_SPEC ((CORBA::SystemException)); - -private: - - const TAO_Link_Attributes_i& attrs_; -}; - - // ************************************************************* - // TAO_Sequence_Extracter - // ************************************************************* - -template -class TAO_Element_Equal -{ - // = TITLE - // Function object for determining if the sequence element at the - // current position of the dynamic sequence any parameter is equal to - // the element parameter. -public: - int operator () (TAO_DynSequence_i& dyn_any, - const ELEMENT_TYPE& element); - // Calls the correct method on dyn_seq to extract the element type, then - // uses the appropriate form of equals comparison. -}; - -template -CORBA::Boolean TAO_find (const CORBA::Any& sequence, const OPERAND_TYPE& operand); - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "Trader_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#endif /* ACE_TRADER_H */ - diff --git a/TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.cpp b/TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.cpp deleted file mode 100644 index 992eb84de2c..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.cpp +++ /dev/null @@ -1,1497 +0,0 @@ -// $Id$ - -#include "Trader_Utils.h" - -ACE_RCSID(Trader, Trader_Utils, "$Id$") - - // ************************************************************* - // TAO_Policy_Manager - // ************************************************************* - -TAO_Policy_Manager::TAO_Policy_Manager (int num_policies) - : policies_ (num_policies), - num_policies_ (0) -{ - for (int i = 0; i < TAO_Policies::REQUEST_ID + 1; i++) - this->poltable_[i] = -1; -} - -void -TAO_Policy_Manager::search_card (CORBA::ULong scard) -{ - CosTrading::Policy& policy = - this->fetch_next_policy (TAO_Policies::SEARCH_CARD); - policy.value <<= scard; -} - -void -TAO_Policy_Manager::match_card (CORBA::ULong mcard) -{ - CosTrading::Policy& policy = - this->fetch_next_policy (TAO_Policies::MATCH_CARD); - policy.value <<= mcard; -} - -void -TAO_Policy_Manager::return_card (CORBA::ULong rcard) -{ - CosTrading::Policy& policy = - this->fetch_next_policy (TAO_Policies::RETURN_CARD); - policy.value <<= rcard; -} - -void -TAO_Policy_Manager::use_modifiable_properties (CORBA::Boolean mod_props) -{ - CosTrading::Policy& policy = - this->fetch_next_policy (TAO_Policies::USE_MODIFIABLE_PROPERTIES); - policy.value <<= CORBA::Any::from_boolean (mod_props); -} - -void -TAO_Policy_Manager::use_dynamic_properties (CORBA::Boolean dyn_props) -{ - CosTrading::Policy& policy = - this->fetch_next_policy (TAO_Policies::USE_DYNAMIC_PROPERTIES); - policy.value <<= CORBA::Any::from_boolean (dyn_props); -} - -void -TAO_Policy_Manager::use_proxy_offers (CORBA::Boolean prox_offs) -{ - CosTrading::Policy& policy = - this->fetch_next_policy (TAO_Policies::USE_PROXY_OFFERS); - policy.value <<= CORBA::Any::from_boolean (prox_offs); -} - -void -TAO_Policy_Manager::starting_trader (const CosTrading::TraderName& name) -{ - CosTrading::Policy& policy = - this->fetch_next_policy (TAO_Policies::STARTING_TRADER); - policy.value <<= name; -} - -void -TAO_Policy_Manager::starting_trader (CosTrading::TraderName* name) -{ - CosTrading::Policy& policy = - this->fetch_next_policy (TAO_Policies::STARTING_TRADER); - policy.value <<= name; -} - -void -TAO_Policy_Manager:: -link_follow_rule (CosTrading::FollowOption follow_option) -{ - CosTrading::Policy& policy = - this->fetch_next_policy (TAO_Policies::LINK_FOLLOW_RULE); - policy.value <<= follow_option; -} - -void -TAO_Policy_Manager::hop_count (CORBA::ULong hop_count) -{ - CosTrading::Policy& policy = - this->fetch_next_policy (TAO_Policies::HOP_COUNT); - policy.value <<= hop_count; -} - -void -TAO_Policy_Manager::exact_type_match (CORBA::Boolean exact_type) -{ - CosTrading::Policy& policy = - this->fetch_next_policy (TAO_Policies::EXACT_TYPE_MATCH); - policy.value <<= CORBA::Any::from_boolean (exact_type); -} - -void -TAO_Policy_Manager::request_id (const CosTrading::Admin::OctetSeq& request_id) -{ - CosTrading::Policy& policy = - this->fetch_next_policy (TAO_Policies::REQUEST_ID); - policy.value <<= request_id; -} - -TAO_Policy_Manager::operator const CosTrading::PolicySeq& (void) const -{ - return this->policies_; -} - -const CosTrading::PolicySeq& -TAO_Policy_Manager::policy_seq (void) const -{ - return this->policies_; -} - -CosTrading::Policy& -TAO_Policy_Manager::fetch_next_policy (TAO_Policies::POLICY_TYPE pol_type) -{ - CORBA::ULong index = 0; - - if (this->poltable_[pol_type] == -1) - { - // Expand the policy sequence, and copy in the policy name into - // the new element. - CORBA::ULong length = this->policies_.length (); - this->num_policies_++; - - if (length < this->num_policies_) - this->policies_.length (this->num_policies_); - - index = this->num_policies_ - 1; - - // Ensure the starting trader policy gets the first slot. - if (pol_type != TAO_Policies::STARTING_TRADER || index == 0) - { - this->policies_[index].name = TAO_Policies::POLICY_NAMES[pol_type]; - this->poltable_[pol_type] = index; - } - else - { - // Copy the element in the first slot to the newly - // allocated slot. - TAO_Policies::POLICY_TYPE occupying_policy = - TAO_Policies::STARTING_TRADER; - for (CORBA::ULong i = 0; i < this->num_policies_ - 1; i++) - { - if (this->poltable_[i] == 0) - { - occupying_policy = - ACE_static_cast (TAO_Policies::POLICY_TYPE, i); - break; - } - } - - this->poltable_[occupying_policy] = index; - this->poltable_[TAO_Policies::STARTING_TRADER] = 0; - this->policies_[index].name = - TAO_Policies::POLICY_NAMES[occupying_policy]; - this->policies_[index].value = this->policies_[0].value; - this->policies_[0].name = - TAO_Policies::POLICY_NAMES[TAO_Policies::STARTING_TRADER]; - - index = 0; - } - } - else - index = this->poltable_[pol_type]; - - return this->policies_[index]; -} - - - // ************************************************************* - // TAO_Property_Evaluator - // ************************************************************* - -// Constructor - -TAO_Property_Evaluator:: -TAO_Property_Evaluator(const CosTrading::PropertySeq& props, - CORBA::Boolean supports_dp) - : props_ (props), - supports_dp_ (supports_dp), - dp_cache_ (new CORBA::Any*[props.length ()]) -{ - if (this->dp_cache_ != 0) - { - for (CORBA::ULong i = 0; i < this->props_.length (); i++) - this->dp_cache_[i] = 0; - } -} - - -TAO_Property_Evaluator:: -TAO_Property_Evaluator(CosTrading::Offer& offer, - CORBA::Boolean supports_dp) - : props_ (offer.properties), - supports_dp_ (supports_dp), - dp_cache_ (new CORBA::Any*[offer.properties.length ()]) -{ - if (this->dp_cache_ != 0) - { - for (CORBA::ULong i = 0; i < this->props_.length (); i++) - this->dp_cache_[i] = 0; - } -} - -TAO_Property_Evaluator::~TAO_Property_Evaluator (void) -{ - // Clean up the results of any dynamic properties. - for (CORBA::ULong i = 0; i < this->props_.length (); i++) - { - if (this->dp_cache_[i] != 0) - delete this->dp_cache_[i]; - } - - delete [] this->dp_cache_; -} - -int -TAO_Property_Evaluator::is_dynamic_property (int index) -{ - CORBA::Environment env; - int return_value = 0, - num_properties = this->props_.length(); - - // Ensure index is in bounds. - if (index >= 0 && index < num_properties) - { - // Obtain the value of the property at index . - const CORBA::Any& value = this->props_[index].value; - CORBA::TypeCode_var type = value.type (); - - if (type->equal (CosTradingDynamic::_tc_DynamicProp, env)) - return_value = 1; - } - - return return_value; -} - - -CORBA::Any* -TAO_Property_Evaluator::property_value (int index, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTradingDynamic::DPEvalFailure)) -{ - CORBA::Any* prop_val = 0; - CORBA::Boolean in_cache = - this->dp_cache_ != 0 && this->dp_cache_[index] != 0; - - if (! this->is_dynamic_property (index)) - prop_val = (CORBA::Any *) &(this->props_[index].value); - else if (this->supports_dp_ && in_cache) - prop_val = this->dp_cache_[index]; - else if (this->supports_dp_) - { - // Property is defined at this point. - CosTradingDynamic::DynamicProp* dp_struct; - const CORBA::String_var name = this->props_[index].name.in (); - const CORBA::Any& value = this->props_[index].value; - - // Extract the DP_Struct. - value >>= dp_struct; - - CosTradingDynamic::DynamicPropEval_var dp_eval = - CosTradingDynamic::DynamicPropEval::_duplicate (dp_struct->eval_if.in ()); - - if (CORBA::is_nil (dp_eval.in ())) - { - TAO_THROW_RETURN (CosTradingDynamic:: - DPEvalFailure (name, - CORBA::TypeCode::_nil (), - CORBA::Any ()), - prop_val); - } - else - { - CORBA::TypeCode* type = dp_struct->returned_type.in (); - CORBA::Any& info = dp_struct->extra_info; - - TAO_TRY - { - // Retrieve the value of the dynamic property. - prop_val = dp_eval->evalDP(name, type, info, TAO_TRY_ENV); - TAO_CHECK_ENV; - - if (this->dp_cache_ != 0) - this->dp_cache_[index] = prop_val; - } - TAO_CATCH (CORBA::SystemException, excp) - { - TAO_THROW_RETURN - (CosTradingDynamic::DPEvalFailure (name, type, info), - prop_val); - } - TAO_ENDTRY; - } - } - - return prop_val; -} - -CORBA::TypeCode_ptr -TAO_Property_Evaluator::property_type (int index) -{ - CORBA::TypeCode_ptr prop_type = CORBA::TypeCode::_nil(); - - // Determine if property is both defined and dynamic. - if (this->is_dynamic_property (index)) - { - // Extract type information from the DP_Struct. - const CORBA::Any& value = this->props_[index].value; - CosTradingDynamic::DynamicProp* dp_struct; - value >>= dp_struct; - - // Grab a pointer to the returned_type description - prop_type = CORBA::TypeCode::_duplicate (dp_struct->returned_type.in ()); - } - else - // TypeCode is self-evident at this point. - prop_type = this->props_[index].value.type (); - - return prop_type; -} - - // ************************************************************* - // TAO_Property_Evaluator_By_Name - // ************************************************************* - -TAO_Property_Evaluator_By_Name:: -TAO_Property_Evaluator_By_Name (const CosTrading::PropertySeq& properties, - CORBA::Environment& TAO_IN_ENV, - CORBA::Boolean supports_dp) - TAO_THROW_SPEC ((CosTrading::DuplicatePropertyName, - CosTrading::IllegalPropertyName)) - : TAO_Property_Evaluator (properties, supports_dp) -{ - int length = this->props_.length(); - - for (int i = 0; i < length; i++) - { - const CosTrading::Property& prop = this->props_[i]; - - if (! TAO_Trader_Base::is_valid_identifier_name (prop.name)) - TAO_THROW (CosTrading::IllegalPropertyName (prop.name)); - - TAO_String_Hash_Key prop_name = prop.name.in (); - if (this->table_.bind (prop_name, i)) - TAO_THROW (CosTrading::DuplicatePropertyName (prop.name)); - } -} - -TAO_Property_Evaluator_By_Name:: -TAO_Property_Evaluator_By_Name(CosTrading::Offer& offer, - CORBA::Boolean supports_dp) - : TAO_Property_Evaluator(offer, supports_dp) -{ - int length = this->props_.length(); - - for (int i = 0; i < length; i++) - { - TAO_String_Hash_Key prop_name = (const char*) this->props_[i].name; - this->table_.bind (prop_name, i); - } -} - -int -TAO_Property_Evaluator_By_Name:: -is_dynamic_property(const char* property_name) -{ - int predicate = 0, index = 0; - TAO_String_Hash_Key prop_name (property_name); - - // If the property name is in the map, delegate evaluation to our - // superclass. Otherwise, throw an exception. - if (this->table_.find (prop_name, index) == 0) - predicate = this->TAO_Property_Evaluator::is_dynamic_property(index); - - return predicate; -} - -CORBA::Any* -TAO_Property_Evaluator_By_Name::property_value (const char* property_name, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTradingDynamic::DPEvalFailure)) -{ - int index = 0; - CORBA::Any* prop_value = 0; - TAO_String_Hash_Key prop_name (property_name); - - // If the property name is in the map, delegate evaluation to our - // superclass. Otherwise, throw an exception. - if (this->table_.find (prop_name, index) == 0) - prop_value = this->TAO_Property_Evaluator::property_value (index, TAO_IN_ENV); - - return prop_value; -} - -CORBA::TypeCode_ptr -TAO_Property_Evaluator_By_Name::property_type (const char* property_name) -{ - int index = 0; - TAO_String_Hash_Key prop_name (property_name); - CORBA::TypeCode_ptr prop_type = CORBA::TypeCode::_nil(); - - // If the property name is in the map, delegate evaluation to our - // superclass. Otherwise, throw an exception. - if (this->table_.find (prop_name, index) == 0) - prop_type = this->TAO_Property_Evaluator::property_type (index); - - return prop_type; -} - -const CosTrading::Property* -TAO_Property_Evaluator_By_Name::get_property (const char* property_name) -{ - int index = 0; - CosTrading::Property* property = 0; - TAO_String_Hash_Key prop_name (property_name); - - if (this->table_.find (prop_name, index) == 0) - property = (CosTrading::Property *) &this->props_[index]; - - return property; -} - - // ************************************************************* - // TAO_Dynamic_Property - // ************************************************************* - -TAO_Dynamic_Property::~TAO_Dynamic_Property (void) -{ -} - -CosTradingDynamic::DynamicProp* -TAO_Dynamic_Property:: -construct_dynamic_prop (const char* name, - CORBA::TypeCode_ptr returned_type, - const CORBA::Any& extra_info) -{ - CosTradingDynamic::DynamicProp* dp_struct = 0; - - ACE_NEW_RETURN (dp_struct, CosTradingDynamic::DynamicProp, 0); - - TAO_TRY - { - dp_struct->eval_if = this->_this (TAO_TRY_ENV); - TAO_CHECK_ENV; - dp_struct->returned_type = CORBA::TypeCode::_duplicate (returned_type); - dp_struct->extra_info = extra_info; - } - TAO_CATCHANY - { - return 0; - } - TAO_ENDTRY; - - return dp_struct; -} - - // ************************************************************* - // TAO_Policies - // ************************************************************* - -const char* TAO_Policies::POLICY_NAMES[] = -{ - "starting_trader", - "exact_type_match", - "hop_count", - "link_follow_rule", - "match_card", - "return_card", - "search_card", - "use_dynamic_properties", - "use_modifiable_properties", - "use_proxy_offers", - "request_id" -}; - -TAO_Policies::TAO_Policies (TAO_Trader_Base& trader, - const CosTrading::PolicySeq& policies, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::Lookup::IllegalPolicyName, - CosTrading::DuplicatePolicyName)) - : trader_ (trader) -{ - for (int i = 0; i < TAO_NUM_POLICIES; i++) - this->policies_[i] = 0; - - for (CORBA::ULong j = 0; j < policies.length (); j++) - { - const char* pol_name = (const char*) policies[j].name; - size_t length = (pol_name == 0) ? 0 : ACE_OS::strlen (pol_name); - int index = -1; - - if (length < ACE_OS::strlen (POLICY_NAMES[HOP_COUNT])) - TAO_THROW (CosTrading::Lookup::IllegalPolicyName (pol_name)); - - switch (pol_name[0]) - { - case 'e': - index = EXACT_TYPE_MATCH; - break; - case 'h': - index = HOP_COUNT; - break; - case 'l': - index = LINK_FOLLOW_RULE; - break; - case 'm': - index = MATCH_CARD; - break; - case 'r': - if (pol_name[2] == 't') - index = RETURN_CARD; - else if (pol_name[2] == 'q') - index = REQUEST_ID; - break; - case 's': - if (pol_name[1] == 't') - index = STARTING_TRADER; - else if (pol_name[1] == 'e') - index = SEARCH_CARD; - break; - case 'u': - if (pol_name[4] == 'd') - index = USE_DYNAMIC_PROPERTIES; - if (pol_name[4] == 'm') - index = USE_MODIFIABLE_PROPERTIES; - if (pol_name[4] == 'p') - index = USE_PROXY_OFFERS; - } - - // Match the name of the policy, and insert its value into the - // vector. - if (index == -1 || ACE_OS::strcmp (POLICY_NAMES[index], pol_name) != 0) - TAO_THROW (CosTrading::Lookup::IllegalPolicyName (pol_name)); - else - { - if (this->policies_[index] != 0) - TAO_THROW (CosTrading::DuplicatePolicyName (pol_name)); - else - this->policies_[index] = (CosTrading::Policy *) &(policies[j]); - } - } -} - -TAO_Policies::~TAO_Policies (void) -{ -} - -CORBA::ULong -TAO_Policies::ulong_prop (POLICY_TYPE pol, - CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)) -{ - CORBA::ULong return_value = 0, max_value = 0; - const TAO_Import_Attributes_i& import_attrs = - this->trader_.import_attributes (); - - // Discover the default values for each of the possible cardinality - // policies. - switch (pol) - { - case SEARCH_CARD: - return_value = import_attrs.def_search_card (); - max_value = import_attrs.max_search_card (); - break; - case MATCH_CARD: - return_value = import_attrs.def_match_card (); - max_value = import_attrs.max_match_card (); - break; - case RETURN_CARD: - return_value = import_attrs.def_return_card (); - max_value = import_attrs.max_return_card (); - break; - case HOP_COUNT: - return_value = import_attrs.def_hop_count (); - max_value = import_attrs.max_hop_count (); - break; - default: - break; - } - - if (this->policies_[pol] != 0) - { - // Extract the desired policy value. - const CosTrading::Policy* policy = this->policies_[pol]; - const CosTrading::PolicyValue& value = policy->value; - CORBA::TypeCode_var type = value.type (); - - if (!type->equal (CORBA::_tc_ulong, TAO_IN_ENV)) - TAO_THROW_RETURN (CosTrading::Lookup::PolicyTypeMismatch (*policy), - return_value); - else - value >>= return_value; - - if (max_value < return_value) - return_value = max_value; - } - - return return_value; -} - -CORBA::ULong -TAO_Policies::search_card (CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)) -{ - return this->ulong_prop (SEARCH_CARD, TAO_IN_ENV); -} - -CORBA::ULong -TAO_Policies::match_card (CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)) -{ - return this->ulong_prop (MATCH_CARD, TAO_IN_ENV); -} - -CORBA::ULong -TAO_Policies::return_card (CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)) -{ - return this->ulong_prop (RETURN_CARD, TAO_IN_ENV); -} - -CORBA::Boolean -TAO_Policies::boolean_prop (POLICY_TYPE pol, - CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)) -{ - CORBA::Boolean def_value = 1, - return_value = 1; - const TAO_Support_Attributes_i& support_attrs = - this->trader_.support_attributes (); - - switch (pol) - { - case USE_MODIFIABLE_PROPERTIES: - def_value = support_attrs.supports_modifiable_properties (); - break; - case USE_DYNAMIC_PROPERTIES: - def_value = support_attrs.supports_dynamic_properties (); - break; - case USE_PROXY_OFFERS: - def_value = support_attrs.supports_proxy_offers (); - break; - case EXACT_TYPE_MATCH: - def_value = 0; - break; - default: - break; - } - - if (this->policies_[pol] != 0) - { - const CosTrading::Policy* policy = this->policies_[pol]; - const CosTrading::PolicyValue& value = policy->value; - CORBA::TypeCode_var type = value.type (); - - if (!type->equal (CORBA::_tc_boolean, TAO_IN_ENV)) - TAO_THROW_RETURN (CosTrading::Lookup::PolicyTypeMismatch (*policy), - return_value); - else - value >>= CORBA::Any::to_boolean (return_value); - - if (def_value == 0 && - pol != EXACT_TYPE_MATCH) - return_value = 0; - } - else - return_value = def_value; - - return return_value; -} - - -CORBA::Boolean -TAO_Policies::use_modifiable_properties (CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)) -{ - return this->boolean_prop (USE_MODIFIABLE_PROPERTIES, TAO_IN_ENV); -} - -CORBA::Boolean -TAO_Policies::use_dynamic_properties (CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)) -{ - return this->boolean_prop (USE_DYNAMIC_PROPERTIES, TAO_IN_ENV); -} - -CORBA::Boolean -TAO_Policies::use_proxy_offers (CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)) -{ - return this->boolean_prop (USE_PROXY_OFFERS, TAO_IN_ENV); -} - -CORBA::Boolean -TAO_Policies::exact_type_match (CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)) -{ - return this->boolean_prop (EXACT_TYPE_MATCH, TAO_IN_ENV); -} - - -CosTrading::TraderName* -TAO_Policies::starting_trader (CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch, - CosTrading::Lookup::InvalidPolicyValue)) -{ - CosTrading::TraderName* trader_name = 0; - - if (this->policies_[STARTING_TRADER] != 0) - { - CosTrading::Policy* policy = this->policies_[STARTING_TRADER]; - CosTrading::PolicyValue& value = policy->value; - CORBA::TypeCode_var type = value.type (); - - if (! (type->equal (CosTrading::_tc_TraderName, TAO_IN_ENV) || - type->equal (CosTrading::_tc_LinkNameSeq, TAO_IN_ENV))) - TAO_THROW_RETURN (CosTrading::Lookup::PolicyTypeMismatch (*policy), - trader_name); - else - value >>= trader_name; - } - - return trader_name; -} - -CosTrading::FollowOption -TAO_Policies::link_follow_rule (CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)) -{ - CosTrading::FollowOption return_value = - this->trader_.import_attributes ().def_follow_policy (); - - if (this->policies_[LINK_FOLLOW_RULE] != 0) - { - CosTrading::FollowOption max_follow_policy = - this->trader_.import_attributes ().max_follow_policy (); - - CosTrading::Policy* policy = this->policies_[LINK_FOLLOW_RULE]; - CosTrading::PolicyValue& value = policy->value; - CORBA::TypeCode_var type = value.type (); - - // Extract the link follow rule - if (!type->equal (CosTrading::_tc_FollowOption, TAO_IN_ENV)) - TAO_THROW_RETURN (CosTrading::Lookup::PolicyTypeMismatch (*policy), - return_value); - else - value >>= return_value; - - if (return_value > max_follow_policy) - return_value = max_follow_policy; - } - - return return_value; -} - -CosTrading::FollowOption -TAO_Policies::link_follow_rule (const CosTrading::Link::LinkInfo& link_info, - CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch, - CosTrading::Lookup::InvalidPolicyValue, - CosTrading::Link::IllegalLinkName, - CosTrading::Link::UnknownLinkName)) -{ - CosTrading::FollowOption return_value = CosTrading::local_only; - CosTrading::FollowOption trader_max_follow_policy = - this->trader_.import_attributes ().max_follow_policy (); - CosTrading::FollowOption link_limiting_follow_rule = - link_info.limiting_follow_rule; - - // If not defined defaults to trader.def_link_follow_rule - CosTrading::FollowOption query_link_follow_rule = - this->link_follow_rule (TAO_IN_ENV); - TAO_CHECK_ENV_RETURN (TAO_IN_ENV, return_value); - - return_value = (query_link_follow_rule < trader_max_follow_policy) - ? query_link_follow_rule : trader_max_follow_policy; - return_value = (return_value < link_limiting_follow_rule) - ? return_value : link_limiting_follow_rule; - - return return_value; -} - -CORBA::ULong -TAO_Policies::hop_count (CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)) -{ - return this->ulong_prop (HOP_COUNT, TAO_IN_ENV); -} - -CosTrading::Admin::OctetSeq* -TAO_Policies::request_id (CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)) -{ - CosTrading::Admin::OctetSeq* request_id = 0; - - if (this->policies_[REQUEST_ID] != 0) - { - CosTrading::Policy* policy = this->policies_[REQUEST_ID]; - CosTrading::PolicyValue& value = policy->value; - CORBA::TypeCode_var type = value.type (); - - if (!type->equal (CosTrading::Admin::_tc_OctetSeq, TAO_IN_ENV)) - { - TAO_THROW_RETURN (CosTrading::Lookup::PolicyTypeMismatch (*policy), - request_id); - } - else - value >>= request_id; - } - - return request_id; -} - -void -TAO_Policies:: -copy_in_follow_option (CosTrading::PolicySeq& policy_seq, - const CosTrading::Link::LinkInfo& link_info, - CORBA::Environment& TAO_IN_ENV) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch, - CosTrading::Lookup::InvalidPolicyValue)) -{ - CosTrading::FollowOption follow_option = CosTrading::local_only; - CosTrading::FollowOption trader_max_follow_policy = - this->trader_.import_attributes ().max_follow_policy (); - - if (this->policies_[LINK_FOLLOW_RULE] != 0) - { - CORBA::Environment env; - CosTrading::FollowOption query_link_follow_rule = - this->link_follow_rule (env); - TAO_CHECK_ENV_RETURN_VOID (env); - - follow_option = - (link_info.limiting_follow_rule < trader_max_follow_policy) ? - ((link_info.limiting_follow_rule < query_link_follow_rule) ? - link_info.limiting_follow_rule : query_link_follow_rule) : - ((trader_max_follow_policy < query_link_follow_rule) ? - trader_max_follow_policy : query_link_follow_rule); - } - else - { - follow_option = - (link_info.def_pass_on_follow_rule < trader_max_follow_policy) ? - link_info.def_pass_on_follow_rule : trader_max_follow_policy; - } - - CORBA::ULong i = 0; - for (i = 0; i < policy_seq.length (); i++) - { - if (ACE_OS::strcmp (policy_seq[i].name, - POLICY_NAMES[LINK_FOLLOW_RULE]) == 0) - { - policy_seq[i].value <<= follow_option; - break; - } - } - - if (i == policy_seq.length ()) - { - policy_seq.length (i + 1); - policy_seq[i].name = POLICY_NAMES[LINK_FOLLOW_RULE]; - policy_seq[i].value <<= follow_option; - } -} - -void -TAO_Policies:: -copy_to_pass (CosTrading::PolicySeq& policy_seq, - const CosTrading::Admin::OctetSeq& request_id) const -{ - CORBA::ULong counter = 0; - CosTrading::Policy* policy_buffer = - CosTrading::PolicySeq::allocbuf (REQUEST_ID + 1); - - if (policy_buffer == 0) - return; - - for (int i = 0; i <= REQUEST_ID; i++) - { - CosTrading::Policy& new_policy = policy_buffer[counter]; - - if (i == REQUEST_ID) - { - // Set the new request id. - new_policy.name = POLICY_NAMES[REQUEST_ID]; - new_policy.value <<= request_id; - counter++; - } - else if (this->policies_[i] != 0) - { - // Copy in the existing policies. - new_policy.name = POLICY_NAMES[i]; - new_policy.value = this->policies_[i]->value; - counter++; - } - - // We always require a hop count. - if (i == HOP_COUNT) - { - CORBA::Environment env; - new_policy.name = POLICY_NAMES[HOP_COUNT]; - new_policy.value <<= this->hop_count (env) - 1; - - // Don't count hop count twice. - if (this->policies_[i] == 0) - counter++; - } - } - - policy_seq.replace (REQUEST_ID + 1, counter, policy_buffer, 1); -} - - -void -TAO_Policies::copy_to_forward (CosTrading::PolicySeq& policy_seq, - const CosTrading::TraderName& trader_name) const -{ - // Create a new policy sequence, shortening the starting trader - // policy by one link. - - CORBA::ULong counter = 0; - CosTrading::Policy* policy_buffer = - CosTrading::PolicySeq::allocbuf (REQUEST_ID + 1); - - if (policy_buffer == 0) - return; - - for (int i = 0; i <= REQUEST_ID; i++) - { - CosTrading::Policy& new_policy = policy_buffer[counter]; - - if (this->policies_[i] != 0) - { - // Copy in the existing policies. - if (i == STARTING_TRADER && trader_name.length () > 1) - { - // Eliminate the first link of the trader name. - // Only pass on the property if the sequence - // contains more links after us. - - // The any will sieze control of this memory. - // Allocating here avoids copying in the policy - // any. - CORBA::ULong length = trader_name.length (); - CosTrading::LinkName* buf = - CosTrading::TraderName::allocbuf (length - 1); - - if (buf != 0) - { - for (CORBA::ULong j = 1; j < length; j++) - buf[j - 1] = CORBA::string_dup (trader_name[j]); - - new_policy.name = this->policies_[i]->name; - CosTrading::TraderName new_name (length - 1, - length - 1, - buf, - 1); - - new_policy.value <<= new_name; - counter++; - } - } - else if (i != STARTING_TRADER) - { - new_policy.name = this->policies_[i]->name; - new_policy.value = this->policies_[i]->value; - counter++; - } - } - } - - // Create the new sequence - policy_seq.replace (REQUEST_ID + 1, counter, policy_buffer, 1); -} - - // ************************************************************* - // TAO_Offer_Modifier - // ************************************************************* - -TAO_Offer_Modifier:: -TAO_Offer_Modifier (const char* type_name, - const CosTradingRepos::ServiceTypeRepository::TypeStruct& type_struct, - CosTrading::Offer* offer) - : type_ (type_name), - offer_ (offer) -{ - const CosTradingRepos::ServiceTypeRepository::PropStructSeq& - pstructs = type_struct.props; - CosTrading::PropertySeq& prop_seq = this->offer_->properties; - CORBA::ULong pstructs_length = pstructs.length (), - props_length = prop_seq.length (), - i = 0; - - // Create a mapping of property names to their types. - for (i = 0; i < pstructs_length; i++) - { - TAO_String_Hash_Key prop_name = pstructs[i].name.in (); - CORBA::TypeCode_ptr type_code = - CORBA::TypeCode::_duplicate (pstructs[i].value_type.in ()); - this->prop_types_.bind (prop_name, type_code); - } - - // Separate the type defined properties into mandatory and readonly - for (i = 0; i < pstructs_length; i++) - { - const char* pname = pstructs[i].name; - - if (pstructs[i].mode == - CosTradingRepos::ServiceTypeRepository::PROP_MANDATORY) - { - TAO_String_Hash_Key prop_name (pname); - this->mandatory_.insert (prop_name); - } - else if (pstructs[i].mode == - CosTradingRepos::ServiceTypeRepository::PROP_READONLY) - { - TAO_String_Hash_Key prop_name (pname); - this->readonly_.insert (prop_name); - } - } - - // Insert the indices of the offer properties into a map. - for (i = 0; i < props_length; i++) - { - TAO_String_Hash_Key prop_name = - ACE_static_cast (const char*, prop_seq[i].name); - this->props_.bind (prop_name, &prop_seq[i]); - } -} - -TAO_Offer_Modifier::~TAO_Offer_Modifier (void) -{ - for (TAO_Typecode_Table::iterator type_iter (this->prop_types_); - ! type_iter.done (); - type_iter++) - { - CORBA::TypeCode_ptr corba_type = (*type_iter).int_id_; - CORBA::release (corba_type); - } -} - -void -TAO_Offer_Modifier:: -delete_properties (const CosTrading::PropertyNameSeq& deletes, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::Register::UnknownPropertyName, - CosTrading::Register::MandatoryProperty, - CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName)) -{ - // Validate that the listed property names can be deleted - CORBA::ULong i = 0, - length = deletes.length (); - TAO_String_Set delete_me; - - for (i = 0; i < length; i++) - { - const char* dname = ACE_static_cast (const char*, deletes[i]); - if (! TAO_Trader_Base::is_valid_identifier_name (dname)) - TAO_THROW (CosTrading::IllegalPropertyName (dname)); - else - { - TAO_String_Hash_Key prop_name (dname); - if (this->mandatory_.find (prop_name) == 0) - TAO_THROW (CosTrading::Register::MandatoryProperty (this->type_, dname)); - else if (delete_me.insert (prop_name) == 1) - TAO_THROW (CosTrading::DuplicatePropertyName (dname)); - else if (this->props_.find (prop_name) == -1) - TAO_THROW (CosTrading::Register::UnknownPropertyName (dname)); - } - } - - // Delete those properties from the offer. - for (i = 0; i < length; i++) - { - TAO_String_Hash_Key prop_name = - ACE_static_cast (const char *, deletes[i]); - this->props_.unbind (prop_name); - } -} - -void -TAO_Offer_Modifier:: -merge_properties (const CosTrading::PropertySeq& modifies, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName, - CosTrading::PropertyTypeMismatch, - CosTrading::ReadonlyDynamicProperty, - CosTrading::Register::ReadonlyProperty)) -{ - int i = 0, length = 0; - TAO_String_Set modify_me; - - // Ensure that the proposed changes aren't to readonly properties or - // otherwise invalid. - TAO_Property_Evaluator prop_eval (modifies); - for (i = 0, length = modifies.length (); i < length; i++) - { - const char* mname = modifies[i].name; - if (TAO_Trader_Base::is_valid_identifier_name (mname)) - { - TAO_String_Hash_Key prop_name (mname); - if (this->readonly_.find (prop_name) == 0) - { - // Can't assign a dynamic property to a property with - // readonly mode, and can't reassign a readonly property. - if (prop_eval.is_dynamic_property (i)) - TAO_THROW (CosTrading::ReadonlyDynamicProperty (this->type_, mname)); - else if (this->props_.find (prop_name) == 0) - TAO_THROW (CosTrading::Register::ReadonlyProperty (this->type_, mname)); - } - - // Validate the property type if the property is defined in - // the service type description. - CORBA::TypeCode_ptr type_def = 0; - if (this->prop_types_.find (prop_name, type_def) == 0) - { - CORBA::Environment TAO_IN_ENV; - CORBA::TypeCode_var prop_type = prop_eval.property_type (i); - - if (! type_def->equal (prop_type.in (), TAO_IN_ENV)) - TAO_THROW (CosTrading::PropertyTypeMismatch (mname, modifies[i])); - } - - if (modify_me.insert (prop_name) == 1) - TAO_THROW (CosTrading::DuplicatePropertyName (mname)); - } - else - TAO_THROW (CosTrading::IllegalPropertyName (mname)); - } -} - -void -TAO_Offer_Modifier::affect_change (const CosTrading::PropertySeq& modifies) -{ - // Create a new property list reflecting the deletes, modifies, and - // add operations performed, and place this property list in the - // offer. - - // Merge these properties with the original set. - CORBA::ULong i = 0, - merge_length = modifies.length (); - for (i = 0; i < merge_length; i++) - { - Property_Table::ENTRY* entry = 0; - TAO_String_Hash_Key prop_name = modifies[i].name.in (); - - CosTrading::Property* prop = - ACE_const_cast (CosTrading::Property*, &modifies[i]); - if (this->props_.bind (prop_name, prop, entry) == 1) - { - // We need to rebind here. - entry->int_id_ = prop; - } - } - - CORBA::ULong num_modified = 0, - original_length = this->offer_->properties.length (), - total_length = this->props_.current_size (); - - // Scrap the existing property sequence and begin a new one - CosTrading::PropertySeq prop_seq (total_length); - // this->offer_->properties.length (total_length); - - // Copy in the unaffected and modified props into the offer, - // excluding those that were deleted. Let's try and retain their - // relative ordering. - for (i = 0; i < original_length; i++) - { - CosTrading::Property* prop_value = 0; - const char* name = this->offer_->properties[i].name; - TAO_String_Hash_Key prop_name (name); - if (this->props_.unbind (prop_name, prop_value) == 0) - prop_seq[num_modified++] = *prop_value; - } - - for (i = 0; i < merge_length; i++) - { - CosTrading::Property* prop_value = 0; - const char* name = modifies[i].name; - TAO_String_Hash_Key prop_name (name); - if (this->props_.unbind (prop_name, prop_value) == 0) - prop_seq[num_modified++] = *prop_value; - } - - this->offer_->properties.length (total_length); - for (i = 0; i < total_length; i++) - this->offer_->properties[i] = prop_seq[i]; - // Free the old, orphaned sequence. - // CosTrading::PropertySeq::freebuf (prop_buf); -} - - - - // ************************************************************* - // TAO_Offer_Filter - // ************************************************************* - -TAO_Offer_Filter::TAO_Offer_Filter (TAO_Policies& policies, - CORBA::Environment& TAO_IN_ENV) - : search_card_ (policies.search_card (TAO_IN_ENV)), - match_card_ (policies.match_card (TAO_IN_ENV)), - return_card_ (policies.return_card (TAO_IN_ENV)), - dp_ (policies.use_dynamic_properties (TAO_IN_ENV)), - mod_ (policies.use_modifiable_properties (TAO_IN_ENV)) -{ - if (policies.exact_type_match (TAO_IN_ENV) == 1) - { - TAO_String_Hash_Key exact_match - (TAO_Policies::POLICY_NAMES[TAO_Policies::EXACT_TYPE_MATCH]); - this->limits_.insert (exact_match); - } -} - -void -TAO_Offer_Filter:: -configure_type (CosTradingRepos::ServiceTypeRepository::TypeStruct* type_struct) -{ - CosTradingRepos::ServiceTypeRepository::PropStructSeq& - prop_seq = type_struct->props; - - // Take note of non-modifiable properties in the type_struct - this->not_mod_props_.reset (); - for (int i = prop_seq.length () - 1; i >= 0; i--) - { - CosTradingRepos::ServiceTypeRepository::PropertyMode mode = prop_seq[i].mode; - if (mode == CosTradingRepos::ServiceTypeRepository::PROP_MANDATORY_READONLY || - mode == CosTradingRepos::ServiceTypeRepository::PROP_READONLY) - { - TAO_String_Hash_Key prop_name ((const char*) prop_seq[i].name); - this->not_mod_props_.insert (prop_name); - } - } -} - -CORBA::Boolean -TAO_Offer_Filter::ok_to_consider (CosTrading::Offer* offer) -{ - TAO_String_Hash_Key use_mods = - TAO_Policies::POLICY_NAMES[TAO_Policies::USE_MODIFIABLE_PROPERTIES]; - TAO_String_Hash_Key use_dyns = - TAO_Policies::POLICY_NAMES[TAO_Policies::USE_DYNAMIC_PROPERTIES]; - CORBA::Boolean return_value = 1; - TAO_Property_Evaluator prop_eval (*offer); - - // If we should screen offers, determine if this offer is unworthy - // for consideration. - if (! (this->mod_ && this->dp_)) - { - for (int i = offer->properties.length () - 1; - i >= 0 && return_value; - i--) - { - // Winnow away the unwanted offers with modifiable or - // dynamic properties. - if (! this->mod_) - { - // Determine if this property name is found in the set - // of modifiable properties for the type being considered. - TAO_String_Hash_Key prop_name ((const char*) offer->properties[i].name); - if (this->not_mod_props_.find (prop_name) == -1) - { - this->limits_.insert (use_mods); - return_value = 0; - } - } - - if (! this->dp_ && return_value) - { - // Determine if this property is dynamic. - if (prop_eval.is_dynamic_property (i)) - { - this->limits_.insert (use_dyns); - return_value = 0; - } - } - - if (return_value == 0) - break; - } - } - - // If we're good to go, consider this offer considered and decrement - // the search cardinality counter. - if (return_value) - { - this->search_card_--; - if (this->search_card_ == 0) - { - TAO_String_Hash_Key search_card = - TAO_Policies::POLICY_NAMES[TAO_Policies::SEARCH_CARD]; - this->limits_.insert (search_card); - } - } - - return return_value; -} - -CORBA::Boolean -TAO_Offer_Filter::ok_to_consider_more (void) -{ - return this->search_card_ > 0 && this->match_card_ > 0; -} - -void -TAO_Offer_Filter::matched_offer (void) -{ - this->match_card_--; - this->return_card_--; - - if (this->match_card_ == 0) - { - TAO_String_Hash_Key match_card = - TAO_Policies::POLICY_NAMES[TAO_Policies::MATCH_CARD]; - this->limits_.insert (match_card); - } - - if (this->return_card_ == 0) - { - TAO_String_Hash_Key return_card = - TAO_Policies::POLICY_NAMES[TAO_Policies::MATCH_CARD]; - this->limits_.insert (return_card); - } -} - -CORBA::ULong -TAO_Offer_Filter::search_card_remaining (void) const -{ - return this->search_card_; -} - -CORBA::ULong -TAO_Offer_Filter::match_card_remaining (void) const -{ - return this->match_card_; -} - -CosTrading::PolicyNameSeq* -TAO_Offer_Filter::limits_applied (void) -{ - int i = 0; - CORBA::ULong size = this->limits_.size (); - CosTrading::PolicyName* temp = - CosTrading::PolicyNameSeq::allocbuf (size); - - for (TAO_String_Set::iterator p_iter (this->limits_.begin()); - ! p_iter.done (); - p_iter.advance ()) - { - TAO_String_Hash_Key* policy_name_ptr = 0; - p_iter.next (policy_name_ptr); - temp[i++] = CORBA::string_dup ((const char*) *policy_name_ptr); - } - - return new CosTrading::PolicyNameSeq (size, size, temp, 1); -} - - // ************************************************************* - // TAO_Property_Filter - // ************************************************************* - -TAO_Property_Filter:: -TAO_Property_Filter (const SPECIFIED_PROPS& desired_props, - CORBA::Environment& TAO_IN_ENV) - TAO_THROW_SPEC ((CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName)) - : policy_ (desired_props._d ()) -{ - if (this->policy_ == CosTrading::Lookup::some) - { - const CosTrading::PropertyNameSeq& - prop_seq = desired_props.prop_names (); - int length = prop_seq.length (); - - for (int i = 0; i < length; i++) - { - const char* pname = prop_seq[i]; - - // Check for errors or duplicates - if (TAO_Trader_Base::is_valid_identifier_name (pname)) - { - TAO_String_Hash_Key prop_name (pname); - if (this->props_.insert (prop_name) == 1) - TAO_THROW (CosTrading::DuplicatePropertyName (pname)); - } - else - TAO_THROW (CosTrading::IllegalPropertyName (pname)); - } - } -} - -TAO_Property_Filter:: -TAO_Property_Filter (const TAO_Property_Filter& prop_filter) - : props_ (prop_filter.props_), - policy_ (prop_filter.policy_) -{ -} - -TAO_Property_Filter& -TAO_Property_Filter::operator= (const TAO_Property_Filter& other) -{ - this->props_ = other.props_; - this->policy_ = other.policy_; - - return *this; -} - -void -TAO_Property_Filter::filter_offer (CosTrading::Offer* source, - CosTrading::Offer& destination) -{ - Prop_Queue prop_queue; - CosTrading::PropertySeq& s_props = source->properties; - CosTrading::PropertySeq& d_props = destination.properties; - CORBA::ULong length = s_props.length (), elem = 0; - - destination.reference = CORBA::Object::_duplicate (source->reference.in ()); - if (this->policy_ == CosTrading::Lookup::some) - { - for (CORBA::ULong i = 0; i < length; i++) - { - if (this->policy_ == CosTrading::Lookup::all) - prop_queue.enqueue_tail (&s_props[i]); - else - { - const char* p_name = s_props[i].name; - TAO_String_Hash_Key prop_name (p_name); - - // Save those property that match. - if (this->props_.find (prop_name) == 0) - prop_queue.enqueue_tail (&s_props[i]); - } - } - - // Shove the matched properties into the destination property - // sequence. - length = prop_queue.size (); - d_props.length (prop_queue.size ()); - for (Prop_Queue::ITERATOR prop_iter (prop_queue); - ! prop_iter.done (); - prop_iter.advance (), elem++) - { - CosTrading::Property** prop_ptr = 0; - - prop_iter.next (prop_ptr); - d_props[elem] = **prop_ptr; - } - } - else if (this->policy_ == CosTrading::Lookup::all) - { - d_props = s_props; - // CosTrading::Property* props = s_props.get_buffer (0); - // d_props.replace (length, length, props, 0); - } -} - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Hash_Map_Entry; -template class ACE_Hash_Map_Manager; -template class ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator; -template class ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator; -template class ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; -template class ACE_Node; -template class ACE_Unbounded_Queue; -template class ACE_Unbounded_Queue_Iterator; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Hash_Map_Entry -#pragma instantiate ACE_Hash_Map_Manager -#pragma instantiate ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator -#pragma instantiate ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> -#pragma instantiate ACE_Node -#pragma instantiate ACE_Unbounded_Queue -#pragma instantiate ACE_Unbounded_Queue_Iterator -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.h b/TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.h deleted file mode 100644 index dcb170e9e3b..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.h +++ /dev/null @@ -1,772 +0,0 @@ -/* -*- C++ -*- */ - -// ======================================================================== -// $Id$ -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// Trader_Utils.h -// -// = AUTHOR -// Seth Widoff -// -// Client Utils: -// TAO_Dynamic_Property -// TAO_Policy_Manager -// TAO_Property_Evaluator -// TAO_Property_Evaluator_By_Name -// -// Service Utils: -// TAO_Policies -// TAO_Offer_Filter -// TAO_Offer_Modifier -// TAO_Property_Filter -// TAO_Property_Evaluator -// TAO_Property_Evaluator_By_Name -// -// ======================================================================== - -#ifndef TAO_TRADER_UTILS_H -#define TAO_TRADER_UTILS_H - -#include "Trader.h" - - // ************************************************************* - // TAO_Property_Evaluator - // ************************************************************* - -class TAO_ORBSVCS_Export TAO_Property_Evaluator -// -// = TITLE -// This class abstracts away the details of obtaining property -// values and property types. Since the procedure for obtaining the -// value or type of a dynamic property is disparate from the method -// for a static property, TAO_Property_Evaluator provides methods -// that will unify the two approaches under a single -// interface. Since dynamic properties aren't necessarily supported -// by a trader, this class accounts for that contingency. The use of -// indexed lookups allows them to occur in constant time on the -// CORBA sequences, but requires that the client know the layout of -// properties ahead of time. -{ -public: - - TAO_Property_Evaluator(const CosTrading::PropertySeq& properties, - CORBA::Boolean supports_dp = 1); - - TAO_Property_Evaluator(CosTrading::Offer& offer, - CORBA::Boolean supports_dp = 1); - // Construct an instance of TAO_Property_Evaluator that operates on - // an where the support for dynamic properties is dictated - // by . - - virtual ~TAO_Property_Evaluator (void); - // Clean up dynamic properties. - - int is_dynamic_property(int index); - // Returns 1 if the property at index is dynamic. Returns a - // 0 when the index is out of bounds. - - CORBA::Any* property_value(int index, CORBA::Environment& _env) - TAO_THROW_SPEC ((CosTradingDynamic::DPEvalFailure)); - - // Returns value of the property whose index is . If the - // property at that index is dynamic and the trader supports dynamic - // properties, then the property_value method will obtain the value - // of the dynamic property using the evalDP method on the - // CosTradingDynamic::DynamicPropEval interface, passing on a - // CosTradingDynamic::DPEvalFailure exception on failure. If the - // property index is undefined, the method returns a null pointer. - - CORBA::TypeCode_ptr property_type (int index); - // Returns the type of the property whose index is . If the - // property is dynamic and the trader supports dynamic properties, - // then the method returns the field of the - // CosTradingDynamic::DynamicProp struct associated with the - // property name. If the index is out of bounds, the method returns - // a null pointer (that is, 0). - - protected: - - typedef CosTradingDynamic::DynamicProp DP_Struct; - typedef CosTradingDynamic::DynamicPropEval DP_Eval; - - const CosTrading::PropertySeq& props_; - // The offer from which the TAO_Property_Evaluator extracts property - // information. - - int supports_dp_; - - CORBA::Any** dp_cache_; - // In order for the client to treat the results of property_value - // uniformly, we need to collect the dynamically allocated anys - // retrieved from dynamic properties and free them upon deletion. If - // we didn't do this, then the property_value method would leak or - // cause seg faults, since the client wouldn't be able to tell - // whether or not the return value should be freed. - - private: - - TAO_Property_Evaluator (const TAO_Property_Evaluator&); - TAO_Property_Evaluator& operator= (const TAO_Property_Evaluator&); -}; - - // ************************************************************* - // TAO_Property_Evaluator_By_Name - // ************************************************************* - -class TAO_ORBSVCS_Export TAO_Property_Evaluator_By_Name : - public TAO_Property_Evaluator -// -// = TITLE -// This class extends the TAO_Property_Evaluator to allow lookups -// based on the property name of interest. Since the property -// information is contained within an integer indexed array, -// lookups may occur in O(n) time, where n is the length of the -// array. To make lookups by name more efficient, -// TAO_Property_Evaluator_By_Name creates a mapping of property -// names to integer indicies, upon which lookups are guaranteed to -// be O(lg n). -{ -public: - - TAO_Property_Evaluator_By_Name (const CosTrading::PropertySeq& properties, - CORBA::Environment& _env, - CORBA::Boolean supports_dp = 1) - TAO_THROW_SPEC ((CosTrading::DuplicatePropertyName, - CosTrading::IllegalPropertyName)); - - TAO_Property_Evaluator_By_Name(CosTrading::Offer& offer, - CORBA::Boolean supports_dp = 1); - // Construct an instance of TAO_Property_Evaluator that operates on - // an where the support for dynamic properties is dictated - // by . - - int is_dynamic_property(const char* property_name); - // Returns 1 if the property whose name is is - // defined and dynamic. If the property is undefined, this method - // will throw a Property_Undefined exception with impunity. - - CORBA::Any* property_value(const char* property_name, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CosTradingDynamic::DPEvalFailure)); - - // This method is identical to its counterpart in - // TAO_Property_Evaluator, except property_value first discovers the - // index through a string matching lookup. - - CORBA::TypeCode_ptr property_type(const char* property_name); - // This method is identical to its counterpart in - // TAO_Property_Evaluator, exception property_type first discovers - // the index through a string matching lookup. - - const CosTrading::Property* get_property (const char* property_name); - -private: - - TAO_Property_Evaluator_By_Name (const TAO_Property_Evaluator_By_Name&); - TAO_Property_Evaluator_By_Name& operator= (const TAO_Property_Evaluator_By_Name&); - - TAO_Lookup_Table table_; - // The instance of the above mapping for the offer provided in the - // constructor. -}; - - // ************************************************************* - // TAO_Dynamic_Property - // ************************************************************* - -class TAO_ORBSVCS_Export TAO_Dynamic_Property : - public POA_CosTradingDynamic::DynamicPropEval -// = TITLE -// Little helper class that you can extend to have your dynamic -// property handler construct CosTradingDynamic::DynamicProp structs. -{ -public: - - TAO_Dynamic_Property (void) {} - - TAO_Dynamic_Property (const TAO_Dynamic_Property &) {} - - virtual ~TAO_Dynamic_Property (void); - - virtual CORBA::Any* evalDP(const char* name, - CORBA::TypeCode_ptr returned_type, - const CORBA::Any& extra_info, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CORBA::SystemException, - CosTradingDynamic::DPEvalFailure)) = 0; - // Dynamic property evaluation call-back method. - - CosTradingDynamic::DynamicProp* - construct_dynamic_prop (const char* name, - CORBA::TypeCode_ptr returned_type, - const CORBA::Any& extra_info); - // Method to construct a dynamic property structure suitable for - // exporting in a CosTrading::PropertyStruct to the Trading Service. -}; - - - // ************************************************************* - // TAO_Policies - // ************************************************************* - -class TAO_Policies -// -// = TITLE -// This class ensures that policies submitted to Lookup make sense, -// have the correct value types, and don't exceed the maximums set -// through the Admin Interface. -// -// = DESCRIPTION -// TAO_Policies does an admirable job of reconciling differences -// between the default parameter settings of the Trader and the import -// and other policies set by the client. Unbeknownst to its client -// TAO_Policies hides this arbitration, and records whether the user -// policy was chosen, or the default. This information gets returned -// to the invoker of the query method. -{ -public: - -#define TAO_NUM_POLICIES 11 - - enum POLICY_TYPE - { - STARTING_TRADER, - EXACT_TYPE_MATCH, - HOP_COUNT, - LINK_FOLLOW_RULE, - MATCH_CARD, - RETURN_CARD, - SEARCH_CARD, - USE_DYNAMIC_PROPERTIES, - USE_MODIFIABLE_PROPERTIES, - USE_PROXY_OFFERS, - REQUEST_ID - }; - // This enum represents the relative order that properties are - // passed from one trader to another. Hence, as recommended by the - // spec, the starting_trader policies will be the first element in - // the polcy sequence if it's set for a query. - - static const char * POLICY_NAMES[]; - - TAO_Policies (TAO_Trader_Base& trader, - const CosTrading::PolicySeq& policies, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CosTrading::Lookup::IllegalPolicyName, - CosTrading::DuplicatePolicyName)); - - // BEGIN SPEC - // The "policies" parameter allows the importer to specify how the - // search should be performed as opposed to what sort of services - // should be found in the course of the search. This can be viewed - // as parameterizing the algorithms within the trader - // implementation. The "policies" are a sequence of name-value - // pairs. The names available to an importer depend on the - // implementation of the trader. However, some names are - // standardized where they effect the interpretation of other - // parameters or where they may impact linking and federation of - // traders. ° If a policy name in this parameter does not obey the - // syntactic rules for legal PolicyName's, then an IllegalPolicyName - // exception is raised. ° If the type of the value associated with a - // policy differs from that specified in this specification, then a - // PolicyTypeMismatch exception is raised. ° If subsequent - // processing of a PolicyValue yields any errors (e.g., the - // starting_trader policy value is malformed), then an - // InvalidPolicyValue exception is raised. ° If the same policy name - // is included two or more times in this parameter, then the - // DuplicatePolicyName exception is raised. - // END SPEC - - ~TAO_Policies (void); - - CORBA::ULong search_card (CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); - - // BEGIN SPEC - // The "search_card" policy indicates to the trader the maximum - // number of offers it should consider when looking for type - // conformance and constraint expression match. The lesser of this - // value and the trader's max_search_card attribute is used by the - // trader. If this policy is not specified, then the value of the - // trader's def_search_card attribute is used. - // END SPEC - - CORBA::ULong match_card (CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); - - // BEGIN SPEC - // The "match_card" policy indicates to the trader the maximum - // number of matching offers to which the preference specification - // should be applied. The lesser of this value and the trader's - // max_match_card attribute is used by the trader. If this policy is - // not specified, then the value of the trader's def_match_card - // attribute is used. - // END SPEC - - CORBA::ULong return_card (CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); - - // BEGIN SPEC - // The "return_card" policy indicates to the trader the maximum - // number of matching offers to return as a result of this - // query. The lesser of this value and the trader's max_return_card - // attribute is used by the trader. If this policy is not specified, - // then the value of the trader's def_return_card attribute is - // used. - // END SPEC - - // = Offer consideration policies - - CORBA::Boolean use_modifiable_properties (CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); - - // BEGIN SPEC - // The "use_modifiable_properties" policy indicates whether the - // trader should consider offers which have modifiable properties - // when constructing the set of offers to which type conformance and - // constraint processing should be applied. If the value of this - // policy is TRUE, then such offers will be included; if FALSE, they - // will not. If this policy is not specified, such offers will be - // included. - // END SPEC - - CORBA::Boolean use_dynamic_properties (CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); - - // BEGIN SPEC - // The "use_dynamic_properties" policy indicates whether the trader - // should consider offers which have dynamic properties when - // constructing the set of offers to which type conformance and - // constraint processing should be applied. If the value of this - // policy is TRUE, then such offers will be included; if FALSE, they - // will not. If this policy is not specified, such offers will be - // included. - // END SPEC - - CORBA::Boolean use_proxy_offers (CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); - - // BEGIN SPEC - // The "use_proxy_offers" policy indicates whether the trader should - // consider proxy offers when constructing the set of offers to - // which type conformance and constraint processing should be - // applied. If the value of this policy is TRUE, then such offers - // will be included; if FALSE, they will not. If this policy is not - // specified, such offers will be included. - // END SPEC - - CORBA::Boolean exact_type_match (CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); - - // BEGIN SPEC - // The "exact_type_match" policy indicates to the trader whether the - // importer's service type must exactly match an offer's service - // type; if not (and by default), then any offer of a type - // conformant to the importer's service type is considered. - // END SPEC - - // = Federated trader policies (not implemented yet) - - CosTrading::TraderName* starting_trader (CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch, - CosTrading::Lookup::InvalidPolicyValue)); - // BEGIN SPEC - // The "starting_trader" policy facilitates the distribution of the - // trading service itself. It allows an importer to scope a search - // by choosing to explicitly navigate the links of the trading - // graph. If the policy is used in a query invocation it is - // recommended that it be the first policy-value pair; this - // facilitates an optimal forwarding of the query operation. A - // "policies" parameter need not include a value for the - // "starting_trader" policy. Where this policy is present, the first - // name component is compared against the name held in each link. If - // no match is found, the InvalidPolicyValue exception is - // raised. Otherwise, the trader invokes query() on the Lookup - // interface held by the named link, but passing the - // "starting_trader" policy with the first component removed. - // END SPEC - - CosTrading::FollowOption link_follow_rule (CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); - // Determine the link follow policy for this query overall. - - // BEGIN SPEC - //The "link_follow_rule" policy indicates how the client wishes - //links to be followed in the resolution of its query. See the - //discussion in "Link Follow Behavior" on page 16-16 for details. - // END SPEC - - - CosTrading::FollowOption link_follow_rule (const CosTrading::Link::LinkInfo& link_info, - CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch, - CosTrading::Lookup::InvalidPolicyValue, - CosTrading::Link::IllegalLinkName, - CosTrading::Link::UnknownLinkName)); - // Determine the link follow policy for a given . - // This method returns the link_follow_rule for a link whose name is - // using the following formula: - // if the importer specified a link_follow_rule policy - // min(trader.max_follow_policy, link.limiting_follow_rule, - // query.link_follow_rule) - // else min(trader.max_follow_policy, link.limiting_follow_rule, - // trader.def_follow_policy) - - CORBA::ULong hop_count (CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); - - // BEGIN SPEC - // The "hop_count" policy indicates to the trader the maximum number - // of hops across federation links that should be tolerated in the - // resolution of this query. The hop_count at the current trader is - // determined by taking the minimum of the trader's max_hop_count - // attribute and the importer's hop_count policy, if provided, or - // the trader's def_hop_count attribute if it is not. If the - // resulting value is zero, then no federated queries are - // permitted. If it is greater than zero, then it must be - // decremented before passing on to a federated trader. - // END SPEC - - CosTrading::Admin::OctetSeq* request_id (CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); - // Return the request_id passed to the query method across a link to - // another trader. - - void copy_to_pass (CosTrading::PolicySeq& policy_seq, - const CosTrading::Admin::OctetSeq& request_id) const; - // Policies to forward to the next trader in a federated query. - - void copy_to_forward (CosTrading::PolicySeq& policy_seq, - const CosTrading::TraderName& name) const; - // Policies to forward to the next trader in a directed query. - - void copy_in_follow_option (CosTrading::PolicySeq& policy_seq, - const CosTrading::Link::LinkInfo& link_info, - CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch, - CosTrading::Lookup::InvalidPolicyValue)); - // Determine the link follow policy to pass down the link with . - // This method returns the link_follow_rule for a link whose name is - // using the following formula: - // If the importer specified a link_follow_rule, policy - // pass on min(query.link_follow_rule, link.limiting_follow_rule, - // trader.max_follow_policy) - // else pass on min(link.def_pass_on_follow_rule, - // trader.max_follow_policy) - -private: - - CORBA::ULong ulong_prop (POLICY_TYPE pol, - CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); - // Reconclile a ULong property with its default. - - CORBA::Boolean boolean_prop (POLICY_TYPE pol, - CORBA::Environment& _env) const - TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); - // Reconcile a Boolean property with its debault. - - TAO_Policies (const TAO_Policies&); - TAO_Policies& operator= (const TAO_Policies&); - - CosTrading::Policy* policies_[TAO_NUM_POLICIES]; - // The policies indexable from the enumerated type. - - TAO_Trader_Base& trader_; - // For the validating identifier names. -}; - - // ************************************************************* - // TAO_Policy_Manager - // ************************************************************* - -class TAO_ORBSVCS_Export TAO_Policy_Manager -// = TITLE -// -// This class is a utility for clients using the CosTrading::Lookup -// interface that helps them build a policy sequence without violating -// syntax rules and having to mess with typecodes. -{ -public: - - TAO_Policy_Manager (int num_policies = 0); - - // = Routines to set policies. - - void search_card (CORBA::ULong scard); - // Set the maximum number of offers searched for the query. - - void match_card (CORBA::ULong mcard); - // Set the maximum number of offers searched for the query. - - void return_card (CORBA::ULong rcard); - // Set the maximum number of offers rerturned for the query. - - // A note about cardinalities: The spec implies that these - // cardinalities apply to the global office space, that is, all - // offers on all linked traders. However, there's no mechanism for - // one trader to return to the calling trader the number of offers - // searched or matched. Thus, these cardinalities are applied on a - // per-trader basis. - - void use_modifiable_properties (CORBA::Boolean mod_props); - // Consider offers with modifiable properties. - - void use_dynamic_properties (CORBA::Boolean dyn_props); - // Consider offers with dynamic properties. - - void use_proxy_offers (CORBA::Boolean prox_offs); - // Consider proxy offers (NOT SUPPORTED). - - void starting_trader (const CosTrading::TraderName& name); // Copy - void starting_trader (CosTrading::TraderName* name); // Own - // Designate a trader at which to begin the query. - - void link_follow_rule (CosTrading::FollowOption follow_option); - // Specify under what conditions a federated query is appropriate. - - void hop_count (CORBA::ULong hop_count); - // Limit the breadth of a federated query. - - void request_id (const CosTrading::Admin::OctetSeq& request_id); - // Set the identifier for this query (clients shouldn't use this). - - void exact_type_match (CORBA::Boolean exact_type); - // Search only the designated type --- not it's subtypes. - - operator const CosTrading::PolicySeq& (void) const; - // Return the constructed policy sequence. - - const CosTrading::PolicySeq& policy_seq (void) const; - // Return a PolicySeq suitable for passing to the query method of - // the Lookup interface. - -private: - - TAO_Policy_Manager (const TAO_Policy_Manager&); - TAO_Policy_Manager& operator= (const TAO_Policy_Manager&); - - CosTrading::Policy& fetch_next_policy (TAO_Policies::POLICY_TYPE pol_type); - // Method to prepare the next slot in the policies_ sequence for - // policy insertion. - - int poltable_[TAO_Policies::REQUEST_ID + 1]; - // Table mapping policy enum value to the index in the policies sequence. - - CosTrading::PolicySeq policies_; - // The sequence being prepared for submittal to the query method. - - CORBA::ULong num_policies_; - // The number of policies so far in the sequence. -}; - - - // ************************************************************* - // TAO_Offer_Modifier - // ************************************************************* - -class TAO_Offer_Modifier -// = TITLE -// This class deletes, modifies, and adds properties to a given -// offer according to the rules of the modify method on the Register -// interface. -{ -public: - - TAO_Offer_Modifier (const char* type, - const CosTradingRepos::ServiceTypeRepository::TypeStruct& type_struct, - CosTrading::Offer* offer); - // Modify an of type , whose properties are described - // by - - ~TAO_Offer_Modifier (void); - - void delete_properties (const CosTrading::PropertyNameSeq& deletes, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CosTrading::Register::UnknownPropertyName, - CosTrading::Register::MandatoryProperty, - CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName)); - // Delete the properties whose names were given to the - // constructor. Ensure we don't delete mandatory properties. - - void merge_properties (const CosTrading::PropertySeq& modifies, - CORBA::Environment& _env) - TAO_THROW_SPEC ((CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName, - CosTrading::PropertyTypeMismatch, - CosTrading::ReadonlyDynamicProperty, - CosTrading::Register::ReadonlyProperty)); - // Copy to the destination the union of the source and destination - // properties. In the case of duplicate properties, update the - // destination with the source's value. This class claims the memory - // in the modifies sequence. - - void affect_change (const CosTrading::PropertySeq& modifies); - // Return a reference to the Offer with the changes affected. - -private: - - TAO_Offer_Modifier (const TAO_Offer_Modifier&); - TAO_Offer_Modifier& operator= (const TAO_Offer_Modifier&); - - typedef ACE_Hash_Map_Manager - < - TAO_String_Hash_Key, - CosTrading::Property*, - ACE_Null_Mutex - > - Property_Table; - - const char* type_; - // The type of the offer. - - Property_Table props_; - // The map of properties in the offer. - - TAO_Typecode_Table prop_types_; - // Table of property types. - - TAO_String_Set readonly_, mandatory_; - // The set of readonly and mandatory property names in the offer's - // type. - - CosTrading::Offer* offer_; - // A reference to the offer undergoing change. -}; - - // ************************************************************* - // TAO_Offer_Filter - // ************************************************************* - -class TAO_Offer_Filter -// = TITLE -// The purpose of this class is to ensure that offers that -// shouldn't be considered by the TAO_Constraint_Interpreter -// aren't. -// -// = DESCRIPTION -// There two classes of reasons why an offer for a correct -// type shouldn't be considered: 1) The default parameters of the -// Trader or policies passed to the Lookup::query method deem it -// inappropriate to consider offers with modifiable (i.e., not -// readonly) or dynamic properties. 2) We've exceeded the -// default or provided cardinality constraints. TAO_Offer_Filter -// ensures that violation of policies doesn't occur. It's the -// enforcer. -{ -public: - - TAO_Offer_Filter (TAO_Policies& policies, - CORBA::Environment& _env); - // Glean from the TypeStruct and Policy setting the appropriate way - // to screen unsuitable offers from consideration. - - void configure_type (CosTradingRepos::ServiceTypeRepository::TypeStruct* type_struct); - // Set the offer filter to screen for offers containing properties - // that aren't marked as readonly in this TypeStruct. - - CORBA::Boolean ok_to_consider (CosTrading::Offer* offer); - // Determine whether the poicies contained in the given policy - // object allow the Lookup interface to consider the offer. That is, - // if use_modifiable_properties is false, and the offer contains - // modifiable properties as designated in the type struct, return - // false. If use_dynamic_properties is false, and the offer contains - // dynamic properties, then return false. If the lookup interface is - // safe in considering this offer, return true and subtract from the - // search card value. When the search card value falls to zero, - // ok_to_consider always returns false. - - CORBA::Boolean ok_to_consider_more (void); - // It's ok to consider more offers when lookup hasn't exceeded the - // cardinality values for searching and matching offers. - - void matched_offer (void); - // Signal that the Lookup method has matched an offer; decrement the - // match_card. - - // = Return the limits applied. - CosTrading::PolicyNameSeq* limits_applied (void); - // BEGIN SPEC - // If any cardinality or other limits were applied by one or more - // traders in responding to a particular query, then the - // "limits_applied" parameter will contain the names of the policies - // which limited the query. The sequence of names returned in - // "limits_applied" from any federated or proxy queries must be - // concatenated onto the names of limits applied locally and - // returned. - // END SPEC - - CORBA::ULong search_card_remaining (void) const; - CORBA::ULong match_card_remaining (void) const; - // Accessors to retrieve the adjusted cardinalities. - -private: - - TAO_Offer_Filter (const TAO_Offer_Filter&); - TAO_Offer_Filter& operator= (const TAO_Offer_Filter&); - - TAO_String_Set not_mod_props_; - // The set of the name of modifiable properties. - - TAO_String_Set limits_; - // Cardinality and property limitations applied. - - CORBA::ULong search_card_, match_card_, return_card_; - // Keep track of the cardinalities. - - CORBA::Boolean dp_; - CORBA::Boolean mod_; - // Keep track of property limitations: modifiable or dynamic ones - // may be bad. -}; - - // ************************************************************* - // TAO_Property_Filter - // ************************************************************* - -class TAO_Property_Filter -// = TITLE -// -// The Ace_Property_Filter copies those properties specified in a -// CosTrading::Lookup::SpecifiedProps from a source -// CosTrading::Offer to a destination CosTrading::Offer. -{ -public: - - typedef CosTrading::Lookup::SpecifiedProps SPECIFIED_PROPS; - - TAO_Property_Filter (void) : policy_ (CosTrading::Lookup::all) {} - // An accomplice to g++'s insane lust for copy constructors. - - TAO_Property_Filter (const SPECIFIED_PROPS& desired_props, - CORBA::Environment& env) - TAO_THROW_SPEC ((CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName)); - // Verify that the specified properties are correct. - - TAO_Property_Filter (const TAO_Property_Filter& prop_filter); - TAO_Property_Filter& operator= (const TAO_Property_Filter& prop_filter); - - void filter_offer (CosTrading::Offer* source, - CosTrading::Offer& destination); - // Copy the desired properties from the source offer to the - // destination offer. - -private: - - typedef ACE_Unbounded_Queue< CosTrading::Property* > Prop_Queue; - - TAO_String_Set props_; - CosTrading::Lookup::HowManyProps policy_; -}; - - // ************************************************************* - // Miscellaneous - // ************************************************************* - -#endif /* TAO_TRADER_UTILS_H */ diff --git a/TAO/orbsvcs/orbsvcs/Trader/constraint.l b/TAO/orbsvcs/orbsvcs/Trader/constraint.l deleted file mode 100644 index c4476bacce1..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/constraint.l +++ /dev/null @@ -1,131 +0,0 @@ -%{ -// $Id$ -// ======================================================================== -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// constraint.l -// -// = AUTHOR -// Seth Widoff -// -// ======================================================================== - -#include "ace/OS.h" -#include "Constraint_Interpreter.h" -#include "Constraint_Nodes.h" -#include "Constraint_Tokens.h" - -static TAO_Literal_Constraint* extract_string(const char*); - -#define TAO_YY_LEX_DEBUG - -#ifdef TAO_CONSTRAINT_DEBUG -#define TAO_YY_LEX_DEBUG TAO_OS::fprintf(stderr, "%s\n", yytext) -#endif /* TAO_CONSTRAINT_DEBUG */ - - -%} - -white_space [ \t] -letter [a-zA-Z] -digit [0-9] -alpha_num ({letter}|{digit}) -integer {digit}+ -float ({digit}*\.{digit}+)([eE][-+]?{digit}+)? -string '(([^'\\]*)|([^'\\]*\\')|([^'\\]*\\\\))*' -ident {letter}({alpha_num}|[_])* -newline \n -unknown [^ \t] - -%% - -min { TAO_YY_LEX_DEBUG; return TAO_MIN; } -max { TAO_YY_LEX_DEBUG; return TAO_MAX; } -first { TAO_YY_LEX_DEBUG; return TAO_FIRST; } -random { TAO_YY_LEX_DEBUG; return TAO_RANDOM; } -with { TAO_YY_LEX_DEBUG; return TAO_WITH; } -exist { TAO_YY_LEX_DEBUG; return TAO_EXIST; } -not { TAO_YY_LEX_DEBUG; return TAO_NOT; } -and { TAO_YY_LEX_DEBUG; return TAO_AND; } -or { TAO_YY_LEX_DEBUG; return TAO_OR; } -in { TAO_YY_LEX_DEBUG; return TAO_IN; } -"~" { TAO_YY_LEX_DEBUG; return TAO_TWIDDLE; } -"+" { TAO_YY_LEX_DEBUG; return TAO_PLUS; } -"-" { TAO_YY_LEX_DEBUG; return TAO_MINUS; } -"*" { TAO_YY_LEX_DEBUG; return TAO_MULT; } -"/" { TAO_YY_LEX_DEBUG; return TAO_DIV; } -"<" { TAO_YY_LEX_DEBUG; return TAO_LT; } -"<=" { TAO_YY_LEX_DEBUG; return TAO_LE; } -">" { TAO_YY_LEX_DEBUG; return TAO_GT; } -">=" { TAO_YY_LEX_DEBUG; return TAO_GE; } -"==" { TAO_YY_LEX_DEBUG; return TAO_EQ; } -"!=" { TAO_YY_LEX_DEBUG; return TAO_NE; } -"(" { TAO_YY_LEX_DEBUG; return TAO_LPAREN; } -")" { TAO_YY_LEX_DEBUG; return TAO_RPAREN; } -TRUE { - yylval.constraint_ = - new TAO_Literal_Constraint((CORBA::Boolean) 1); - TAO_YY_LEX_DEBUG; return TAO_BOOLEAN; - } -FALSE { - yylval.constraint_ = - new TAO_Literal_Constraint((CORBA::Boolean) 0); - TAO_YY_LEX_DEBUG; return TAO_BOOLEAN; - } -{integer} { - yylval.constraint_ = - new TAO_Literal_Constraint((CORBA::Long)atoi(yytext)); - TAO_YY_LEX_DEBUG; return TAO_NUMBER; - } -{float} { - yylval.constraint_ = - new TAO_Literal_Constraint((CORBA::Double)atof(yytext)); - TAO_YY_LEX_DEBUG; return TAO_NUMBER; - } -{string} { - yylval.constraint_ = extract_string(yytext); - TAO_YY_LEX_DEBUG; return TAO_STRING; - } -{ident} { - yylval.constraint_ = - new TAO_Property_Constraint(yytext); - TAO_YY_LEX_DEBUG; return TAO_IDENT; - } -{unknown} { - TAO_YY_LEX_DEBUG; return TAO_UNKNOWN; - } -%% - -TAO_Literal_Constraint* -extract_string(const char* total) -{ - int prev_slash = 0, - ctr = 0; - char str[BUFSIZ], - *tmp = (char*) total + 1; - - while (*tmp != '\0') - { - if (*tmp == '\\') - { - if (prev_slash) - prev_slash = 0; - else - { - prev_slash = 1; - continue; - } - } - else if (*tmp == '\'') - prev_slash = 0; - - str[ctr++] = *tmp; - tmp++; - } - - str[ctr - 1] = '\0'; - return new TAO_Literal_Constraint(str); -} \ No newline at end of file diff --git a/TAO/orbsvcs/orbsvcs/Trader/constraint.y b/TAO/orbsvcs/orbsvcs/Trader/constraint.y deleted file mode 100644 index 1e5ab5c81cf..00000000000 --- a/TAO/orbsvcs/orbsvcs/Trader/constraint.y +++ /dev/null @@ -1,136 +0,0 @@ -%{ - // $Id$ -// ======================================================================== -// -// = LIBRARY -// orbsvcs -// -// = FILENAME -// constraint.y -// -// = AUTHOR -// Seth Widoff -// -// ======================================================================== - -#include "ace/OS.h" -#include "Constraint_Interpreter.h" -#include "Constraint_Nodes.h" - -//#define YYDEBUG 1 -%} - -%token TAO_GT TAO_GE TAO_LT TAO_LE TAO_EQ TAO_NE TAO_EXIST -%token TAO_AND TAO_OR TAO_NOT TAO_IN TAO_TWIDDLE TAO_BOOLEAN -%token TAO_PLUS TAO_MINUS TAO_MULT TAO_DIV TAO_UMINUS TAO_NUMBER -%token TAO_RPAREN TAO_LPAREN TAO_IDENT TAO_STRING TAO_UNKNOWN -%token TAO_UNSIGNED TAO_SIGNED TAO_DOUBLE TAO_CONSTRAINT TAO_SEQUENCE -%token TAO_WITH TAO_MAX TAO_MIN TAO_FIRST TAO_RANDOM - -%start constraint - -%type TAO_IDENT TAO_NUMBER TAO_STRING TAO_BOOLEAN -%type constraint preference bool_or bool_and bool_compare -%type expr_in expr_twiddle expr term factor_not factor - -%% - -constraint: bool_or - { $$ = new TAO_Unary_Constraint(TAO_CONSTRAINT, $1); } - | preference - { $$ = $1; } - ; - -preference: TAO_MIN bool_or -{ $$ = new TAO_Unary_Constraint(TAO_MIN, $2); } - | TAO_MAX bool_or -{ $$ = new TAO_Unary_Constraint(TAO_MAX, $2); } - | TAO_WITH bool_or -{ $$ = new TAO_Unary_Constraint(TAO_WITH, $2); } - | TAO_FIRST -{ $$ = new TAO_Noop_Constraint(TAO_FIRST); } - | TAO_RANDOM -{ $$ = new TAO_Noop_Constraint(TAO_RANDOM); } - ; - -bool_or: bool_or TAO_OR bool_and - { $$ = new TAO_Binary_Constraint(TAO_OR, $1, $3); } - | bool_and - { $$ = $1; } - ; - -bool_and: bool_and TAO_AND bool_compare - { $$ = new TAO_Binary_Constraint(TAO_AND, $1, $3); } - | bool_compare - { $$ = $1; } - ; - -bool_compare: expr_in TAO_EQ expr_in - { $$ = new TAO_Binary_Constraint(TAO_EQ, $1, $3); } - | expr_in TAO_NE expr_in - { $$ = new TAO_Binary_Constraint(TAO_NE, $1, $3); } - | expr_in TAO_GT expr_in - { $$ = new TAO_Binary_Constraint(TAO_GT, $1, $3); } - | expr_in TAO_GE expr_in - { $$ = new TAO_Binary_Constraint(TAO_GE, $1, $3); } - | expr_in TAO_LT expr_in - { $$ = new TAO_Binary_Constraint(TAO_LT, $1, $3); } - | expr_in TAO_LE expr_in - { $$ = new TAO_Binary_Constraint(TAO_LE, $1, $3); } - | expr_in - { $$ = $1; } - ; - -expr_in: expr_twiddle TAO_IN TAO_IDENT - { $$ = new TAO_Binary_Constraint(TAO_IN, $1, $3); } - | expr_twiddle - { $$ = $1; } - ; - -expr_twiddle: expr TAO_TWIDDLE expr - { $$ = new TAO_Binary_Constraint(TAO_TWIDDLE, $1, $3); } - | expr - { $$ = $1; } - ; - -expr: expr TAO_PLUS term - { $$ = new TAO_Binary_Constraint(TAO_PLUS, $1, $3); } - | expr TAO_MINUS term - { $$ = new TAO_Binary_Constraint(TAO_MINUS, $1, $3); } - | term - { $$ = $1; } - ; - -term: term TAO_MULT factor_not - { $$ = new TAO_Binary_Constraint(TAO_MULT, $1, $3); } - | term TAO_DIV factor_not - { $$ = new TAO_Binary_Constraint(TAO_DIV, $1, $3); } - | factor_not - { $$ = $1; } - ; - -factor_not: TAO_NOT factor - { $$ = new TAO_Unary_Constraint(TAO_NOT, $2); } - | factor - { $$ = $1; } - ; - -factor: TAO_LPAREN bool_or TAO_RPAREN - { $$ = $2; } - | TAO_EXIST TAO_IDENT - { $$ = new TAO_Unary_Constraint(TAO_EXIST, $2); } - | TAO_IDENT - { $$ = $1; } - | TAO_NUMBER - { $$ = $1; } - | TAO_MINUS TAO_NUMBER - { $$ = new TAO_Unary_Constraint(TAO_UMINUS, $2); } - | TAO_STRING - { $$ = $1; } - | TAO_BOOLEAN - { $$ = $1; } - ; - -%% - -//extern int yydebug = 1; -- cgit v1.2.1