TAO_Property_Filter Class Reference

The Ace_Property_Filter copies those properties specified in a CosTrading::Lookup::SpecifiedProps from a source CosTrading::Offer to a destination CosTrading::Offer. More...

#include <Trader_Utils.h>

Collaboration diagram for TAO_Property_Filter:

Collaboration graph
[legend]
List of all members.

Public Types

typedef CosTrading::Lookup::SpecifiedProps SPECIFIED_PROPS

Public Member Functions

 TAO_Property_Filter (void)
 An accomplice to g++'s insane lust for copy constructors.
 TAO_Property_Filter (const SPECIFIED_PROPS &desired_props)
 Verify that the specified properties are correct.
 TAO_Property_Filter (const TAO_Property_Filter &prop_filter)
TAO_Property_Filteroperator= (const TAO_Property_Filter &prop_filter)
void filter_offer (CosTrading::Offer *source, CosTrading::Offer &destination)

Private Types

typedef ACE_Unbounded_Queue<
CosTrading::Property * > 
Prop_Queue

Private Attributes

TAO_String_Set props_
CosTrading::Lookup::HowManyProps policy_

Detailed Description

The Ace_Property_Filter copies those properties specified in a CosTrading::Lookup::SpecifiedProps from a source CosTrading::Offer to a destination CosTrading::Offer.

Definition at line 697 of file Trader_Utils.h.


Member Typedef Documentation

typedef ACE_Unbounded_Queue< CosTrading::Property* > TAO_Property_Filter::Prop_Queue [private]

Definition at line 719 of file Trader_Utils.h.

typedef CosTrading::Lookup::SpecifiedProps TAO_Property_Filter::SPECIFIED_PROPS

Definition at line 701 of file Trader_Utils.h.


Constructor & Destructor Documentation

TAO_Property_Filter::TAO_Property_Filter ( void   )  [inline]

An accomplice to g++'s insane lust for copy constructors.

Definition at line 704 of file Trader_Utils.h.

TAO_Property_Filter::TAO_Property_Filter ( const SPECIFIED_PROPS desired_props  ) 

Verify that the specified properties are correct.

Definition at line 1359 of file Trader_Utils.cpp.

References TAO_Trader_Base::is_valid_property_name(), CosTrading::Lookup::SpecifiedProps::prop_names, and CosTrading::Lookup::some.

01360   : policy_  (desired_props._d ())
01361 {
01362   if (this->policy_ == CosTrading::Lookup::some)
01363     {
01364       const CosTrading::PropertyNameSeq&
01365         prop_seq = desired_props.prop_names ();
01366       int length = prop_seq.length ();
01367 
01368       for (int i = 0; i < length; i++)
01369         {
01370           const char* pname = prop_seq[i];
01371 
01372           // Check for errors or duplicates
01373           if (TAO_Trader_Base::is_valid_property_name (pname))
01374             {
01375               CORBA::String_var prop_name (pname);
01376               if (this->props_.insert (prop_name) == 1)
01377                 throw CosTrading::DuplicatePropertyName (pname);
01378             }
01379           else
01380             throw CosTrading::IllegalPropertyName (pname);
01381         }
01382     }
01383 }

TAO_Property_Filter::TAO_Property_Filter ( const TAO_Property_Filter prop_filter  ) 

Definition at line 1386 of file Trader_Utils.cpp.

01387   : props_ (prop_filter.props_),
01388     policy_ (prop_filter.policy_)
01389 {
01390 }


Member Function Documentation

void TAO_Property_Filter::filter_offer ( CosTrading::Offer source,
CosTrading::Offer destination 
)

Copy the desired properties from the source offer to the destination offer.

Definition at line 1402 of file Trader_Utils.cpp.

References CORBA::Object::_duplicate(), CosTrading::Lookup::all, ACE_Unbounded_Queue< T >::enqueue_tail(), CosTrading::Offer::properties, CosTrading::Offer::reference, ACE_Unbounded_Queue< T >::size(), and CosTrading::Lookup::some.

Referenced by TAO_Lookup< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::fill_receptacles(), TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::next_n(), and TAO_Query_Only_Offer_Iterator::next_n().

01404 {
01405   Prop_Queue prop_queue;
01406   CosTrading::PropertySeq& s_props = source->properties;
01407   CosTrading::PropertySeq& d_props = destination.properties;
01408   CORBA::ULong length = static_cast<CORBA::ULong> (s_props.length ()),
01409                elem = 0;
01410 
01411   destination.reference = CORBA::Object::_duplicate (source->reference.in ());
01412   if (this->policy_ == CosTrading::Lookup::some)
01413     {
01414       for (CORBA::ULong i = 0; i < length; i++)
01415         {
01416           if (this->policy_ == CosTrading::Lookup::all)
01417             prop_queue.enqueue_tail (&s_props[i]);
01418           else
01419             {
01420               const char* p_name = s_props[i].name;
01421               CORBA::String_var prop_name (p_name);
01422 
01423               // Save those property that match.
01424               if (this->props_.find (prop_name) == 0)
01425                 prop_queue.enqueue_tail (&s_props[i]);
01426             }
01427         }
01428 
01429       // Shove the matched properties into the destination property
01430       // sequence.
01431       length = static_cast<CORBA::ULong> (prop_queue.size ());
01432       d_props.length (length);
01433       for (Prop_Queue::ITERATOR prop_iter (prop_queue);
01434            ! prop_iter.done ();
01435            prop_iter.advance (), elem++)
01436         {
01437           CosTrading::Property** prop_ptr = 0;
01438 
01439           prop_iter.next (prop_ptr);
01440           d_props[elem] = **prop_ptr;
01441         }
01442     }
01443   else if (this->policy_ == CosTrading::Lookup::all)
01444     //      CosTrading::Property* props = s_props.get_buffer (0);
01445     //      d_props.replace (length, length, props, 0);
01446     d_props = s_props;
01447 }

TAO_Property_Filter & TAO_Property_Filter::operator= ( const TAO_Property_Filter prop_filter  ) 

Definition at line 1393 of file Trader_Utils.cpp.

References policy_, and props_.

01394 {
01395   this->props_ = other.props_;
01396   this->policy_ = other.policy_;
01397 
01398   return *this;
01399 }


Member Data Documentation

CosTrading::Lookup::HowManyProps TAO_Property_Filter::policy_ [private]

Definition at line 722 of file Trader_Utils.h.

Referenced by operator=().

TAO_String_Set TAO_Property_Filter::props_ [private]

Definition at line 721 of file Trader_Utils.h.

Referenced by operator=().


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