2001-06-14 08:20:41 +00:00
|
|
|
|
// -*- C++ -*-
|
2001-02-07 16:44:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file Timeout.h
|
|
|
|
|
* Copyright 2001 LyX Team
|
|
|
|
|
* Read COPYING
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author John Levon
|
|
|
|
|
*/
|
|
|
|
|
#ifndef TIMEOUT_H
|
|
|
|
|
#define TIMEOUT_H
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma interface
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <sigc++/signal_system.h>
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This class executes the callback when the timeout expires.
|
|
|
|
|
*/
|
|
|
|
|
class Timeout {
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
enum Type {
|
|
|
|
|
/// one-shot timer
|
|
|
|
|
ONETIME,
|
|
|
|
|
/// repeating
|
|
|
|
|
CONTINUOUS
|
|
|
|
|
};
|
|
|
|
|
///
|
|
|
|
|
Timeout();
|
|
|
|
|
///
|
|
|
|
|
Timeout(unsigned int msec, Type = ONETIME);
|
|
|
|
|
///
|
|
|
|
|
~Timeout();
|
|
|
|
|
/// start the timer
|
|
|
|
|
void start();
|
|
|
|
|
/// stop the timer
|
|
|
|
|
void stop();
|
|
|
|
|
/// restart the timer
|
|
|
|
|
void restart();
|
|
|
|
|
/// signal emitted on timer expiry
|
2001-03-15 18:21:56 +00:00
|
|
|
|
SigC::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:
|
|
|
|
|
struct Pimpl;
|
|
|
|
|
friend struct Pimpl;
|
|
|
|
|
/// implementation
|
|
|
|
|
Pimpl * pimpl_;
|
|
|
|
|
|
|
|
|
|
/// one-shot or repeating
|
|
|
|
|
Type type;
|
|
|
|
|
/// timeout value in milliseconds
|
|
|
|
|
unsigned int timeout_ms;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|