00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef TAO_OFFER_DATABASE_H
00015 #define TAO_OFFER_DATABASE_H
00016 #include "ace/pre.h"
00017
00018 #include "orbsvcs/Trader/Trader.h"
00019 #include "orbsvcs/Trader/Offer_Iterators.h"
00020 #include "ace/Null_Mutex.h"
00021
00022 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00023
00024 template <class LOCK_TYPE> class TAO_Service_Offer_Iterator;
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 template <class LOCK_TYPE>
00051 class TAO_Offer_Database
00052 {
00053 friend class TAO_Service_Offer_Iterator<LOCK_TYPE>;
00054 public:
00055
00056
00057 typedef TAO_Service_Offer_Iterator<LOCK_TYPE> offer_iterator;
00058
00059
00060 TAO_Offer_Database (void);
00061
00062 ~TAO_Offer_Database (void);
00063
00064
00065
00066 CosTrading::OfferId insert_offer (const char* type,
00067 CosTrading::Offer* offer);
00068
00069 int remove_offer (const CosTrading::OfferId offer_id
00070 ACE_ENV_ARG_DECL)
00071 ACE_THROW_SPEC ((CosTrading::IllegalOfferId,
00072 CosTrading::UnknownOfferId));
00073
00074
00075
00076 CosTrading::Offer* lookup_offer (const CosTrading::OfferId offer_id
00077 ACE_ENV_ARG_DECL)
00078 ACE_THROW_SPEC ((CosTrading::IllegalOfferId,
00079 CosTrading::UnknownOfferId));
00080
00081
00082
00083
00084
00085
00086 CosTrading::Offer* lookup_offer (const CosTrading::OfferId offer_id,
00087 char*& type_name
00088 ACE_ENV_ARG_DECL)
00089 ACE_THROW_SPEC ((CosTrading::IllegalOfferId,
00090 CosTrading::UnknownOfferId));
00091
00092
00093
00094 TAO_Offer_Id_Iterator* retrieve_all_offer_ids (void);
00095
00096 struct Offer_Map_Entry
00097 {
00098 TAO_Offer_Map* offer_map_;
00099 CORBA::ULong counter_;
00100 LOCK_TYPE lock_;
00101 };
00102
00103 typedef ACE_Hash_Map_Manager_Ex
00104 <
00105 CORBA::String_var,
00106 Offer_Map_Entry*,
00107 ACE_Hash<CORBA::String_var>,
00108 ACE_Equal_To<CORBA::String_var>,
00109 ACE_Null_Mutex
00110 >
00111 Offer_Database;
00112
00113 private:
00114
00115
00116
00117
00118
00119
00120
00121
00122 CosTrading::Offer* lookup_offer (const char* type,
00123 CORBA::ULong id);
00124
00125
00126
00127
00128
00129
00130 int remove_offer (const char* type, CORBA::ULong id);
00131
00132
00133
00134 static CosTrading::OfferId generate_offer_id (const char *type_name,
00135 CORBA::ULong id);
00136
00137
00138
00139 static void parse_offer_id (const CosTrading::OfferId offer_id,
00140 char* &service_type,
00141 CORBA::ULong& id
00142 ACE_ENV_ARG_DECL)
00143 ACE_THROW_SPEC ((CosTrading::IllegalOfferId));
00144
00145
00146 ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Offer_Database<LOCK_TYPE> &))
00147 ACE_UNIMPLEMENTED_FUNC (TAO_Offer_Database (const TAO_Offer_Database<LOCK_TYPE> &))
00148
00149 LOCK_TYPE db_lock_;
00150
00151 Offer_Database offer_db_;
00152
00153 };
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 template <class LOCK_TYPE>
00164 class TAO_Service_Offer_Iterator
00165 {
00166 public:
00167
00168 typedef TAO_Offer_Database<LOCK_TYPE> Offer_Database;
00169
00170 TAO_Service_Offer_Iterator (const char* type,
00171 TAO_Offer_Database<LOCK_TYPE>& offer_database);
00172
00173
00174 ~TAO_Service_Offer_Iterator (void);
00175
00176
00177 int has_more_offers (void);
00178
00179
00180 CosTrading::OfferId get_id (void);
00181
00182
00183 CosTrading::Offer* get_offer (void);
00184
00185
00186 void next_offer (void);
00187
00188 private:
00189
00190
00191
00192 TAO_Offer_Database<LOCK_TYPE>& stm_;
00193
00194
00195 LOCK_TYPE* lock_;
00196
00197
00198 TAO_Offer_Map::iterator* offer_iter_;
00199
00200
00201 const char* type_;
00202 };
00203
00204 TAO_END_VERSIONED_NAMESPACE_DECL
00205
00206 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00207 #include "orbsvcs/Trader/Offer_Database.cpp"
00208 #endif
00209
00210 #include "ace/post.h"
00211 #endif