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

Definition at line 333 of file Trader_Utils.cpp.

References TAO_Trader_Base::is_valid_property_name(), and TAO_Property_Evaluator::props_.

00336     : TAO_Property_Evaluator (properties, supports_dp)
00337 {
00338   int length = this->props_.length();
00339 
00340   for (int i = 0; i < length; i++)
00341     {
00342       const CosTrading::Property& prop = this->props_[i];
00343 
00344       if (! TAO_Trader_Base::is_valid_property_name (prop.name))
00345         throw CosTrading::IllegalPropertyName (prop.name);
00346 
00347       CORBA::String_var prop_name = prop.name.in ();
00348       if (this->table_.bind (prop_name, i))
00349         throw CosTrading::DuplicatePropertyName (prop.name);
00350     }
00351 }

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 <offer> where the support for dynamic properties is dictated by <supports_dynamic_properties>.

Definition at line 354 of file Trader_Utils.cpp.

References TAO_Property_Evaluator::props_.

00356   : TAO_Property_Evaluator(offer, supports_dp)
00357 {
00358   int length = this->props_.length();
00359 
00360   for (int i = 0; i < length; i++)
00361     {
00362       CORBA::String_var prop_name = (const char*) this->props_[i].name;
00363       this->table_.bind (prop_name, i);
00364     }
00365 }

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

References TAO_Property_Evaluator::props_.

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

00418 {
00419   int index = 0;
00420   CosTrading::Property* property = 0;
00421   CORBA::String_var prop_name (property_name);
00422 
00423   if (this->table_.find (prop_name, index) == 0)
00424     property = (CosTrading::Property *) &this->props_[index];
00425 
00426   return property;
00427 }

int TAO_Property_Evaluator_By_Name::is_dynamic_property ( const char *  property_name  ) 

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

Definition at line 369 of file Trader_Utils.cpp.

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

00370 {
00371   int predicate = 0;
00372   int index = 0;
00373   CORBA::String_var prop_name (property_name);
00374 
00375   // If the property name is in the map, delegate evaluation to our
00376   // superclass. Otherwise, throw an exception.
00377   if (this->table_.find (prop_name, index) == 0)
00378     predicate = this->TAO_Property_Evaluator::is_dynamic_property(index);
00379 
00380   return predicate;
00381 }

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

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

00403 {
00404   int index = 0;
00405   CORBA::String_var prop_name (property_name);
00406   CORBA::TypeCode_ptr prop_type = CORBA::TypeCode::_nil();
00407 
00408   // If the property name is in the map, delegate evaluation to our
00409   // superclass. Otherwise, throw an exception.
00410   if (this->table_.find (prop_name, index) == 0)
00411     prop_type = this->TAO_Property_Evaluator::property_type (index);
00412 
00413   return prop_type;
00414 }

CORBA::Any * TAO_Property_Evaluator_By_Name::property_value ( const char *  property_name  ) 

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

00385 {
00386   int index = 0;
00387   CORBA::Any* prop_value = 0;
00388   CORBA::String_var prop_name (property_name);
00389 
00390   // If the property name is in the map, delegate evaluation to our
00391   // superclass. Otherwise, throw an exception.
00392   if (this->table_.find (prop_name, index) == 0)
00393     {
00394       prop_value =
00395         this->TAO_Property_Evaluator::property_value (index);
00396     }
00397 
00398   return prop_value;
00399 }


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 171 of file Trader_Utils.h.


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