Public Member Functions | Static Public Member Functions | Protected Attributes | Friends

sp::io::Timer Class Reference

#include <spTimer.hpp>

List of all members.

Public Member Functions

 Timer (u64 Duration=0)
 Timer (bool UseFrequenceQuery)
virtual ~Timer ()
void start (u64 Duration)
 Starts the stop watch with the given duration.
void stop ()
 Stops the stop watch.
void pause (bool isPaused=true)
 Pauses the stop watch.
void reset ()
 Resets the stop watch and uses the same duration as before.
bool finish ()
 Returns true if the timer has finished.
u64 getElapsedMicroseconds ()
void resetClockCounter ()
f64 getCurrentFPS ()
bool paused () const
 Returns true if the timer was paused.

Static Public Member Functions

static u64 microsecs ()
static u64 millisecs ()
 Returns the count of elapsed milliseconds since your computer started.
static u64 secs ()
 Returns the count of elapsed seconds since your computer started.
static u32 getTime (const ETimeTypes Type)
 Returns the specified time value.
static io::stringc getTime ()
 Returns current time as a string in the form "DD/MM/YYYY HH:MM:SS" (e.g. "03/01/2008 15:23:46").
static f64 getFPS ()
static u32 getElapsedFrames (u64 Duration=1000)
static void setGlobalSpeedEnable (bool Enable)
static bool getGlobalSpeedEnable ()
 Returbs the global speed adjustment. By default enabled.
static void setGlobalSpeedMultiplier (f32 Factor)
static f32 getGlobalSpeedMultiplier ()
 Returbs the global speed multiplier. By default 1.0.
static f32 getGlobalSpeed ()
static u64 convertDuration (u64 Duration)
static void sleep (u32 Milliseconds)
 Waits for the specified time.
static void yield ()
 Waits for 1 millisecond to give other processes time to run. This can be used in multi-threading.

Protected Attributes

u64 StartTime_
u64 EndTime_
u64 TimeOut_
u64 Duration_

Friends

class sp::SoftPixelDevice

Detailed Description

The Timer class can be used as stop watch or just to have simple time access.

Since:
Version 3.2

Constructor & Destructor Documentation

sp::io::Timer::Timer ( u64  Duration = 0  ) 
sp::io::Timer::Timer ( bool  UseFrequenceQuery  ) 
sp::io::Timer::~Timer (  )  [virtual]

Member Function Documentation

u64 sp::io::Timer::convertDuration ( u64  Duration  )  [static]

Converts the given duration when the 'global speed multiplier' is enabled.

Returns:
Converted duration. When the multiplier is 2.0 the return value of 1000 milliseconds is 500. When the multiplier is 0.25 the return value of 1000 milliseconds is 4000.
bool sp::io::Timer::finish (  ) 

Returns true if the timer has finished.

f64 sp::io::Timer::getCurrentFPS (  ) 

Returns the statistic count of frames per seconds.

Note:
This can only be used if this timer was created with a frequence query. Otherwise the function will always return 60.
        io::Timer timer(true);
        // ...
        f64 fps = timer.getCurrentFPS();
See also:
getElapsedMicroseconds
u32 sp::io::Timer::getElapsedFrames ( u64  Duration = 1000  )  [static]

Returns the count of frame since the elapsed second.

Parameters:
Duration,: Specifies the duration after which the elapsed frames will be updated.
Note:
Call this function only once in each frame!
u64 sp::io::Timer::getElapsedMicroseconds (  ) 

Returns the elapsed microseconds since the last reset or creation time.

Note:
This can only be used if this timer was created with a frequence query.
See also:
resetClockCounter
f64 sp::io::Timer::getFPS (  )  [static]

Returns the statistic count of frames per seconds.

Parameters:
UpdateFrameRate,: Specifies the count of frames which need to elapse before the new FPS value will be computed (e.g. 5 is a good value).
Returns:
Frames per second as double precision floating point (statistic value).
f32 sp::io::Timer::getGlobalSpeed (  )  [static]

Returns the global speed. When the global FPS is 60.0 this value is 1.0. This the global FPS value is greater the return value is smaller. This is used that animations and other scene movements look always the same regardless of FPS.

See also:
getFPS
bool sp::io::Timer::getGlobalSpeedEnable (  )  [static]

Returbs the global speed adjustment. By default enabled.

f32 sp::io::Timer::getGlobalSpeedMultiplier (  )  [static]

Returbs the global speed multiplier. By default 1.0.

u32 sp::io::Timer::getTime ( const ETimeTypes  Type  )  [static]

Returns the specified time value.

io::stringc sp::io::Timer::getTime (  )  [static]

Returns current time as a string in the form "DD/MM/YYYY HH:MM:SS" (e.g. "03/01/2008 15:23:46").

u64 sp::io::Timer::microsecs (  )  [static]

Returns the count of elapsed microseconds since your computer started.

Note:
This is actually only supported for Linux systems. For Windows you can use "getElapsedMicroseconds".
See also:
getElapsedMicroseconds
u64 sp::io::Timer::millisecs (  )  [static]

Returns the count of elapsed milliseconds since your computer started.

void sp::io::Timer::pause ( bool  isPaused = true  ) 

Pauses the stop watch.

bool sp::io::Timer::paused (  )  const [inline]

Returns true if the timer was paused.

void sp::io::Timer::reset (  ) 

Resets the stop watch and uses the same duration as before.

void sp::io::Timer::resetClockCounter (  ) 

Resets the clock counter which is used get the elapsed microseconds.

See also:
getElapsedMicroseconds
u64 sp::io::Timer::secs (  )  [static]

Returns the count of elapsed seconds since your computer started.

void sp::io::Timer::setGlobalSpeedEnable ( bool  Enable  )  [static]

Enables the global speed adjustment. By default enabled.

See also:
getGlobalSpeed
void sp::io::Timer::setGlobalSpeedMultiplier ( f32  Factor  )  [static]

Sets the global speed multiplier. By default 1.0. If you want that all animations etc. run faster, increase this value.

See also:
getGlobalSpeed
void sp::io::Timer::sleep ( u32  Milliseconds  )  [static]

Waits for the specified time.

void sp::io::Timer::start ( u64  Duration  ) 

Starts the stop watch with the given duration.

void sp::io::Timer::stop (  ) 

Stops the stop watch.

static void sp::io::Timer::yield (  )  [inline, static]

Waits for 1 millisecond to give other processes time to run. This can be used in multi-threading.


Friends And Related Function Documentation

friend class sp::SoftPixelDevice [friend]

Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines