TAO_Property_Evaluator_By_Name Class Reference

This class extends the TAO_Property_Evaluator to allow lookups based on the property name of interest. Since the property information is contained within an integer indexed array, lookups may occur in O(n) time, where n is the length of the array. To make lookups by name more efficient, TAO_Property_Evaluator_By_Name creates a mapping of property names to integer indicies, upon which lookups are guaranteed to be O(lg n). More...

#include <Trader_Utils.h>

Inheritance diagram for TAO_Property_Evaluator_By_Name:

Inheritance graph
[legend]
Collaboration diagram for TAO_Property_Evaluator_By_Name:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Property_Evaluator_By_Name (const CosTrading::PropertySeq &properties, CORBA::Boolean supports_dp=1) throw (CosTrading::DuplicatePropertyName, CosTrading::IllegalPropertyName)
 TAO_Property_Evaluator_By_Name (CosTrading::Offer &offer, CORBA::Boolean supports_dp=1)
int is_dynamic_property (const char *property_name)
CORBA::Any * property_value (const char *property_name) throw (CosTradingDynamic::DPEvalFailure)
CORBA::TypeCode_ptr property_type (const char *property_name)
const CosTrading::Propertyget_property (const char *property_name)

Private Member Functions

 TAO_Property_Evaluator_By_Name (const TAO_Property_Evaluator_By_Name &)
TAO_Property_Evaluator_By_Nameoperator= (const TAO_Property_Evaluator_By_Name &)

Private Attributes

TAO_Lookup_Table table_

Detailed Description

This class extends the TAO_Property_Evaluator to allow lookups based on the property name of interest. Since the property information is contained within an integer indexed array, lookups may occur in O(n) time, where n is the length of the array. To make lookups by name more efficient, TAO_Property_Evaluator_By_Name creates a mapping of property names to integer indicies, upon which lookups are guaranteed to be O(lg n).

Definition at line 126 of file Trader_Utils.h.


Constructor & Destructor Documentation

TAO_Property_Evaluator_By_Name::TAO_Property_Evaluator_By_Name const CosTrading::PropertySeq properties,
CORBA::Boolean  supports_dp = 1
throw (CosTrading::DuplicatePropertyName, CosTrading::IllegalPropertyName)
 

Definition at line 342 of file Trader_Utils.cpp.

References ACE_THROW, TAO_Trader_Base::is_valid_property_name(), CosTrading::Property::name, and CosTrading::PropertySeq.

00347     : TAO_Property_Evaluator (properties, supports_dp)
00348 {
00349   int length = this->props_.length();
00350 
00351   for (int i = 0; i < length; i++)
00352     {
00353       const CosTrading::Property& prop = this->props_[i];
00354 
00355       if (! TAO_Trader_Base::is_valid_property_name (prop.name))
00356         ACE_THROW (CosTrading::IllegalPropertyName (prop.name));
00357 
00358       CORBA::String_var prop_name = prop.name.in ();
00359       if (this->table_.bind (prop_name, i))
00360         ACE_THROW (CosTrading::DuplicatePropertyName (prop.name));
00361     }
00362 }

TAO_Property_Evaluator_By_Name::TAO_Property_Evaluator_By_Name CosTrading::Offer offer,
CORBA::Boolean  supports_dp = 1
 

Construct an instance of TAO_Property_Evaluator that operates on an where the support for dynamic properties is dictated by .

Definition at line 365 of file Trader_Utils.cpp.

References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind().

00367   : TAO_Property_Evaluator(offer, supports_dp)
00368 {
00369   int length = this->props_.length();
00370 
00371   for (int i = 0; i < length; i++)
00372     {
00373       CORBA::String_var prop_name = (const char*) this->props_[i].name;
00374       this->table_.bind (prop_name, i);
00375     }
00376 }

TAO_Property_Evaluator_By_Name::TAO_Property_Evaluator_By_Name const TAO_Property_Evaluator_By_Name  )  [private]
 


Member Function Documentation

const CosTrading::Property * TAO_Property_Evaluator_By_Name::get_property const char *  property_name  ) 
 

Definition at line 432 of file Trader_Utils.cpp.

References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find().

Referenced by TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::validate_properties().

00433 {
00434   int index = 0;
00435   CosTrading::Property* property = 0;
00436   CORBA::String_var prop_name (property_name);
00437 
00438   if (this->table_.find (prop_name, index) == 0)
00439     property = (CosTrading::Property *) &this->props_[index];
00440 
00441   return property;
00442 }

int TAO_Property_Evaluator_By_Name::is_dynamic_property const char *  property_name  ) 
 

Returns 1 if the property whose name is is defined and dynamic. If the property is undefined, this method will throw a Property_Undefined exception with impunity.

Definition at line 380 of file Trader_Utils.cpp.

References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), and TAO_Property_Evaluator::is_dynamic_property().

Referenced by TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::validate_properties().

00381 {
00382   int predicate = 0;
00383   int index = 0;
00384   CORBA::String_var prop_name (property_name);
00385 
00386   // If the property name is in the map, delegate evaluation to our
00387   // superclass. Otherwise, throw an exception.
00388   if (this->table_.find (prop_name, index) == 0)
00389     predicate = this->TAO_Property_Evaluator::is_dynamic_property(index);
00390 
00391   return predicate;
00392 }

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

CORBA::TypeCode_ptr TAO_Property_Evaluator_By_Name::property_type const char *  property_name  ) 
 

This method is identical to its counterpart in TAO_Property_Evaluator, exception property_type first discovers the index through a string matching lookup.

Definition at line 417 of file Trader_Utils.cpp.

References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), and TAO_Property_Evaluator::property_type().

Referenced by TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::validate_properties().

00418 {
00419   int index = 0;
00420   CORBA::String_var prop_name (property_name);
00421   CORBA::TypeCode_ptr prop_type = CORBA::TypeCode::_nil();
00422 
00423   // If the property name is in the map, delegate evaluation to our
00424   // superclass. Otherwise, throw an exception.
00425   if (this->table_.find (prop_name, index) == 0)
00426     prop_type = this->TAO_Property_Evaluator::property_type (index);
00427 
00428   return prop_type;
00429 }

CORBA::Any * TAO_Property_Evaluator_By_Name::property_value const char *  property_name  )  throw (CosTradingDynamic::DPEvalFailure)
 

This method is identical to its counterpart in TAO_Property_Evaluator, except property_value first discovers the index through a string matching lookup.

Definition at line 395 of file Trader_Utils.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, and TAO_Property_Evaluator::property_value().

00398 {
00399   int index = 0;
00400   CORBA::Any* prop_value = 0;
00401   CORBA::String_var prop_name (property_name);
00402 
00403   // If the property name is in the map, delegate evaluation to our
00404   // superclass. Otherwise, throw an exception.
00405   if (this->table_.find (prop_name, index) == 0)
00406     {
00407       prop_value =
00408         this->TAO_Property_Evaluator::property_value (index
00409                                                       ACE_ENV_ARG_PARAMETER);
00410       ACE_CHECK_RETURN (0);
00411     }
00412 
00413   return prop_value;
00414 }


Member Data Documentation

TAO_Lookup_Table TAO_Property_Evaluator_By_Name::table_ [private]
 

The instance of the above mapping for the offer provided in the constructor.

Definition at line 176 of file Trader_Utils.h.


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