Timer Class Reference
[Miscellaneous Tools]

Implement a passive timer, with time accuracy in seconds.You have to start, stop, restart, and check the remaining time yourself. The timer can be paused, then re-started. More...

#include <Timer.hh>

List of all members.

Public Member Functions

 Timer (int allowed_time)
void setAllowedTime (int allowed_time)
 Set the maximum allowed time, in second.
int getAllowedTime () const
 Get the allowed time.
int getTimeRemaining () const
 Get the remaining time, in seconds.
bool isTimeElapsed () const
 Check is the time is elapsed.
bool isPaused () const
 Check if the timer is paused.
void start ()
 Start the timer.
void stop ()
 Stop the timer.
void restart ()
 Restart the timer. This is equivalent to calling stop then start.
void pause ()
 Do a pause.

Detailed Description

Implement a passive timer, with time accuracy in seconds.

You have to start, stop, restart, and check the remaining time yourself. The timer can be paused, then re-started.

Currently, the timer has a second precision. Something more accurate (ie milliseconds) should be implemented, but for the time being this ssufficient.

Author:
victor
Date:
28/01/2006

Member Function Documentation

int Timer::getTimeRemaining (  )  const

Get the remaining time, in seconds.

Note:
If called when the timer is stopped, it will return a high value (> 0).

Referenced by SMatch::checkForCurrentOpponentChoice(), isTimeElapsed(), Api::remainingTime(), and SMatch::waitForCurrentOpponentChoice().

bool Timer::isPaused (  )  const

Check if the timer is paused.

Note:
If called when the timer is stopped, it will return false.

Referenced by SMatch::checkForCurrentOpponentChoice(), Api::isTimerPaused(), and SMatch::waitForCurrentOpponentChoice().

bool Timer::isTimeElapsed (  )  const

Check is the time is elapsed.

Note:
If called when the timer is stopped, it will return false.

References getTimeRemaining().

Referenced by SRules::serverProcess().

void Timer::pause (  ) 

Do a pause.

Note:
To restart at the current position, call start, not restart.

Referenced by SMatch::waitForCurrentOpponentChoice().

void Timer::setAllowedTime ( int  allowed_time  ) 

Set the maximum allowed time, in second.

Note:
This function does nothing if the timer is started.

The documentation for this class was generated from the following files:
Generated on Mon Apr 5 21:17:50 2010 for Stechec/TBT by  doxygen 1.6.3