#include <Offer_Iterators_T.h>
Inheritance diagram for TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >:
Public Member Functions | |
TAO_Register_Offer_Iterator (TAO_Offer_Database< MAP_LOCK_TYPE > &db, const TAO_Property_Filter &pfilter) | |
virtual | ~TAO_Register_Offer_Iterator (void) |
Destructor. | |
virtual CORBA::Boolean | next_n (CORBA::ULong n, CosTrading::OfferSeq_out offers) |
virtual CORBA::ULong | max_left (void) |
void | add_offer (CosTrading::OfferId id, const CosTrading::Offer *) |
Add an offer the iterator should iterate over. | |
Private Attributes | |
TAO_Offer_Database< MAP_LOCK_TYPE > & | db_ |
A reference to the trader is needed for access to the map of offers. | |
TAO_String_Queue | offer_ids_ |
Offer ids of offers to iterate over. |
Stores ids of offers to be iterated over. Before returning an offer, checks if the offer is still there (since it may have been removed by the Register).
Definition at line 41 of file Offer_Iterators_T.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::TAO_Register_Offer_Iterator | ( | TAO_Offer_Database< MAP_LOCK_TYPE > & | db, | |
const TAO_Property_Filter & | pfilter | |||
) |
Takes service type and trader reference in order to later locate offers using their ids.
Definition at line 12 of file Offer_Iterators_T.cpp.
00014 : TAO_Offer_Iterator (pfilter), 00015 db_ (db) 00016 { 00017 }
TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::~TAO_Register_Offer_Iterator | ( | void | ) | [virtual] |
Destructor.
Definition at line 21 of file Offer_Iterators_T.cpp.
References ACE_Unbounded_Queue< T >::dequeue_head(), TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::offer_ids_, and CORBA::string_free().
00022 { 00023 while (! this->offer_ids_.is_empty ()) 00024 { 00025 CosTrading::OfferId offer_id = 0; 00026 this->offer_ids_.dequeue_head (offer_id); 00027 00028 CORBA::string_free (offer_id); 00029 } 00030 }
void TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::add_offer | ( | CosTrading::OfferId | id, | |
const CosTrading::Offer * | ||||
) | [virtual] |
Add an offer the iterator should iterate over.
Implements TAO_Offer_Iterator.
Definition at line 34 of file Offer_Iterators_T.cpp.
References ACE_Unbounded_Queue< T >::enqueue_tail(), and TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::offer_ids_.
00036 { 00037 this->offer_ids_.enqueue_tail (id); 00038 }
CORBA::ULong TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::max_left | ( | void | ) | [virtual] |
Throws CosTrading::UnknownMaxLeft since with the presence of "Register" functionality, the iterator cannot guarantee that the trader will have all the offers it has now when the time to return them comes.
Implements TAO_Offer_Iterator.
Definition at line 42 of file Offer_Iterators_T.cpp.
References TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::offer_ids_, and ACE_Unbounded_Queue< T >::size().
00043 { 00044 return static_cast<CORBA::ULong> (this->offer_ids_.size ()); 00045 }
CORBA::Boolean TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::next_n | ( | CORBA::ULong | n, | |
CosTrading::OfferSeq_out | offers | |||
) | [virtual] |
Deposit at maximum n offers into the return sequence and return 1, or return 0 if the iterator is done and no offers are returned.
Implements TAO_Offer_Iterator.
Definition at line 49 of file Offer_Iterators_T.cpp.
References ACE_NEW_THROW_EX, TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::db_, ACE_Unbounded_Queue< T >::dequeue_head(), TAO_Property_Filter::filter_offer(), TAO_Offer_Database< LOCK_TYPE >::lookup_offer(), TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::offer_ids_, TAO_Offer_Iterator::pfilter_, and ACE_Unbounded_Queue< T >::size().
00051 { 00052 CORBA::ULong ret_offers = 0; 00053 00054 CORBA::ULong max_possible_offers_in_sequence = 00055 (n < this->offer_ids_.size ()) ? n : 00056 static_cast<CORBA::ULong> (this->offer_ids_.size ()); 00057 00058 ACE_NEW_THROW_EX (offers, 00059 CosTrading::OfferSeq, 00060 CORBA::NO_MEMORY ()); 00061 00062 offers->length (max_possible_offers_in_sequence); 00063 00064 // While there are entries left and we haven't filled <offers> 00065 // with requested number. 00066 while (! this->offer_ids_.is_empty () 00067 && n > ret_offers) 00068 { 00069 // If offer is found, put it into the sequence. 00070 // remove this id irrespective of whether the offer is found 00071 // or not. 00072 CosTrading::OfferId id = 0; 00073 this->offer_ids_.dequeue_head (id); 00074 00075 CosTrading::OfferId_var offerid_var (id); 00076 CosTrading::Offer* offer = this->db_.lookup_offer (id); 00077 00078 if (offer != 0) 00079 this->pfilter_.filter_offer (offer, 00080 offers[ret_offers++]); 00081 } 00082 00083 // Reset the length to the correct value 00084 offers->length (ret_offers); 00085 00086 return static_cast<CORBA::Boolean> (ret_offers != 0); 00087 }
TAO_Offer_Database<MAP_LOCK_TYPE>& TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::db_ [private] |
A reference to the trader is needed for access to the map of offers.
Definition at line 75 of file Offer_Iterators_T.h.
Referenced by TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::next_n().
TAO_String_Queue TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::offer_ids_ [private] |
Offer ids of offers to iterate over.
Definition at line 78 of file Offer_Iterators_T.h.
Referenced by TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::add_offer(), TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::max_left(), TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::next_n(), and TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::~TAO_Register_Offer_Iterator().