ECG_Reactive_ConsumerEC_Control.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /**
00004  *  @file   ECG_Reactive_ConsumerEC_Control.h
00005  *
00006  *  $Id: ECG_Reactive_ConsumerEC_Control.h 76589 2007-01-25 18:04:11Z elliott_c $
00007  *
00008  *  @author Johnny Willemsen (jwillemsen@remedy.nl)
00009  *
00010  */
00011 
00012 #ifndef TAO_ECG_REACTIVE_CONSUMEREC_CONTROL_H
00013 #define TAO_ECG_REACTIVE_CONSUMEREC_CONTROL_H
00014 
00015 #include /**/ "ace/pre.h"
00016 
00017 #include "orbsvcs/Event/ECG_ConsumerEC_Control.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 #include "tao/ORB.h"
00024 #include "tao/PolicyC.h"
00025 
00026 #include "ace/Event_Handler.h"
00027 
00028 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00029 
00030 class TAO_ECG_Reactive_ConsumerEC_Control;
00031 class TAO_EC_Gateway_IIOP;
00032 
00033 /**
00034  * @class TAO_ECG_Reactive_ConsumerEC_Control_Adapter
00035  *
00036  * @brief Forwards timeout events to the Reactive ConsumerControl
00037  *
00038  * The Reactive ConsumerControl strategy uses the reactor to
00039  * periodically wakeup and verify the state of the consumers
00040  * registered with the Event Channel.
00041  */
00042 class TAO_RTEvent_Serv_Export TAO_ECG_Reactive_ConsumerEC_Control_Adapter
00043   : public ACE_Event_Handler
00044 {
00045 public:
00046   /// Constructor
00047   TAO_ECG_Reactive_ConsumerEC_Control_Adapter (TAO_ECG_Reactive_ConsumerEC_Control *adaptee);
00048 
00049   // = Documented in ACE_Event_Handler.
00050   virtual int handle_timeout (const ACE_Time_Value &tv,
00051                               const void *arg = 0);
00052 
00053 private:
00054   /// The adapted object
00055   TAO_ECG_Reactive_ConsumerEC_Control *adaptee_;
00056 };
00057 
00058 /**
00059  * @class TAO_ECG_Reactive_ConsumerEC_Control
00060  *
00061  * @brief Consumer event channel control
00062  *
00063  * Defines the interface for the consumer event channel control strategy.
00064  * This strategy handles misbehaving or failing consumer event channels.
00065  */
00066 class TAO_RTEvent_Serv_Export TAO_ECG_Reactive_ConsumerEC_Control
00067   : public TAO_ECG_ConsumerEC_Control
00068 {
00069 public:
00070   /// Constructor.  It does not assume ownership of the @a event_channel
00071   /// parameter.
00072   TAO_ECG_Reactive_ConsumerEC_Control (const ACE_Time_Value &rate,
00073                                        const ACE_Time_Value &timeout,
00074                                        TAO_EC_Gateway_IIOP* gateway,
00075                                        CORBA::ORB_ptr orb);
00076 
00077   /// Destructor.
00078   virtual ~TAO_ECG_Reactive_ConsumerEC_Control (void);
00079 
00080   /// Receive the timeout from the adapter
00081   void handle_timeout (const ACE_Time_Value &tv,
00082                        const void* arg);
00083 
00084   // = Documented in TAO_EC_ConsumerControl
00085   virtual int activate (void);
00086   virtual int shutdown (void);
00087   virtual void event_channel_not_exist (TAO_EC_Gateway_IIOP *gateway);
00088   virtual void system_exception (TAO_EC_Gateway_IIOP *gateway,
00089                                  CORBA::SystemException &);
00090 
00091 private:
00092   /// Check if the consumers still exists.  It is a helper method for
00093   /// handle_timeout() to isolate the exceptions.
00094   void query_eventchannel (void);
00095 
00096 private:
00097   /// The polling rate
00098   ACE_Time_Value rate_;
00099 
00100   /// The polling timeout
00101   ACE_Time_Value timeout_;
00102 
00103   /// The Adapter for the reactor events
00104   TAO_ECG_Reactive_ConsumerEC_Control_Adapter adapter_;
00105 
00106   /// The gateway
00107   TAO_EC_Gateway_IIOP* gateway_;
00108 
00109   /// The ORB
00110   CORBA::ORB_var orb_;
00111 
00112   /// To control the timeout policy in the thread
00113   CORBA::PolicyCurrent_var policy_current_;
00114 
00115   /// Precomputed policy list to the set timeout.
00116   CORBA::PolicyList policy_list_;
00117 
00118   /// The ORB reactor
00119   ACE_Reactor *reactor_;
00120 
00121 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
00122   /// The timer id
00123   long timer_id_;
00124 #endif /* TAO_HAS_CORBA_MESSAGING */
00125 };
00126 
00127 TAO_END_VERSIONED_NAMESPACE_DECL
00128 
00129 #include /**/ "ace/post.h"
00130 
00131 #endif /* TAO_ECG_REACTIVE_CONSUMEREC_CONTROL_H */

Generated on Tue Feb 2 17:44:06 2010 for TAO_RTEvent by  doxygen 1.4.7