Clock Class Reference
#include <Clock.h>
Description
Timing class with millisecond resolution.
The setup is made to be very much like a stopwatch.
Supported Component events:
- clock-step: Called every step when the clock is active.
- clock-draw: Called every draw when the clock is active.
- clock-expire: Called when the clock expires
Functions | |
Clock () | |
int | GetTimeSince () |
int | GetTimeLeft () |
int | GetDuration () |
void | Set (int msToExpire=-1) |
void | Reset () |
void | Pause () |
void | Resume () |
bool | IsExpired () |
bool | IsPaused () |
std::string | GetInfo () |
![]() | |
std::string | GetTag () |
Entity * | GetHost () const |
template<typename T > | |
T * | GetHostAs () const |
Entity::ID | GetHostID () const |
bool | EmitEvent (const std::string &eventName, Entity::ID source=Entity::ID(), const std::vector< std::string > &args={}) |
bool | CanHandleEvent (const std::string &eventName) |
void | InstallHook (const std::string &eventName, EventHandler, void *data=nullptr) |
void | UninstallHook (const std::string &eventName, EventHandler) |
void | InstallHandler (const std::string &eventName, EventHandler, void *data=nullptr) |
void | UninstallHandler (const std::string &eventName, EventHandler) |
std::vector< std::string > | GetKnownEvents () const |
Additional Inherited Members | |
![]() | |
using | EventHandler = bool(*)(void *, Component *component, Entity::ID self, Entity::ID source, const std::vector< std::string > &args) |
![]() | |
virtual void | OnAttach () |
void | InstallEvent (const std::string &eventName, EventHandler mainHandler=nullptr, void *data=nullptr) |
void | UninstallEvent (const std::string &) |
Constructor & Destructor Documentation
Clock | ( | ) |
Initializes the timer with no expiration time.
Member Function Documentation
int GetTimeSince | ( | ) |
Returns the ms since the start of timing.
int GetTimeLeft | ( | ) |
Returns the ms until the timer expires.
int GetDuration | ( | ) |
Returns the duration of the clock.
void Set | ( | int | msToExpire = -1 | ) |
Resets the timer with the time it should expire.
void Reset | ( | ) |
Resets the timer with the previously used time limit.
void Pause | ( | ) |
Pauses timing.
void Resume | ( | ) |
Resumes timing.
bool IsExpired | ( | ) |
Returns whether or not time has run out on the timer.
If there is no time limit, it will always return false.
bool IsPaused | ( | ) |
Returns whether or not this time is paused.
|
virtual |
Returns a string containing human-readable information on the state of the component.
Reimplemented from Component.
The documentation for this class was generated from the following file:
- /home/jc/git/Dynacoe/DynacoeSrc/includes/Dynacoe/Components/Clock.h