00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Trader_Utils.h 00006 * 00007 * $Id: Trader_Utils.h 77001 2007-02-12 07:54:49Z johnnyw $ 00008 * 00009 * @author Seth Widoff <sbw1@cs.wustl.edu> 00010 */ 00011 //============================================================================= 00012 00013 00014 #ifndef TAO_TRADER_UTILS_H 00015 #define TAO_TRADER_UTILS_H 00016 00017 #include /**/ "ace/pre.h" 00018 00019 #include "orbsvcs/Trader/Trader.h" 00020 00021 #if defined(_MSC_VER) 00022 #pragma warning(push) 00023 #pragma warning(disable:4250) 00024 #endif /* _MSC_VER */ 00025 00026 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00027 00028 /** 00029 * @class TAO_Property_Evaluator 00030 * 00031 * @brief This class abstracts away the details of obtaining property 00032 * values and property types. Since the procedure for obtaining the 00033 * value or type of a dynamic property is disparate from the method 00034 * for a static property, TAO_Property_Evaluator provides methods 00035 * that will unify the two approaches under a single 00036 * interface. Since dynamic properties aren't necessarily supported 00037 * by a trader, this class accounts for that contingency. The use of 00038 * indexed lookups allows them to occur in constant time on the 00039 * CORBA sequences, but requires that the client know the layout of 00040 * properties ahead of time. 00041 */ 00042 class TAO_Trading_Serv_Export TAO_Property_Evaluator 00043 { 00044 public: 00045 00046 TAO_Property_Evaluator(const CosTrading::PropertySeq& properties, 00047 CORBA::Boolean supports_dp = 1); 00048 00049 /** 00050 * Construct an instance of TAO_Property_Evaluator that operates on 00051 * an <offer> where the support for dynamic properties is dictated 00052 * by <supports_dynamic_properties>. 00053 */ 00054 TAO_Property_Evaluator(CosTrading::Offer& offer, 00055 CORBA::Boolean supports_dp = 1); 00056 00057 /// Clean up dynamic properties. 00058 virtual ~TAO_Property_Evaluator (void); 00059 00060 /// Returns 1 if the property at index <index> is dynamic. Returns a 00061 /// 0 when the index is out of bounds. 00062 int is_dynamic_property(int index); 00063 00064 /** 00065 * Returns value of the property whose index is <index>. If the 00066 * property at that index is dynamic and the trader supports dynamic 00067 * properties, then the property_value method will obtain the value 00068 * of the dynamic property using the evalDP method on the 00069 * CosTradingDynamic::DynamicPropEval interface, passing on a 00070 * CosTradingDynamic::DPEvalFailure exception on failure. If the 00071 * property index is undefined, the method returns a null pointer. 00072 */ 00073 CORBA::Any* property_value(int index); 00074 00075 00076 /** 00077 * Returns the type of the property whose index is <index>. If the 00078 * property is dynamic and the trader supports dynamic properties, 00079 * then the method returns the <returned_type> field of the 00080 * CosTradingDynamic::DynamicProp struct associated with the 00081 * property name. If the index is out of bounds, the method returns 00082 * a null pointer (that is, 0). 00083 */ 00084 CORBA::TypeCode_ptr property_type (int index); 00085 00086 protected: 00087 00088 typedef CosTradingDynamic::DynamicProp DP_Struct; 00089 typedef CosTradingDynamic::DynamicPropEval DP_Eval; 00090 00091 /// The offer from which the TAO_Property_Evaluator extracts property 00092 /// information. 00093 const CosTrading::PropertySeq& props_; 00094 00095 int supports_dp_; 00096 00097 /** 00098 * In order for the client to treat the results of property_value 00099 * uniformly, we need to collect the dynamically allocated anys 00100 * retrieved from dynamic properties and free them upon deletion. If 00101 * we didn't do this, then the property_value method would leak or 00102 * cause seg faults, since the client wouldn't be able to tell 00103 * whether or not the return value should be freed. 00104 */ 00105 CORBA::Any** dp_cache_; 00106 00107 private: 00108 00109 TAO_Property_Evaluator (const TAO_Property_Evaluator&); 00110 TAO_Property_Evaluator& operator= (const TAO_Property_Evaluator&); 00111 }; 00112 00113 /** 00114 * @class TAO_Property_Evaluator_By_Name 00115 * 00116 * @brief This class extends the TAO_Property_Evaluator to allow lookups 00117 * based on the property name of interest. Since the property 00118 * information is contained within an integer indexed array, 00119 * lookups may occur in O(n) time, where n is the length of the 00120 * array. To make lookups by name more efficient, 00121 * TAO_Property_Evaluator_By_Name creates a mapping of property 00122 * names to integer indicies, upon which lookups are guaranteed to 00123 * be O(lg n). 00124 */ 00125 class TAO_Trading_Serv_Export TAO_Property_Evaluator_By_Name : public TAO_Property_Evaluator 00126 { 00127 public: 00128 00129 TAO_Property_Evaluator_By_Name (const CosTrading::PropertySeq& properties 00130 , 00131 CORBA::Boolean supports_dp = 1); 00132 00133 /** 00134 * Construct an instance of TAO_Property_Evaluator that operates on 00135 * an <offer> where the support for dynamic properties is dictated 00136 * by <supports_dynamic_properties>. 00137 */ 00138 TAO_Property_Evaluator_By_Name(CosTrading::Offer& offer, 00139 CORBA::Boolean supports_dp = 1); 00140 00141 /** 00142 * Returns 1 if the property whose name is <property_name> is 00143 * defined and dynamic. If the property is undefined, this method 00144 * will throw a Property_Undefined exception with impunity. 00145 */ 00146 int is_dynamic_property(const char* property_name); 00147 00148 /** 00149 * This method is identical to its counterpart in 00150 * TAO_Property_Evaluator, except property_value first discovers the 00151 * index through a string matching lookup. 00152 */ 00153 CORBA::Any* property_value(const char* property_name); 00154 00155 /** 00156 * This method is identical to its counterpart in 00157 * TAO_Property_Evaluator, exception property_type first discovers 00158 * the index through a string matching lookup. 00159 */ 00160 CORBA::TypeCode_ptr property_type(const char* property_name); 00161 00162 const CosTrading::Property* get_property (const char* property_name); 00163 00164 private: 00165 00166 TAO_Property_Evaluator_By_Name (const TAO_Property_Evaluator_By_Name&); 00167 TAO_Property_Evaluator_By_Name& operator= (const TAO_Property_Evaluator_By_Name&); 00168 00169 /// The instance of the above mapping for the offer provided in the 00170 /// constructor. 00171 TAO_Lookup_Table table_; 00172 }; 00173 00174 /** 00175 * @class TAO_Dynamic_Property 00176 * 00177 * @brief Little helper class that you can extend to have your dynamic 00178 * property handler construct CosTradingDynamic::DynamicProp structs. 00179 */ 00180 class TAO_Trading_Serv_Export TAO_Dynamic_Property 00181 : public virtual POA_CosTradingDynamic::DynamicPropEval 00182 { 00183 public: 00184 00185 TAO_Dynamic_Property (void) {} 00186 virtual ~TAO_Dynamic_Property (void); 00187 00188 void destroy (void); 00189 00190 /// Dynamic property evaluation call-back method. 00191 virtual CORBA::Any* evalDP(const char* name, 00192 CORBA::TypeCode_ptr returned_type, 00193 const CORBA::Any& extra_info) 00194 = 0; 00195 00196 /// Method to construct a dynamic property structure suitable for 00197 /// exporting in a CosTrading::PropertyStruct to the Trading Service. 00198 CosTradingDynamic::DynamicProp* 00199 construct_dynamic_prop (const char* name, 00200 CORBA::TypeCode_ptr returned_type, 00201 const CORBA::Any& extra_info); 00202 00203 private: 00204 00205 CosTradingDynamic::DynamicPropEval_var prop_; 00206 }; 00207 00208 /** 00209 * @class TAO_Policies 00210 * 00211 * @brief This class ensures that policies submitted to Lookup make sense, 00212 * have the correct value types, and don't exceed the maximums set 00213 * through the Admin Interface. 00214 * 00215 * TAO_Policies does an admirable job of reconciling differences 00216 * between the default parameter settings of the Trader and the import 00217 * and other policies set by the client. Unbeknownst to its client 00218 * TAO_Policies hides this arbitration, and records whether the user 00219 * policy was chosen, or the default. This information gets returned 00220 * to the invoker of the query method. 00221 */ 00222 class TAO_Policies 00223 { 00224 public: 00225 00226 #define TAO_NUM_POLICIES 11 00227 00228 /** 00229 * This enum represents the relative order that properties are 00230 * passed from one trader to another. Hence, as recommended by the 00231 * spec, the starting_trader policies will be the first element in 00232 * the polcy sequence if it's set for a query. 00233 */ 00234 enum POLICY_TYPE 00235 { 00236 STARTING_TRADER, 00237 EXACT_TYPE_MATCH, 00238 HOP_COUNT, 00239 LINK_FOLLOW_RULE, 00240 MATCH_CARD, 00241 RETURN_CARD, 00242 SEARCH_CARD, 00243 USE_DYNAMIC_PROPERTIES, 00244 USE_MODIFIABLE_PROPERTIES, 00245 USE_PROXY_OFFERS, 00246 REQUEST_ID 00247 }; 00248 00249 static const char * POLICY_NAMES[]; 00250 00251 TAO_Policies (TAO_Trader_Base& trader, 00252 const CosTrading::PolicySeq& policies); 00253 00254 // BEGIN SPEC 00255 // The "policies" parameter allows the importer to specify how the 00256 // search should be performed as opposed to what sort of services 00257 // should be found in the course of the search. This can be viewed 00258 // as parameterizing the algorithms within the trader 00259 // implementation. The "policies" are a sequence of name-value 00260 // pairs. The names available to an importer depend on the 00261 // implementation of the trader. However, some names are 00262 // standardized where they effect the interpretation of other 00263 // parameters or where they may impact linking and federation of 00264 // traders. ° If a policy name in this parameter does not obey the 00265 // syntactic rules for legal PolicyName's, then an IllegalPolicyName 00266 // exception is raised. ° If the type of the value associated with a 00267 // policy differs from that specified in this specification, then a 00268 // PolicyTypeMismatch exception is raised. ° If subsequent 00269 // processing of a PolicyValue yields any errors (e.g., the 00270 // starting_trader policy value is malformed), then an 00271 // InvalidPolicyValue exception is raised. ° If the same policy name 00272 // is included two or more times in this parameter, then the 00273 // DuplicatePolicyName exception is raised. 00274 // END SPEC 00275 00276 ~TAO_Policies (void); 00277 00278 CORBA::ULong search_card (void) const; 00279 00280 // BEGIN SPEC 00281 // The "search_card" policy indicates to the trader the maximum 00282 // number of offers it should consider when looking for type 00283 // conformance and constraint expression match. The lesser of this 00284 // value and the trader's max_search_card attribute is used by the 00285 // trader. If this policy is not specified, then the value of the 00286 // trader's def_search_card attribute is used. 00287 // END SPEC 00288 00289 CORBA::ULong match_card (void) const; 00290 00291 // BEGIN SPEC 00292 // The "match_card" policy indicates to the trader the maximum 00293 // number of matching offers to which the preference specification 00294 // should be applied. The lesser of this value and the trader's 00295 // max_match_card attribute is used by the trader. If this policy is 00296 // not specified, then the value of the trader's def_match_card 00297 // attribute is used. 00298 // END SPEC 00299 00300 CORBA::ULong return_card (void) const; 00301 00302 // BEGIN SPEC 00303 // The "return_card" policy indicates to the trader the maximum 00304 // number of matching offers to return as a result of this 00305 // query. The lesser of this value and the trader's max_return_card 00306 // attribute is used by the trader. If this policy is not specified, 00307 // then the value of the trader's def_return_card attribute is 00308 // used. 00309 // END SPEC 00310 00311 // = Offer consideration policies 00312 00313 CORBA::Boolean use_modifiable_properties (void) const; 00314 00315 // BEGIN SPEC 00316 // The "use_modifiable_properties" policy indicates whether the 00317 // trader should consider offers which have modifiable properties 00318 // when constructing the set of offers to which type conformance and 00319 // constraint processing should be applied. If the value of this 00320 // policy is TRUE, then such offers will be included; if FALSE, they 00321 // will not. If this policy is not specified, such offers will be 00322 // included. 00323 // END SPEC 00324 00325 CORBA::Boolean use_dynamic_properties (void) const; 00326 00327 // BEGIN SPEC 00328 // The "use_dynamic_properties" policy indicates whether the trader 00329 // should consider offers which have dynamic properties when 00330 // constructing the set of offers to which type conformance and 00331 // constraint processing should be applied. If the value of this 00332 // policy is TRUE, then such offers will be included; if FALSE, they 00333 // will not. If this policy is not specified, such offers will be 00334 // included. 00335 // END SPEC 00336 00337 CORBA::Boolean use_proxy_offers (void) const; 00338 00339 // BEGIN SPEC 00340 // The "use_proxy_offers" policy indicates whether the trader should 00341 // consider proxy offers when constructing the set of offers to 00342 // which type conformance and constraint processing should be 00343 // applied. If the value of this policy is TRUE, then such offers 00344 // will be included; if FALSE, they will not. If this policy is not 00345 // specified, such offers will be included. 00346 // END SPEC 00347 00348 CORBA::Boolean exact_type_match (void) const; 00349 00350 // BEGIN SPEC 00351 // The "exact_type_match" policy indicates to the trader whether the 00352 // importer's service type must exactly match an offer's service 00353 // type; if not (and by default), then any offer of a type 00354 // conformant to the importer's service type is considered. 00355 // END SPEC 00356 00357 // = Federated trader policies (not implemented yet) 00358 00359 /** 00360 * BEGIN SPEC 00361 * The "starting_trader" policy facilitates the distribution of the 00362 * trading service itself. It allows an importer to scope a search 00363 * by choosing to explicitly navigate the links of the trading 00364 * graph. If the policy is used in a query invocation it is 00365 * recommended that it be the first policy-value pair; this 00366 * facilitates an optimal forwarding of the query operation. A 00367 * "policies" parameter need not include a value for the 00368 * "starting_trader" policy. Where this policy is present, the first 00369 * name component is compared against the name held in each link. If 00370 * no match is found, the InvalidPolicyValue exception is 00371 * raised. Otherwise, the trader invokes query() on the Lookup 00372 * interface held by the named link, but passing the 00373 * "starting_trader" policy with the first component removed. 00374 * END SPEC 00375 */ 00376 CosTrading::TraderName* starting_trader (void) const; 00377 00378 /// Determine the link follow policy for this query overall. 00379 CosTrading::FollowOption link_follow_rule (void) const; 00380 00381 // BEGIN SPEC 00382 //The "link_follow_rule" policy indicates how the client wishes 00383 //links to be followed in the resolution of its query. See the 00384 //discussion in "Link Follow Behavior" on page 16-16 for details. 00385 // END SPEC 00386 00387 00388 /** 00389 * Determine the link follow policy for a given <link_name>. 00390 * This method returns the link_follow_rule for a link whose name is 00391 * <link_name> using the following formula: 00392 * if the importer specified a link_follow_rule policy 00393 * min(trader.max_follow_policy, link.limiting_follow_rule, 00394 * query.link_follow_rule) 00395 * else min(trader.max_follow_policy, link.limiting_follow_rule, 00396 * trader.def_follow_policy) 00397 */ 00398 CosTrading::FollowOption link_follow_rule (const CosTrading::Link::LinkInfo& link_info) const; 00399 00400 CORBA::ULong hop_count (void) const; 00401 00402 // BEGIN SPEC 00403 // The "hop_count" policy indicates to the trader the maximum number 00404 // of hops across federation links that should be tolerated in the 00405 // resolution of this query. The hop_count at the current trader is 00406 // determined by taking the minimum of the trader's max_hop_count 00407 // attribute and the importer's hop_count policy, if provided, or 00408 // the trader's def_hop_count attribute if it is not. If the 00409 // resulting value is zero, then no federated queries are 00410 // permitted. If it is greater than zero, then it must be 00411 // decremented before passing on to a federated trader. 00412 // END SPEC 00413 00414 /// Return the request_id passed to the query method across a link to 00415 /// another trader. 00416 CosTrading::Admin::OctetSeq* request_id (void) const; 00417 00418 /// Policies to forward to the next trader in a federated query. 00419 void copy_to_pass (CosTrading::PolicySeq& policy_seq, 00420 const CosTrading::Admin::OctetSeq& request_id) const; 00421 00422 /// Policies to forward to the next trader in a directed query. 00423 void copy_to_forward (CosTrading::PolicySeq& policy_seq, 00424 const CosTrading::TraderName& name) const; 00425 00426 /** 00427 * Determine the link follow policy to pass down the link with <link_name>. 00428 * This method returns the link_follow_rule for a link whose name is 00429 * <link_name> using the following formula: 00430 * If the importer specified a link_follow_rule, policy 00431 * pass on min(query.link_follow_rule, link.limiting_follow_rule, 00432 * trader.max_follow_policy) 00433 * else pass on min(link.def_pass_on_follow_rule, 00434 * trader.max_follow_policy) 00435 */ 00436 void copy_in_follow_option (CosTrading::PolicySeq& policy_seq, 00437 const CosTrading::Link::LinkInfo& link_info) const; 00438 00439 private: 00440 00441 /// Reconclile a ULong property with its default. 00442 CORBA::ULong ulong_prop (POLICY_TYPE pol) const; 00443 00444 /// Reconcile a Boolean property with its debault. 00445 CORBA::Boolean boolean_prop (POLICY_TYPE pol) const; 00446 00447 TAO_Policies (const TAO_Policies&); 00448 TAO_Policies& operator= (const TAO_Policies&); 00449 00450 /// The policies indexable from the enumerated type. 00451 CosTrading::Policy* policies_[TAO_NUM_POLICIES]; 00452 00453 /// For the validating identifier names. 00454 TAO_Trader_Base& trader_; 00455 }; 00456 00457 /** 00458 * @class TAO_Policy_Creator 00459 * 00460 * @brief This class is a utility for clients using the CosTrading::Lookup 00461 * interface that helps them build a policy sequence without violating 00462 * syntax rules and having to mess with typecodes. 00463 */ 00464 class TAO_Trading_Serv_Export TAO_Policy_Creator 00465 { 00466 public: 00467 00468 TAO_Policy_Creator (int num_policies = 0); 00469 00470 // = Routines to set policies. 00471 00472 /// Set the maximum number of offers searched for the query. 00473 void search_card (CORBA::ULong scard); 00474 00475 /// Set the maximum number of offers searched for the query. 00476 void match_card (CORBA::ULong mcard); 00477 00478 /// Set the maximum number of offers rerturned for the query. 00479 void return_card (CORBA::ULong rcard); 00480 00481 // A note about cardinalities: The spec implies that these 00482 // cardinalities apply to the global office space, that is, all 00483 // offers on all linked traders. However, there's no mechanism for 00484 // one trader to return to the calling trader the number of offers 00485 // searched or matched. Thus, these cardinalities are applied on a 00486 // per-trader basis. 00487 00488 /// Consider offers with modifiable properties. 00489 void use_modifiable_properties (CORBA::Boolean mod_props); 00490 00491 /// Consider offers with dynamic properties. 00492 void use_dynamic_properties (CORBA::Boolean dyn_props); 00493 00494 /// Consider proxy offers (NOT SUPPORTED). 00495 void use_proxy_offers (CORBA::Boolean prox_offs); 00496 00497 /// Designate a trader at which to begin the query. 00498 void starting_trader (const CosTrading::TraderName& name); // Copy 00499 void starting_trader (CosTrading::TraderName* name); // Own 00500 00501 /// Specify under what conditions a federated query is appropriate. 00502 void link_follow_rule (CosTrading::FollowOption follow_option); 00503 00504 /// Limit the breadth of a federated query. 00505 void hop_count (CORBA::ULong hop_count); 00506 00507 /// Set the identifier for this query (clients shouldn't use this). 00508 void request_id (const CosTrading::Admin::OctetSeq& request_id); 00509 00510 /// Search only the designated type --- not it's subtypes. 00511 void exact_type_match (CORBA::Boolean exact_type); 00512 00513 /// Return the constructed policy sequence. 00514 operator const CosTrading::PolicySeq& (void) const; 00515 00516 /// Return a PolicySeq suitable for passing to the query method of 00517 /// the Lookup interface. 00518 const CosTrading::PolicySeq& policy_seq (void) const; 00519 00520 private: 00521 00522 TAO_Policy_Creator (const TAO_Policy_Creator&); 00523 TAO_Policy_Creator& operator= (const TAO_Policy_Creator&); 00524 00525 /// Method to prepare the next slot in the policies_ sequence for 00526 /// policy insertion. 00527 CosTrading::Policy& fetch_next_policy (TAO_Policies::POLICY_TYPE pol_type); 00528 00529 /// Table mapping policy enum value to the index in the policies sequence. 00530 int poltable_[TAO_Policies::REQUEST_ID + 1]; 00531 00532 /// The sequence being prepared for submittal to the query method. 00533 CosTrading::PolicySeq policies_; 00534 00535 /// The number of policies so far in the sequence. 00536 CORBA::ULong num_policies_; 00537 }; 00538 00539 /** 00540 * @class TAO_Offer_Modifier 00541 * 00542 * @brief This class deletes, modifies, and adds properties to a given 00543 * offer according to the rules of the modify method on the Register 00544 * interface. 00545 */ 00546 class TAO_Offer_Modifier 00547 { 00548 public: 00549 00550 /// Modify an <offer> of type <type>, whose properties are described 00551 /// by <type_struct> 00552 TAO_Offer_Modifier (const char* type, 00553 const CosTradingRepos::ServiceTypeRepository::TypeStruct& type_struct, 00554 CosTrading::Offer* offer); 00555 00556 ~TAO_Offer_Modifier (void); 00557 00558 /// Delete the properties whose names were given to the 00559 /// constructor. Ensure we don't delete mandatory properties. 00560 void delete_properties (const CosTrading::PropertyNameSeq& deletes); 00561 00562 /** 00563 * Copy to the destination the union of the source and destination 00564 * properties. In the case of duplicate properties, update the 00565 * destination with the source's value. This class claims the memory 00566 * in the modifies sequence. 00567 */ 00568 void merge_properties (const CosTrading::PropertySeq& modifies); 00569 00570 /// Return a reference to the Offer with the changes affected. 00571 void affect_change (const CosTrading::PropertySeq& modifies); 00572 00573 private: 00574 00575 TAO_Offer_Modifier (const TAO_Offer_Modifier&); 00576 TAO_Offer_Modifier& operator= (const TAO_Offer_Modifier&); 00577 00578 typedef ACE_Hash_Map_Manager_Ex <CORBA::String_var, 00579 CosTrading::Property *, 00580 ACE_Hash<CORBA::String_var>, 00581 ACE_Equal_To<CORBA::String_var>, 00582 ACE_Null_Mutex> 00583 Property_Table; 00584 00585 /// The type of the offer. 00586 const char *type_; 00587 00588 /// The map of properties in the offer. 00589 Property_Table props_; 00590 00591 /// Table of property types. 00592 TAO_Typecode_Table prop_types_; 00593 00594 /// The set of readonly and mandatory property names in the offer's 00595 /// type. 00596 TAO_String_Set readonly_; 00597 TAO_String_Set mandatory_; 00598 00599 /// A reference to the offer undergoing change. 00600 CosTrading::Offer* offer_; 00601 }; 00602 00603 /** 00604 * @class TAO_Offer_Filter 00605 * 00606 * @brief The purpose of this class is to ensure that offers that 00607 * shouldn't be considered by the TAO_Constraint_Interpreter 00608 * aren't. 00609 * 00610 * There two classes of reasons why an offer for a correct 00611 * type shouldn't be considered: 1) The default parameters of the 00612 * Trader or policies passed to the Lookup::query method deem it 00613 * inappropriate to consider offers with modifiable (i.e., not 00614 * readonly) or dynamic properties. 2) We've exceeded the 00615 * default or provided cardinality constraints. TAO_Offer_Filter 00616 * ensures that violation of policies doesn't occur. It's the 00617 * enforcer. 00618 */ 00619 class TAO_Offer_Filter 00620 { 00621 public: 00622 00623 /// Glean from the TypeStruct and Policy setting the appropriate way 00624 /// to screen unsuitable offers from consideration. 00625 TAO_Offer_Filter (TAO_Policies& policies); 00626 00627 /// Set the offer filter to screen for offers containing properties 00628 /// that aren't marked as readonly in this TypeStruct. 00629 void configure_type (CosTradingRepos::ServiceTypeRepository::TypeStruct* type_struct); 00630 00631 /** 00632 * Determine whether the poicies contained in the given policy 00633 * object allow the Lookup interface to consider the offer. That is, 00634 * if use_modifiable_properties is false, and the offer contains 00635 * modifiable properties as designated in the type struct, return 00636 * false. If use_dynamic_properties is false, and the offer contains 00637 * dynamic properties, then return false. If the lookup interface is 00638 * safe in considering this offer, return true and subtract from the 00639 * search card value. When the search card value falls to zero, 00640 * ok_to_consider always returns false. 00641 */ 00642 CORBA::Boolean ok_to_consider (CosTrading::Offer* offer); 00643 00644 /// It's ok to consider more offers when lookup hasn't exceeded the 00645 /// cardinality values for searching and matching offers. 00646 CORBA::Boolean ok_to_consider_more (void); 00647 00648 /// Signal that the Lookup method has matched an offer; decrement the 00649 /// match_card. 00650 void matched_offer (void); 00651 00652 // = Return the limits applied. 00653 /** 00654 * BEGIN SPEC 00655 * If any cardinality or other limits were applied by one or more 00656 * traders in responding to a particular query, then the 00657 * "limits_applied" parameter will contain the names of the policies 00658 * which limited the query. The sequence of names returned in 00659 * "limits_applied" from any federated or proxy queries must be 00660 * concatenated onto the names of limits applied locally and 00661 * returned. 00662 * END SPEC 00663 */ 00664 CosTrading::PolicyNameSeq* limits_applied (void); 00665 00666 /// Accessors to retrieve the adjusted cardinalities. 00667 CORBA::ULong search_card_remaining (void) const; 00668 CORBA::ULong match_card_remaining (void) const; 00669 00670 private: 00671 00672 TAO_Offer_Filter (const TAO_Offer_Filter&); 00673 TAO_Offer_Filter& operator= (const TAO_Offer_Filter&); 00674 00675 /// The set of the name of modifiable properties. 00676 TAO_String_Set not_mod_props_; 00677 00678 /// Cardinality and property limitations applied. 00679 TAO_String_Set limits_; 00680 00681 /// Keep track of the cardinalities. 00682 CORBA::ULong search_card_, match_card_, return_card_; 00683 00684 /// Keep track of property limitations: modifiable or dynamic ones 00685 /// may be bad. 00686 CORBA::Boolean dp_; 00687 CORBA::Boolean mod_; 00688 }; 00689 00690 /** 00691 * @class TAO_Property_Filter 00692 * 00693 * @brief The Ace_Property_Filter copies those properties specified in a 00694 * CosTrading::Lookup::SpecifiedProps from a source 00695 * CosTrading::Offer to a destination CosTrading::Offer. 00696 */ 00697 class TAO_Property_Filter 00698 { 00699 public: 00700 00701 typedef CosTrading::Lookup::SpecifiedProps SPECIFIED_PROPS; 00702 00703 /// An accomplice to g++'s insane lust for copy constructors. 00704 TAO_Property_Filter (void) : policy_ (CosTrading::Lookup::all) {} 00705 00706 /// Verify that the specified properties are correct. 00707 TAO_Property_Filter (const SPECIFIED_PROPS& desired_props); 00708 00709 TAO_Property_Filter (const TAO_Property_Filter& prop_filter); 00710 TAO_Property_Filter& operator= (const TAO_Property_Filter& prop_filter); 00711 00712 /// Copy the desired properties from the source offer to the 00713 /// destination offer. 00714 void filter_offer (CosTrading::Offer* source, 00715 CosTrading::Offer& destination); 00716 00717 private: 00718 00719 typedef ACE_Unbounded_Queue< CosTrading::Property* > Prop_Queue; 00720 00721 TAO_String_Set props_; 00722 CosTrading::Lookup::HowManyProps policy_; 00723 }; 00724 00725 TAO_END_VERSIONED_NAMESPACE_DECL 00726 00727 #if defined(_MSC_VER) 00728 #pragma warning(pop) 00729 #endif /* _MSC_VER */ 00730 00731 #include /**/ "ace/post.h" 00732 00733 #endif /* TAO_TRADER_UTILS_H */