Isle
Loading...
Searching...
No Matches
MxTimer Class Reference

Timer class for measuring elapsed time or frame time. More...

#include <mxtimer.h>

Inheritance diagram for MxTimer:
Collaboration diagram for MxTimer:

Public Member Functions

 MxTimer ()
 Constructs and initializes the timer to the current tick count, and resets static globals. More...
 
void Start ()
 Starts the timer and records the real time when started. More...
 
void Stop ()
 Stops the timer, updating internal counters to reflect elapsed time until now. More...
 
MxLong GetRealTime ()
 Retrieves the elapsed real time (in ms) since timer construction or last reset. More...
 
void InitLastTimeCalculated ()
 Initializes the static 'last time calculated' field to the timer's start time. More...
 
MxLong GetTime ()
 Returns the current timer value in ms, depending on running state. More...
 
- Public Member Functions inherited from MxCore
 MxCore ()
 [AI] Constructs a new MxCore object and assigns it a unique id. More...
 
virtual ~MxCore ()
 [AI] Virtual destructor. Required for correct polymorphic cleanup in derived classes. More...
 
virtual MxLong Notify (MxParam &p_param)
 [AI] Virtual callback notification mechanism. More...
 
virtual MxResult Tickle ()
 [AI] Called by tickle managers to allow the object to update itself. More...
 
virtual const char * ClassName () const
 [AI] Returns the runtime class name of this object. More...
 
virtual MxBool IsA (const char *p_name) const
 [AI] Checks whether this object's class type or parents match the given name. More...
 
MxU32 GetId ()
 [AI] Gets the unique (per-process) id assigned to this object instance. More...
 

Detailed Description

Timer class for measuring elapsed time or frame time.

[AI] Forward declaration for the central timer used for measuring and providing simulation time.

[AI]

[AI] MxTimer implements a timer utility based on timeGetTime (Windows tick count). It allows measuring elapsed times from a start point, pausing/resuming, and retrieving accumulated times in various formats. It maintains both per-instance state (timer started, running, etc.) and static global values for last calculated/started time. [AI]

Definition at line 14 of file mxtimer.h.

Constructor & Destructor Documentation

◆ MxTimer()

MxTimer::MxTimer ( )

Constructs and initializes the timer to the current tick count, and resets static globals.

[AI]

[AI] m_isRunning is initialized to FALSE, m_startTime is set to the OS tick count (timeGetTime), and g_lastTimeCalculated is set to m_startTime via InitLastTimeCalculated. [AI]

Definition at line 14 of file mxtimer.cpp.

Member Function Documentation

◆ GetRealTime()

MxLong MxTimer::GetRealTime ( )

Retrieves the elapsed real time (in ms) since timer construction or last reset.

[AI]

[AI] Updates g_lastTimeCalculated with the current OS tick (timeGetTime) and returns the difference from m_startTime. [AI]

Definition at line 23 of file mxtimer.cpp.

◆ GetTime()

MxLong MxTimer::GetTime ( )
inline

Returns the current timer value in ms, depending on running state.

[AI]

[AI] If the timer is running, returns g_lastTimeTimerStarted (static, records tick count at last Start); otherwise returns the difference between g_lastTimeCalculated and m_startTime (i.e., elapsed ticks so far). In BETA10, only the second branch is present. [AI]

Definition at line 50 of file mxtimer.h.

◆ InitLastTimeCalculated()

void MxTimer::InitLastTimeCalculated ( )
inline

Initializes the static 'last time calculated' field to the timer's start time.

[AI]

[AI] Used to synchronize the static counter (g_lastTimeCalculated) with the current timer's moment of construction or reset. [AI]

Definition at line 44 of file mxtimer.h.

◆ Start()

void MxTimer::Start ( )

Starts the timer and records the real time when started.

[AI]

[AI] Sets m_isRunning to TRUE and updates g_lastTimeTimerStarted with the elapsed time via GetRealTime. If already running, has no additional effect. [AI]

Definition at line 30 of file mxtimer.cpp.

◆ Stop()

void MxTimer::Stop ( )

Stops the timer, updating internal counters to reflect elapsed time until now.

[AI]

[AI] Sets m_isRunning to FALSE, and adjusts m_startTime so that future queries (while stopped) return the total elapsed time up to the call. Implementation is based on the difference between the real time and the last time the timer was started, with a slight adjustment (-5) for original engine logic. [AI]

Definition at line 37 of file mxtimer.cpp.


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