Bromeon
Public Types | Public Member Functions
thor::TriggeringTimer Class Reference

Advanced timer with the ability to trigger function calls. More...

Inheritance diagram for thor::TriggeringTimer:
Inheritance graph

List of all members.

Public Types

typedef std::tr1::function
< void(TriggeringTimer &) > 
Listener
 Callback type for events being processed by TriggeringTimer.

Public Member Functions

 TriggeringTimer ()
 Default constructor: Creates an TriggeringTimer that is initially expired.
 TriggeringTimer (sf::Time timeLimit, bool initiallyRunning=false)
 Constructor: Sets up a new Timer with the given time limit.
virtual void Reset (sf::Time timeLimit, bool restart=false)
 Resets the timer's countdown to the given time limit.
void Update ()
 Trigger listeners, if expired.
Connection Connect (const Listener &listener)
 Registers a function which will be called when the time reaches zero.
void ClearConnections ()
 Removes all currently associated timer listeners.
sf::Time GetRemainingTime () const
 Returns the remaining time.
bool IsRunning () const
 Checks if the timer is currently running.
bool IsExpired () const
 Checks if the timer has expired yet.
void Start ()
 Starts or continues the timer.
void Stop ()
 Pauses the timer.

Detailed Description

Advanced timer with the ability to trigger function calls.

Clock class that counts time down. As an extension of Timer, this class is able to register functions that are called at expiration time.


Constructor & Destructor Documentation

Default constructor: Creates an TriggeringTimer that is initially expired.

You have to call Reset() before you can use the countdown functionality.

thor::TriggeringTimer::TriggeringTimer ( sf::Time  timeLimit,
bool  initiallyRunning = false 
) [explicit]

Constructor: Sets up a new Timer with the given time limit.

Parameters:
timeLimitThe initial time (must be greater than zero).
initiallyRunningIndicates whether the timer is immediately being started.

Member Function Documentation

Removes all currently associated timer listeners.

This also invalidates all connections to those listeners.

Registers a function which will be called when the time reaches zero.

Make sure to call Update() each frame to invoke potential listeners.

Parameters:
listenerThe function you want to associate with the timer expiration.
Returns:
Connection that can be used to disconnect the listener.
sf::Time thor::Timer::GetRemainingTime ( ) const [inherited]

Returns the remaining time.

If the timer has expired, sf::Time::Zero is returned.

bool thor::Timer::IsExpired ( ) const [inherited]

Checks if the timer has expired yet.

Timers expire when their remaining time reaches zero.

bool thor::Timer::IsRunning ( ) const [inherited]

Checks if the timer is currently running.

As soon as the timer expires, it stops running until Reset() is called.

virtual void thor::TriggeringTimer::Reset ( sf::Time  timeLimit,
bool  restart = false 
) [virtual]

Resets the timer's countdown to the given time limit.

Parameters:
timeLimitThe new time limit (must be greater than zero).
restartTrue when the timer continues to run, false if it waits for the next Start() call.

Reimplemented from thor::Timer.

void thor::Timer::Start ( ) [inherited]

Starts or continues the timer.

If it is already running, nothing happens.

void thor::Timer::Stop ( ) [inherited]

Pauses the timer.

If it is already paused, nothing happens.

Trigger listeners, if expired.

This is the most important function of this class. You should call Update() every frame (or, the better way, let this an automated routine do) to assure that all associated listeners are invoked when the timer expires.


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