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