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

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) throw (CosTrading::Lookup::IllegalPolicyName, CosTrading::DuplicatePolicyName)
 ~TAO_Policies (void)
CORBA::ULong search_card () const throw (CosTrading::Lookup::PolicyTypeMismatch)
CORBA::ULong match_card () const throw (CosTrading::Lookup::PolicyTypeMismatch)
CORBA::ULong return_card () const throw (CosTrading::Lookup::PolicyTypeMismatch)
CORBA::Boolean use_modifiable_properties () const throw (CosTrading::Lookup::PolicyTypeMismatch)
CORBA::Boolean use_dynamic_properties () const throw (CosTrading::Lookup::PolicyTypeMismatch)
CORBA::Boolean use_proxy_offers () const throw (CosTrading::Lookup::PolicyTypeMismatch)
CORBA::Boolean exact_type_match () const throw (CosTrading::Lookup::PolicyTypeMismatch)
CosTrading::TraderNamestarting_trader () const throw (CosTrading::Lookup::PolicyTypeMismatch, CosTrading::Lookup::InvalidPolicyValue)
CosTrading::FollowOption link_follow_rule () const throw (CosTrading::Lookup::PolicyTypeMismatch)
 Determine the link follow policy for this query overall.

CosTrading::FollowOption link_follow_rule (const CosTrading::Link::LinkInfo &link_info) const throw (CosTrading::Lookup::PolicyTypeMismatch, CosTrading::Lookup::InvalidPolicyValue, CosTrading::Link::IllegalLinkName, CosTrading::Link::UnknownLinkName)
CORBA::ULong hop_count () const throw (CosTrading::Lookup::PolicyTypeMismatch)
CosTrading::Admin::OctetSeqrequest_id () const throw (CosTrading::Lookup::PolicyTypeMismatch)
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 throw (CosTrading::Lookup::PolicyTypeMismatch, CosTrading::Lookup::InvalidPolicyValue)

Static Public Attributes

const char * POLICY_NAMES []

Private Member Functions

CORBA::ULong ulong_prop (POLICY_TYPE pol) const throw (CosTrading::Lookup::PolicyTypeMismatch)
 Reconclile a ULong property with its default.

CORBA::Boolean boolean_prop (POLICY_TYPE pol) const throw (CosTrading::Lookup::PolicyTypeMismatch)
 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 229 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.

Enumeration values:
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 241 of file Trader_Utils.h.


Constructor & Destructor Documentation

TAO_Policies::TAO_Policies TAO_Trader_Base trader,
const CosTrading::PolicySeq policies
throw (CosTrading::Lookup::IllegalPolicyName, CosTrading::DuplicatePolicyName)
 

Definition at line 520 of file Trader_Utils.cpp.

References ACE_THROW, CosTrading::PolicySeq, ACE_OS::strcmp(), ACE_OS::strlen(), and TAO_NUM_POLICIES.

00525   : trader_ (trader)
00526 {
00527   for (int i = 0; i < TAO_NUM_POLICIES; i++)
00528     this->policies_[i] = 0;
00529 
00530   for (CORBA::ULong j = 0; j < policies.length (); j++)
00531     {
00532       const char *pol_name = (const char *) policies[j].name;
00533       size_t length = (pol_name == 0) ? 0 : ACE_OS::strlen (pol_name);
00534       int index = -1;
00535 
00536       if (length < ACE_OS::strlen (POLICY_NAMES[HOP_COUNT]))
00537         ACE_THROW (CosTrading::Lookup::IllegalPolicyName (pol_name));
00538 
00539       switch (pol_name[0])
00540         {
00541         case 'e':
00542           index = EXACT_TYPE_MATCH;
00543           break;
00544         case 'h':
00545           index = HOP_COUNT;
00546           break;
00547         case 'l':
00548           index = LINK_FOLLOW_RULE;
00549           break;
00550         case 'm':
00551           index = MATCH_CARD;
00552           break;
00553         case 'r':
00554           if (pol_name[2] == 't')
00555             index = RETURN_CARD;
00556           else if (pol_name[2] == 'q')
00557             index = REQUEST_ID;
00558           break;
00559         case 's':
00560           if (pol_name[1] == 't')
00561             index = STARTING_TRADER;
00562           else if (pol_name[1] == 'e')
00563             index = SEARCH_CARD;
00564           break;
00565         case 'u':
00566           if (pol_name[4] == 'd')
00567             index = USE_DYNAMIC_PROPERTIES;
00568           if (pol_name[4] == 'm')
00569             index = USE_MODIFIABLE_PROPERTIES;
00570           if (pol_name[4] == 'p')
00571             index = USE_PROXY_OFFERS;
00572         }
00573 
00574       // Match the name of the policy, and insert its value into the
00575       // vector.
00576       if (index == -1 || ACE_OS::strcmp (POLICY_NAMES[index], pol_name) != 0)
00577         ACE_THROW (CosTrading::Lookup::IllegalPolicyName (pol_name));
00578       else if (this->policies_[index] != 0)
00579         ACE_THROW (CosTrading::DuplicatePolicyName (pol_name));
00580       else
00581         this->policies_[index] = (CosTrading::Policy *) &(policies[j]);
00582     }
00583 }

TAO_Policies::~TAO_Policies void   ) 
 

Definition at line 585 of file Trader_Utils.cpp.

00586 {
00587 }

TAO_Policies::TAO_Policies const TAO_Policies  )  [private]
 


Member Function Documentation

CORBA::Boolean TAO_Policies::boolean_prop POLICY_TYPE  pol  )  const throw (CosTrading::Lookup::PolicyTypeMismatch) [private]
 

Reconcile a Boolean property with its debault.

Definition at line 667 of file Trader_Utils.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, CosTrading::PolicyValue, TAO_Support_Attributes_i::supports_dynamic_properties(), TAO_Support_Attributes_i::supports_modifiable_properties(), TAO_Support_Attributes_i::supports_proxy_offers(), and CosTrading::Policy::value.

00670 {
00671   CORBA::Boolean def_value = 1,
00672     return_value = 1;
00673   const TAO_Support_Attributes_i& support_attrs =
00674     this->trader_.support_attributes ();
00675 
00676   switch (pol)
00677     {
00678     case USE_MODIFIABLE_PROPERTIES:
00679       def_value = support_attrs.supports_modifiable_properties ();
00680       break;
00681     case USE_DYNAMIC_PROPERTIES:
00682       def_value = support_attrs.supports_dynamic_properties ();
00683       break;
00684     case USE_PROXY_OFFERS:
00685       def_value = support_attrs.supports_proxy_offers ();
00686       break;
00687     case EXACT_TYPE_MATCH:
00688       def_value = 0;
00689       break;
00690     default:
00691       break;
00692     }
00693 
00694   if (this->policies_[pol] != 0)
00695     {
00696       const CosTrading::Policy* policy = this->policies_[pol];
00697       const CosTrading::PolicyValue& value = policy->value;
00698       CORBA::TypeCode_var type = value.type ();
00699 
00700       CORBA::Boolean equal_boolean =
00701         type->equal (CORBA::_tc_boolean ACE_ENV_ARG_PARAMETER);
00702       ACE_CHECK_RETURN (return_value);
00703 
00704       if (!equal_boolean)
00705         ACE_THROW_RETURN (CosTrading::Lookup::PolicyTypeMismatch (*policy),
00706                           return_value);
00707       else
00708         value >>= CORBA::Any::to_boolean (return_value);
00709 
00710       if (def_value == 0 &&
00711           pol != EXACT_TYPE_MATCH)
00712         return_value = 0;
00713     }
00714   else
00715     return_value = def_value;
00716 
00717   return return_value;
00718 }

void TAO_Policies::copy_in_follow_option CosTrading::PolicySeq policy_seq,
const CosTrading::Link::LinkInfo link_info
const throw (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)

Definition at line 878 of file Trader_Utils.cpp.

References ACE_CHECK, ACE_ENV_SINGLE_ARG_PARAMETER, CosTrading::PolicySeq, and ACE_OS::strcmp().

00883 {
00884   CosTrading::FollowOption follow_option = CosTrading::local_only;
00885   CosTrading::FollowOption trader_max_follow_policy =
00886     this->trader_.import_attributes ().max_follow_policy ();
00887 
00888   if (this->policies_[LINK_FOLLOW_RULE] != 0)
00889     {
00890       CosTrading::FollowOption query_link_follow_rule =
00891         this->link_follow_rule (ACE_ENV_SINGLE_ARG_PARAMETER);
00892       ACE_CHECK;
00893 
00894       follow_option = (CosTrading::FollowOption)
00895         (link_info.limiting_follow_rule < trader_max_follow_policy
00896          ? (link_info.limiting_follow_rule < query_link_follow_rule
00897             ? link_info.limiting_follow_rule
00898             : query_link_follow_rule)
00899          : (trader_max_follow_policy < query_link_follow_rule
00900             ? trader_max_follow_policy
00901             : query_link_follow_rule));
00902     }
00903   else
00904     follow_option = (CosTrading::FollowOption)
00905       (link_info.def_pass_on_follow_rule < trader_max_follow_policy
00906        ? link_info.def_pass_on_follow_rule
00907        : trader_max_follow_policy);
00908 
00909   CORBA::ULong i = 0;
00910   for (i = 0; i < policy_seq.length (); i++)
00911     if (ACE_OS::strcmp (policy_seq[i].name,
00912                         POLICY_NAMES[LINK_FOLLOW_RULE]) == 0)
00913       {
00914         policy_seq[i].value <<= follow_option;
00915         break;
00916       }
00917 
00918   if (i == policy_seq.length ())
00919     {
00920       policy_seq.length (i + 1);
00921       policy_seq[i].name = POLICY_NAMES[LINK_FOLLOW_RULE];
00922       policy_seq[i].value <<= follow_option;
00923     }
00924 }

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 980 of file Trader_Utils.cpp.

References CosTrading::LinkName, CosTrading::Policy::name, CosTrading::PolicySeq, REQUEST_ID, STARTING_TRADER, CORBA::string_dup(), CosTrading::TraderName, and CosTrading::Policy::value.

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

00982 {
00983   // Create a new policy sequence, shortening the starting trader
00984   // policy by one link.
00985 
00986   CORBA::ULong counter = 0;
00987   CosTrading::Policy* policy_buffer =
00988     CosTrading::PolicySeq::allocbuf (REQUEST_ID + 1);
00989 
00990   if (policy_buffer == 0)
00991     return;
00992 
00993   for (int i = 0; i <= REQUEST_ID; i++)
00994     {
00995       CosTrading::Policy& new_policy = policy_buffer[counter];
00996 
00997       if (this->policies_[i] != 0)
00998         {
00999           // Copy in the existing policies.
01000           if (i == STARTING_TRADER && trader_name.length () > 1)
01001             {
01002               // Eliminate the first link of the trader name.
01003               // Only pass on the property if the sequence
01004               // contains more links after us.
01005 
01006               // The any will sieze control of this memory.
01007               // Allocating here avoids copying in the policy
01008               // any.
01009               CORBA::ULong length = trader_name.length ();
01010               CosTrading::LinkName* buf =
01011                 CosTrading::TraderName::allocbuf (length - 1);
01012 
01013               if (buf != 0)
01014                 {
01015                   for (CORBA::ULong j = 1; j < length; j++)
01016                     buf[j - 1] = CORBA::string_dup (trader_name[j]);
01017 
01018                   new_policy.name = this->policies_[i]->name;
01019                   CosTrading::TraderName new_name (length - 1,
01020                                                    length - 1,
01021                                                    buf,
01022                                                    1);
01023 
01024                   new_policy.value <<= new_name;
01025                   counter++;
01026                 }
01027             }
01028           else if (i != STARTING_TRADER)
01029             {
01030               new_policy.name = this->policies_[i]->name;
01031               new_policy.value = this->policies_[i]->value;
01032               counter++;
01033             }
01034         }
01035     }
01036 
01037   // Create the new sequence
01038   policy_seq.replace (REQUEST_ID + 1,
01039                       counter,
01040                       policy_buffer, 1);
01041 }

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 928 of file Trader_Utils.cpp.

References ACE_CHECK, ACE_ENV_SINGLE_ARG_PARAMETER, hop_count(), HOP_COUNT, CosTrading::Policy::name, POLICY_NAMES, CosTrading::PolicySeq, REQUEST_ID, and CosTrading::Policy::value.

00931 {
00932   CORBA::ULong counter = 0;
00933   CosTrading::Policy* policy_buffer =
00934     CosTrading::PolicySeq::allocbuf (REQUEST_ID + 1);
00935 
00936   if (policy_buffer == 0)
00937     return;
00938 
00939   for (int i = 0; i <= REQUEST_ID; i++)
00940     {
00941       CosTrading::Policy& new_policy = policy_buffer[counter];
00942 
00943        if (i == REQUEST_ID)
00944         {
00945           // Set the new request id.
00946           new_policy.name = POLICY_NAMES[REQUEST_ID];
00947           new_policy.value <<= request_id;
00948           counter++;
00949         }
00950        else if (this->policies_[i] != 0)
00951         {
00952           // Copy in the existing policies.
00953           new_policy.name = POLICY_NAMES[i];
00954           new_policy.value = this->policies_[i]->value;
00955           counter++;
00956         }
00957 
00958       // We always require a hop count.
00959       if (i == HOP_COUNT)
00960         {
00961           CORBA::ULong count = this->hop_count (ACE_ENV_SINGLE_ARG_PARAMETER);
00962           ACE_CHECK;
00963 
00964           new_policy.name = POLICY_NAMES[HOP_COUNT];
00965           new_policy.value <<= count - 1;
00966 
00967           // Don't count hop count twice.
00968           if (this->policies_[i] == 0)
00969             counter++;
00970         }
00971     }
00972 
00973   policy_seq.replace (REQUEST_ID + 1,
00974                       counter,
00975                       policy_buffer,
00976                       1);
00977 }

CORBA::Boolean TAO_Policies::exact_type_match  )  const throw (CosTrading::Lookup::PolicyTypeMismatch)
 

Definition at line 743 of file Trader_Utils.cpp.

References ACE_ENV_ARG_PARAMETER.

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

00745 {
00746   return this->boolean_prop (EXACT_TYPE_MATCH ACE_ENV_ARG_PARAMETER);
00747 }

CORBA::ULong TAO_Policies::hop_count  )  const throw (CosTrading::Lookup::PolicyTypeMismatch)
 

Definition at line 844 of file Trader_Utils.cpp.

References ACE_ENV_ARG_PARAMETER.

Referenced by copy_to_pass().

00846 {
00847   return this->ulong_prop (HOP_COUNT ACE_ENV_ARG_PARAMETER);
00848 }

CosTrading::FollowOption TAO_Policies::link_follow_rule const CosTrading::Link::LinkInfo link_info  )  const throw (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)

Definition at line 817 of file Trader_Utils.cpp.

References ACE_CHECK_RETURN, and ACE_ENV_SINGLE_ARG_PARAMETER.

00823 {
00824   CosTrading::FollowOption return_value = CosTrading::local_only;
00825   CosTrading::FollowOption trader_max_follow_policy =
00826     this->trader_.import_attributes ().max_follow_policy ();
00827   CosTrading::FollowOption link_limiting_follow_rule =
00828     link_info.limiting_follow_rule;
00829 
00830   // If not defined defaults to trader.def_link_follow_rule
00831   CosTrading::FollowOption query_link_follow_rule =
00832     this->link_follow_rule (ACE_ENV_SINGLE_ARG_PARAMETER);
00833   ACE_CHECK_RETURN (return_value);
00834 
00835   return_value = (query_link_follow_rule < trader_max_follow_policy)
00836     ? query_link_follow_rule : trader_max_follow_policy;
00837   return_value = (return_value < link_limiting_follow_rule)
00838     ? return_value : link_limiting_follow_rule;
00839 
00840   return return_value;
00841 }

CosTrading::FollowOption TAO_Policies::link_follow_rule  )  const throw (CosTrading::Lookup::PolicyTypeMismatch)
 

Determine the link follow policy for this query overall.

Definition at line 783 of file Trader_Utils.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, CosTrading::PolicyValue, and CosTrading::Policy::value.

00785 {
00786   CosTrading::FollowOption return_value =
00787     this->trader_.import_attributes ().def_follow_policy ();
00788 
00789   if (this->policies_[LINK_FOLLOW_RULE] != 0)
00790     {
00791       CosTrading::FollowOption max_follow_policy =
00792         this->trader_.import_attributes ().max_follow_policy ();
00793 
00794       CosTrading::Policy* policy = this->policies_[LINK_FOLLOW_RULE];
00795       CosTrading::PolicyValue& value = policy->value;
00796       CORBA::TypeCode_var type = value.type ();
00797 
00798       // Extract the link follow rule
00799       CORBA::Boolean type_equal =
00800         type->equal (CosTrading::_tc_FollowOption ACE_ENV_ARG_PARAMETER);
00801       ACE_CHECK_RETURN (return_value);
00802 
00803       if (!type_equal)
00804         ACE_THROW_RETURN (CosTrading::Lookup::PolicyTypeMismatch (*policy),
00805                           return_value);
00806       else
00807         value >>= return_value;
00808 
00809       if (return_value > max_follow_policy)
00810         return_value = max_follow_policy;
00811     }
00812 
00813   return return_value;
00814 }

CORBA::ULong TAO_Policies::match_card  )  const throw (CosTrading::Lookup::PolicyTypeMismatch)
 

Definition at line 653 of file Trader_Utils.cpp.

References ACE_ENV_ARG_PARAMETER.

00655 {
00656   return this->ulong_prop (MATCH_CARD ACE_ENV_ARG_PARAMETER);
00657 }

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

CosTrading::Admin::OctetSeq * TAO_Policies::request_id  )  const throw (CosTrading::Lookup::PolicyTypeMismatch)
 

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

Definition at line 851 of file Trader_Utils.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, CosTrading::PolicyValue, and CosTrading::Policy::value.

00853 {
00854   CosTrading::Admin::OctetSeq* request_id = 0;
00855 
00856   if (this->policies_[REQUEST_ID] != 0)
00857     {
00858       CosTrading::Policy* policy = this->policies_[REQUEST_ID];
00859       CosTrading::PolicyValue& value = policy->value;
00860       CORBA::TypeCode_var type = value.type ();
00861 
00862       CORBA::Boolean equal_octetseq =
00863         type->equal (CosTrading::Admin::_tc_OctetSeq ACE_ENV_ARG_PARAMETER);
00864       ACE_CHECK_RETURN (request_id);
00865 
00866       if (!equal_octetseq)
00867         ACE_THROW_RETURN (CosTrading::Lookup::PolicyTypeMismatch (*policy),
00868                           request_id);
00869       else
00870         value >>= request_id;
00871     }
00872 
00873   return request_id;
00874 }

CORBA::ULong TAO_Policies::return_card  )  const throw (CosTrading::Lookup::PolicyTypeMismatch)
 

Definition at line 660 of file Trader_Utils.cpp.

References ACE_ENV_ARG_PARAMETER.

00662 {
00663   return this->ulong_prop (RETURN_CARD ACE_ENV_ARG_PARAMETER);
00664 }

CORBA::ULong TAO_Policies::search_card  )  const throw (CosTrading::Lookup::PolicyTypeMismatch)
 

Definition at line 646 of file Trader_Utils.cpp.

References ACE_ENV_ARG_PARAMETER.

00648 {
00649   return this->ulong_prop (SEARCH_CARD ACE_ENV_ARG_PARAMETER);
00650 }

CosTrading::TraderName * TAO_Policies::starting_trader  )  const throw (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

Definition at line 751 of file Trader_Utils.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, CosTrading::PolicyValue, CosTrading::TraderName, and CosTrading::Policy::value.

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

00754 {
00755   CosTrading::TraderName* trader_name = 0;
00756 
00757   if (this->policies_[STARTING_TRADER] != 0)
00758     {
00759       CosTrading::Policy* policy = this->policies_[STARTING_TRADER];
00760       CosTrading::PolicyValue& value = policy->value;
00761       CORBA::TypeCode_var type = value.type ();
00762 
00763       CORBA::Boolean equal_tradername =
00764         type->equal (CosTrading::_tc_TraderName ACE_ENV_ARG_PARAMETER);
00765       ACE_CHECK_RETURN (trader_name);
00766 
00767       CORBA::Boolean equal_linknameseq =
00768         type->equal (CosTrading::_tc_LinkNameSeq ACE_ENV_ARG_PARAMETER);
00769       ACE_CHECK_RETURN (trader_name);
00770 
00771       if (!equal_tradername ||
00772           !equal_linknameseq)
00773         ACE_THROW_RETURN (CosTrading::Lookup::PolicyTypeMismatch (*policy),
00774                           trader_name);
00775       else
00776         value >>= trader_name;
00777     }
00778 
00779   return trader_name;
00780 }

CORBA::ULong TAO_Policies::ulong_prop POLICY_TYPE  pol  )  const throw (CosTrading::Lookup::PolicyTypeMismatch) [private]
 

Reconclile a ULong property with its default.

Definition at line 590 of file Trader_Utils.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, 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(), 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(), CosTrading::PolicyValue, and CosTrading::Policy::value.

00593 {
00594   CORBA::ULong return_value = 0, max_value = 0;
00595   const TAO_Import_Attributes_i& import_attrs =
00596     this->trader_.import_attributes ();
00597 
00598   // Discover the default values for each of the possible cardinality
00599   // policies.
00600   switch (pol)
00601     {
00602     case SEARCH_CARD:
00603       return_value = import_attrs.def_search_card ();
00604       max_value = import_attrs.max_search_card ();
00605       break;
00606     case MATCH_CARD:
00607       return_value = import_attrs.def_match_card ();
00608       max_value = import_attrs.max_match_card ();
00609       break;
00610     case RETURN_CARD:
00611       return_value = import_attrs.def_return_card ();
00612       max_value = import_attrs.max_return_card ();
00613       break;
00614     case HOP_COUNT:
00615       return_value = import_attrs.def_hop_count ();
00616       max_value = import_attrs.max_hop_count ();
00617       break;
00618     default:
00619       break;
00620     }
00621 
00622   if (this->policies_[pol] != 0)
00623     {
00624       // Extract the desired policy value.
00625       const CosTrading::Policy* policy = this->policies_[pol];
00626       const CosTrading::PolicyValue& value = policy->value;
00627       CORBA::TypeCode_var type = value.type ();
00628 
00629       CORBA::Boolean equal_ulong = type->equal (CORBA::_tc_ulong ACE_ENV_ARG_PARAMETER);
00630       ACE_CHECK_RETURN (return_value);
00631 
00632       if (!equal_ulong)
00633         ACE_THROW_RETURN (CosTrading::Lookup::PolicyTypeMismatch (*policy),
00634                           return_value);
00635       else
00636         value >>= return_value;
00637 
00638       if (max_value < return_value)
00639         return_value = max_value;
00640     }
00641 
00642   return return_value;
00643 }

CORBA::Boolean TAO_Policies::use_dynamic_properties  )  const throw (CosTrading::Lookup::PolicyTypeMismatch)
 

Definition at line 729 of file Trader_Utils.cpp.

References ACE_ENV_ARG_PARAMETER.

00731 {
00732   return this->boolean_prop (USE_DYNAMIC_PROPERTIES ACE_ENV_ARG_PARAMETER);
00733 }

CORBA::Boolean TAO_Policies::use_modifiable_properties  )  const throw (CosTrading::Lookup::PolicyTypeMismatch)
 

Definition at line 722 of file Trader_Utils.cpp.

References ACE_ENV_ARG_PARAMETER.

00724 {
00725   return this->boolean_prop (USE_MODIFIABLE_PROPERTIES ACE_ENV_ARG_PARAMETER);
00726 }

CORBA::Boolean TAO_Policies::use_proxy_offers  )  const throw (CosTrading::Lookup::PolicyTypeMismatch)
 

Definition at line 736 of file Trader_Utils.cpp.

References ACE_ENV_ARG_PARAMETER.

00738 {
00739   return this->boolean_prop (USE_PROXY_OFFERS ACE_ENV_ARG_PARAMETER);
00740 }


Member Data Documentation

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

The policies indexable from the enumerated type.

Definition at line 486 of file Trader_Utils.h.

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 505 of file Trader_Utils.cpp.

Referenced by copy_to_pass().

TAO_Trader_Base& TAO_Policies::trader_ [private]
 

For the validating identifier names.

Definition at line 489 of file Trader_Utils.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 14:01:03 2006 for TAO_CosTrader by doxygen 1.3.6