fixing parse error in execcommand
[bbkeys.git] / src / Timer.hh
blob793f0ab6c70133e1fc2d905c406c3ec767e7db99
1 // Timer.hh for Blackbox - An X11 Window Manager
2 // Copyright (c) 1997 - 1999 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:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
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.
22 // $Id$
24 #ifndef __Timer_hh
25 #define __Timer_hh
27 #ifdef TIME_WITH_SYS_TIME
28 # include <sys/time.h>
29 # include <time.h>
30 #else // !TIME_WITH_SYS_TIME
31 # ifdef HAVE_SYS_TIME_H
32 # include <sys/time.h>
33 # else // !HAVE_SYS_TIME_H
34 # include <time.h>
35 # endif // HAVE_SYS_TIME_H
36 #endif // TIME_WITH_SYS_TIME
38 #include "BaseDisplay.hh"
40 // forward declaration
41 class BTimer;
42 class TimeoutHandler;
44 class TimeoutHandler {
45 public:
46 virtual void timeout(void) = 0;
50 class BTimer {
51 friend class BaseDisplay;
52 private:
53 BaseDisplay *display;
54 TimeoutHandler *handler;
55 int timing, once;
57 timeval _start, _timeout;
60 protected:
61 void fireTimeout(void);
64 public:
65 BTimer(BaseDisplay *, TimeoutHandler *);
66 virtual ~BTimer(void);
68 inline int &isTiming(void) { return timing; }
69 inline int &doOnce(void) { return once; }
71 inline const timeval &getTimeout(void) const { return _timeout; }
72 inline const timeval &getStartTime(void) const { return _start; }
74 inline void fireOnce(int o) { once = o; }
76 void setTimeout(long);
77 void setTimeout(timeval);
78 void start(void);
79 void stop(void);
80 void reset(void);
84 #endif // __Timer_hh