Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

TkReactor.h

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

Generated on Mon Jun 16 11:21:54 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002