CEC_ProxyPullSupplier.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   CEC_ProxyPullSupplier.h
00006  *
00007  *  CEC_ProxyPullSupplier.h,v 1.24 2006/03/15 07:52:21 jtc Exp
00008  *
00009  *  @author Carlos O'Ryan (coryan@cs.wustl.edu)
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef TAO_CEC_PROXYPULLSUPPLIER_H
00015 #define TAO_CEC_PROXYPULLSUPPLIER_H
00016 
00017 #include /**/ "ace/pre.h"
00018 
00019 #include "orbsvcs/CosEventChannelAdminS.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 #include "ace/Message_Queue.h"
00026 #include "ace/Condition_Thread_Mutex.h"
00027 #include "ace/Unbounded_Queue.h"
00028 
00029 #include "orbsvcs/CosEvent/event_serv_export.h"
00030 
00031 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00032 
00033 class TAO_CEC_EventChannel;
00034 class TAO_CEC_ProxyPullConsumer;
00035 
00036 /**
00037  * @class TAO_CEC_ProxyPullSupplier
00038  *
00039  * @brief ProxyPullSupplier
00040  *
00041  * Implement the CosEventChannelAdmin::ProxyPullSupplier interface,
00042  * remember that this class is used to communicate with a
00043  * PullConsumer, so, in effect, this is the ambassador for a
00044  * consumer inside the event channel.
00045  * = MEMORY MANAGMENT
00046  * It does not assume ownership of the TAO_CEC_Dispatching object.
00047  * It makes a copy of the ConsumerQOS and the consumer object
00048  * reference.
00049  * = LOCKING
00050  * Locking is strategized, the event channel acts as a factory for
00051  * the locking strategies.
00052  */
00053 class TAO_Event_Serv_Export TAO_CEC_ProxyPullSupplier : public POA_CosEventChannelAdmin::ProxyPullSupplier
00054 {
00055 public:
00056   typedef CosEventChannelAdmin::ProxyPullSupplier_ptr _ptr_type;
00057   typedef CosEventChannelAdmin::ProxyPullSupplier_var _var_type;
00058 
00059   /// constructor...
00060   TAO_CEC_ProxyPullSupplier (TAO_CEC_EventChannel* event_channel);
00061 
00062   /// destructor...
00063   virtual ~TAO_CEC_ProxyPullSupplier (void);
00064 
00065   /// Activate in the POA
00066   virtual void activate (
00067       CosEventChannelAdmin::ProxyPullSupplier_ptr &activated_proxy
00068       ACE_ENV_ARG_DECL)
00069     ACE_THROW_SPEC ((CORBA::SystemException));
00070 
00071   /// Deactivate from the POA
00072   virtual void deactivate (ACE_ENV_SINGLE_ARG_DECL)
00073     ACE_THROW_SPEC ((CORBA::SystemException));
00074 
00075   /// Return 0 if no consumer is connected...
00076   CORBA::Boolean is_connected (void) const;
00077 
00078   /**
00079    * Return the consumer object reference. It returns nil() if it has
00080    * not connected yet.
00081    * NOTE: This method does not return a new reference!!! Doing so
00082    * will increase the locking overhead on the critical path.
00083    */
00084   CosEventComm::PullConsumer_ptr consumer (void) const;
00085 
00086   /// The event channel is shutting down
00087   virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL);
00088 
00089   /**
00090    * Invoke the _non_existent() pseudo-operation on the consumer. If
00091    * it is disconnected then it returns true and sets the
00092    * <disconnected> flag.
00093    */
00094   CORBA::Boolean consumer_non_existent (CORBA::Boolean_out disconnected
00095                                         ACE_ENV_ARG_DECL);
00096 
00097   /// Push an event into the queue.
00098   void push (const CORBA::Any &event
00099              ACE_ENV_ARG_DECL);
00100 
00101   // = The CosEventChannelAdmin::ProxyPullSupplier methods...
00102   virtual void connect_pull_consumer (
00103                 CosEventComm::PullConsumer_ptr pull_consumer
00104                 ACE_ENV_ARG_DECL_NOT_USED)
00105       ACE_THROW_SPEC ((CORBA::SystemException,
00106                        CosEventChannelAdmin::AlreadyConnected));
00107   virtual CORBA::Any * pull (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00108       ACE_THROW_SPEC ((CORBA::SystemException,CosEventComm::Disconnected));
00109   virtual CORBA::Any * try_pull (CORBA::Boolean_out has_event
00110                                  ACE_ENV_ARG_DECL_NOT_USED)
00111       ACE_THROW_SPEC ((CORBA::SystemException,CosEventComm::Disconnected));
00112   virtual void disconnect_pull_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00113       ACE_THROW_SPEC ((CORBA::SystemException));
00114 
00115   /// Increment and decrement the reference count.
00116   CORBA::ULong _incr_refcnt (void);
00117   CORBA::ULong _decr_refcnt (void);
00118 
00119   // = The Servant methods
00120   virtual PortableServer::POA_ptr _default_POA (ACE_ENV_SINGLE_ARG_DECL);
00121   virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL);
00122   virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL);
00123 
00124 protected:
00125   /// Set the consumer, used by some implementations to change the
00126   /// policies used when invoking operations on the consumer.
00127   void consumer (CosEventComm::PullConsumer_ptr consumer);
00128   void consumer_i (CosEventComm::PullConsumer_ptr consumer);
00129 
00130   /// The private version (without locking) of is_connected().
00131   CORBA::Boolean is_connected_i (void) const;
00132 
00133   /// Release the child and the consumer
00134   void cleanup_i (void);
00135 
00136 private:
00137   /// The Event Channel that owns this object.
00138   TAO_CEC_EventChannel* event_channel_;
00139 
00140   /// The locking strategy.
00141   ACE_Lock* lock_;
00142 
00143   /// The reference count.
00144   CORBA::ULong refcount_;
00145 
00146   /// The consumer....
00147   CosEventComm::PullConsumer_var consumer_;
00148 
00149   /// If the flag is not zero then we are connected, notice that the
00150   /// consumer can be nil.
00151   int connected_;
00152 
00153   /// Store the default POA.
00154   PortableServer::POA_var default_POA_;
00155 
00156   /// Use a message queue to pass the
00157   TAO_SYNCH_MUTEX queue_lock_;
00158   TAO_SYNCH_CONDITION wait_not_empty_;
00159   ACE_Unbounded_Queue<CORBA::Any> queue_;
00160 };
00161 
00162 TAO_END_VERSIONED_NAMESPACE_DECL
00163 
00164 #if defined (__ACE_INLINE__)
00165 #include "orbsvcs/CosEvent/CEC_ProxyPullSupplier.i"
00166 #endif /* __ACE_INLINE__ */
00167 
00168 #include /**/ "ace/post.h"
00169 
00170 #endif  /* TAO_CEC_PROXYPULLSUPPLIER_H */

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