2001-06-14 08:20:41 +00:00
|
|
|
|
// -*- C++ -*-
|
2001-02-07 16:44:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file Timeout.h
|
2002-09-05 15:14:23 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-02-07 16:44:49 +00:00
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author John Levon
|
2002-09-05 14:10:50 +00:00
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-02-07 16:44:49 +00:00
|
|
|
|
*/
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
2001-02-07 16:44:49 +00:00
|
|
|
|
#ifndef TIMEOUT_H
|
|
|
|
|
#define TIMEOUT_H
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma interface
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
|
#include <boost/signals/signal0.hpp>
|
2001-02-07 16:44:49 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This class executes the callback when the timeout expires.
|
|
|
|
|
*/
|
|
|
|
|
class Timeout {
|
|
|
|
|
public:
|
2002-06-12 02:54:19 +00:00
|
|
|
|
/// the timeout type
|
2001-02-07 16:44:49 +00:00
|
|
|
|
enum Type {
|
2002-06-12 02:54:19 +00:00
|
|
|
|
ONETIME, //< one-shot timer
|
|
|
|
|
CONTINUOUS //< repeating
|
2001-02-07 16:44:49 +00:00
|
|
|
|
};
|
|
|
|
|
///
|
|
|
|
|
Timeout(unsigned int msec, Type = ONETIME);
|
|
|
|
|
///
|
|
|
|
|
~Timeout();
|
2002-02-18 19:13:48 +00:00
|
|
|
|
/// Is the timer running?
|
|
|
|
|
bool running() const;
|
2001-02-07 16:44:49 +00:00
|
|
|
|
/// start the timer
|
|
|
|
|
void start();
|
|
|
|
|
/// stop the timer
|
|
|
|
|
void stop();
|
|
|
|
|
/// restart the timer
|
|
|
|
|
void restart();
|
|
|
|
|
/// signal emitted on timer expiry
|
2002-05-29 16:21:03 +00:00
|
|
|
|
boost::signal0<void> timeout;
|
2001-02-07 16:44:49 +00:00
|
|
|
|
/// emit the signal
|
|
|
|
|
void emit();
|
|
|
|
|
/// set the timer type
|
|
|
|
|
Timeout & setType(Type t);
|
|
|
|
|
/// set the timeout value
|
|
|
|
|
Timeout & setTimeout(unsigned int msec);
|
|
|
|
|
|
|
|
|
|
private:
|
2002-03-11 22:47:41 +00:00
|
|
|
|
///
|
2001-02-07 16:44:49 +00:00
|
|
|
|
struct Pimpl;
|
2002-03-11 22:47:41 +00:00
|
|
|
|
///
|
2001-02-07 16:44:49 +00:00
|
|
|
|
friend struct Pimpl;
|
|
|
|
|
/// implementation
|
|
|
|
|
Pimpl * pimpl_;
|
|
|
|
|
/// one-shot or repeating
|
|
|
|
|
Type type;
|
|
|
|
|
/// timeout value in milliseconds
|
|
|
|
|
unsigned int timeout_ms;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|