#include <timer.h>
Inheritance diagram for PSimpleTimer:
Public Member Functions | |
Construction | |
PSimpleTimer (long milliseconds=0, int seconds=0, int minutes=0, int hours=0, int days=0) | |
Create a new timer object which will be expired the specified time interval after "now" in real time. | |
PSimpleTimer (const PTimeInterval &time) | |
PSimpleTimer (const PSimpleTimer &timer) | |
PSimpleTimer & | operator= (DWORD milliseconds) |
Restart the timer using the specified time value. | |
PSimpleTimer & | operator= (const PTimeInterval &time) |
PSimpleTimer & | operator= (const PSimpleTimer &timer) |
Control functions | |
virtual void | SetInterval (PInt64 milliseconds=0, long seconds=0, long minutes=0, long hours=0, int days=0) |
Set the value of the time interval. | |
PTimeInterval | GetElapsed () const |
Return the real time elapsed since instantiation. | |
PTimeInterval | GetRemaining () const |
Return the real time remaining before expiry. | |
bool | IsRunning () const |
Indicate timer has not expired. | |
bool | HasExpired () const |
Indicate timer has expired. | |
operator bool () const | |
Indicate timer has expired. | |
Protected Attributes | |
PTimeInterval | m_startTick |
Unlike the PTimer class this does not support call back operations, nor is it startable and stoppable. It is intended for very simple real time operations where an elapsed time from a starting point is required. For example:
PSimpleTimer timeout(0, 10); // 10 seconds while (!timeout) { DoStuff(); }
PSimpleTimer::PSimpleTimer | ( | long | milliseconds = 0 , |
|
int | seconds = 0 , |
|||
int | minutes = 0 , |
|||
int | hours = 0 , |
|||
int | days = 0 | |||
) |
Create a new timer object which will be expired the specified time interval after "now" in real time.
milliseconds | Number of milliseconds for timer. |
seconds | Number of seconds for timer. |
minutes | Number of minutes for timer. |
hours | Number of hours for timer. |
days | Number of days for timer. |
PSimpleTimer::PSimpleTimer | ( | const PTimeInterval & | time | ) |
time | New time interval for timer. |
PSimpleTimer::PSimpleTimer | ( | const PSimpleTimer & | timer | ) |
timer | Timer to copy. |
PTimeInterval PSimpleTimer::GetElapsed | ( | ) | const |
Return the real time elapsed since instantiation.
PTimeInterval PSimpleTimer::GetRemaining | ( | ) | const |
Return the real time remaining before expiry.
bool PSimpleTimer::HasExpired | ( | ) | const |
Indicate timer has expired.
bool PSimpleTimer::IsRunning | ( | ) | const |
Indicate timer has not expired.
PSimpleTimer::operator bool | ( | ) | const |
Indicate timer has expired.
PSimpleTimer& PSimpleTimer::operator= | ( | const PSimpleTimer & | timer | ) |
timer | New time interval for timer. |
PSimpleTimer& PSimpleTimer::operator= | ( | const PTimeInterval & | time | ) |
time | New time interval for timer. |
PSimpleTimer& PSimpleTimer::operator= | ( | DWORD | milliseconds | ) |
Restart the timer using the specified time value.
It will be expired the specified time interval after "now" in real time.
milliseconds | New time interval for timer. |
virtual void PSimpleTimer::SetInterval | ( | PInt64 | milliseconds = 0 , |
|
long | seconds = 0 , |
|||
long | minutes = 0 , |
|||
long | hours = 0 , |
|||
int | days = 0 | |||
) | [virtual] |
Set the value of the time interval.
The time interval, in milliseconds, is the sum of all of the parameters. For example all of the following are equivalent:
SetInterval(120000)
SetInterval(60000, 60)
SetInterval(60000, 0, 1)
SetInterval(0, 60, 1)
SetInterval(0, 0, 2)
The timer will be expired the specified time interval after "now" in real time.
milliseconds | Number of milliseconds for interval. |
seconds | Number of seconds for interval. |
minutes | Number of minutes for interval. |
hours | Number of hours for interval. |
days | Number of days for interval. |
Reimplemented from PTimeInterval.
PTimeInterval PSimpleTimer::m_startTick [protected] |