This class implements a simple interval timer that generates a GTimerEvent
with a specified frequency.
More...
#include "gtimer.h"
Public Member Functions | |
GTimer(double milliseconds) | |
Creates a timer object that generates a GTimerEvent each time the specified number of milliseconds has elapsed. More... | |
~GTimer() | |
Destroys the timer, stopping it if it's currently running. More... | |
double | getDelay() const |
Returns the delay in milliseconds between each tick of this timer. More... | |
bool | isStarted() const |
Method: isStarted Usage: if (timer.isStarted()) { ... More... | |
void | restart() |
Stops the timer (if it was started) and then starts it again. More... | |
void | setDelay(double ms) |
Changes the delay in milliseconds between each tick of this timer. More... | |
void | start() |
Starts the timer. More... | |
void | stop() |
Stops the timer so that it stops generating events until it is restarted. More... | |
This class implements a simple interval timer that generates a GTimerEvent
with a specified frequency.
GTimer | ( | double | milliseconds | ) |
Creates a timer object that generates a GTimerEvent
each time the specified number of milliseconds has elapsed.
No events are generated until the client calls start
on the timer.
Due to implementation details, you must create at least one GWindow before you can start() a GTimer object.
ErrorException | if milliseconds is negative |
~GTimer | ( | ) |
Destroys the timer, stopping it if it's currently running.
double getDelay | ( | ) | const |
Returns the delay in milliseconds between each tick of this timer.
bool isStarted | ( | ) | const |
Method: isStarted Usage: if (timer.isStarted()) { ...
Returns true if the given timer has been started (via start()). If you stop the timer or have not started it yet, this method will return false.
void restart | ( | ) |
Stops the timer (if it was started) and then starts it again.
void setDelay | ( | double | ms | ) |
Changes the delay in milliseconds between each tick of this timer.
If the timer is currently running, calling this method will stop and restart the timer with the new delay.
ErrorException | if milliseconds is negative |
void start | ( | ) |
Starts the timer.
A timer continues to generate timer events until it is stopped; to achieve the effect of a one-shot timer, the simplest approach is to call the stop
method inside the event handler.
void stop | ( | ) |
Stops the timer so that it stops generating events until it is restarted.