diff options
author | fluxgen <fluxgen> | 2001-12-11 20:47:02 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2001-12-11 20:47:02 (GMT) |
commit | 18830ac9add80cbd3bf7369307d7e35a519dca9b (patch) | |
tree | 4759a5434a34ba317fe77bbf8b0ed9bb57bb6018 /src/Timer.hh | |
parent | 1523b48bff07dead084af3064ad11c79a9b25df0 (diff) | |
download | fluxbox-18830ac9add80cbd3bf7369307d7e35a519dca9b.zip fluxbox-18830ac9add80cbd3bf7369307d7e35a519dca9b.tar.bz2 |
Initial revision
Diffstat (limited to 'src/Timer.hh')
-rw-r--r-- | src/Timer.hh | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/Timer.hh b/src/Timer.hh new file mode 100644 index 0000000..0cc6bbe --- /dev/null +++ b/src/Timer.hh | |||
@@ -0,0 +1,87 @@ | |||
1 | // Timer.hh for Blackbox - An X11 Window Manager | ||
2 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) | ||
3 | // | ||
4 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | // copy of this software and associated documentation files (the "Software"), | ||
6 | // to deal in the Software without restriction, including without limitation | ||
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | // and/or sell copies of the Software, and to permit persons to whom the | ||
9 | // Software is furnished to do so, subject to the following conditions: | ||
10 | // | ||
11 | // The above copyright notice and this permission notice shall be included in | ||
12 | // all copies or substantial portions of the Software. | ||
13 | // | ||
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | // DEALINGS IN THE SOFTWARE. | ||
21 | |||
22 | #ifndef _TIMER_HH_ | ||
23 | #define _TIMER_HH_ | ||
24 | |||
25 | #ifdef HAVE_CONFIG_H | ||
26 | #include "../config.h" | ||
27 | #endif //HAVE_CONFIG_H | ||
28 | |||
29 | #ifdef TIME_WITH_SYS_TIME | ||
30 | # include <sys/time.h> | ||
31 | # include <time.h> | ||
32 | #else // !TIME_WITH_SYS_TIME | ||
33 | # ifdef HAVE_SYS_TIME_H | ||
34 | #include <sys/time.h> | ||
35 | # else // !HAVE_SYS_TIME_H | ||
36 | # include <time.h> | ||
37 | # endif // HAVE_SYS_TIME_H | ||
38 | #endif // TIME_WITH_SYS_TIME | ||
39 | |||
40 | // forward declaration | ||
41 | class BTimer; | ||
42 | class TimeoutHandler; | ||
43 | |||
44 | #include "BaseDisplay.hh" | ||
45 | |||
46 | |||
47 | class TimeoutHandler { | ||
48 | public: | ||
49 | virtual void timeout(void) = 0; | ||
50 | }; | ||
51 | |||
52 | |||
53 | class BTimer { | ||
54 | friend class BaseDisplay; | ||
55 | private: | ||
56 | BaseDisplay *display; | ||
57 | TimeoutHandler *handler; | ||
58 | int timing, once; | ||
59 | |||
60 | timeval _start, _timeout; | ||
61 | |||
62 | |||
63 | protected: | ||
64 | void fireTimeout(void); | ||
65 | |||
66 | |||
67 | public: | ||
68 | BTimer(BaseDisplay *, TimeoutHandler *); | ||
69 | virtual ~BTimer(void); | ||
70 | |||
71 | inline const int &isTiming(void) const { return timing; } | ||
72 | inline const int &doOnce(void) const { return once; } | ||
73 | |||
74 | inline const timeval &getTimeout(void) const { return _timeout; } | ||
75 | inline const timeval &getStartTime(void) const { return _start; } | ||
76 | |||
77 | inline void fireOnce(int o) { once = o; } | ||
78 | |||
79 | void setTimeout(long); | ||
80 | void setTimeout(timeval); | ||
81 | void start(void); | ||
82 | void stop(void); | ||
83 | }; | ||
84 | |||
85 | |||
86 | #endif // _TIMER_HH_ | ||
87 | |||