#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) throw (CORBA::SystemException) |
virtual CORBA::ULong | max_left () throw (CORBA::SystemException, CosTrading::UnknownMaxLeft) |
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.
|
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 } |
|
Destructor.
Definition at line 21 of file Offer_Iterators_T.cpp. References ACE_Unbounded_Queue< T >::dequeue_head(), ACE_Unbounded_Queue< T >::is_empty(), TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::offer_ids_, CosTrading::OfferId, 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 } |
|
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(), TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::offer_ids_, and CosTrading::OfferId.
00036 { 00037 this->offer_ids_.enqueue_tail (id); 00038 } |
|
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.
00045 { 00046 return static_cast<CORBA::ULong> (this->offer_ids_.size ()); 00047 } |
|
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 51 of file Offer_Iterators_T.cpp. References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_NEW_THROW_EX, CosTrading::OfferId, and CosTrading::OfferSeq.
00055 { 00056 CORBA::ULong ret_offers = 0; 00057 00058 CORBA::ULong max_possible_offers_in_sequence = 00059 (n < this->offer_ids_.size ()) ? n : 00060 static_cast<CORBA::ULong> (this->offer_ids_.size ()); 00061 00062 ACE_NEW_THROW_EX (offers, 00063 CosTrading::OfferSeq, 00064 CORBA::NO_MEMORY ()); 00065 ACE_CHECK_RETURN (0); 00066 00067 offers->length (max_possible_offers_in_sequence); 00068 00069 // While there are entries left and we haven't filled <offers> 00070 // with requested number. 00071 while (! this->offer_ids_.is_empty () 00072 && n > ret_offers) 00073 { 00074 // If offer is found, put it into the sequence. 00075 // remove this id irrespective of whether the offer is found 00076 // or not. 00077 CosTrading::OfferId id = 0; 00078 this->offer_ids_.dequeue_head (id); 00079 00080 CosTrading::OfferId_var offerid_var (id); 00081 CosTrading::Offer* offer = this->db_.lookup_offer (id ACE_ENV_ARG_PARAMETER); 00082 ACE_CHECK_RETURN (0); 00083 00084 if (offer != 0) 00085 this->pfilter_.filter_offer (offer, 00086 offers[ret_offers++]); 00087 } 00088 00089 // Reset the length to the correct value 00090 offers->length (ret_offers); 00091 00092 return static_cast<CORBA::Boolean> (ret_offers != 0); 00093 } |
|
A reference to the trader is needed for access to the map of offers.
Definition at line 79 of file Offer_Iterators_T.h. |
|
Offer ids of offers to iterate over.
Definition at line 82 of file Offer_Iterators_T.h. Referenced by TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::add_offer(), and TAO_Register_Offer_Iterator< MAP_LOCK_TYPE >::~TAO_Register_Offer_Iterator(). |