#include <Timer.h>
Inheritance diagram for Odyssey::Timer:

Public Types | |
| typedef std::set< TimerListener * > | ListenerSet |
| typedef ContainerIterator< ListenerSet > | ListenerIterator |
| typedef std::pair< float32, TimerEventListener * > | EventPair |
| typedef std::list< EventPair > | EventQueue |
Public Member Functions | |
| Timer () | |
| Constructs a new, empty timer. | |
| virtual | ~Timer () |
| void | reset () |
| Reset the timer, including its internal timing info and counters. | |
| void | tick () |
| Updates the internal counters with the time since the last tick/reset. | |
| float32 | getDeltaTime () const |
| Returns the time between the last tick/resets. | |
| float64 | getTotalTime () const |
| Returns the total time since the last reset. | |
| void | setScale (float32 scale) |
| Sets time scaling. This scales the delta times recorded. | |
| float32 | getScale () const |
| Returns the current time scaling value. | |
| void | setActive (bool active=true) |
| Sets the active state of the timer. | |
| bool | getActive () const |
| Returns the current active state. | |
| void | addTimerListener (TimerListener *listener) |
| Adds a new callback to be updated during timer operations. | |
| void | removeTimerListener (TimerListener *listener) |
| Removes a registered callback listener. | |
| void | _fireTickEvent (float32 time) const |
| Internal method for firing a timer tick event. | |
| void | _fireResetEvent () const |
| Internal method for firing a reset timer event. | |
| void | addEvent (float32 delta, TimerEventListener *listener) |
| Adds a new event to the timer. | |
| void | clearEvents () |
| Removes all of the previously registered events. | |
Protected Attributes | |
| bool | _active |
| float32 | _delta |
| float32 | _scale |
| float64 | _total |
| bool | _perfCounter |
| int64 | _freq |
| union { | |
| int64 _count64 | |
| int32 _count32 | |
| } | _count |
| ListenerSet | _listeners |
| EventQueue | _events |
This class is able to track timing information with very high precision. It also supports callbacks as well as events that are tied with expired time.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Constructs a new, empty timer.
|
|
|
|
|
|
Internal method for firing a reset timer event.
|
|
|
Internal method for firing a timer tick event.
|
|
||||||||||||
|
Adds a new event to the timer. Events are stored in a queue. The delta parameter refers to the time until the event occur. When an event is triggered the event is destroyed. This means that events are one-time. In order to have repeating events (e.g. every 1 second) you need to re-register the event each time.
|
|
|
Adds a new callback to be updated during timer operations.
|
|
|
Removes all of the previously registered events.
|
|
|
Returns the current active state.
|
|
|
Returns the time between the last tick/resets.
|
|
|
Returns the current time scaling value.
|
|
|
Returns the total time since the last reset.
|
|
|
Removes a registered callback listener.
|
|
|
Reset the timer, including its internal timing info and counters. This performs a fill reset, which means both the counters and the timing info used internally is reset and reaquired. |
|
|
Sets the active state of the timer. An inactive timer does nothing when tick is called. Internal counters aren't updated, no callbacks are called, and no events are triggered. |
|
|
Sets time scaling. This scales the delta times recorded.
|
|
|
Updates the internal counters with the time since the last tick/reset. This is the counting function, which will update the internal counters with the passage of time. This function also calls the callbacks that are registered as well as handling time-based events. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.4.6-NO