Spore ModAPI  2.4.0
API for creating C++ mods for Spore
Public Types | Public Member Functions | Protected Attributes | List of all members
Clock Class Reference

A class used for measuring time. More...

#include <Clock.h>

Public Types

enum  Mode {
  Mode::Ticks = 0, Mode::ProcessorTimeStamp = 1, Mode::Nanoseconds = 2, Mode::Microseconds = 3,
  Mode::Milliseconds = 4, Mode::Seconds = 5, Mode::Minutes = 6
}
 

Public Member Functions

 Clock (Clock::Mode mode=Clock::Mode::Ticks, bool bStart=false)
 Creates a new clock object with the specified precision mode. More...
 
void SetMode (Clock::Mode mode)
 Changes the precision mode. More...
 
void Start ()
 Starts the clock, measuring the initial time; if it has already been started, does nothing. More...
 
void Stop ()
 Stops the clock, reseting the initial time to 0. More...
 
float GetElapsed ()
 Returns the elapsed time in the specified precision measure, conserving all decimals. More...
 
LARGE_INTEGER GetElapsedTicks ()
 Returns the elapsed time in ticks (regardles of the clock mode). More...
 
LARGE_INTEGER GetElapsedTime ()
 Returns the elapsed time in the specified precision measure, rounded to the closest integer. More...
 

Protected Attributes

LARGE_INTEGER mStartTime
 
LARGE_INTEGER field_8
 
Clock::Mode mMode
 The mode (precision) with which the time is measured. More...
 
float mfMeasurePerTick
 Derived from mMode, how many units of measurement (seconds, nanoseconds, etc) are equal to 1 tick. More...
 

Detailed Description

A class used for measuring time.

It supports multiple precisions expressed in the enum Clock::Mode: minutes, seconds, milliseconds, microseconds, nanoseconds, ticks and nanoseprocessor time stamp. In order to use a clock, first you have to start it with the Clock::Start() method. Then just use the Clock::GetElapsed() method (or its variants) to get the elapsed time since the clock was started. In order to reset the counter, you must use Clock::Stop() and then you can start the clock again.

Member Enumeration Documentation

◆ Mode

enum Clock::Mode
strong
Enumerator
Ticks 

Uses QueryPerformanceCounter to measure time (in ticks).

ProcessorTimeStamp 

Uses __rdtsc (Read Time Stamp Counter) to get the current time (in ticks?), instead of QueryPerformanceCounter.

Nanoseconds 

Measures the time with nanosecond precision (1 second = 10e9 nanoseconds).

Uses QueryPerformanceCounter to measure time.

Microseconds 

Measures the time with microsecond precision (1 second = 10e6 microseconds).

Uses QueryPerformanceCounter to measure time.

Milliseconds 

Measures the time with milliseconds precision (1 second = 10e3 milliseconds).

Uses QueryPerformanceCounter to measure time.

Seconds 

Measures the time with seconds precision.

Uses QueryPerformanceCounter to measure time.

Minutes 

Measures the time with minute precision (60 seconds = 1 minute).

Uses QueryPerformanceCounter to measure time.

Constructor & Destructor Documentation

◆ Clock()

Clock::Clock ( Clock::Mode  mode = Clock::Mode::Ticks,
bool  bStart = false 
)

Creates a new clock object with the specified precision mode.

Optionally, you can make the clock start counting.

Parameters
modeThe precision with which the clock will measure time.
bStart[Optional] If true, the clock will start counting time. False by default.

Member Function Documentation

◆ GetElapsed()

float Clock::GetElapsed ( )
inline

Returns the elapsed time in the specified precision measure, conserving all decimals.

◆ GetElapsedTicks()

LARGE_INTEGER Clock::GetElapsedTicks ( )

Returns the elapsed time in ticks (regardles of the clock mode).

◆ GetElapsedTime()

LARGE_INTEGER Clock::GetElapsedTime ( )

Returns the elapsed time in the specified precision measure, rounded to the closest integer.

◆ SetMode()

void Clock::SetMode ( Clock::Mode  mode)

Changes the precision mode.

Parameters
modeThe precision with which the clock will measure time.

◆ Start()

void Clock::Start ( )
inline

Starts the clock, measuring the initial time; if it has already been started, does nothing.

◆ Stop()

void Clock::Stop ( )

Stops the clock, reseting the initial time to 0.

After using stop, the clock can be started again using Clock::Start().

Member Data Documentation

◆ field_8

LARGE_INTEGER Clock::field_8
protected

◆ mfMeasurePerTick

float Clock::mfMeasurePerTick
protected

Derived from mMode, how many units of measurement (seconds, nanoseconds, etc) are equal to 1 tick.

◆ mMode

Clock::Mode Clock::mMode
protected

The mode (precision) with which the time is measured.

◆ mStartTime

LARGE_INTEGER Clock::mStartTime
protected

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