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