diff options
Diffstat (limited to 'TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.h')
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.h | 254 |
1 files changed, 151 insertions, 103 deletions
diff --git a/TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.h b/TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.h index 962eea88816..ead8aa6c008 100644 --- a/TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.h +++ b/TAO/orbsvcs/orbsvcs/Trader/Trader_Utils.h @@ -33,19 +33,24 @@ #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. { - // = 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, @@ -65,7 +70,7 @@ public: // 0 when the index is out of bounds. CORBA::Any* property_value(int index, CORBA::Environment& _env) - ACE_THROW_SPEC ((CosTradingDynamic::DPEvalFailure)); + TAO_THROW_SPEC ((CosTradingDynamic::DPEvalFailure)); // Returns value of the property whose index is <index>. If the // property at that index is dynamic and the trader supports dynamic @@ -83,7 +88,7 @@ public: // property name. If the index is out of bounds, the method returns // a null pointer (that is, 0). -protected: + protected: typedef CosTradingDynamic::DynamicProp DP_Struct; typedef CosTradingDynamic::DynamicPropEval DP_Eval; @@ -102,29 +107,35 @@ protected: // cause seg faults, since the client wouldn't be able to tell // whether or not the return value should be freed. -private: + private: TAO_Property_Evaluator (const TAO_Property_Evaluator&); TAO_Property_Evaluator& operator= (const TAO_Property_Evaluator&); }; -class TAO_ORBSVCS_Export TAO_Property_Evaluator_By_Name : public 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). { - // = 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) - ACE_THROW_SPEC ((CosTrading::DuplicatePropertyName, + TAO_THROW_SPEC ((CosTrading::DuplicatePropertyName, CosTrading::IllegalPropertyName)); TAO_Property_Evaluator_By_Name(CosTrading::Offer& offer, @@ -140,7 +151,7 @@ public: CORBA::Any* property_value(const char* property_name, CORBA::Environment& _env) - ACE_THROW_SPEC ((CosTradingDynamic::DPEvalFailure)); + TAO_THROW_SPEC ((CosTradingDynamic::DPEvalFailure)); // This method is identical to its counterpart in // TAO_Property_Evaluator, except property_value first discovers the @@ -163,54 +174,67 @@ private: // constructor. }; -class TAO_ORBSVCS_Export TAO_Dynamic_Property : public virtual POA_CosTradingDynamic::DynamicPropEval, public virtual PortableServer::RefCountServantBase + // ************************************************************* + // TAO_Dynamic_Property + // ************************************************************* + +class TAO_ORBSVCS_Export TAO_Dynamic_Property : + public virtual POA_CosTradingDynamic::DynamicPropEval, + public virtual PortableServer::RefCountServantBase +// = TITLE +// Little helper class that you can extend to have your dynamic +// property handler construct CosTradingDynamic::DynamicProp structs. { - // = 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 &) {} - void operator= (const TAO_Dynamic_Property &) {} + virtual ~TAO_Dynamic_Property (void); void destroy (void); - + virtual CORBA::Any* evalDP(const char* name, CORBA::TypeCode_ptr returned_type, const CORBA::Any& extra_info, CORBA::Environment& _env) - ACE_THROW_SPEC ((CORBA::SystemException, + 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); + 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. -private: + private: CosTradingDynamic::DynamicPropEval_var prop_; }; + + // ************************************************************* + // 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. { - // = 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 @@ -239,7 +263,7 @@ public: TAO_Policies (TAO_Trader_Base& trader, const CosTrading::PolicySeq& policies, CORBA::Environment& _env) - ACE_THROW_SPEC ((CosTrading::Lookup::IllegalPolicyName, + TAO_THROW_SPEC ((CosTrading::Lookup::IllegalPolicyName, CosTrading::DuplicatePolicyName)); // BEGIN SPEC @@ -267,7 +291,7 @@ public: ~TAO_Policies (void); CORBA::ULong search_card (CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); + TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); // BEGIN SPEC // The "search_card" policy indicates to the trader the maximum @@ -279,7 +303,7 @@ public: // END SPEC CORBA::ULong match_card (CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); + TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); // BEGIN SPEC // The "match_card" policy indicates to the trader the maximum @@ -291,7 +315,7 @@ public: // END SPEC CORBA::ULong return_card (CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); + TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); // BEGIN SPEC // The "return_card" policy indicates to the trader the maximum @@ -305,7 +329,7 @@ public: // = Offer consideration policies CORBA::Boolean use_modifiable_properties (CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); + TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); // BEGIN SPEC // The "use_modifiable_properties" policy indicates whether the @@ -318,7 +342,7 @@ public: // END SPEC CORBA::Boolean use_dynamic_properties (CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); + TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); // BEGIN SPEC // The "use_dynamic_properties" policy indicates whether the trader @@ -331,7 +355,7 @@ public: // END SPEC CORBA::Boolean use_proxy_offers (CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); + TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); // BEGIN SPEC // The "use_proxy_offers" policy indicates whether the trader should @@ -343,7 +367,7 @@ public: // END SPEC CORBA::Boolean exact_type_match (CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); + TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); // BEGIN SPEC // The "exact_type_match" policy indicates to the trader whether the @@ -355,8 +379,8 @@ public: // = Federated trader policies (not implemented yet) CosTrading::TraderName* starting_trader (CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch, - CosTrading::Lookup::InvalidPolicyValue)); + 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 @@ -374,7 +398,7 @@ public: // END SPEC CosTrading::FollowOption link_follow_rule (CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); + TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); // Determine the link follow policy for this query overall. // BEGIN SPEC @@ -386,7 +410,7 @@ public: CosTrading::FollowOption link_follow_rule (const CosTrading::Link::LinkInfo& link_info, CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch, + TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch, CosTrading::Lookup::InvalidPolicyValue, CosTrading::Link::IllegalLinkName, CosTrading::Link::UnknownLinkName)); @@ -400,7 +424,7 @@ public: // trader.def_follow_policy) CORBA::ULong hop_count (CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); + TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); // BEGIN SPEC // The "hop_count" policy indicates to the trader the maximum number @@ -415,7 +439,7 @@ public: // END SPEC CosTrading::Admin::OctetSeq* request_id (CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); + TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); // Return the request_id passed to the query method across a link to // another trader. @@ -430,7 +454,7 @@ public: void copy_in_follow_option (CosTrading::PolicySeq& policy_seq, const CosTrading::Link::LinkInfo& link_info, CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch, + TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch, CosTrading::Lookup::InvalidPolicyValue)); // Determine the link follow policy to pass down the link with <link_name>. // This method returns the link_follow_rule for a link whose name is @@ -445,12 +469,12 @@ private: CORBA::ULong ulong_prop (POLICY_TYPE pol, CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); + TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); // Reconclile a ULong property with its default. CORBA::Boolean boolean_prop (POLICY_TYPE pol, CORBA::Environment& _env) const - ACE_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); + TAO_THROW_SPEC ((CosTrading::Lookup::PolicyTypeMismatch)); // Reconcile a Boolean property with its debault. TAO_Policies (const TAO_Policies&); @@ -463,6 +487,10 @@ private: // For the validating identifier names. }; + // ************************************************************* + // TAO_Policy_Creator + // ************************************************************* + class TAO_ORBSVCS_Export TAO_Policy_Creator { // = TITLE @@ -543,12 +571,17 @@ private: // 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. { - // = 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, @@ -561,16 +594,16 @@ public: void delete_properties (const CosTrading::PropertyNameSeq& deletes, CORBA::Environment& _env) - ACE_THROW_SPEC ((CosTrading::Register::UnknownPropertyName, - CosTrading::Register::MandatoryProperty, - CosTrading::IllegalPropertyName, - CosTrading::DuplicatePropertyName)); + 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) - ACE_THROW_SPEC ((CosTrading::IllegalPropertyName, + TAO_THROW_SPEC ((CosTrading::IllegalPropertyName, CosTrading::DuplicatePropertyName, CosTrading::PropertyTypeMismatch, CosTrading::ReadonlyDynamicProperty, @@ -588,14 +621,17 @@ private: TAO_Offer_Modifier (const TAO_Offer_Modifier&); TAO_Offer_Modifier& operator= (const TAO_Offer_Modifier&); - typedef ACE_Hash_Map_Manager_Ex <TAO_String_Hash_Key, - CosTrading::Property *, - ACE_Hash<TAO_String_Hash_Key>, - ACE_Equal_To<TAO_String_Hash_Key>, - ACE_Null_Mutex> - Property_Table; - - const char *type_; + typedef ACE_Hash_Map_Manager_Ex + < + TAO_String_Hash_Key, + CosTrading::Property*, + ACE_Hash<TAO_String_Hash_Key>, + ACE_Equal_To<TAO_String_Hash_Key>, + ACE_Null_Mutex + > + Property_Table; + + const char* type_; // The type of the offer. Property_Table props_; @@ -612,22 +648,26 @@ private: // 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. { - // = 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, @@ -694,13 +734,17 @@ private: // 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. { - // = 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; @@ -710,7 +754,7 @@ public: TAO_Property_Filter (const SPECIFIED_PROPS& desired_props, CORBA::Environment& env) - ACE_THROW_SPEC ((CosTrading::IllegalPropertyName, + TAO_THROW_SPEC ((CosTrading::IllegalPropertyName, CosTrading::DuplicatePropertyName)); // Verify that the specified properties are correct. @@ -730,4 +774,8 @@ private: CosTrading::Lookup::HowManyProps policy_; }; + // ************************************************************* + // Miscellaneous + // ************************************************************* + #endif /* TAO_TRADER_UTILS_H */ |