CEC_TypedProxyPushConsumer.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   CEC_TypedProxyPushConsumer.h
00006  *
00007  *  $Id: CEC_TypedProxyPushConsumer.h 77001 2007-02-12 07:54:49Z johnnyw $
00008  *
00009  *  @author Jon Astle (jon@astle45.fsnet.co.uk)
00010  *
00011  *  Based on the untyped version by Carlos O'Ryan (coryan@cs.wustl.edu)
00012  */
00013 //=============================================================================
00014 
00015 
00016 #ifndef TAO_CEC_TYPEDPROXYPUSHCONSUMER_H_
00017 #define TAO_CEC_TYPEDPROXYPUSHCONSUMER_H_
00018 #include /**/ "ace/pre.h"
00019 
00020 #include "orbsvcs/CosTypedEventChannelAdminS.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 #include "orbsvcs/CosEvent/event_serv_export.h"
00028 
00029 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00030 
00031 class TAO_CEC_TypedEvent;
00032 class TAO_CEC_TypedEventChannel;
00033 class TAO_CEC_DynamicImplementationServer;
00034 
00035 //Class TAO_CEC_TypedProxyPushConsumer
00036 class TAO_Event_Serv_Export TAO_CEC_TypedProxyPushConsumer
00037   : public virtual POA_CosTypedEventChannelAdmin::TypedProxyPushConsumer
00038 {
00039 public:
00040   typedef CosTypedEventChannelAdmin::TypedProxyPushConsumer_ptr _ptr_type;
00041   typedef CosTypedEventChannelAdmin::TypedProxyPushConsumer_var _var_type;
00042 
00043   //Constructor
00044   TAO_CEC_TypedProxyPushConsumer (
00045       TAO_CEC_TypedEventChannel* typed_event_channel,
00046       const ACE_Time_Value &timeout
00047     );
00048 
00049   //Destructor
00050   virtual ~TAO_CEC_TypedProxyPushConsumer (void);
00051 
00052   /// Activate in the POA
00053   virtual void activate (
00054       CosTypedEventChannelAdmin::TypedProxyPushConsumer_ptr &activated_proxy);
00055 
00056   /// Deactivate from the POA
00057   virtual void deactivate (void);
00058 
00059   /**
00060    * Invoke the _non_existent() pseudo-operation on the supplier. If
00061    * it is disconnected then it returns true and sets the
00062    * <disconnected> flag.
00063    */
00064   CORBA::Boolean supplier_non_existent (CORBA::Boolean_out disconnected);
00065 
00066   /// The event channel is shutting down
00067   virtual void shutdown (void);
00068 
00069   /// Increment and decrement the reference count.
00070   CORBA::ULong _incr_refcnt (void);
00071   CORBA::ULong _decr_refcnt (void);
00072 
00073   // = The CosEventChannelAdmin::ProxyPushConsumer methods (abstract overloads)...
00074   virtual void connect_push_supplier (
00075                 CosEventComm::PushSupplier_ptr push_supplier);
00076 
00077   virtual void push (const CORBA::Any& event);
00078 
00079   virtual void invoke (const TAO_CEC_TypedEvent& typed_event);
00080 
00081   virtual void disconnect_push_consumer (void);
00082 
00083   // = The CosTypedEventComm::TypedPushConsumer methods (abstract overloads)...
00084   virtual CORBA::Object_ptr get_typed_consumer (
00085     );
00086 
00087   // = The Servant methods
00088   virtual PortableServer::POA_ptr _default_POA (void);
00089   virtual void _add_ref (void);
00090   virtual void _remove_ref (void);
00091 
00092 protected:
00093   // The guard needs access to the following protected methods.
00094   friend class TAO_CEC_TypedProxyPushConsumer_Guard;
00095 
00096   /// The private version (without locking) of is_connected().
00097   CORBA::Boolean is_connected_i (void) const;
00098 
00099   /// Release the supplier
00100   void cleanup_i (void);
00101 
00102   /// Assigns the parameter to both supplier_ and nopolicy_supplier_, and
00103   /// applies policies (when appropriate) to supplier_.
00104   CosEventComm::PushSupplier_ptr apply_policy
00105   (CosEventComm::PushSupplier_ptr pre);
00106 
00107 private:
00108   /// The typed supplier admin, used for activation and memory managment.
00109   TAO_CEC_TypedEventChannel* typed_event_channel_;
00110 
00111   ACE_Time_Value timeout_;
00112 
00113   /// The locking strategy.
00114   ACE_Lock* lock_;
00115 
00116   /// The reference count.
00117   CORBA::ULong refcount_;
00118 
00119   /// The typed supplier -- use apply_policy() instead of assigning directly to
00120   /// typed_supplier_.  This will keep typed_supplier_ and
00121   /// nopolicy_typed_supplier_ in sync.
00122   CosEventComm::PushSupplier_var typed_supplier_;
00123 
00124   /// The typed supplier without any policies applied
00125   CosEventComm::PushSupplier_var nopolicy_typed_supplier_;
00126 
00127   /// The DSI impl
00128   TAO_CEC_DynamicImplementationServer* dsi_impl_;
00129 
00130   /// The DSI Portable Server OID
00131   PortableServer::ObjectId_var oid_;
00132 
00133   /// If the flag is not zero then we are connected, notice that the
00134   /// supplier can be nil.
00135   int connected_;
00136 
00137   /// Store the default POA.
00138   PortableServer::POA_var default_POA_;
00139 };
00140 
00141 // ****************************************************************
00142 
00143 /**
00144  * @class TAO_CEC_TypedProxyPushConsumer_Guard
00145  *
00146  * @brief A Guard for the TypedProxyPushConsumer reference count
00147  *
00148  * This is a helper class used in the implementation of
00149  * TypedProxyPushConumer.  It provides a Guard mechanism to increment
00150  * the reference count on the proxy, eliminating the need to hold
00151  * mutexes during long operations.
00152  */
00153 class TAO_Event_Serv_Export TAO_CEC_TypedProxyPushConsumer_Guard
00154 {
00155 public:
00156   /// Constructor
00157   TAO_CEC_TypedProxyPushConsumer_Guard (
00158       ACE_Lock *lock,
00159       CORBA::ULong &refcount,
00160       TAO_CEC_TypedEventChannel *ec,
00161       TAO_CEC_TypedProxyPushConsumer *proxy
00162     );
00163 
00164   /// Destructor
00165   ~TAO_CEC_TypedProxyPushConsumer_Guard (void);
00166 
00167   /// Returns 1 if the reference count successfully acquired
00168   int locked (void) const;
00169 
00170 private:
00171   /// The lock used to protect the reference count
00172   ACE_Lock *lock_;
00173 
00174   /// The reference count
00175   CORBA::ULong &refcount_;
00176 
00177   /// The event channel used to destroy the proxy
00178   TAO_CEC_TypedEventChannel *typed_event_channel_;
00179 
00180   /// The proxy whose lifetime is controlled by the reference count
00181   TAO_CEC_TypedProxyPushConsumer *proxy_;
00182 
00183   /// This flag is set to 1 if the reference count was successfully
00184   /// acquired.
00185   int locked_;
00186 };
00187 
00188 TAO_END_VERSIONED_NAMESPACE_DECL
00189 
00190 #if defined (__ACE_INLINE__)
00191 #include "orbsvcs/CosEvent/CEC_TypedProxyPushConsumer.inl"
00192 #endif /* __ACE_INLINE__ */
00193 
00194 #include /**/ "ace/post.h"
00195 
00196 #endif /* TAO_CEC_TYPEDPROXYPUSHCONSUMER_H_ */

Generated on Tue Feb 2 17:44:51 2010 for TAO_CosEvent by  doxygen 1.4.7