00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Trader_T.h 00006 * 00007 * Trader_T.h,v 1.40 2006/03/14 06:14:35 jtc Exp 00008 * 00009 * @author Marina Spivak <marina@cs.wustl.edu> 00010 * @author Seth Widoff <sbw1@cs.wustl.edu> 00011 * @author Irfan Pyarali <irfan@cs.wustl.edu> 00012 */ 00013 //============================================================================= 00014 00015 00016 #ifndef TAO_TRADER_H 00017 #define TAO_TRADER_H 00018 #include /**/ "ace/pre.h" 00019 00020 #include "orbsvcs/Trader/Trader.h" 00021 #include "orbsvcs/Trader/Offer_Database.h" 00022 #include "ace/Containers.h" 00023 #include "ace/Lock_Adapter_T.h" 00024 00025 // ************************************************************* 00026 // TAO_Trader 00027 // ************************************************************* 00028 00029 #if defined(_MSC_VER) 00030 #pragma warning(push) 00031 #pragma warning (disable:4250) 00032 #endif /* _MSC_VER */ 00033 00034 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00035 00036 class TAO_DynSequence_i; 00037 00038 /** 00039 * @class TAO_Trader 00040 * 00041 * @brief This class packages together all the various pieces that 00042 * provide functionality specified in COS Trading specification. 00043 * 00044 * TAO_Trader contains all the components that together represent 00045 * a single trader. Based on its constructor arguments, 00046 * TAO_Trader creates instances of appropriate interface 00047 * implementations as well as instances of objects common to 00048 * more than one interface (offers, attributes, etc.). 00049 * TAO_Trader also enforces the proper order on all 00050 * initializations. TAO_Trader acts like a "glue" class that 00051 * creates appropriate components, holds everything together, 00052 * and enforces order. TAO_Trader is parameterized by two types 00053 * of locks: one for its service service offers, one for its 00054 * state (configuration). 00055 */ 00056 template <class TRADER_LOCK_TYPE, class MAP_LOCK_TYPE> 00057 class TAO_Trader : public TAO_Trader_Base 00058 { 00059 public: 00060 00061 // The desired combination of interfaces to be passed to the 00062 // TAO_Trader constructor. 00063 00064 /// Offer Database Trait. 00065 typedef TAO_Offer_Database<MAP_LOCK_TYPE> Offer_Database; 00066 00067 /** 00068 * Constructor which based on its arguments will create 00069 * a particular type of trader (e.g. Query trader, Simple trader, etc.) 00070 * The argument is a bitwise OR of desired Trader_Components as listed 00071 * in enumerated type above. 00072 */ 00073 TAO_Trader (Trader_Components components = LOOKUP); 00074 00075 /// Destructor. 00076 virtual ~TAO_Trader (void); 00077 00078 /// Accessor for the structure with all the service offers. 00079 Offer_Database& offer_database (void); 00080 00081 /// Returns the trader 00082 ACE_Lock &lock (void); 00083 00084 protected: 00085 00086 typedef TAO_Trader<TRADER_LOCK_TYPE, MAP_LOCK_TYPE> TRADER_SELF; 00087 00088 Offer_Database offer_database_; 00089 00090 /// Lock that guards the state of the trader (its configuration). 00091 ACE_Lock_Adapter<TRADER_LOCK_TYPE> lock_; 00092 00093 enum { LOOKUP_IF, REGISTER_IF, ADMIN_IF, PROXY_IF, LINK_IF }; 00094 00095 PortableServer::ServantBase* ifs_[5]; 00096 00097 private: 00098 00099 // = Disallow these operations. 00100 ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Trader<TRADER_LOCK_TYPE, MAP_LOCK_TYPE> &)) 00101 }; 00102 00103 // ************************************************************* 00104 // Template Attribute Classes 00105 // ************************************************************* 00106 00107 template <class IF> 00108 class TAO_Trader_Components : 00109 public virtual IF 00110 { 00111 public: 00112 00113 TAO_Trader_Components (const TAO_Trading_Components_i& comps); 00114 00115 // = CosTrading::TraderComponents methods. 00116 /// Returns an object reference to the Lookup interface of the trader. 00117 /// Returns nil if the trader does not support Lookup interface. 00118 virtual CosTrading::Lookup_ptr lookup_if (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00119 ACE_THROW_SPEC ((CORBA::SystemException)); 00120 00121 /// Returns object reference for the Register interface of the trader. 00122 /// Returns nil if the trader does not support Register interface. 00123 virtual CosTrading::Register_ptr register_if (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00124 ACE_THROW_SPEC ((CORBA::SystemException)); 00125 00126 /// Returns object reference for the Link interface of the trader. 00127 /// Returns nil if the trader does not support Link interface. 00128 virtual CosTrading::Link_ptr link_if (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00129 ACE_THROW_SPEC ((CORBA::SystemException)); 00130 00131 /// Returns object reference to the Proxy interface of the trader. 00132 /// Returns nil if the trader does not support Proxy interface. 00133 virtual CosTrading::Proxy_ptr proxy_if (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00134 ACE_THROW_SPEC ((CORBA::SystemException)); 00135 00136 /// Returns object reference for the Admin interface of the trader. 00137 /// Returns nil if the trader does not support Admin interface. 00138 virtual CosTrading::Admin_ptr admin_if (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00139 ACE_THROW_SPEC ((CORBA::SystemException)); 00140 00141 private: 00142 00143 const TAO_Trading_Components_i& comps_; 00144 }; 00145 00146 template <class IF> 00147 class TAO_Support_Attributes : public virtual IF 00148 { 00149 public: 00150 00151 TAO_Support_Attributes (const TAO_Support_Attributes_i& attrs); 00152 00153 // = CosTrading::SupportAttributes methods. 00154 00155 virtual CORBA::Boolean supports_modifiable_properties (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00156 ACE_THROW_SPEC ((CORBA::SystemException)); 00157 00158 virtual CORBA::Boolean supports_dynamic_properties (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00159 ACE_THROW_SPEC ((CORBA::SystemException)); 00160 00161 virtual CORBA::Boolean supports_proxy_offers (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00162 ACE_THROW_SPEC ((CORBA::SystemException)); 00163 00164 virtual CosTrading::TypeRepository_ptr type_repos (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00165 ACE_THROW_SPEC ((CORBA::SystemException)); 00166 00167 private: 00168 00169 const TAO_Support_Attributes_i& attrs_; 00170 }; 00171 00172 template <class IF> 00173 class TAO_Import_Attributes : public virtual IF 00174 { 00175 public: 00176 00177 TAO_Import_Attributes (const TAO_Import_Attributes_i& attrs); 00178 00179 // = CosTrading::ImportAttributes methods. 00180 00181 virtual CORBA::ULong def_search_card (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00182 ACE_THROW_SPEC ((CORBA::SystemException)); 00183 00184 virtual CORBA::ULong max_search_card (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00185 ACE_THROW_SPEC ((CORBA::SystemException)); 00186 00187 // Search cardinality determines the maximum number of offers searched 00188 // before not considering other offers. 00189 00190 virtual CORBA::ULong def_match_card (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00191 ACE_THROW_SPEC ((CORBA::SystemException)); 00192 00193 virtual CORBA::ULong max_match_card (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00194 ACE_THROW_SPEC ((CORBA::SystemException)); 00195 00196 // Match cardinality determines the maximum number of offers 00197 // matched to the constraints before not considering other offers.. 00198 00199 virtual CORBA::ULong def_return_card (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00200 ACE_THROW_SPEC ((CORBA::SystemException)); 00201 00202 virtual CORBA::ULong max_return_card (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00203 ACE_THROW_SPEC ((CORBA::SystemException)); 00204 00205 // Return cardinality determines the maximum number of offers marked 00206 // to return before not considering other offers. 00207 00208 00209 virtual CORBA::ULong max_list (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00210 ACE_THROW_SPEC ((CORBA::SystemException)); 00211 00212 virtual CORBA::ULong def_hop_count (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00213 ACE_THROW_SPEC ((CORBA::SystemException)); 00214 00215 virtual CORBA::ULong max_hop_count (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00216 ACE_THROW_SPEC ((CORBA::SystemException)); 00217 00218 virtual CosTrading::FollowOption def_follow_policy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00219 ACE_THROW_SPEC ((CORBA::SystemException)); 00220 00221 virtual CosTrading::FollowOption max_follow_policy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00222 ACE_THROW_SPEC ((CORBA::SystemException)); 00223 00224 00225 private: 00226 00227 const TAO_Import_Attributes_i& attrs_; 00228 }; 00229 00230 template <class IF> 00231 class TAO_Link_Attributes : public virtual IF 00232 { 00233 public: 00234 00235 TAO_Link_Attributes (const TAO_Link_Attributes_i& attrs); 00236 00237 // = CosTrading::LinkAttributes methods 00238 virtual CosTrading::FollowOption max_link_follow_policy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00239 ACE_THROW_SPEC ((CORBA::SystemException)); 00240 00241 private: 00242 00243 const TAO_Link_Attributes_i& attrs_; 00244 }; 00245 00246 // ************************************************************* 00247 // TAO_Sequence_Extracter 00248 // ************************************************************* 00249 00250 /** 00251 * @class TAO_Element_Equal 00252 * 00253 * @brief Function object for determining if the sequence element at the 00254 * current position of the dynamic sequence any parameter is equal to 00255 * the element parameter. 00256 */ 00257 template <class ELEMENT_TYPE> 00258 class TAO_Element_Equal 00259 { 00260 public: 00261 /// Calls the correct method on dyn_seq to extract the element type, then 00262 /// uses the appropriate form of equals comparison. 00263 int operator () (TAO_DynSequence_i& dyn_any, 00264 const ELEMENT_TYPE& element); 00265 }; 00266 00267 TAO_END_VERSIONED_NAMESPACE_DECL 00268 00269 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) 00270 #include "orbsvcs/Trader/Trader_T.cpp" 00271 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ 00272 00273 #if defined(_MSC_VER) 00274 #pragma warning(pop) 00275 #endif /* _MSC_VER */ 00276 00277 #include /**/ "ace/post.h" 00278 #endif /* ACE_TRADER_H */