TAO_Policies Class Reference

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. More...

#include <Trader_Utils.h>

Collaboration diagram for TAO_Policies:

Collaboration graph
[legend]
List of all members.

Public Types

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

Public Member Functions

 TAO_Policies (TAO_Trader_Base &trader, const CosTrading::PolicySeq &policies)
 ~TAO_Policies (void)
CORBA::ULong search_card (void) const
CORBA::ULong match_card (void) const
CORBA::ULong return_card (void) const
CORBA::Boolean use_modifiable_properties (void) const
CORBA::Boolean use_dynamic_properties (void) const
CORBA::Boolean use_proxy_offers (void) const
CORBA::Boolean exact_type_match (void) const
CosTrading::TraderNamestarting_trader (void) const
CosTrading::FollowOption link_follow_rule (void) const
 Determine the link follow policy for this query overall.
CosTrading::FollowOption link_follow_rule (const CosTrading::Link::LinkInfo &link_info) const
CORBA::ULong hop_count (void) const
CosTrading::Admin::OctetSeqrequest_id (void) const
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) const

Static Public Attributes

static const char * POLICY_NAMES []

Private Member Functions

CORBA::ULong ulong_prop (POLICY_TYPE pol) const
 Reconclile a ULong property with its default.
CORBA::Boolean boolean_prop (POLICY_TYPE pol) const
 Reconcile a Boolean property with its debault.
 TAO_Policies (const TAO_Policies &)
TAO_Policiesoperator= (const TAO_Policies &)

Private Attributes

CosTrading::Policypolicies_ [TAO_NUM_POLICIES]
 The policies indexable from the enumerated type.
TAO_Trader_Basetrader_
 For the validating identifier names.

Detailed Description

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.

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.

Definition at line 222 of file Trader_Utils.h.


Member Enumeration Documentation

enum TAO_Policies::POLICY_TYPE

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.

Enumerator:
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 

Definition at line 234 of file Trader_Utils.h.


Constructor & Destructor Documentation

TAO_Policies::TAO_Policies ( TAO_Trader_Base trader,
const CosTrading::PolicySeq policies 
)

Definition at line 496 of file Trader_Utils.cpp.

References EXACT_TYPE_MATCH, HOP_COUNT, LINK_FOLLOW_RULE, MATCH_CARD, policies_, POLICY_NAMES, REQUEST_ID, RETURN_CARD, SEARCH_CARD, STARTING_TRADER, ACE_OS::strcmp(), ACE_OS::strlen(), TAO_NUM_POLICIES, USE_DYNAMIC_PROPERTIES, USE_MODIFIABLE_PROPERTIES, and USE_PROXY_OFFERS.

00498   : trader_ (trader)
00499 {
00500   for (int i = 0; i < TAO_NUM_POLICIES; i++)
00501     this->policies_[i] = 0;
00502 
00503   for (CORBA::ULong j = 0; j < policies.length (); j++)
00504     {
00505       const char *pol_name = (const char *) policies[j].name;
00506       size_t length = (pol_name == 0) ? 0 : ACE_OS::strlen (pol_name);
00507       int index = -1;
00508 
00509       if (length < ACE_OS::strlen (POLICY_NAMES[HOP_COUNT]))
00510         throw CosTrading::Lookup::IllegalPolicyName (pol_name);
00511 
00512       switch (pol_name[0])
00513         {
00514         case 'e':
00515           index = EXACT_TYPE_MATCH;
00516           break;
00517         case 'h':
00518           index = HOP_COUNT;
00519           break;
00520         case 'l':
00521           index = LINK_FOLLOW_RULE;
00522           break;
00523         case 'm':
00524           index = MATCH_CARD;
00525           break;
00526         case 'r':
00527           if (pol_name[2] == 't')
00528             index = RETURN_CARD;
00529           else if (pol_name[2] == 'q')
00530             index = REQUEST_ID;
00531           break;
00532         case 's':
00533           if (pol_name[1] == 't')
00534             index = STARTING_TRADER;
00535           else if (pol_name[1] == 'e')
00536             index = SEARCH_CARD;
00537           break;
00538         case 'u':
00539           if (pol_name[4] == 'd')
00540             index = USE_DYNAMIC_PROPERTIES;
00541           if (pol_name[4] == 'm')
00542             index = USE_MODIFIABLE_PROPERTIES;
00543           if (pol_name[4] == 'p')
00544             index = USE_PROXY_OFFERS;
00545         }
00546 
00547       // Match the name of the policy, and insert its value into the
00548       // vector.
00549       if (index == -1 || ACE_OS::strcmp (POLICY_NAMES[index], pol_name) != 0)
00550         throw CosTrading::Lookup::IllegalPolicyName (pol_name);
00551       else if (this->policies_[index] != 0)
00552         throw CosTrading::DuplicatePolicyName (pol_name);
00553       else
00554         this->policies_[index] = (CosTrading::Policy *) &(policies[j]);
00555     }
00556 }

TAO_Policies::~TAO_Policies ( void   ) 

Definition at line 558 of file Trader_Utils.cpp.

00559 {
00560 }

TAO_Policies::TAO_Policies ( const TAO_Policies  )  [private]


Member Function Documentation

CORBA::Boolean TAO_Policies::boolean_prop ( POLICY_TYPE  pol  )  const [private]

Reconcile a Boolean property with its debault.

Definition at line 633 of file Trader_Utils.cpp.

References EXACT_TYPE_MATCH, policies_, TAO_Trader_Base::support_attributes(), TAO_Support_Attributes_i::supports_dynamic_properties(), TAO_Support_Attributes_i::supports_modifiable_properties(), TAO_Support_Attributes_i::supports_proxy_offers(), trader_, USE_DYNAMIC_PROPERTIES, USE_MODIFIABLE_PROPERTIES, USE_PROXY_OFFERS, and CosTrading::Policy::value.

Referenced by exact_type_match(), use_dynamic_properties(), use_modifiable_properties(), and use_proxy_offers().

00634 {
00635   CORBA::Boolean def_value = 1,
00636     return_value = 1;
00637   const TAO_Support_Attributes_i& support_attrs =
00638     this->trader_.support_attributes ();
00639 
00640   switch (pol)
00641     {
00642     case USE_MODIFIABLE_PROPERTIES:
00643       def_value = support_attrs.supports_modifiable_properties ();
00644       break;
00645     case USE_DYNAMIC_PROPERTIES:
00646       def_value = support_attrs.supports_dynamic_properties ();
00647       break;
00648     case USE_PROXY_OFFERS:
00649       def_value = support_attrs.supports_proxy_offers ();
00650       break;
00651     case EXACT_TYPE_MATCH:
00652       def_value = 0;
00653       break;
00654     default:
00655       break;
00656     }
00657 
00658   if (this->policies_[pol] != 0)
00659     {
00660       const CosTrading::Policy* policy = this->policies_[pol];
00661       const CosTrading::PolicyValue& value = policy->value;
00662       CORBA::TypeCode_var type = value.type ();
00663 
00664       CORBA::Boolean equal_boolean =
00665         type->equal (CORBA::_tc_boolean);
00666 
00667       if (!equal_boolean)
00668         throw CosTrading::Lookup::PolicyTypeMismatch (*policy);
00669       else
00670         value >>= CORBA::Any::to_boolean (return_value);
00671 
00672       if (def_value == 0 &&
00673           pol != EXACT_TYPE_MATCH)
00674         return_value = 0;
00675     }
00676   else
00677     return_value = def_value;
00678 
00679   return return_value;
00680 }

void TAO_Policies::copy_in_follow_option ( CosTrading::PolicySeq policy_seq,
const CosTrading::Link::LinkInfo link_info 
) const

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

Definition at line 818 of file Trader_Utils.cpp.

References CosTrading::Link::LinkInfo::def_pass_on_follow_rule, TAO_Trader_Base::import_attributes(), CosTrading::Link::LinkInfo::limiting_follow_rule, link_follow_rule(), LINK_FOLLOW_RULE, CosTrading::local_only, TAO_Import_Attributes_i::max_follow_policy(), POLICY_NAMES, ACE_OS::strcmp(), and trader_.

Referenced by TAO_Lookup< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::federated_query().

00820 {
00821   CosTrading::FollowOption follow_option = CosTrading::local_only;
00822   CosTrading::FollowOption trader_max_follow_policy =
00823     this->trader_.import_attributes ().max_follow_policy ();
00824 
00825   if (this->policies_[LINK_FOLLOW_RULE] != 0)
00826     {
00827       CosTrading::FollowOption query_link_follow_rule =
00828         this->link_follow_rule ();
00829 
00830       follow_option = (CosTrading::FollowOption)
00831         (link_info.limiting_follow_rule < trader_max_follow_policy
00832          ? (link_info.limiting_follow_rule < query_link_follow_rule
00833             ? link_info.limiting_follow_rule
00834             : query_link_follow_rule)
00835          : (trader_max_follow_policy < query_link_follow_rule
00836             ? trader_max_follow_policy
00837             : query_link_follow_rule));
00838     }
00839   else
00840     follow_option = (CosTrading::FollowOption)
00841       (link_info.def_pass_on_follow_rule < trader_max_follow_policy
00842        ? link_info.def_pass_on_follow_rule
00843        : trader_max_follow_policy);
00844 
00845   CORBA::ULong i = 0;
00846   for (i = 0; i < policy_seq.length (); i++)
00847     if (ACE_OS::strcmp (policy_seq[i].name,
00848                         POLICY_NAMES[LINK_FOLLOW_RULE]) == 0)
00849       {
00850         policy_seq[i].value <<= follow_option;
00851         break;
00852       }
00853 
00854   if (i == policy_seq.length ())
00855     {
00856       policy_seq.length (i + 1);
00857       policy_seq[i].name = POLICY_NAMES[LINK_FOLLOW_RULE];
00858       policy_seq[i].value <<= follow_option;
00859     }
00860 }

void TAO_Policies::copy_to_forward ( CosTrading::PolicySeq policy_seq,
const CosTrading::TraderName name 
) const

Policies to forward to the next trader in a directed query.

Definition at line 914 of file Trader_Utils.cpp.

References CosTrading::Policy::name, policies_, REQUEST_ID, STARTING_TRADER, CORBA::string_dup(), and CosTrading::Policy::value.

Referenced by TAO_Lookup< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::query().

00916 {
00917   // Create a new policy sequence, shortening the starting trader
00918   // policy by one link.
00919 
00920   CORBA::ULong counter = 0;
00921   CosTrading::Policy* policy_buffer =
00922     CosTrading::PolicySeq::allocbuf (REQUEST_ID + 1);
00923 
00924   if (policy_buffer == 0)
00925     return;
00926 
00927   for (int i = 0; i <= REQUEST_ID; i++)
00928     {
00929       CosTrading::Policy& new_policy = policy_buffer[counter];
00930 
00931       if (this->policies_[i] != 0)
00932         {
00933           // Copy in the existing policies.
00934           if (i == STARTING_TRADER && trader_name.length () > 1)
00935             {
00936               // Eliminate the first link of the trader name.
00937               // Only pass on the property if the sequence
00938               // contains more links after us.
00939 
00940               // The any will sieze control of this memory.
00941               // Allocating here avoids copying in the policy
00942               // any.
00943               CORBA::ULong length = trader_name.length ();
00944               CosTrading::LinkName* buf =
00945                 CosTrading::TraderName::allocbuf (length - 1);
00946 
00947               if (buf != 0)
00948                 {
00949                   for (CORBA::ULong j = 1; j < length; j++)
00950                     buf[j - 1] = CORBA::string_dup (trader_name[j]);
00951 
00952                   new_policy.name = this->policies_[i]->name;
00953                   CosTrading::TraderName new_name (length - 1,
00954                                                    length - 1,
00955                                                    buf,
00956                                                    1);
00957 
00958                   new_policy.value <<= new_name;
00959                   counter++;
00960                 }
00961             }
00962           else if (i != STARTING_TRADER)
00963             {
00964               new_policy.name = this->policies_[i]->name;
00965               new_policy.value = this->policies_[i]->value;
00966               counter++;
00967             }
00968         }
00969     }
00970 
00971   // Create the new sequence
00972   policy_seq.replace (REQUEST_ID + 1,
00973                       counter,
00974                       policy_buffer, 1);
00975 }

void TAO_Policies::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.

Definition at line 864 of file Trader_Utils.cpp.

References HOP_COUNT, CosTrading::Policy::name, POLICY_NAMES, and REQUEST_ID.

Referenced by TAO_Lookup< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::federated_query().

00866 {
00867   CORBA::ULong counter = 0;
00868   CosTrading::Policy* policy_buffer =
00869     CosTrading::PolicySeq::allocbuf (REQUEST_ID + 1);
00870 
00871   if (policy_buffer == 0)
00872     return;
00873 
00874   for (int i = 0; i <= REQUEST_ID; i++)
00875     {
00876       CosTrading::Policy& new_policy = policy_buffer[counter];
00877 
00878        if (i == REQUEST_ID)
00879         {
00880           // Set the new request id.
00881           new_policy.name = POLICY_NAMES[REQUEST_ID];
00882           new_policy.value <<= request_id;
00883           counter++;
00884         }
00885        else if (this->policies_[i] != 0)
00886         {
00887           // Copy in the existing policies.
00888           new_policy.name = POLICY_NAMES[i];
00889           new_policy.value = this->policies_[i]->value;
00890           counter++;
00891         }
00892 
00893       // We always require a hop count.
00894       if (i == HOP_COUNT)
00895         {
00896           CORBA::ULong count = this->hop_count ();
00897 
00898           new_policy.name = POLICY_NAMES[HOP_COUNT];
00899           new_policy.value <<= count - 1;
00900 
00901           // Don't count hop count twice.
00902           if (this->policies_[i] == 0)
00903             counter++;
00904         }
00905     }
00906 
00907   policy_seq.replace (REQUEST_ID + 1,
00908                       counter,
00909                       policy_buffer,
00910                       1);
00911 }

CORBA::Boolean TAO_Policies::exact_type_match ( void   )  const

Definition at line 702 of file Trader_Utils.cpp.

References boolean_prop(), and EXACT_TYPE_MATCH.

Referenced by TAO_Lookup< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::query(), and TAO_Offer_Filter::TAO_Offer_Filter().

00703 {
00704   return this->boolean_prop (EXACT_TYPE_MATCH);
00705 }

CORBA::ULong TAO_Policies::hop_count ( void   )  const

Definition at line 788 of file Trader_Utils.cpp.

References HOP_COUNT, and ulong_prop().

Referenced by TAO_Lookup< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::retrieve_links().

00789 {
00790   return this->ulong_prop (HOP_COUNT);
00791 }

CosTrading::FollowOption TAO_Policies::link_follow_rule ( const CosTrading::Link::LinkInfo link_info  )  const

Determine the link follow policy for a given <link_name>. This method returns the link_follow_rule for a link whose name is <link_name> 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)

Definition at line 767 of file Trader_Utils.cpp.

References TAO_Trader_Base::import_attributes(), CosTrading::Link::LinkInfo::limiting_follow_rule, link_follow_rule(), CosTrading::local_only, TAO_Import_Attributes_i::max_follow_policy(), and trader_.

00768 {
00769   CosTrading::FollowOption return_value = CosTrading::local_only;
00770   CosTrading::FollowOption trader_max_follow_policy =
00771     this->trader_.import_attributes ().max_follow_policy ();
00772   CosTrading::FollowOption link_limiting_follow_rule =
00773     link_info.limiting_follow_rule;
00774 
00775   // If not defined defaults to trader.def_link_follow_rule
00776   CosTrading::FollowOption query_link_follow_rule =
00777     this->link_follow_rule ();
00778 
00779   return_value = (query_link_follow_rule < trader_max_follow_policy)
00780     ? query_link_follow_rule : trader_max_follow_policy;
00781   return_value = (return_value < link_limiting_follow_rule)
00782     ? return_value : link_limiting_follow_rule;
00783 
00784   return return_value;
00785 }

CosTrading::FollowOption TAO_Policies::link_follow_rule ( void   )  const

Determine the link follow policy for this query overall.

Definition at line 736 of file Trader_Utils.cpp.

References TAO_Import_Attributes_i::def_follow_policy(), TAO_Trader_Base::import_attributes(), LINK_FOLLOW_RULE, TAO_Import_Attributes_i::max_follow_policy(), policies_, trader_, and CosTrading::Policy::value.

Referenced by copy_in_follow_option(), link_follow_rule(), and TAO_Lookup< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::retrieve_links().

00737 {
00738   CosTrading::FollowOption return_value =
00739     this->trader_.import_attributes ().def_follow_policy ();
00740 
00741   if (this->policies_[LINK_FOLLOW_RULE] != 0)
00742     {
00743       CosTrading::FollowOption max_follow_policy =
00744         this->trader_.import_attributes ().max_follow_policy ();
00745 
00746       CosTrading::Policy* policy = this->policies_[LINK_FOLLOW_RULE];
00747       CosTrading::PolicyValue& value = policy->value;
00748       CORBA::TypeCode_var type = value.type ();
00749 
00750       // Extract the link follow rule
00751       CORBA::Boolean type_equal =
00752         type->equal (CosTrading::_tc_FollowOption);
00753 
00754       if (!type_equal)
00755         throw CosTrading::Lookup::PolicyTypeMismatch (*policy);
00756       else
00757         value >>= return_value;
00758 
00759       if (return_value > max_follow_policy)
00760         return_value = max_follow_policy;
00761     }
00762 
00763   return return_value;
00764 }

CORBA::ULong TAO_Policies::match_card ( void   )  const

Definition at line 621 of file Trader_Utils.cpp.

References MATCH_CARD, and ulong_prop().

Referenced by TAO_Offer_Filter::TAO_Offer_Filter().

00622 {
00623   return this->ulong_prop (MATCH_CARD);
00624 }

TAO_Policies& TAO_Policies::operator= ( const TAO_Policies  )  [private]

CosTrading::Admin::OctetSeq * TAO_Policies::request_id ( void   )  const

Return the request_id passed to the query method across a link to another trader.

Definition at line 794 of file Trader_Utils.cpp.

References policies_, REQUEST_ID, and CosTrading::Policy::value.

Referenced by TAO_Lookup< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::seen_request_id().

00795 {
00796   CosTrading::Admin::OctetSeq* request_id = 0;
00797 
00798   if (this->policies_[REQUEST_ID] != 0)
00799     {
00800       CosTrading::Policy* policy = this->policies_[REQUEST_ID];
00801       CosTrading::PolicyValue& value = policy->value;
00802       CORBA::TypeCode_var type = value.type ();
00803 
00804       CORBA::Boolean equal_octetseq =
00805         type->equal (CosTrading::Admin::_tc_OctetSeq);
00806 
00807       if (!equal_octetseq)
00808         throw CosTrading::Lookup::PolicyTypeMismatch (*policy);
00809       else
00810         value >>= request_id;
00811     }
00812 
00813   return request_id;
00814 }

CORBA::ULong TAO_Policies::return_card ( void   )  const

Definition at line 627 of file Trader_Utils.cpp.

References RETURN_CARD, and ulong_prop().

Referenced by TAO_Lookup< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::fill_receptacles(), and TAO_Offer_Filter::TAO_Offer_Filter().

00628 {
00629   return this->ulong_prop (RETURN_CARD);
00630 }

CORBA::ULong TAO_Policies::search_card ( void   )  const

Definition at line 615 of file Trader_Utils.cpp.

References SEARCH_CARD, and ulong_prop().

Referenced by TAO_Offer_Filter::TAO_Offer_Filter().

00616 {
00617   return this->ulong_prop (SEARCH_CARD);
00618 }

CosTrading::TraderName * TAO_Policies::starting_trader ( void   )  const

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

Definition at line 709 of file Trader_Utils.cpp.

References policies_, STARTING_TRADER, and CosTrading::Policy::value.

Referenced by TAO_Lookup< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::query().

00710 {
00711   CosTrading::TraderName* trader_name = 0;
00712 
00713   if (this->policies_[STARTING_TRADER] != 0)
00714     {
00715       CosTrading::Policy* policy = this->policies_[STARTING_TRADER];
00716       CosTrading::PolicyValue& value = policy->value;
00717       CORBA::TypeCode_var type = value.type ();
00718 
00719       CORBA::Boolean equal_tradername =
00720         type->equal (CosTrading::_tc_TraderName);
00721 
00722       CORBA::Boolean equal_linknameseq =
00723         type->equal (CosTrading::_tc_LinkNameSeq);
00724 
00725       if (!equal_tradername ||
00726           !equal_linknameseq)
00727         throw CosTrading::Lookup::PolicyTypeMismatch (*policy);
00728       else
00729         value >>= trader_name;
00730     }
00731 
00732   return trader_name;
00733 }

CORBA::ULong TAO_Policies::ulong_prop ( POLICY_TYPE  pol  )  const [private]

Reconclile a ULong property with its default.

Definition at line 563 of file Trader_Utils.cpp.

References TAO_Import_Attributes_i::def_hop_count(), TAO_Import_Attributes_i::def_match_card(), TAO_Import_Attributes_i::def_return_card(), TAO_Import_Attributes_i::def_search_card(), HOP_COUNT, TAO_Trader_Base::import_attributes(), MATCH_CARD, TAO_Import_Attributes_i::max_hop_count(), TAO_Import_Attributes_i::max_match_card(), TAO_Import_Attributes_i::max_return_card(), TAO_Import_Attributes_i::max_search_card(), policies_, RETURN_CARD, SEARCH_CARD, trader_, and CosTrading::Policy::value.

Referenced by hop_count(), match_card(), return_card(), and search_card().

00564 {
00565   CORBA::ULong return_value = 0, max_value = 0;
00566   const TAO_Import_Attributes_i& import_attrs =
00567     this->trader_.import_attributes ();
00568 
00569   // Discover the default values for each of the possible cardinality
00570   // policies.
00571   switch (pol)
00572     {
00573     case SEARCH_CARD:
00574       return_value = import_attrs.def_search_card ();
00575       max_value = import_attrs.max_search_card ();
00576       break;
00577     case MATCH_CARD:
00578       return_value = import_attrs.def_match_card ();
00579       max_value = import_attrs.max_match_card ();
00580       break;
00581     case RETURN_CARD:
00582       return_value = import_attrs.def_return_card ();
00583       max_value = import_attrs.max_return_card ();
00584       break;
00585     case HOP_COUNT:
00586       return_value = import_attrs.def_hop_count ();
00587       max_value = import_attrs.max_hop_count ();
00588       break;
00589     default:
00590       break;
00591     }
00592 
00593   if (this->policies_[pol] != 0)
00594     {
00595       // Extract the desired policy value.
00596       const CosTrading::Policy* policy = this->policies_[pol];
00597       const CosTrading::PolicyValue& value = policy->value;
00598       CORBA::TypeCode_var type = value.type ();
00599 
00600       CORBA::Boolean equal_ulong = type->equal (CORBA::_tc_ulong);
00601 
00602       if (!equal_ulong)
00603         throw CosTrading::Lookup::PolicyTypeMismatch (*policy);
00604       else
00605         value >>= return_value;
00606 
00607       if (max_value < return_value)
00608         return_value = max_value;
00609     }
00610 
00611   return return_value;
00612 }

CORBA::Boolean TAO_Policies::use_dynamic_properties ( void   )  const

Definition at line 690 of file Trader_Utils.cpp.

References boolean_prop(), and USE_DYNAMIC_PROPERTIES.

Referenced by TAO_Offer_Filter::TAO_Offer_Filter().

00691 {
00692   return this->boolean_prop (USE_DYNAMIC_PROPERTIES);
00693 }

CORBA::Boolean TAO_Policies::use_modifiable_properties ( void   )  const

Definition at line 684 of file Trader_Utils.cpp.

References boolean_prop(), and USE_MODIFIABLE_PROPERTIES.

Referenced by TAO_Offer_Filter::TAO_Offer_Filter().

00685 {
00686   return this->boolean_prop (USE_MODIFIABLE_PROPERTIES);
00687 }

CORBA::Boolean TAO_Policies::use_proxy_offers ( void   )  const

Definition at line 696 of file Trader_Utils.cpp.

References boolean_prop(), and USE_PROXY_OFFERS.

00697 {
00698   return this->boolean_prop (USE_PROXY_OFFERS);
00699 }


Member Data Documentation

CosTrading::Policy* TAO_Policies::policies_[TAO_NUM_POLICIES] [private]

The policies indexable from the enumerated type.

Definition at line 451 of file Trader_Utils.h.

Referenced by boolean_prop(), copy_to_forward(), link_follow_rule(), request_id(), starting_trader(), TAO_Policies(), and ulong_prop().

const char * TAO_Policies::POLICY_NAMES [static]

Initial value:

{
  "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"
}

Definition at line 249 of file Trader_Utils.h.

Referenced by copy_in_follow_option(), copy_to_pass(), TAO_Policy_Creator::fetch_next_policy(), TAO_Lookup< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::forward_query(), TAO_Offer_Filter::matched_offer(), TAO_Offer_Filter::ok_to_consider(), TAO_Offer_Filter::TAO_Offer_Filter(), and TAO_Policies().

TAO_Trader_Base& TAO_Policies::trader_ [private]

For the validating identifier names.

Definition at line 454 of file Trader_Utils.h.

Referenced by boolean_prop(), copy_in_follow_option(), link_follow_rule(), and ulong_prop().


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