]> git.lyx.org Git - lyx.git/blob - src/frontends/Timeout.h
fix rbearing
[lyx.git] / src / frontends / Timeout.h
1 // -*- C++ -*-
2 /**
3  * \file Timeout.h
4  * Copyright 2001 LyX Team
5  * This file is part of LyX, the document processor.
6  * Licence details can be found in the file COPYING.
7  *
8  * \author Lars Gullik Bjønnes
9  * \author John Levon
10  *
11  * Full author contact details are available in file CREDITS
12  */
13  
14 #ifndef TIMEOUT_H
15 #define TIMEOUT_H
16
17 #ifdef __GNUG__
18 #pragma interface
19 #endif
20
21 #include <boost/signals/signal0.hpp>
22
23 /**
24  * This class executes the callback when the timeout expires.
25  */
26 class Timeout {
27 public:
28         /// the timeout type
29         enum Type {
30                 ONETIME, //< one-shot timer
31                 CONTINUOUS //< repeating
32         };
33         ///
34         Timeout(unsigned int msec, Type = ONETIME);
35         ///
36         ~Timeout();
37         /// Is the timer running?
38         bool running() const;
39         /// start the timer
40         void start();
41         /// stop the timer
42         void stop();
43         /// restart the timer
44         void restart();
45         /// signal emitted on timer expiry
46         boost::signal0<void> timeout;
47         /// emit the signal
48         void emit();
49         /// set the timer type
50         Timeout & setType(Type t);
51         /// set the timeout value
52         Timeout & setTimeout(unsigned int msec);
53
54 private:
55         ///
56         struct Pimpl;
57         ///
58         friend struct Pimpl;
59         /// implementation
60         Pimpl * pimpl_;
61         /// one-shot or repeating
62         Type type;
63         /// timeout value in milliseconds
64         unsigned int timeout_ms;
65 };
66
67 #endif