- changing MaxInstructions to 100 for cthulhain (crazy nut) =:)
[bbkeys.git] / src / Timer.hh
blob6bdc02da6257ea46b8864c7b96067be7dede8f2f
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 // forward declaration
39 class BTimer;
40 class TimeoutHandler;
42 #include "BaseDisplay.hh"
45 class TimeoutHandler {
46 public:
47 virtual void timeout(void) = 0;
51 class BTimer {
52 friend class BaseDisplay;
53 private:
54 BaseDisplay *display;
55 TimeoutHandler *handler;
56 int timing, once;
58 timeval _start, _timeout;
61 protected:
62 void fireTimeout(void);
65 public:
66 BTimer(BaseDisplay *, TimeoutHandler *);
67 virtual ~BTimer(void);
69 inline int &isTiming(void) { return timing; }
70 inline int &doOnce(void) { return once; }
72 inline const timeval &getTimeout(void) const { return _timeout; }
73 inline const timeval &getStartTime(void) const { return _start; }
75 inline void fireOnce(int o) { once = o; }
77 void setTimeout(long);
78 void setTimeout(timeval);
79 void start(void);
80 void stop(void);
81 void reset(void);
85 #endif // __Timer_hh