ESF_Proxy_Admin.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /**
00004  *  @file   ESF_Proxy_Admin.h
00005  *
00006  *  ESF_Proxy_Admin.h,v 1.13 2006/03/15 11:22:17 jwillemsen Exp
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  * void create_proxy (PROXY*&);
00036  * // create a new proxy
00037  *
00038  * void destroy_proxy (PROXY*);
00039  * // destroy a proxy
00040  *
00041  * void create_proxy_collection (TAO_ESF_Proxy_Collection<PROXY>*&);
00042  * // create a proxy collection
00043  *
00044  * void destroy_proxy_collection (TAO_ESF_Proxy_Collection<PROXY>*&);
00045  * // destroy a proxy collection
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  * typename .... _ptr_type;
00053  * // The T_ptr for the IDL interface implemented by the PROXY.
00054  *
00055  * typename .... _var_type;
00056  * // The T_var for the IDL interface implemented by the PROXY.
00057  *
00058  * PROXY::_ptr_type
00059  * PROXY::activate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) throw ();
00060  * // activate the proxy and return the object reference
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                  ACE_ENV_ARG_DECL)
00077       ACE_THROW_SPEC ((CORBA::SystemException));
00078 
00079   // @todo We should use INTERFACE::_ptr_type or PROXY::_ptr_type, but
00080   // the MSVC compiler (v6.0) gets confused when we do so.  So we have
00081   // to choose for the lesser evil.  The code works because TAO uses
00082   // pointers to implement the _ptr types, and that is OK because this
00083   // code is supposed to run under TAO only.
00084   /// Create a new PROXY and activate it.
00085   virtual INTERFACE*
00086       obtain (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00087           ACE_THROW_SPEC ((CORBA::SystemException));
00088 
00089   /**
00090    * The Event Channel that owns this Admin object is going
00091    * down. Invoke <shutdown> on all the proxies, cleanup the
00092    * collection and prepare to terminate.
00093    */
00094   virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL)
00095       ACE_THROW_SPEC ((CORBA::SystemException));
00096 
00097   /**
00098    * A <proxy> has connected, this is invoked when the proxy's client
00099    * has invoked the connect_xxx_yyy() method.
00100    * The default implementation is a no-op.
00101    */
00102   virtual void connected (PROXY *proxy
00103                           ACE_ENV_ARG_DECL)
00104       ACE_THROW_SPEC ((CORBA::SystemException));
00105 
00106   /**
00107    * A <proxy> has reconnected, i.e. its client has invoked the
00108    * connect_xxx_yyy() method, but the proxy was connected already.
00109    * The default implementation delegates on the collection
00110    * <reconnected> method
00111    */
00112   virtual void reconnected (PROXY *proxy
00113                             ACE_ENV_ARG_DECL)
00114       ACE_THROW_SPEC ((CORBA::SystemException));
00115 
00116   /**
00117    * A <proxy> has been disconnected. The default implementation
00118    * removes the object from the collection and deactivates the
00119    * proxy.
00120    */
00121   virtual void disconnected (PROXY *proxy
00122                              ACE_ENV_ARG_DECL)
00123       ACE_THROW_SPEC ((CORBA::SystemException));
00124 
00125 protected:
00126   /// The Event Channel we belong to
00127   EVENT_CHANNEL *event_channel_;
00128 
00129 private:
00130   /// Shorthand for the Proxy collection
00131   typedef TAO_ESF_Proxy_Collection<PROXY> Collection;
00132 
00133   /// The proxy collection object
00134   Collection *collection_;
00135 };
00136 
00137 // ****************************************************************
00138 template <class COUNTED>
00139 class TAO_ESF_RefCountedRef
00140 {
00141 public:
00142   TAO_ESF_RefCountedRef (COUNTED *counted);
00143   ~TAO_ESF_RefCountedRef ();
00144 private:
00145   TAO_ESF_RefCountedRef (TAO_ESF_RefCountedRef<COUNTED> const & );
00146   TAO_ESF_RefCountedRef& operator= (TAO_ESF_RefCountedRef<COUNTED> const & );
00147 
00148   COUNTED *counted_;
00149 };
00150 
00151 // ****************************************************************
00152 
00153 TAO_END_VERSIONED_NAMESPACE_DECL
00154 
00155 #if defined (__ACE_INLINE__)
00156 #include "orbsvcs/ESF/ESF_Proxy_Admin.i"
00157 #endif /* __ACE_INLINE__ */
00158 
00159 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00160 #include "orbsvcs/ESF/ESF_Proxy_Admin.cpp"
00161 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
00162 
00163 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00164 #pragma implementation ("ESF_Proxy_Admin.cpp")
00165 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
00166 
00167 #endif /* TAO_ESF_PROXY_ADMIN_H */

Generated on Thu Nov 9 13:08:13 2006 for TAO_ESF by doxygen 1.3.6