#include <Offer_Iterators.h>
Collaboration diagram for TAO_Offer_Iterator_Collection:
Public Member Functions | |
TAO_Offer_Iterator_Collection (void) | |
virtual | ~TAO_Offer_Iterator_Collection (void) |
virtual CORBA::Boolean | next_n (CORBA::ULong n, CosTrading::OfferSeq_out offers) |
Retrieve n offers from the set of iterators. | |
virtual void | destroy (void) |
Destroy the collection of iterators. | |
virtual CORBA::ULong | max_left (void) |
Determine how many offers are left in the collection. | |
void | add_offer_iterator (CosTrading::OfferIterator_ptr offer_iter) |
Add an iterator to the collection. | |
Private Types | |
typedef ACE_Unbounded_Queue< CosTrading::OfferIterator * > | Offer_Iters |
Private Member Functions | |
TAO_Offer_Iterator_Collection (const TAO_Offer_Iterator_Collection &) | |
TAO_Offer_Iterator_Collection & | operator= (const TAO_Offer_Iterator_Collection &) |
Private Attributes | |
Offer_Iters | iters_ |
The iterator collection. |
Definition at line 156 of file Offer_Iterators.h.
typedef ACE_Unbounded_Queue<CosTrading::OfferIterator*> TAO_Offer_Iterator_Collection::Offer_Iters [private] |
Definition at line 199 of file Offer_Iterators.h.
TAO_Offer_Iterator_Collection::TAO_Offer_Iterator_Collection | ( | void | ) |
TAO_Offer_Iterator_Collection::~TAO_Offer_Iterator_Collection | ( | void | ) | [virtual] |
Definition at line 82 of file Offer_Iterators.cpp.
References ACE_Unbounded_Queue< T >::dequeue_head(), iters_, and CORBA::release().
00083 { 00084 while (! this->iters_.is_empty ()) 00085 { 00086 CosTrading::OfferIterator* offer_iter = 0; 00087 this->iters_.dequeue_head (offer_iter); 00088 00089 try 00090 { 00091 offer_iter->destroy (); 00092 00093 CORBA::release (offer_iter); 00094 } 00095 catch (const CORBA::Exception&) 00096 { 00097 // Don't let the exceptions propagate since we're in a 00098 // destructor! 00099 } 00100 } 00101 }
TAO_Offer_Iterator_Collection::TAO_Offer_Iterator_Collection | ( | const TAO_Offer_Iterator_Collection & | ) | [private] |
void TAO_Offer_Iterator_Collection::add_offer_iterator | ( | CosTrading::OfferIterator_ptr | offer_iter | ) |
Add an iterator to the collection.
Definition at line 105 of file Offer_Iterators.cpp.
References ACE_Unbounded_Queue< T >::enqueue_tail(), CORBA::is_nil(), and iters_.
Referenced by TAO_Lookup< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::federated_query().
00106 { 00107 if (! CORBA::is_nil (offer_iter)) 00108 this->iters_.enqueue_tail (offer_iter); 00109 }
void TAO_Offer_Iterator_Collection::destroy | ( | void | ) | [virtual] |
Destroy the collection of iterators.
Definition at line 164 of file Offer_Iterators.cpp.
00165 { 00166 // Destroy all iterators in the collection. 00167 for (Offer_Iters::ITERATOR iters_iter (this->iters_); 00168 ! iters_iter.done (); 00169 iters_iter.advance ()) 00170 { 00171 CosTrading::OfferIterator** iter = 0; 00172 00173 iters_iter.next (iter); 00174 (*iter)->destroy (); 00175 } 00176 00177 // Remove self from POA 00178 00179 PortableServer::POA_var poa = 00180 this->_default_POA (); 00181 00182 PortableServer::ObjectId_var id = 00183 poa->servant_to_id (this); 00184 00185 poa->deactivate_object (id.in ()); 00186 }
CORBA::ULong TAO_Offer_Iterator_Collection::max_left | ( | void | ) | [virtual] |
Determine how many offers are left in the collection.
Definition at line 189 of file Offer_Iterators.cpp.
00190 { 00191 throw CosTrading::UnknownMaxLeft(); 00192 }
CORBA::Boolean TAO_Offer_Iterator_Collection::next_n | ( | CORBA::ULong | n, | |
CosTrading::OfferSeq_out | offers | |||
) | [virtual] |
Retrieve n offers from the set of iterators.
Definition at line 112 of file Offer_Iterators.cpp.
References ACE_NEW_THROW_EX, ACE_Unbounded_Queue< T >::dequeue_head(), CosTrading::OfferIterator::destroy(), ACE_Unbounded_Queue< T >::enqueue_head(), iters_, CosTrading::OfferIterator::next_n(), and CORBA::release().
00114 { 00115 CORBA::ULong offers_left = n; 00116 CORBA::Boolean return_value = 1; 00117 CosTrading::OfferSeq_var out_offers; 00118 00119 ACE_NEW_THROW_EX (offers, 00120 CosTrading::OfferSeq, 00121 CORBA::NO_MEMORY ()); 00122 00123 while (offers_left > 0 && ! this->iters_.is_empty ()) 00124 { 00125 CORBA::ULong offset = 0; 00126 CORBA::Boolean any_left = 0; 00127 CosTrading::OfferIterator* iter = 0; 00128 this->iters_.dequeue_head (iter); 00129 00130 // Determine how many offers we should retrieve from this 00131 // iterator. 00132 00133 // Retrieve the set of offers. 00134 any_left = 00135 iter->next_n (offers_left, 00136 CosTrading::OfferSeq_out (out_offers.out ())); 00137 00138 // If we've exhausted this iterator, destroy it. 00139 if (any_left == 0) 00140 { 00141 iter->destroy (); 00142 CORBA::release (iter); 00143 } 00144 else 00145 this->iters_.enqueue_head (iter); 00146 00147 // Merge it with the passed set. 00148 offset = offers->length (); 00149 offers->length (out_offers->length () + offset); 00150 for (CORBA::ULong j = out_offers->length (); j > 0; j--) 00151 offers[j + offset - 1] = out_offers[j - 1]; 00152 00153 offers_left -= out_offers->length (); 00154 } 00155 00156 // Determine if we have anything left to offer. 00157 if (this->iters_.is_empty ()) 00158 return_value = 0; 00159 00160 return return_value; 00161 }
TAO_Offer_Iterator_Collection& TAO_Offer_Iterator_Collection::operator= | ( | const TAO_Offer_Iterator_Collection & | ) | [private] |
The iterator collection.
Definition at line 202 of file Offer_Iterators.h.
Referenced by add_offer_iterator(), next_n(), and ~TAO_Offer_Iterator_Collection().