CEC_ProxyPushConsumer.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   CEC_ProxyPushConsumer.h
00006  *
00007  *  CEC_ProxyPushConsumer.h,v 1.25 2006/04/19 15:10:36 jwillemsen Exp
00008  *
00009  *  @author Carlos O'Ryan (coryan@cs.wustl.edu)
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef TAO_CEC_PROXYPUSHCONSUMER_H
00015 #define TAO_CEC_PROXYPUSHCONSUMER_H
00016 
00017 #include /**/ "ace/pre.h"
00018 
00019 #include "orbsvcs/CosEventChannelAdminS.h"
00020 #include "orbsvcs/CosEvent/event_serv_export.h"
00021 
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 # pragma once
00024 #endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 #include "orbsvcs/ESF/ESF_Worker.h"
00027 
00028 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00029 
00030 class TAO_CEC_EventChannel;
00031 class TAO_CEC_Dispatching;
00032 class TAO_CEC_ProxyPushSupplier;
00033 
00034 /**
00035  * @class TAO_CEC_ProxyPushConsumer
00036  *
00037  * @brief ProxyPushConsumer
00038  *
00039  * Implement the CosEventChannelAdmin::ProxyPushConsumer interface,
00040  * remember that this class is used to communicate with a
00041  * PushSupplier, so, in effect, this is the ambassador for a
00042  * supplier inside the event channel.
00043  * = MEMORY MANAGMENT
00044  * The object commits suicide when disconnect_push_consumer() is
00045  * called.
00046  */
00047 class TAO_Event_Serv_Export TAO_CEC_ProxyPushConsumer
00048   : public POA_CosEventChannelAdmin::ProxyPushConsumer
00049 {
00050 public:
00051   typedef CosEventChannelAdmin::ProxyPushConsumer_ptr _ptr_type;
00052   typedef CosEventChannelAdmin::ProxyPushConsumer_var _var_type;
00053 
00054   /// constructor...
00055   TAO_CEC_ProxyPushConsumer (TAO_CEC_EventChannel* event_channel);
00056 
00057   /// destructor...
00058   virtual ~TAO_CEC_ProxyPushConsumer (void);
00059 
00060   /// Activate in the POA
00061   virtual void activate (
00062       CosEventChannelAdmin::ProxyPushConsumer_ptr &activated_proxy
00063       ACE_ENV_ARG_DECL)
00064     ACE_THROW_SPEC ((CORBA::SystemException));
00065 
00066   /// Deactivate from the POA
00067   virtual void deactivate (ACE_ENV_SINGLE_ARG_DECL)
00068     ACE_THROW_SPEC ((CORBA::SystemException));
00069 
00070   /// Return false if no supplier is connected...
00071   CORBA::Boolean is_connected (void) const;
00072 
00073   /// Return the consumer object reference. It returns nil() if it has
00074   /// not connected yet.
00075   CosEventComm::PushSupplier_ptr supplier (void) const;
00076 
00077   /**
00078    * Invoke the _non_existent() pseudo-operation on the supplier. If
00079    * it is disconnected then it returns true and sets the
00080    * <disconnected> flag.
00081    */
00082   CORBA::Boolean supplier_non_existent (CORBA::Boolean_out disconnected
00083                                         ACE_ENV_ARG_DECL);
00084 
00085   /// The event channel is shutting down
00086   virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED);
00087 
00088   /// Increment and decrement the reference count.
00089   CORBA::ULong _incr_refcnt (void);
00090   CORBA::ULong _decr_refcnt (void);
00091 
00092   // = The CosEventChannelAdmin::ProxyPushConsumer methods...
00093   virtual void connect_push_supplier (
00094                 CosEventComm::PushSupplier_ptr push_supplier
00095                 ACE_ENV_ARG_DECL_NOT_USED)
00096       ACE_THROW_SPEC ((CORBA::SystemException,
00097                        CosEventChannelAdmin::AlreadyConnected));
00098   virtual void push (const CORBA::Any& event
00099                      ACE_ENV_ARG_DECL_NOT_USED)
00100       ACE_THROW_SPEC ((CORBA::SystemException));
00101   virtual void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00102       ACE_THROW_SPEC ((CORBA::SystemException));
00103 
00104   // = The Servant methods
00105   virtual PortableServer::POA_ptr _default_POA (ACE_ENV_SINGLE_ARG_DECL);
00106   virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
00107   virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
00108 
00109 protected:
00110   /// Set the supplier, used by some implementations to change the
00111   /// policies used when invoking operations on the supplier.
00112   void supplier (CosEventComm::PushSupplier_ptr supplier);
00113   void supplier_i (CosEventComm::PushSupplier_ptr supplier);
00114 
00115   friend class TAO_CEC_ProxyPushConsumer_Guard;
00116   // The guard needs access to the following protected methods.
00117 
00118   /// The private version (without locking) of is_connected().
00119   CORBA::Boolean is_connected_i (void) const;
00120 
00121   /// Release the supplier
00122   void cleanup_i (void);
00123 
00124 private:
00125   /// The supplier admin, used for activation and memory managment.
00126   TAO_CEC_EventChannel* event_channel_;
00127 
00128   /// The locking strategy.
00129   ACE_Lock* lock_;
00130 
00131   /// The reference count.
00132   CORBA::ULong refcount_;
00133 
00134   /// The supplier....
00135   CosEventComm::PushSupplier_var supplier_;
00136 
00137   /// If the flag is true then we are connected, notice that the
00138   /// supplier can be nil.
00139   bool connected_;
00140 
00141   /// Store the default POA.
00142   PortableServer::POA_var default_POA_;
00143 };
00144 
00145 // ****************************************************************
00146 
00147 /**
00148  * @class TAO_CEC_ProxyPushConsumer_Guard
00149  *
00150  * @brief A Guard for the ProxyPushConsumer reference count
00151  *
00152  * This is a helper class used in the implementation of
00153  * ProxyPushConumer.  It provides a Guard mechanism to increment
00154  * the reference count on the proxy, eliminating the need to hold
00155  * mutexes during long operations.
00156  */
00157 class TAO_Event_Serv_Export TAO_CEC_ProxyPushConsumer_Guard
00158 {
00159 public:
00160   /// Constructor
00161   TAO_CEC_ProxyPushConsumer_Guard (ACE_Lock *lock,
00162                                    CORBA::ULong &refcount,
00163                                    TAO_CEC_EventChannel *ec,
00164                                    TAO_CEC_ProxyPushConsumer *proxy);
00165 
00166   /// Destructor
00167   ~TAO_CEC_ProxyPushConsumer_Guard (void);
00168 
00169   /// Returns true if the reference count successfully acquired
00170   bool locked (void) const;
00171 
00172 private:
00173   /// The lock used to protect the reference count
00174   ACE_Lock *lock_;
00175 
00176   /// The reference count
00177   CORBA::ULong &refcount_;
00178 
00179   /// The event channel used to destroy the proxy
00180   TAO_CEC_EventChannel *event_channel_;
00181 
00182   /// The proxy whose lifetime is controlled by the reference count
00183   TAO_CEC_ProxyPushConsumer *proxy_;
00184 
00185   /// This flag is set to true if the reference count was successfully
00186   /// acquired.
00187   bool locked_;
00188 };
00189 
00190 TAO_END_VERSIONED_NAMESPACE_DECL
00191 
00192 #if defined (__ACE_INLINE__)
00193 #include "orbsvcs/CosEvent/CEC_ProxyPushConsumer.i"
00194 #endif /* __ACE_INLINE__ */
00195 
00196 #include /**/ "ace/post.h"
00197 
00198 #endif /* TAO_CEC_PROXYPUSHCONSUMER_H */

Generated on Thu Nov 9 13:18:17 2006 for TAO_CosEvent by doxygen 1.3.6