# PSimpleTimer Class Reference

A class represeting a simple timer. More...

`#include <timer.h>`

Inheritance diagram for PSimpleTimer:

List of all members.

## 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.
void | Stop ()
| Stop the timer.
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

## Detailed Description

A class represeting a simple timer.

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(); }`

## Constructor & Destructor Documentation

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.

Parameters:

  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 | ) |

Parameters:

  time | New time interval for timer.

PSimpleTimer::PSimpleTimer | ( | const PSimpleTimer & | timer | ) |

Parameters:

  timer | Timer to copy.

## Member Function Documentation

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 | ) |

Parameters:

  timer | New time interval for timer.

PSimpleTimer& PSimpleTimer::operator= | ( | const PTimeInterval & | time | ) |

Parameters:

  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.

Returns:
  reference to the timer.

Parameters:

  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.

Parameters:

  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.

void PSimpleTimer::Stop | ( |  | ) |

Stop the timer.

## Member Data Documentation

PTimeInterval PSimpleTimer::m_startTick `[protected]`

The documentation for this class was generated from the following file:

- timer.h