aboutsummaryrefslogtreecommitdiff
path: root/src/Timer.hh
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-01-09 21:52:09 (GMT)
committerfluxgen <fluxgen>2003-01-09 21:52:09 (GMT)
commitc9299fff8f5492df6aafce4455c1ee7cff1ab1f8 (patch)
tree4de76e3b6e3100bb9869ea0eaef2c0e38866e808 /src/Timer.hh
parent7dd4823340ae5f710a08ff3a8fbe4276defc6b85 (diff)
downloadfluxbox-c9299fff8f5492df6aafce4455c1ee7cff1ab1f8.zip
fluxbox-c9299fff8f5492df6aafce4455c1ee7cff1ab1f8.tar.bz2
moved to FbTk
Diffstat (limited to 'src/Timer.hh')
-rw-r--r--src/Timer.hh91
1 files changed, 0 insertions, 91 deletions
diff --git a/src/Timer.hh b/src/Timer.hh
deleted file mode 100644
index 873aaef..0000000
--- a/src/Timer.hh
+++ /dev/null
@@ -1,91 +0,0 @@
1// Timer.hh for fluxbox
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen at linuxmail.org)
3//
4// Timer.hh for Blackbox - An X11 Window Manager
5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net)
6//
7// Permission is hereby granted, free of charge, to any person obtaining a
8// copy of this software and associated documentation files (the "Software"),
9// to deal in the Software without restriction, including without limitation
10// the rights to use, copy, modify, merge, publish, distribute, sublicense,
11// and/or sell copies of the Software, and to permit persons to whom the
12// Software is furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE.
24
25#ifndef TIMER_HH
26#define TIMER_HH
27
28#include <ctime>
29#include <list>
30
31/**
32 Inherit this to have a timed object, that calls
33 timeout function when the time is out
34*/
35class TimeoutHandler {
36public:
37 /// called when the time is out
38 virtual void timeout() = 0;
39};
40
41/**
42 Handles TimeoutHandles
43*/
44class BTimer {
45public:
46 explicit BTimer(TimeoutHandler *handler);
47 virtual ~BTimer();
48
49 inline int isTiming() const { return m_timing; }
50 inline int doOnce() const { return m_once; }
51
52 inline const timeval &getTimeout() const { return m_timeout; }
53 inline const timeval &getStartTime() const { return m_start; }
54
55 inline void fireOnce(bool once) { m_once = once; }
56 /// set timeout
57 void setTimeout(long val);
58 /// set timeout
59 void setTimeout(timeval val);
60 /// start timing
61 void start();
62 /// stop timing
63 void stop();
64 /// update all timers
65 static void updateTimers(int file_descriptor);
66
67protected:
68 /// force a timeout
69 void fireTimeout();
70
71private:
72 /// add a timer to the static list
73 static void addTimer(BTimer *timer);
74 /// remove a timer from the static list
75 static void removeTimer(BTimer *timer);
76
77 typedef std::list<BTimer *> TimerList;
78 static TimerList m_timerlist; ///< list of all timers
79
80 TimeoutHandler *m_handler; ///< handler
81
82 bool m_timing; ///< clock running?
83 bool m_once; ///< do timeout only once?
84
85 timeval m_start; ///< start time
86 timeval m_timeout; ///< time length
87
88};
89
90#endif // TIMER_HH
91