TAO_Policy_Creator Class Reference

This class is a utility for clients using the CosTrading::Lookup interface that helps them build a policy sequence without violating syntax rules and having to mess with typecodes. More...

#include <Trader_Utils.h>

List of all members.

Public Member Functions

 TAO_Policy_Creator (int num_policies=0)
void search_card (CORBA::ULong scard)
 Set the maximum number of offers searched for the query.

void match_card (CORBA::ULong mcard)
 Set the maximum number of offers searched for the query.

void return_card (CORBA::ULong rcard)
 Set the maximum number of offers rerturned for the query.

void use_modifiable_properties (CORBA::Boolean mod_props)
 Consider offers with modifiable properties.

void use_dynamic_properties (CORBA::Boolean dyn_props)
 Consider offers with dynamic properties.

void use_proxy_offers (CORBA::Boolean prox_offs)
 Consider proxy offers (NOT SUPPORTED).

void starting_trader (const CosTrading::TraderName &name)
 Designate a trader at which to begin the query.

void starting_trader (CosTrading::TraderName *name)
void link_follow_rule (CosTrading::FollowOption follow_option)
 Specify under what conditions a federated query is appropriate.

void hop_count (CORBA::ULong hop_count)
 Limit the breadth of a federated query.

void request_id (const CosTrading::Admin::OctetSeq &request_id)
 Set the identifier for this query (clients shouldn't use this).

void exact_type_match (CORBA::Boolean exact_type)
 Search only the designated type --- not it's subtypes.

 operator const CosTrading::PolicySeq & (void) const
 Return the constructed policy sequence.

const CosTrading::PolicySeqpolicy_seq (void) const

Private Member Functions

 TAO_Policy_Creator (const TAO_Policy_Creator &)
TAO_Policy_Creatoroperator= (const TAO_Policy_Creator &)
CosTrading::Policyfetch_next_policy (TAO_Policies::POLICY_TYPE pol_type)

Private Attributes

int poltable_ [TAO_Policies::REQUEST_ID+1]
 Table mapping policy enum value to the index in the policies sequence.

CosTrading::PolicySeq policies_
 The sequence being prepared for submittal to the query method.

CORBA::ULong num_policies_
 The number of policies so far in the sequence.


Detailed Description

This class is a utility for clients using the CosTrading::Lookup interface that helps them build a policy sequence without violating syntax rules and having to mess with typecodes.

Definition at line 499 of file Trader_Utils.h.


Constructor & Destructor Documentation

TAO_Policy_Creator::TAO_Policy_Creator int  num_policies = 0  ) 
 

Definition at line 17 of file Trader_Utils.cpp.

References poltable_.

00018   : policies_ (num_policies),
00019     num_policies_ (0)
00020 {
00021   for (int i = 0; i < TAO_Policies::REQUEST_ID + 1; i++)
00022     this->poltable_[i] = -1;
00023 }

TAO_Policy_Creator::TAO_Policy_Creator const TAO_Policy_Creator  )  [private]
 


Member Function Documentation

void TAO_Policy_Creator::exact_type_match CORBA::Boolean  exact_type  ) 
 

Search only the designated type --- not it's subtypes.

Definition at line 107 of file Trader_Utils.cpp.

References fetch_next_policy(), and CosTrading::Policy::value.

00108 {
00109   CosTrading::Policy& policy =
00110     this->fetch_next_policy (TAO_Policies::EXACT_TYPE_MATCH);
00111   policy.value <<= CORBA::Any::from_boolean (exact_type);
00112 }

CosTrading::Policy & TAO_Policy_Creator::fetch_next_policy TAO_Policies::POLICY_TYPE  pol_type  )  [private]
 

Method to prepare the next slot in the policies_ sequence for policy insertion.

Definition at line 134 of file Trader_Utils.cpp.

References num_policies_, and poltable_.

Referenced by exact_type_match(), hop_count(), link_follow_rule(), match_card(), request_id(), return_card(), search_card(), starting_trader(), use_dynamic_properties(), use_modifiable_properties(), and use_proxy_offers().

00135 {
00136   CORBA::ULong index = 0;
00137 
00138   if (this->poltable_[pol_type] == -1)
00139     {
00140       // Expand the policy sequence, and copy in the policy name into
00141       // the new element.
00142       CORBA::ULong length = this->policies_.length ();
00143       this->num_policies_++;
00144 
00145       if (length < this->num_policies_)
00146         this->policies_.length (this->num_policies_);
00147 
00148       index = this->num_policies_ - 1;
00149 
00150       // Ensure the starting trader policy gets the first slot.
00151       if (pol_type != TAO_Policies::STARTING_TRADER
00152           || index == 0)
00153         {
00154           this->policies_[index].name = TAO_Policies::POLICY_NAMES[pol_type];
00155           this->poltable_[pol_type] = index;
00156         }
00157       else
00158         {
00159           // Copy the element in the first slot to the newly
00160           // allocated slot.
00161           TAO_Policies::POLICY_TYPE occupying_policy =
00162             TAO_Policies::STARTING_TRADER;
00163           for (CORBA::ULong i = 0; i < this->num_policies_ - 1; i++)
00164             {
00165               if (this->poltable_[i] == 0)
00166                 {
00167                   occupying_policy =
00168                     static_cast<TAO_Policies::POLICY_TYPE> (i);
00169                   break;
00170                 }
00171             }
00172 
00173           this->poltable_[occupying_policy] = index;
00174           this->poltable_[TAO_Policies::STARTING_TRADER] = 0;
00175           this->policies_[index].name =
00176             TAO_Policies::POLICY_NAMES[occupying_policy];
00177           this->policies_[index].value = this->policies_[0].value;
00178           this->policies_[0].name =
00179             TAO_Policies::POLICY_NAMES[TAO_Policies::STARTING_TRADER];
00180 
00181           index = 0;
00182         }
00183     }
00184   else
00185     index = this->poltable_[pol_type];
00186 
00187   return this->policies_[index];
00188 }

void TAO_Policy_Creator::hop_count CORBA::ULong  hop_count  ) 
 

Limit the breadth of a federated query.

Definition at line 99 of file Trader_Utils.cpp.

References fetch_next_policy(), and CosTrading::Policy::value.

00100 {
00101   CosTrading::Policy& policy =
00102     this->fetch_next_policy (TAO_Policies::HOP_COUNT);
00103   policy.value <<= hop_count;
00104 }

void TAO_Policy_Creator::link_follow_rule CosTrading::FollowOption  follow_option  ) 
 

Specify under what conditions a federated query is appropriate.

Definition at line 91 of file Trader_Utils.cpp.

References fetch_next_policy(), and CosTrading::Policy::value.

00092 {
00093   CosTrading::Policy& policy =
00094     this->fetch_next_policy (TAO_Policies::LINK_FOLLOW_RULE);
00095   policy.value <<= follow_option;
00096 }

void TAO_Policy_Creator::match_card CORBA::ULong  mcard  ) 
 

Set the maximum number of offers searched for the query.

Definition at line 34 of file Trader_Utils.cpp.

References fetch_next_policy(), and CosTrading::Policy::value.

00035 {
00036   CosTrading::Policy& policy =
00037     this->fetch_next_policy (TAO_Policies::MATCH_CARD);
00038   policy.value <<= mcard;
00039 }

TAO_Policy_Creator::operator const CosTrading::PolicySeq & void   )  const
 

Return the constructed policy sequence.

Definition at line 122 of file Trader_Utils.cpp.

00123 {
00124   return this->policies_;
00125 }

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

const CosTrading::PolicySeq & TAO_Policy_Creator::policy_seq void   )  const
 

Return a PolicySeq suitable for passing to the query method of the Lookup interface.

Definition at line 128 of file Trader_Utils.cpp.

00129 {
00130   return this->policies_;
00131 }

void TAO_Policy_Creator::request_id const CosTrading::Admin::OctetSeq request_id  ) 
 

Set the identifier for this query (clients shouldn't use this).

Definition at line 115 of file Trader_Utils.cpp.

References fetch_next_policy(), and CosTrading::Policy::value.

00116 {
00117   CosTrading::Policy& policy =
00118     this->fetch_next_policy (TAO_Policies::REQUEST_ID);
00119   policy.value <<= request_id;
00120 }

void TAO_Policy_Creator::return_card CORBA::ULong  rcard  ) 
 

Set the maximum number of offers rerturned for the query.

Definition at line 42 of file Trader_Utils.cpp.

References fetch_next_policy(), and CosTrading::Policy::value.

00043 {
00044   CosTrading::Policy& policy =
00045     this->fetch_next_policy (TAO_Policies::RETURN_CARD);
00046   policy.value <<= rcard;
00047 }

void TAO_Policy_Creator::search_card CORBA::ULong  scard  ) 
 

Set the maximum number of offers searched for the query.

Definition at line 26 of file Trader_Utils.cpp.

References fetch_next_policy(), and CosTrading::Policy::value.

00027 {
00028   CosTrading::Policy& policy =
00029     this->fetch_next_policy (TAO_Policies::SEARCH_CARD);
00030   policy.value <<= scard;
00031 }

void TAO_Policy_Creator::starting_trader CosTrading::TraderName name  ) 
 

Definition at line 82 of file Trader_Utils.cpp.

References fetch_next_policy(), CosTrading::TraderName, and CosTrading::Policy::value.

00083 {
00084   CosTrading::Policy& policy =
00085     this->fetch_next_policy (TAO_Policies::STARTING_TRADER);
00086   policy.value <<= name;
00087 }

void TAO_Policy_Creator::starting_trader const CosTrading::TraderName name  ) 
 

Designate a trader at which to begin the query.

Definition at line 74 of file Trader_Utils.cpp.

References fetch_next_policy(), CosTrading::TraderName, and CosTrading::Policy::value.

00075 {
00076   CosTrading::Policy& policy =
00077     this->fetch_next_policy (TAO_Policies::STARTING_TRADER);
00078   policy.value <<= name;
00079 }

void TAO_Policy_Creator::use_dynamic_properties CORBA::Boolean  dyn_props  ) 
 

Consider offers with dynamic properties.

Definition at line 58 of file Trader_Utils.cpp.

References fetch_next_policy(), and CosTrading::Policy::value.

00059 {
00060   CosTrading::Policy& policy =
00061     this->fetch_next_policy (TAO_Policies::USE_DYNAMIC_PROPERTIES);
00062   policy.value <<= CORBA::Any::from_boolean (dyn_props);
00063 }

void TAO_Policy_Creator::use_modifiable_properties CORBA::Boolean  mod_props  ) 
 

Consider offers with modifiable properties.

Definition at line 50 of file Trader_Utils.cpp.

References fetch_next_policy(), and CosTrading::Policy::value.

00051 {
00052   CosTrading::Policy& policy =
00053     this->fetch_next_policy (TAO_Policies::USE_MODIFIABLE_PROPERTIES);
00054   policy.value <<= CORBA::Any::from_boolean (mod_props);
00055 }

void TAO_Policy_Creator::use_proxy_offers CORBA::Boolean  prox_offs  ) 
 

Consider proxy offers (NOT SUPPORTED).

Definition at line 66 of file Trader_Utils.cpp.

References fetch_next_policy(), and CosTrading::Policy::value.

00067 {
00068   CosTrading::Policy& policy =
00069     this->fetch_next_policy (TAO_Policies::USE_PROXY_OFFERS);
00070   policy.value <<= CORBA::Any::from_boolean (prox_offs);
00071 }


Member Data Documentation

CORBA::ULong TAO_Policy_Creator::num_policies_ [private]
 

The number of policies so far in the sequence.

Definition at line 571 of file Trader_Utils.h.

Referenced by fetch_next_policy().

CosTrading::PolicySeq TAO_Policy_Creator::policies_ [private]
 

The sequence being prepared for submittal to the query method.

Definition at line 568 of file Trader_Utils.h.

int TAO_Policy_Creator::poltable_[TAO_Policies::REQUEST_ID + 1] [private]
 

Table mapping policy enum value to the index in the policies sequence.

Definition at line 565 of file Trader_Utils.h.

Referenced by fetch_next_policy(), and TAO_Policy_Creator().


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