00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Offer_Iterators_T.h 00006 * 00007 * $Id: Offer_Iterators_T.h 77001 2007-02-12 07:54:49Z johnnyw $ 00008 * 00009 * @author Marina Spivak <marina@cs.wustl.edu> 00010 * @author Seth Widoff <sbw1@cs.wustl.edu> 00011 */ 00012 //============================================================================= 00013 00014 00015 #ifndef TAO_REGISTER_OFFER_ITERATOR_H 00016 #define TAO_REGISTER_OFFER_ITERATOR_H 00017 #include /**/ "ace/pre.h" 00018 00019 #include "orbsvcs/Trader/Offer_Iterators.h" 00020 #include "orbsvcs/Trader/Offer_Database.h" 00021 00022 #if defined(_MSC_VER) 00023 #pragma warning(push) 00024 #pragma warning(disable:4250) 00025 #endif /* _MSC_VER */ 00026 00027 00028 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00029 00030 /** 00031 * @class TAO_Register_Offer_Iterator 00032 * 00033 * @brief An implementation of CosTrading::OfferIterator IDL interface 00034 * appropriate when trader has Register functionality. 00035 * 00036 * Stores ids of offers to be iterated over. Before returning 00037 * an offer, checks if the offer is still there (since it may 00038 * have been removed by the Register). 00039 */ 00040 template <class MAP_LOCK_TYPE> 00041 class TAO_Register_Offer_Iterator : public TAO_Offer_Iterator 00042 { 00043 public: 00044 00045 // = Initialization and termination methods. 00046 00047 /// Takes service type and trader reference in order to 00048 /// later locate offers using their ids. 00049 TAO_Register_Offer_Iterator (TAO_Offer_Database<MAP_LOCK_TYPE> &db, 00050 const TAO_Property_Filter& pfilter); 00051 00052 /// Destructor. 00053 virtual ~TAO_Register_Offer_Iterator (void); 00054 00055 /// Deposit at maximum n offers into the return sequence and return 1, 00056 /// or return 0 if the iterator is done and no offers are returned. 00057 virtual CORBA::Boolean next_n (CORBA::ULong n, 00058 CosTrading::OfferSeq_out offers); 00059 00060 /** 00061 * Throws CosTrading::UnknownMaxLeft since with the presence of 00062 * "Register" functionality, the iterator cannot guarantee that 00063 * the trader will have all the offers it has now when the time 00064 * to return them comes. 00065 */ 00066 virtual CORBA::ULong max_left (void); 00067 00068 /// Add an offer the iterator should iterate over. 00069 void add_offer (CosTrading::OfferId id, 00070 const CosTrading::Offer *); 00071 00072 private: 00073 00074 /// A reference to the trader is needed for access to the map of offers. 00075 TAO_Offer_Database<MAP_LOCK_TYPE> &db_; 00076 00077 /// Offer ids of offers to iterate over. 00078 TAO_String_Queue offer_ids_; 00079 }; 00080 00081 TAO_END_VERSIONED_NAMESPACE_DECL 00082 00083 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) 00084 #include "orbsvcs/Trader/Offer_Iterators_T.cpp" 00085 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ 00086 00087 #if defined(_MSC_VER) 00088 #pragma warning(pop) 00089 #endif /* _MSC_VER */ 00090 00091 #include /**/ "ace/post.h" 00092 #endif /* TAO_REGISTER_OFFER_ITERATOR_H */