#include <Offer_Iterators.h>
Collaboration diagram for TAO_Offer_Id_Iterator:
Public Member Functions | |
TAO_Offer_Id_Iterator (void) | |
No op constructor. | |
~TAO_Offer_Id_Iterator (void) | |
virtual CORBA::ULong | max_left (void) |
virtual void | destroy (void) |
virtual CORBA::Boolean | next_n (CORBA::ULong _n, CosTrading::OfferIdSeq_out _ids) |
void | insert_id (CosTrading::OfferId new_id) |
Insert a <new_id> into the contents of the iterator. | |
Private Member Functions | |
TAO_Offer_Id_Iterator (const TAO_Offer_Id_Iterator &) | |
TAO_Offer_Id_Iterator & | operator= (TAO_Offer_Id_Iterator &) |
Private Attributes | |
TAO_String_Queue | ids_ |
Definition at line 209 of file Offer_Iterators.h.
TAO_Offer_Id_Iterator::TAO_Offer_Id_Iterator | ( | void | ) |
TAO_Offer_Id_Iterator::~TAO_Offer_Id_Iterator | ( | void | ) |
Definition at line 198 of file Offer_Iterators.cpp.
References ACE_Unbounded_Queue< T >::dequeue_head(), ids_, and CORBA::string_free().
00199 { 00200 int return_value = 0; 00201 00202 do 00203 { 00204 CosTrading::OfferId offer_id = 0; 00205 00206 return_value = this->ids_.dequeue_head (offer_id); 00207 if (return_value == 0) 00208 CORBA::string_free (offer_id); 00209 } 00210 while (return_value == 0); 00211 }
TAO_Offer_Id_Iterator::TAO_Offer_Id_Iterator | ( | const TAO_Offer_Id_Iterator & | ) | [private] |
void TAO_Offer_Id_Iterator::destroy | ( | void | ) | [virtual] |
The destroy operation destroys the iterator. No further operations can be invoked on an iterator after it has been destroyed.
Definition at line 220 of file Offer_Iterators.cpp.
00221 { 00222 // Remove self from POA 00223 00224 PortableServer::POA_var poa = 00225 this->_default_POA (); 00226 00227 PortableServer::ObjectId_var id = 00228 poa->servant_to_id (this); 00229 00230 poa->deactivate_object (id.in ()); 00231 }
void TAO_Offer_Id_Iterator::insert_id | ( | CosTrading::OfferId | new_id | ) |
Insert a <new_id> into the contents of the iterator.
Definition at line 284 of file Offer_Iterators.cpp.
References ACE_Unbounded_Queue< T >::enqueue_tail(), and ids_.
Referenced by TAO_Offer_Database< LOCK_TYPE >::retrieve_all_offer_ids().
00285 { 00286 this->ids_.enqueue_tail (new_id); 00287 }
CORBA::ULong TAO_Offer_Id_Iterator::max_left | ( | void | ) | [virtual] |
The max_left operation returns the number of offer identifiers remaining in the iterator. The exception UnknownMaxLeft is raised if the iterator cannot determine the remaining number of offer identifiers (e.g., if the iterator determines its set of offer identifiers through lazy evaluation).
Definition at line 214 of file Offer_Iterators.cpp.
References ids_, and ACE_Unbounded_Queue< T >::size().
CORBA::Boolean TAO_Offer_Id_Iterator::next_n | ( | CORBA::ULong | _n, | |
CosTrading::OfferIdSeq_out | _ids | |||
) | [virtual] |
The next_n operation returns a set of offer identifiers in the output parameter "ids." The operation returns n offer identifiers if there are at least n offer identifiers remaining in the iterator. If there are fewer than n offer identifiers in the iterator, then all remaining offer identifiers are returned. The actual number of offer identifiers returned can be determined from the length of the "ids" sequence. The next_n operation returns TRUE if there are further offer identifiers to be extracted from the iterator. It returns FALSE if there are no further offer identifiers to be extracted.
Definition at line 234 of file Offer_Iterators.cpp.
References ACE_NEW_RETURN, ACE_Unbounded_Queue< T >::dequeue_head(), ids_, and ACE_Unbounded_Queue< T >::size().
Referenced by TAO_Admin< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::list_offers().
00236 { 00237 // Calculate the number of Ids to be returned in this. 00238 CORBA::ULong items_left = static_cast<CORBA::ULong> (this->ids_.size()); 00239 int difference = items_left - n; 00240 CORBA::ULong returnable_items = (difference >= 0) ? n : items_left; 00241 CORBA::Boolean return_value = (CORBA::Boolean) (difference > 0); 00242 00243 if (returnable_items == 0) 00244 ACE_NEW_RETURN (_ids, 00245 CosTrading::OfferIdSeq, 00246 return_value); 00247 else 00248 { 00249 // Allocate space for the returned OfferIds. 00250 CosTrading::OfferId* id_buf = 00251 CosTrading::OfferIdSeq::allocbuf (returnable_items); 00252 00253 if (id_buf != 0) 00254 { 00255 // Copy in those ids! 00256 for (CORBA::ULong i = 0; i < returnable_items; i++) 00257 { 00258 CosTrading::OfferId offer_id = 0; 00259 00260 this->ids_.dequeue_head (offer_id); 00261 id_buf[i] = offer_id; 00262 } 00263 00264 // Place them into an OfferIdSeq. 00265 ACE_NEW_RETURN (_ids, 00266 CosTrading::OfferIdSeq (returnable_items, 00267 returnable_items, 00268 id_buf, 00269 1), 00270 return_value); 00271 } 00272 else 00273 ACE_NEW_RETURN (_ids, 00274 CosTrading::OfferIdSeq, 00275 return_value); 00276 } 00277 00278 // Return true only if there are items left to be returned in 00279 // subsequent calls. 00280 return return_value; 00281 }
TAO_Offer_Id_Iterator& TAO_Offer_Id_Iterator::operator= | ( | TAO_Offer_Id_Iterator & | ) | [private] |
TAO_String_Queue TAO_Offer_Id_Iterator::ids_ [private] |
Definition at line 271 of file Offer_Iterators.h.
Referenced by insert_id(), max_left(), next_n(), and ~TAO_Offer_Id_Iterator().