]> git.lyx.org Git - lyx.git/blob - src/frontends/Timeout.C
include sys/time.h
[lyx.git] / src / frontends / Timeout.C
1 /**
2  * \file Timeout.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #include <config.h>
13
14 #include "Timeout.h"
15 #include "debug.h"
16
17 #include "Timeout_pimpl.h"
18
19
20 Timeout::Timeout(unsigned int msec, Type t)
21         : type(t), timeout_ms(msec)
22 {
23         pimpl_ = new Pimpl(this);
24 }
25
26
27 Timeout::~Timeout()
28 {
29         pimpl_->stop();
30         delete pimpl_;
31 }
32
33
34 bool Timeout::running() const
35 {
36         return pimpl_->running();
37 }
38
39
40 void Timeout::start()
41 {
42         pimpl_->start();
43 }
44
45 void Timeout::stop()
46 {
47         pimpl_->stop();
48 }
49
50 void Timeout::restart()
51 {
52         pimpl_->stop();
53         pimpl_->start();
54 }
55
56 void Timeout::emit()
57 {
58         pimpl_->reset();
59         timeout();
60         if (type == CONTINUOUS)
61                 pimpl_->start();
62 }
63
64 Timeout & Timeout::setType(Type t)
65 {
66         type = t;
67         return * this;
68 }
69
70
71 Timeout & Timeout::setTimeout(unsigned int msec)
72 {
73         timeout_ms = msec;
74         return * this;
75 }