Trader_T.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  * @file Trader_T.h
00006  *
00007  * $Id: Trader_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  * @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 (void);
00119 
00120   /// Returns object reference for the Register interface of the trader.
00121   /// Returns nil if the trader does not support Register interface.
00122   virtual CosTrading::Register_ptr register_if (void);
00123 
00124   /// Returns object reference for the Link interface of the trader.
00125   /// Returns nil if the trader does not support Link interface.
00126   virtual CosTrading::Link_ptr link_if (void);
00127 
00128   /// Returns object reference to the Proxy interface of the trader.
00129   /// Returns nil if the trader does not support Proxy interface.
00130   virtual CosTrading::Proxy_ptr proxy_if (void);
00131 
00132   /// Returns object reference for the Admin interface of the trader.
00133   /// Returns nil if the trader does not support Admin interface.
00134   virtual CosTrading::Admin_ptr admin_if (void);
00135 
00136 private:
00137 
00138   const TAO_Trading_Components_i& comps_;
00139 };
00140 
00141 template <class IF>
00142 class TAO_Support_Attributes : public virtual IF
00143 {
00144 public:
00145 
00146   TAO_Support_Attributes (const TAO_Support_Attributes_i& attrs);
00147 
00148   // = CosTrading::SupportAttributes methods.
00149 
00150   virtual CORBA::Boolean supports_modifiable_properties (void);
00151 
00152   virtual CORBA::Boolean supports_dynamic_properties (void);
00153 
00154   virtual CORBA::Boolean supports_proxy_offers (void);
00155 
00156   virtual CosTrading::TypeRepository_ptr type_repos (void);
00157 
00158 private:
00159 
00160   const TAO_Support_Attributes_i& attrs_;
00161 };
00162 
00163 template <class IF>
00164 class TAO_Import_Attributes : public virtual IF
00165 {
00166 public:
00167 
00168   TAO_Import_Attributes (const TAO_Import_Attributes_i& attrs);
00169 
00170   // = CosTrading::ImportAttributes methods.
00171 
00172   virtual CORBA::ULong def_search_card (void);
00173 
00174   virtual CORBA::ULong max_search_card (void);
00175 
00176   // Search cardinality determines the maximum number of offers searched
00177   // before not considering other offers.
00178 
00179   virtual CORBA::ULong def_match_card (void);
00180 
00181   virtual CORBA::ULong max_match_card (void);
00182 
00183   // Match cardinality determines the maximum number of offers
00184   // matched to the constraints before not considering other offers..
00185 
00186   virtual CORBA::ULong def_return_card (void);
00187 
00188   virtual CORBA::ULong max_return_card (void);
00189 
00190   // Return cardinality determines the maximum number of offers marked
00191   // to return before not considering other offers.
00192 
00193 
00194   virtual CORBA::ULong max_list (void);
00195 
00196   virtual CORBA::ULong def_hop_count (void);
00197 
00198   virtual CORBA::ULong max_hop_count (void);
00199 
00200   virtual CosTrading::FollowOption def_follow_policy (void);
00201 
00202   virtual CosTrading::FollowOption max_follow_policy (void);
00203 
00204 
00205 private:
00206 
00207   const TAO_Import_Attributes_i& attrs_;
00208 };
00209 
00210 template <class IF>
00211 class TAO_Link_Attributes : public virtual IF
00212 {
00213 public:
00214 
00215   TAO_Link_Attributes (const TAO_Link_Attributes_i& attrs);
00216 
00217   // = CosTrading::LinkAttributes methods
00218   virtual CosTrading::FollowOption max_link_follow_policy (void);
00219 
00220 private:
00221 
00222   const TAO_Link_Attributes_i& attrs_;
00223 };
00224 
00225   // *************************************************************
00226   // TAO_Sequence_Extracter
00227   // *************************************************************
00228 
00229 /**
00230  * @class TAO_Element_Equal
00231  *
00232  * @brief Function object for determining if the sequence element at the
00233  * current position of the dynamic sequence any parameter is equal to
00234  * the element parameter.
00235  */
00236 template <class ELEMENT_TYPE>
00237 class TAO_Element_Equal
00238 {
00239 public:
00240   /// Calls the correct method on dyn_seq to extract the element type, then
00241   /// uses the appropriate form of equals comparison.
00242   int operator () (TAO_DynSequence_i& dyn_any,
00243                    const ELEMENT_TYPE& element);
00244 };
00245 
00246 TAO_END_VERSIONED_NAMESPACE_DECL
00247 
00248 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00249 #include "orbsvcs/Trader/Trader_T.cpp"
00250 #endif  /* ACE_TEMPLATES_REQUIRE_SOURCE */
00251 
00252 #if defined(_MSC_VER)
00253 #pragma warning(pop)
00254 #endif /* _MSC_VER */
00255 
00256 #include /**/ "ace/post.h"
00257 #endif /* ACE_TRADER_H */

Generated on Tue Feb 2 17:49:26 2010 for TAO_CosTrader by  doxygen 1.4.7