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  *  ECG_Reactive_ConsumerEC_Control.h,v 1.8 2006/03/14 06:14:25 jtc Exp
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                                         ACE_ENV_ARG_DECL_NOT_USED);
00089   virtual void system_exception (TAO_EC_Gateway_IIOP *gateway,
00090                                  CORBA::SystemException &
00091                                  ACE_ENV_ARG_DECL_NOT_USED);
00092 
00093 private:
00094   /// Check if the consumers still exists.  It is a helper method for
00095   /// handle_timeout() to isolate the exceptions.
00096   void query_eventchannel (ACE_ENV_SINGLE_ARG_DECL);
00097 
00098 private:
00099   /// The polling rate
00100   ACE_Time_Value rate_;
00101 
00102   /// The polling timeout
00103   ACE_Time_Value timeout_;
00104 
00105   /// The Adapter for the reactor events
00106   TAO_ECG_Reactive_ConsumerEC_Control_Adapter adapter_;
00107 
00108   /// The gateway
00109   TAO_EC_Gateway_IIOP* gateway_;
00110 
00111   /// The ORB
00112   CORBA::ORB_var orb_;
00113 
00114   /// To control the timeout policy in the thread
00115   CORBA::PolicyCurrent_var policy_current_;
00116 
00117   /// Precomputed policy list to the set timeout.
00118   CORBA::PolicyList policy_list_;
00119 
00120   /// The ORB reactor
00121   ACE_Reactor *reactor_;
00122 
00123 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
00124   /// The timer id
00125   long timer_id_;
00126 #endif /* TAO_HAS_CORBA_MESSAGING */
00127 };
00128 
00129 TAO_END_VERSIONED_NAMESPACE_DECL
00130 
00131 #include /**/ "ace/post.h"
00132 
00133 #endif /* TAO_ECG_REACTIVE_CONSUMEREC_CONTROL_H */

Generated on Thu Nov 9 13:11:10 2006 for TAO_RTEvent by doxygen 1.3.6