CEC_ProxyPushSupplier.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   CEC_ProxyPushSupplier.h
00006  *
00007  *  $Id: CEC_ProxyPushSupplier.h 77001 2007-02-12 07:54:49Z johnnyw $
00008  *
00009  *  @author Carlos O'Ryan (coryan@cs.wustl.edu)
00010  *  @author Jon Astle (jon@astle45.fsnet.co.uk)
00011  */
00012 //=============================================================================
00013 
00014 
00015 #ifndef TAO_CEC_PROXYPUSHSUPPLIER_H
00016 #define TAO_CEC_PROXYPUSHSUPPLIER_H
00017 
00018 #include /**/ "ace/pre.h"
00019 
00020 #include "orbsvcs/CosEventChannelAdminS.h"
00021 
00022 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00023 #include "orbsvcs/CosTypedEventChannelAdminS.h"
00024 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00025 
00026 #include "orbsvcs/CosEvent/event_serv_export.h"
00027 
00028 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00029 # pragma once
00030 #endif /* ACE_LACKS_PRAGMA_ONCE */
00031 
00032 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00033 
00034 class TAO_CEC_EventChannel;
00035 class TAO_CEC_ProxyPushConsumer;
00036 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00037 class TAO_CEC_TypedEvent;
00038 class TAO_CEC_TypedEventChannel;
00039 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00040 
00041 /**
00042  * @class TAO_CEC_ProxyPushSupplier
00043  *
00044  * @brief ProxyPushSupplier
00045  *
00046  * Implement the CosEventChannelAdmin::ProxyPushSupplier interface,
00047  * remember that this class is used to communicate with a
00048  * PushConsumer, so, in effect, this is the ambassador for a
00049  * consumer inside the event channel.
00050  * = MEMORY MANAGMENT
00051  * It does not assume ownership of the TAO_CEC_Dispatching object.
00052  * It makes a copy of the ConsumerQOS and the consumer object
00053  * reference.
00054  * = LOCKING
00055  * Locking is strategized, the event channel acts as a factory for
00056  * the locking strategies.
00057  */
00058 class TAO_Event_Serv_Export TAO_CEC_ProxyPushSupplier : public POA_CosEventChannelAdmin::ProxyPushSupplier
00059 {
00060 public:
00061   typedef CosEventChannelAdmin::ProxyPushSupplier_ptr _ptr_type;
00062   typedef CosEventChannelAdmin::ProxyPushSupplier_var _var_type;
00063 
00064   /// constructor...
00065   TAO_CEC_ProxyPushSupplier (TAO_CEC_EventChannel* event_channel,
00066                              const ACE_Time_Value &timeout);
00067 
00068   /// typed ec constructor
00069 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00070   TAO_CEC_ProxyPushSupplier (TAO_CEC_TypedEventChannel* typed_event_channel,
00071                              const ACE_Time_Value &timeout);
00072 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00073 
00074   /// destructor...
00075   virtual ~TAO_CEC_ProxyPushSupplier (void);
00076 
00077   /// Activate in the POA
00078   virtual void activate (
00079       CosEventChannelAdmin::ProxyPushSupplier_ptr &);
00080 
00081   /// Deactivate from the POA
00082   virtual void deactivate (void);
00083 
00084   /// Return 0 if no consumer is connected...
00085   CORBA::Boolean is_connected (void) const;
00086 
00087   /**
00088    * Return the consumer object reference. It returns nil() if it has
00089    * not connected yet.
00090    * NOTE: This method does not return a new reference!!! Doing so
00091    * will increase the locking overhead on the critical path.
00092    */
00093   CosEventComm::PushConsumer_ptr consumer (void) const;
00094 
00095   /// The event channel is shutting down
00096   virtual void shutdown (void);
00097 
00098   /// Internal methods to push an event to each consumer.
00099   virtual void push (const CORBA::Any &event);
00100   virtual void push_nocopy (CORBA::Any &event);
00101   /// Internal methods to invoke a typed event to each consumer.
00102 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00103   virtual void invoke (const TAO_CEC_TypedEvent& typed_event);
00104 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00105 
00106   /// Pushes to the consumer, verifies that it is connected.
00107   void push_to_consumer (const CORBA::Any &event);
00108   void reactive_push_to_consumer (const CORBA::Any &event);
00109 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00110   void invoke_to_consumer (const TAO_CEC_TypedEvent &typed_event);
00111   void reactive_invoke_to_consumer (const TAO_CEC_TypedEvent &typed_event);
00112 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00113 
00114   /**
00115    * Invoke the _non_existent() pseudo-operation on the consumer. If
00116    * it is disconnected then it returns true and sets the
00117    * <disconnected> flag.
00118    */
00119   CORBA::Boolean consumer_non_existent (CORBA::Boolean_out disconnected);
00120 
00121   // = The CosEventChannelAdmin::ProxyPushSupplier methods...
00122   virtual void connect_push_consumer (
00123                 CosEventComm::PushConsumer_ptr push_consumer);
00124   virtual void disconnect_push_supplier (void);
00125 
00126   /// Increment and decrement the reference count.
00127   CORBA::ULong _incr_refcnt (void);
00128   CORBA::ULong _decr_refcnt (void);
00129 
00130   // = The Servant methods
00131   virtual PortableServer::POA_ptr _default_POA (void);
00132   virtual void _add_ref (void);
00133   virtual void _remove_ref (void);
00134 
00135 protected:
00136   /// Set the consumer, used by some implementations to change the
00137   /// policies used when invoking operations on the consumer.
00138   void consumer (CosEventComm::PushConsumer_ptr consumer);
00139   void consumer_i (CosEventComm::PushConsumer_ptr consumer);
00140 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00141   void consumer (CosTypedEventComm::TypedPushConsumer_ptr typed_consumer);
00142   void consumer_i (CosTypedEventComm::TypedPushConsumer_ptr typed_consumer);
00143 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00144 
00145   /// The private version (without locking) of is_connected().
00146   CORBA::Boolean is_connected_i (void) const;
00147 
00148   /// Release the child and the consumer
00149   void cleanup_i (void);
00150 
00151 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00152   CORBA::Boolean is_typed_ec (void) const;
00153 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00154 
00155   /// Assigns the parameter to both consumer_ and nopolicy_consumer_, and
00156   /// applies policies (when appropriate) to consumer_.
00157   CosEventComm::PushConsumer_ptr apply_policy
00158   (CosEventComm::PushConsumer_ptr c);
00159 
00160 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00161   CosTypedEventComm::TypedPushConsumer_ptr apply_policy
00162   (CosTypedEventComm::TypedPushConsumer_ptr c);
00163 #endif
00164 
00165   CORBA::Object_ptr apply_policy_obj (CORBA::Object_ptr c);
00166 
00167 private:
00168   /// The Event Channel that owns this object.
00169   TAO_CEC_EventChannel* event_channel_;
00170 
00171   ACE_Time_Value timeout_;
00172 
00173   /// The Typed Event Channel that owns this object.
00174 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00175   TAO_CEC_TypedEventChannel *typed_event_channel_;
00176 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00177 
00178   /// The locking strategy.
00179   ACE_Lock* lock_;
00180 
00181   /// The reference count.
00182   CORBA::ULong refcount_;
00183 
00184   /// The consumer -- use apply_policy() instead of assigning directly to
00185   /// consumer_.  This will keep consumer_ and nopolicy_consumer_ in sync.
00186   CosEventComm::PushConsumer_var consumer_;
00187 
00188   /// The consumer without any policies applied
00189   CosEventComm::PushConsumer_var nopolicy_consumer_;
00190 
00191 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00192   /// The typed consumer -- use apply_policy() instead of assigning directly to
00193   /// typed_consumer_.  This will keep typed_consumer_ and
00194   /// nopolicy_typed_consumer_ in sync.
00195   CosTypedEventComm::TypedPushConsumer_var typed_consumer_;
00196 
00197   /// The consumer object returned from get_typed_consumer()
00198   CORBA::Object_var typed_consumer_obj_;
00199 
00200   /// The typed consumer without any policies applied
00201   CosTypedEventComm::TypedPushConsumer_var nopolicy_typed_consumer_;
00202 
00203 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00204 
00205   /// Store the default POA.
00206   PortableServer::POA_var default_POA_;
00207 };
00208 
00209 TAO_END_VERSIONED_NAMESPACE_DECL
00210 
00211 #if defined (__ACE_INLINE__)
00212 #include "orbsvcs/CosEvent/CEC_ProxyPushSupplier.inl"
00213 #endif /* __ACE_INLINE__ */
00214 
00215 #include /**/ "ace/post.h"
00216 
00217 #endif /* TAO_CEC_PROXYPUSHSUPPLIER_H */

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