TkReactor.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    TkReactor.h
00006  *
00007  *  TkReactor.h,v 4.14 2005/10/28 23:55:10 ossama Exp
00008  *
00009  *  @author Nagarajan Surendran <naga@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef ACE_TKREACTOR_H
00015 #define ACE_TKREACTOR_H
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "ace/config-all.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "ace/ACE_TkReactor_export.h"
00025 #include "ace/Select_Reactor.h"
00026 #include /**/ <tk.h>
00027 
00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00029 
00030 /**
00031  * @class ACE_TkReactorID
00032  *
00033  * @brief This little class is necessary due to the way that Microsoft
00034  * implements sockets to be pointers rather than indices.
00035  */
00036 class ACE_TkReactor_Export ACE_TkReactorID
00037 {
00038 public:
00039   /// Underlying handle.
00040   ACE_HANDLE handle_;
00041 
00042   /// Pointer to next node in the linked list.
00043   ACE_TkReactorID *next_;
00044 };
00045 
00046 class ACE_TkReactor;
00047 
00048 class ACE_TkReactor_Export ACE_TkReactor_Input_Callback
00049 {
00050 public:
00051   ACE_TkReactor *reactor_;
00052   ACE_HANDLE handle_;
00053 };
00054 
00055 /**
00056  * @class ACE_TkReactor
00057  *
00058  * @brief An object-oriented event demultiplexor and event handler
00059  * dispatcher that uses the Tk functions.
00060  */
00061 class ACE_TkReactor_Export ACE_TkReactor : public ACE_Select_Reactor
00062 {
00063 public:
00064   // = Initialization and termination methods.
00065   ACE_TkReactor (size_t size = DEFAULT_SIZE,
00066                  int restart = 0,
00067                  ACE_Sig_Handler * = 0);
00068 
00069   virtual ~ACE_TkReactor (void);
00070 
00071   // = Timer operations.
00072   virtual long schedule_timer (ACE_Event_Handler *event_handler,
00073                                const void *arg,
00074                                const ACE_Time_Value &delay,
00075                                const ACE_Time_Value &interval);
00076   virtual int reset_timer_interval (long timer_id,
00077                                     const ACE_Time_Value &interval);
00078   virtual int cancel_timer (ACE_Event_Handler *handler,
00079                             int dont_call_handle_close = 1);
00080   virtual int cancel_timer (long timer_id,
00081                             const void **arg = 0,
00082                             int dont_call_handle_close = 1);
00083 
00084 protected:
00085   // = Register timers/handles with Tk.
00086   /// Register a single <handler>.
00087   virtual int register_handler_i (ACE_HANDLE handle,
00088                                   ACE_Event_Handler *handler,
00089                                   ACE_Reactor_Mask mask);
00090 
00091   /// Register a set of <handlers>.
00092   virtual int register_handler_i (const ACE_Handle_Set &handles,
00093                                   ACE_Event_Handler *handler,
00094                                   ACE_Reactor_Mask mask);
00095 
00096   /// Remove the <handler> associated with this <handle>.
00097   virtual int remove_handler_i (ACE_HANDLE handle,
00098                                 ACE_Reactor_Mask mask);
00099 
00100   /// Remove a set of <handles>.
00101   virtual int remove_handler_i (const ACE_Handle_Set &handles,
00102                                 ACE_Reactor_Mask);
00103 
00104   /// Removes an Tk FileHandler.
00105   virtual void remove_TkFileHandler (ACE_HANDLE handle);
00106 
00107   /// Wait for events to occur.
00108   virtual int wait_for_multiple_events (ACE_Select_Reactor_Handle_Set &,
00109                                         ACE_Time_Value *);
00110 
00111   ///Wait for Tk events to occur.
00112   virtual int TkWaitForMultipleEvents (int,
00113                                        ACE_Select_Reactor_Handle_Set &,
00114                                        ACE_Time_Value *);
00115 
00116   ACE_TkReactorID *ids_;
00117   Tk_TimerToken timeout_;
00118 
00119 private:
00120   /// This method ensures there's a Tk timeout for the first timeout in
00121   /// the Reactor's Timer_Queue.
00122   void reset_timeout (void);
00123 
00124   // = Integrate with the X callback function mechanism.
00125   static void TimerCallbackProc (ClientData cd);
00126   static void InputCallbackProc (ClientData cd,int mask);
00127 
00128   /// Deny access since member-wise won't work...
00129   ACE_TkReactor (const ACE_TkReactor &);
00130   ACE_TkReactor &operator = (const ACE_TkReactor &);
00131 };
00132 
00133 ACE_END_VERSIONED_NAMESPACE_DECL
00134 
00135 #include /**/ "ace/post.h"
00136 #endif /* ACE_TK_REACTOR_H */

Generated on Thu Nov 9 09:42:07 2006 for ACE by doxygen 1.3.6