XtReactor.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    XtReactor.h
00006  *
00007  *  XtReactor.h,v 4.32 2005/10/28 23:55:10 ossama Exp
00008  *
00009  *  @author Eric C. Newton <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 #include "ace/ACE_XtReactor_export.h"
00026 #include "ace/Select_Reactor.h"
00027 
00028 //#define String XtString
00029 #include /**/ <X11/Intrinsic.h>
00030 //#undef String
00031 
00032 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
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_XtReactor_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_XtReactor_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 
00136 ACE_END_VERSIONED_NAMESPACE_DECL
00137 
00138 #include /**/ "ace/post.h"
00139 
00140 #endif /* ACE_XTREACTOR_H */

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