ESF_Proxy_Admin.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /**
00004  *  @file   ESF_Proxy_Admin.h
00005  *
00006  *  $Id: ESF_Proxy_Admin.h 77031 2007-02-12 15:20:17Z johnnyw $
00007  *
00008  *  @author Carlos O'Ryan (coryan@cs.wustl.edu)
00009  *
00010  *  http://doc.ece.uci.edu/~coryan/EC/index.html
00011  */
00012 
00013 #ifndef TAO_ESF_PROXY_ADMIN_H
00014 #define TAO_ESF_PROXY_ADMIN_H
00015 
00016 #include "orbsvcs/ESF/ESF_Proxy_Collection.h"
00017 #include "orbsvcs/ESF/ESF_Worker.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00024 
00025 /**
00026  * @class TAO_ESF_Proxy_Admin
00027  *
00028  * @brief Implement common tasks in the Admin interfaces.
00029  *
00030  * <H2>Requirements</H2>
00031  *
00032  * The EVENT_CHANNEL interface must implement:
00033  *
00034  * @verbatim
00035  * /// create a new proxy
00036  * void create_proxy (PROXY*&);
00037  *
00038  * /// destroy a proxy
00039  * void destroy_proxy (PROXY*);
00040  *
00041  * /// create a proxy collection
00042  * void create_proxy_collection (TAO_ESF_Proxy_Collection<PROXY>*&);
00043  *
00044  * /// destroy a proxy collection
00045  * void destroy_proxy_collection (TAO_ESF_Proxy_Collection<PROXY>*&);
00046  * @endverbatim
00047  *
00048  * In addition to the requirements imposed by
00049  * TAO_ESF_Proxy_Collection<>, the PROXY interface must define:
00050  *
00051  * @verbatim
00052  * /// The T_ptr for the IDL interface implemented by the PROXY.
00053  * typename .... _ptr_type;
00054  *
00055  * /// The T_var for the IDL interface implemented by the PROXY.
00056  * typename .... _var_type;
00057  *
00058  * /// activate the proxy and return the object reference
00059  * PROXY::_ptr_type
00060  * PROXY::activate (void) throw ();
00061  * @endverbatim
00062  *
00063  */
00064 template<class EVENT_CHANNEL, class PROXY, class INTERFACE>
00065 class TAO_ESF_Proxy_Admin
00066 {
00067 public:
00068   /// Constructor, allocate the internal collection
00069   TAO_ESF_Proxy_Admin (EVENT_CHANNEL *ec);
00070 
00071   /// Cleanup internal resources, destroy the internal collection
00072   virtual ~TAO_ESF_Proxy_Admin (void);
00073 
00074   /// Iterate over its internal collection.
00075   void for_each (TAO_ESF_Worker<PROXY> *worker);
00076 
00077   // @todo We should use INTERFACE::_ptr_type or PROXY::_ptr_type, but
00078   // the MSVC compiler (v6.0) gets confused when we do so.  So we have
00079   // to choose for the lesser evil.  The code works because TAO uses
00080   // pointers to implement the _ptr types, and that is OK because this
00081   // code is supposed to run under TAO only.
00082   /// Create a new PROXY and activate it.
00083   virtual INTERFACE*
00084       obtain (void);
00085 
00086   /**
00087    * The Event Channel that owns this Admin object is going
00088    * down. Invoke <shutdown> on all the proxies, cleanup the
00089    * collection and prepare to terminate.
00090    */
00091   virtual void shutdown (void);
00092 
00093   /**
00094    * A <proxy> has connected, this is invoked when the proxy's client
00095    * has invoked the connect_xxx_yyy() method.
00096    * The default implementation is a no-op.
00097    */
00098   virtual void connected (PROXY *proxy);
00099 
00100   /**
00101    * A <proxy> has reconnected, i.e. its client has invoked the
00102    * connect_xxx_yyy() method, but the proxy was connected already.
00103    * The default implementation delegates on the collection
00104    * <reconnected> method
00105    */
00106   virtual void reconnected (PROXY *proxy);
00107 
00108   /**
00109    * A <proxy> has been disconnected. The default implementation
00110    * removes the object from the collection and deactivates the
00111    * proxy.
00112    */
00113   virtual void disconnected (PROXY *proxy);
00114 
00115 protected:
00116   /// The Event Channel we belong to
00117   EVENT_CHANNEL *event_channel_;
00118 
00119 private:
00120   /// Shorthand for the Proxy collection
00121   typedef TAO_ESF_Proxy_Collection<PROXY> Collection;
00122 
00123   /// The proxy collection object
00124   Collection *collection_;
00125 };
00126 
00127 // ****************************************************************
00128 template <class COUNTED>
00129 class TAO_ESF_RefCountedRef
00130 {
00131 public:
00132   TAO_ESF_RefCountedRef (COUNTED *counted);
00133   ~TAO_ESF_RefCountedRef ();
00134 private:
00135   TAO_ESF_RefCountedRef (TAO_ESF_RefCountedRef<COUNTED> const & );
00136   TAO_ESF_RefCountedRef& operator= (TAO_ESF_RefCountedRef<COUNTED> const & );
00137 
00138   COUNTED *counted_;
00139 };
00140 
00141 // ****************************************************************
00142 
00143 TAO_END_VERSIONED_NAMESPACE_DECL
00144 
00145 #if defined (__ACE_INLINE__)
00146 #include "orbsvcs/ESF/ESF_Proxy_Admin.inl"
00147 #endif /* __ACE_INLINE__ */
00148 
00149 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00150 #include "orbsvcs/ESF/ESF_Proxy_Admin.cpp"
00151 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
00152 
00153 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00154 #pragma implementation ("ESF_Proxy_Admin.cpp")
00155 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
00156 
00157 #endif /* TAO_ESF_PROXY_ADMIN_H */

Generated on Sun Jan 27 13:38:38 2008 for TAO_ESF by doxygen 1.3.6