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

FXDispatcher.h
1 /********************************************************************************
2 * *
3 * E v e n t D i s p a t c h e r *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2006,2017 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXDISPATCHER_H
22 #define FXDISPATCHER_H
23 
24 #ifndef FXOBJECT_H
25 #include "FXObject.h"
26 #endif
27 
29 
30 
31 namespace FX {
32 
33 
38 class FXAPI FXDispatcher {
39 protected:
40  struct FXHandles;
41 protected:
42  FXHandles *handles; // Handle to watch
43  volatile FXint signotified[64]; // Signal notify flag
44  FXint sigreceived; // Most recent received signal
45  FXint numhandles; // Number of handles
46  FXint numwatched; // Number of watched
47  FXint numraised; // Number of raised handles
48  FXint current; // Current handle
49  FXbool initialized; // Is initialized
50 protected:
51  static FXDispatcher* volatile sigmanager[64]; // Signals managed flag
52 protected:
53  FXDispatcher(const FXDispatcher&);
54  FXDispatcher &operator=(const FXDispatcher&);
55 private:
56  static CDECL void signalhandler(FXint sig);
57  static CDECL void signalhandlerasync(FXint sig);
58 public:
59  enum {
60  InputNone = 0,
61  InputRead = 1,
62  InputWrite = 2,
63  InputExcept = 4
64  };
65  enum {
66  DispatchAll = 0xffffffff,
67  DispatchSignals = 0x00000001,
68  DispatchTimers = 0x00000002,
69  DispatchIdle = 0x00000004,
70  DispatchInputs = 0x00000008
71  };
72 public:
73 
75  FXDispatcher();
76 
78  virtual FXbool init();
79 
81  FXbool isInitialized() const { return initialized; }
82 
83 
85  virtual FXTime getTimeout();
86 
87 
89  virtual FXbool hasSignal(FXint sig);
90 
92  virtual FXbool addSignal(FXint sig,FXbool async=false);
93 
95  virtual FXbool remSignal(FXint sig);
96 
98  virtual FXbool remAllSignals();
99 
100 
102  virtual FXbool addHandle(FXInputHandle hnd,FXuint mode=InputRead);
103 
105  virtual FXbool remHandle(FXInputHandle hnd);
106 
107 
109  virtual FXbool dispatch(FXTime blocking=forever,FXuint flags=DispatchAll);
110 
111 
113  virtual FXbool dispatchSignal(FXint sig);
114 
116  virtual FXbool dispatchHandle(FXInputHandle hnd,FXuint mode);
117 
119  virtual FXbool dispatchTimeout(FXTime now);
120 
122  virtual FXbool dispatchIdle();
123 
124 
126  virtual FXbool exit();
127 
129  virtual ~FXDispatcher();
130  };
131 
132 }
133 
134 #endif

Copyright © 1997-2016 Jeroen van der Zijp