CEC_ProxyPullConsumer.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   CEC_ProxyPullConsumer.h
00006  *
00007  *  $Id: CEC_ProxyPullConsumer.h 77001 2007-02-12 07:54:49Z johnnyw $
00008  *
00009  *  @author Carlos O'Ryan (coryan@cs.wustl.edu)
00010  */
00011 //=============================================================================
00012 
00013 #ifndef TAO_CEC_PROXYPULLCONSUMER_H
00014 #define TAO_CEC_PROXYPULLCONSUMER_H
00015 
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "orbsvcs/CosEventChannelAdminS.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "orbsvcs/ESF/ESF_Worker.h"
00025 #include "orbsvcs/CosEvent/event_serv_export.h"
00026 
00027 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00028 
00029 class TAO_CEC_EventChannel;
00030 class TAO_CEC_Dispatching;
00031 class TAO_CEC_ProxyPullSupplier;
00032 
00033 /**
00034  * @class TAO_CEC_ProxyPullConsumer
00035  *
00036  * @brief ProxyPullConsumer
00037  *
00038  * Implement the CosEventChannelAdmin::ProxyPullConsumer interface,
00039  * remember that this class is used to communicate with a
00040  * PullSupplier, so, in effect, this is the ambassador for a
00041  * supplier inside the event channel.
00042  * = MEMORY MANAGMENT
00043  * The object commits suicide when disconnect_pull_consumer() is
00044  * called.
00045  */
00046 class TAO_Event_Serv_Export TAO_CEC_ProxyPullConsumer : public POA_CosEventChannelAdmin::ProxyPullConsumer
00047 {
00048 public:
00049   typedef CosEventChannelAdmin::ProxyPullConsumer_ptr _ptr_type;
00050   typedef CosEventChannelAdmin::ProxyPullConsumer_var _var_type;
00051 
00052   /// constructor...
00053   TAO_CEC_ProxyPullConsumer (TAO_CEC_EventChannel* event_channel,
00054                              const ACE_Time_Value &timeout);
00055 
00056   /// destructor...
00057   virtual ~TAO_CEC_ProxyPullConsumer (void);
00058 
00059   /// Activate in the POA
00060   virtual void  activate (
00061       CosEventChannelAdmin::ProxyPullConsumer_ptr &activated_proxy);
00062 
00063   /// Deactivate from the POA
00064   virtual void deactivate (void);
00065 
00066   /// Return 0 if no supplier is connected...
00067   CORBA::Boolean is_connected (void) const;
00068 
00069   /// Return the consumer object reference. It returns nil() if it has
00070   /// not connected yet.
00071   CosEventComm::PullSupplier_ptr supplier (void) const;
00072 
00073   /// Pulls from the supplier, verifies that it is connected.
00074   CORBA::Any* try_pull_from_supplier (CORBA::Boolean_out has_event);
00075   CORBA::Any* pull_from_supplier (void);
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 
00084   /// The event channel is shutting down
00085   virtual void shutdown (void);
00086 
00087   /// Increment and decrement the reference count.
00088   CORBA::ULong _incr_refcnt (void);
00089   CORBA::ULong _decr_refcnt (void);
00090 
00091   // = The CosEventChannelAdmin::ProxyPullConsumer methods...
00092   virtual void connect_pull_supplier (
00093                 CosEventComm::PullSupplier_ptr pull_supplier);
00094   virtual void disconnect_pull_consumer (void);
00095 
00096   // = The Servant methods
00097   virtual PortableServer::POA_ptr _default_POA (void);
00098   virtual void _add_ref (void);
00099   virtual void _remove_ref (void);
00100 
00101 protected:
00102   /// Set the supplier, used by some implementations to change the
00103   /// policies used when invoking operations on the supplier.
00104   void supplier (CosEventComm::PullSupplier_ptr supplier);
00105   void supplier_i (CosEventComm::PullSupplier_ptr supplier);
00106 
00107   /// The private version (without locking) of is_connected().
00108   CORBA::Boolean is_connected_i (void) const;
00109 
00110   /// Release the supplier
00111   void cleanup_i (void);
00112 
00113   /// Assigns the parameter to both supplier_ and nopolicy_supplier_, and
00114   /// applies policies (when appropriate) to supplier_.
00115   CosEventComm::PullSupplier_ptr apply_policy
00116   (CosEventComm::PullSupplier_ptr s);
00117 
00118 private:
00119   /// The supplier admin, used for activation and memory managment.
00120   TAO_CEC_EventChannel* event_channel_;
00121 
00122   ACE_Time_Value timeout_;
00123 
00124   /// The locking strategy.
00125   ACE_Lock* lock_;
00126 
00127   /// The reference count.
00128   CORBA::ULong refcount_;
00129 
00130   /// The supplier -- use apply_policy() instead of assigning directly to
00131   /// supplier_.  This will keep supplier_ and nopolicy_supplier_ in sync.
00132   CosEventComm::PullSupplier_var supplier_;
00133 
00134   /// The supplier without any policies applied
00135   CosEventComm::PullSupplier_var nopolicy_supplier_;
00136 
00137   /// Store the default POA.
00138   PortableServer::POA_var default_POA_;
00139 };
00140 
00141 TAO_END_VERSIONED_NAMESPACE_DECL
00142 
00143 #if defined (__ACE_INLINE__)
00144 #include "orbsvcs/CosEvent/CEC_ProxyPullConsumer.inl"
00145 #endif /* __ACE_INLINE__ */
00146 
00147 #include /**/ "ace/post.h"
00148 
00149 #endif /* TAO_CEC_PROXYPULLCONSUMER_H */

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