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

XtReactor.h

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

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