|
Instrument Neutral Distributed Interface INDI 2.2.5
|
The Timer class provides repetitive and single-shot timers. More...
#include <inditimer.h>
Public Member Functions | |
| Timer () | |
| virtual | ~Timer () |
| void | start () |
| Starts or restarts the timer with the timeout specified in interval. | |
| void | start (int msec) |
| Starts or restarts the timer with a timeout interval of msec milliseconds. | |
| void | stop () |
| Stops the timer. | |
| void | callOnTimeout (const std::function< void()> &callback) |
| void | setInterval (int msec) |
| Set the timeout interval in milliseconds. | |
| void | setSingleShot (bool singleShot) |
| Set whether the timer is a single-shot timer. | |
| bool | isActive () const |
| Returns true if the timer is running (pending); otherwise returns false. | |
| bool | isSingleShot () const |
| Returns whether the timer is a single-shot timer. | |
| int | remainingTime () const |
| Returns the timer's remaining value in milliseconds left until the timeout. If the timer not exists, the returned value will be -1. | |
| int | interval () const |
| Returns the timeout interval in milliseconds. | |
| virtual void | timeout () |
| This function is called when the timer times out. | |
Static Public Member Functions | |
| static void | singleShot (int msec, const std::function< void()> &callback) |
| This static function calls a the given function after a given time interval. | |
Protected Member Functions | |
| Timer (TimerPrivate &dd) | |
Protected Attributes | |
| std::unique_ptr< TimerPrivate > | d_ptr |
The Timer class provides repetitive and single-shot timers.
The Timer class provides a high-level programming interface for timers. To use it, create a Timer, set your function with callOnTimeout, and call start(). From then on, it will call your function at constant intervals.
You can set a timer to time out only once by calling setSingleShot(true). You can also use the static Timer::singleShot() function to call a function after a specified interval.
Definition at line 40 of file inditimer.h.
| INDI::Timer::Timer | ( | ) |
Definition at line 65 of file inditimer.cpp.
|
virtual |
Definition at line 73 of file inditimer.cpp.
|
protected |
Definition at line 69 of file inditimer.cpp.
| void INDI::Timer::callOnTimeout | ( | const std::function< void()> & | callback | ) |
Definition at line 76 of file inditimer.cpp.
| int INDI::Timer::interval | ( | ) | const |
Returns the timeout interval in milliseconds.
Definition at line 133 of file inditimer.cpp.
| bool INDI::Timer::isActive | ( | ) | const |
Returns true if the timer is running (pending); otherwise returns false.
Definition at line 115 of file inditimer.cpp.
| bool INDI::Timer::isSingleShot | ( | ) | const |
Returns whether the timer is a single-shot timer.
Definition at line 121 of file inditimer.cpp.
| int INDI::Timer::remainingTime | ( | ) | const |
Returns the timer's remaining value in milliseconds left until the timeout. If the timer not exists, the returned value will be -1.
Definition at line 127 of file inditimer.cpp.
| void INDI::Timer::setInterval | ( | int | msec | ) |
Set the timeout interval in milliseconds.
Definition at line 103 of file inditimer.cpp.
| void INDI::Timer::setSingleShot | ( | bool | singleShot | ) |
Set whether the timer is a single-shot timer.
Definition at line 109 of file inditimer.cpp.
|
static |
This static function calls a the given function after a given time interval.
Definition at line 146 of file inditimer.cpp.
| void INDI::Timer::start | ( | ) |
Starts or restarts the timer with the timeout specified in interval.
Definition at line 82 of file inditimer.cpp.
| void INDI::Timer::start | ( | int | msec | ) |
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition at line 89 of file inditimer.cpp.
| void INDI::Timer::stop | ( | ) |
Stops the timer.
Definition at line 97 of file inditimer.cpp.
|
virtual |
This function is called when the timer times out.
Definition at line 139 of file inditimer.cpp.
|
protected |
Definition at line 92 of file inditimer.h.