Timer class that has fixed time intervals at which it becomes true.
More...
#include <IntervalTimer.h>
|
| IntervalTimer ()=default |
| Default constructor.
|
|
| IntervalTimer (const timespec &t) |
| Initializing constructor setting the elapse time using a timespec struct.
|
|
| IntervalTimer (int usec) |
| Initializing constructor setting the elapse time in usec.
|
|
| IntervalTimer (double sec) |
| Initializing constructor setting the elapse time in seconds and fraction using a double.
|
|
void | set (const timespec &t) |
| Sets the timers interval time.
|
|
bool | active () const |
| Tests if the timer is active if it is active it returns non-zero and resets the timer to a new event.
|
|
bool | active (const timespec &t) const |
| Allows passing timespec value our self to reduce overhead in case of multiple timers.
|
|
void | enable () |
| Enables the timer with the current interval time.
|
|
void | disable () |
| Disables the timer.
|
|
bool | isEnabled () const |
| Gets timer enabled.
|
|
const TimeSpec & | getInterval () const |
| Gets the set interval time in TimeSpec format.
|
|
const TimeSpec & | getTarget () const |
| Gets the set interval time in TimeSpec format.
|
|
TimeSpec | getTimeLeft () const |
| Gets the time left in msec before function active becomes true.
|
|
TimeSpec | getTimeLeft (const timespec &t) const |
| Gets the time left in TimeSpec format before function active becomes true.
|
|
TimeSpec | getTimeOver () const |
| Same as time left, but it also gives the time passed the target time and before that as a negative value.
|
|
TimeSpec | getTimeOver (const timespec &t) const |
| Same as time left, but it also gives the time passed the target time and before that as a negative value.
|
|
| operator bool () const |
| Test operator.
|
|
bool | operator() (const timespec &t) const |
|
Timer class that has fixed time intervals at which it becomes true.
If one or several intervals are missed, this timer will not catch up.
◆ IntervalTimer() [1/4]
sf::IntervalTimer::IntervalTimer |
( |
| ) |
|
|
default |
Default constructor.
The timer is by default disabled until set() is called.
◆ IntervalTimer() [2/4]
sf::IntervalTimer::IntervalTimer |
( |
const timespec & |
t | ) |
|
|
inlineexplicit |
Initializing constructor setting the elapse time using a timespec struct.
◆ IntervalTimer() [3/4]
sf::IntervalTimer::IntervalTimer |
( |
int |
usec | ) |
|
|
explicit |
Initializing constructor setting the elapse time in usec.
◆ IntervalTimer() [4/4]
sf::IntervalTimer::IntervalTimer |
( |
double |
sec | ) |
|
|
explicit |
Initializing constructor setting the elapse time in seconds and fraction using a double.
◆ active() [1/2]
bool sf::IntervalTimer::active |
( |
| ) |
const |
Tests if the timer is active if it is active it returns non-zero and resets the timer to a new event.
- Returns
- True when active.
◆ active() [2/2]
bool sf::IntervalTimer::active |
( |
const timespec & |
t | ) |
const |
Allows passing timespec value our self to reduce overhead in case of multiple timers.
- Parameters
-
- Returns
- True when active.
◆ disable()
void sf::IntervalTimer::disable |
( |
| ) |
|
|
inline |
◆ enable()
void sf::IntervalTimer::enable |
( |
| ) |
|
|
inline |
Enables the timer with the current interval time.
◆ getInterval()
const TimeSpec & sf::IntervalTimer::getInterval |
( |
| ) |
const |
|
inline |
Gets the set interval time in TimeSpec format.
- Returns
- Interval time.
◆ getTarget()
const TimeSpec & sf::IntervalTimer::getTarget |
( |
| ) |
const |
|
inline |
Gets the set interval time in TimeSpec format.
- Returns
- Interval time.
◆ getTimeLeft() [1/2]
TimeSpec sf::IntervalTimer::getTimeLeft |
( |
| ) |
const |
Gets the time left in msec before function active becomes true.
- Returns
- Time left.
◆ getTimeLeft() [2/2]
TimeSpec sf::IntervalTimer::getTimeLeft |
( |
const timespec & |
t | ) |
const |
Gets the time left in TimeSpec format before function active becomes true.
- Parameters
-
- Returns
- Time left.
◆ getTimeOver() [1/2]
TimeSpec sf::IntervalTimer::getTimeOver |
( |
| ) |
const |
Same as time left, but it also gives the time passed the target time and before that as a negative value.
- Returns
- Time over value.
◆ getTimeOver() [2/2]
TimeSpec sf::IntervalTimer::getTimeOver |
( |
const timespec & |
t | ) |
const |
Same as time left, but it also gives the time passed the target time and before that as a negative value.
- Parameters
-
- Returns
- Time over value.
◆ isEnabled()
bool sf::IntervalTimer::isEnabled |
( |
| ) |
const |
|
inline |
Gets timer enabled.
- Returns
- True on enabled.
◆ operator bool()
sf::IntervalTimer::operator bool |
( |
| ) |
const |
|
inlineexplicit |
Test operator.
Used in if and while statements.
◆ operator()()
bool sf::IntervalTimer::operator() |
( |
const timespec & |
t | ) |
const |
|
inline |
This operator is used to minimize clock() calls by passing the value itself.
- Parameters
-
- Returns
- True if timer is active.
◆ set()
void sf::IntervalTimer::set |
( |
const timespec & |
t | ) |
|
Sets the timers interval time.
When zero is passed it is always active.
The documentation for this class was generated from the following file: