Core/Clock: Add documentation
Former-commit-id: e55e7dff873349eb0cc26e6c364b0d5967c3149a
This commit is contained in:
parent
f71886e66d
commit
0f889a0140
|
|
@ -41,6 +41,18 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \class Nz::Clock
|
||||||
|
* \brief Utility class that measure the elapsed time
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a Clock object
|
||||||
|
*
|
||||||
|
* \param startingValue The starting time value, in microseconds
|
||||||
|
* \param paused The clock pause state
|
||||||
|
*/
|
||||||
|
|
||||||
Clock::Clock(UInt64 startingValue, bool paused) :
|
Clock::Clock(UInt64 startingValue, bool paused) :
|
||||||
m_elapsedTime(startingValue),
|
m_elapsedTime(startingValue),
|
||||||
m_refTime(GetElapsedMicroseconds()),
|
m_refTime(GetElapsedMicroseconds()),
|
||||||
|
|
@ -48,11 +60,25 @@ namespace Nz
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the elapsed time in seconds
|
||||||
|
* \return Seconds elapsed
|
||||||
|
*
|
||||||
|
* \see GetMicroseconds, GetMilliseconds
|
||||||
|
*/
|
||||||
|
|
||||||
float Clock::GetSeconds() const
|
float Clock::GetSeconds() const
|
||||||
{
|
{
|
||||||
return GetMicroseconds()/1000000.f;
|
return GetMicroseconds()/1000000.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the elapsed time in microseconds
|
||||||
|
* \return Microseconds elapsed
|
||||||
|
*
|
||||||
|
* \see GetMilliseconds, GetSeconds
|
||||||
|
*/
|
||||||
|
|
||||||
UInt64 Clock::GetMicroseconds() const
|
UInt64 Clock::GetMicroseconds() const
|
||||||
{
|
{
|
||||||
NazaraLock(m_mutex);
|
NazaraLock(m_mutex);
|
||||||
|
|
@ -64,11 +90,25 @@ namespace Nz
|
||||||
return elapsedMicroseconds;
|
return elapsedMicroseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the elapsed time in milliseconds
|
||||||
|
* \return Milliseconds elapsed
|
||||||
|
*
|
||||||
|
* \see GetMicroseconds, GetSeconds
|
||||||
|
*/
|
||||||
|
|
||||||
UInt64 Clock::GetMilliseconds() const
|
UInt64 Clock::GetMilliseconds() const
|
||||||
{
|
{
|
||||||
return GetMicroseconds()/1000;
|
return GetMicroseconds()/1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the current pause state of the clock
|
||||||
|
* \return Boolean indicating if the clock is currently paused
|
||||||
|
*
|
||||||
|
* \see Pause, Unpause
|
||||||
|
*/
|
||||||
|
|
||||||
bool Clock::IsPaused() const
|
bool Clock::IsPaused() const
|
||||||
{
|
{
|
||||||
NazaraLock(m_mutex);
|
NazaraLock(m_mutex);
|
||||||
|
|
@ -76,6 +116,15 @@ namespace Nz
|
||||||
return m_paused;
|
return m_paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Pause the clock
|
||||||
|
*
|
||||||
|
* Pauses the clock, making the time retrieving functions to always return the value at the time the clock was paused
|
||||||
|
* This has no effect if the clock is already paused
|
||||||
|
*
|
||||||
|
* \see IsPaused, Unpause
|
||||||
|
*/
|
||||||
|
|
||||||
void Clock::Pause()
|
void Clock::Pause()
|
||||||
{
|
{
|
||||||
NazaraLock(m_mutex);
|
NazaraLock(m_mutex);
|
||||||
|
|
@ -85,10 +134,13 @@ namespace Nz
|
||||||
m_elapsedTime += GetElapsedMicroseconds() - m_refTime;
|
m_elapsedTime += GetElapsedMicroseconds() - m_refTime;
|
||||||
m_paused = true;
|
m_paused = true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
NazaraWarning("Clock is already paused, ignoring...");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Restart the clock
|
||||||
|
* Restarts the clock, putting it's time counter back to zero (as if the clock got constructed).
|
||||||
|
*/
|
||||||
|
|
||||||
void Clock::Restart()
|
void Clock::Restart()
|
||||||
{
|
{
|
||||||
NazaraLock(m_mutex);
|
NazaraLock(m_mutex);
|
||||||
|
|
@ -98,6 +150,15 @@ namespace Nz
|
||||||
m_paused = false;
|
m_paused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Unpause the clock
|
||||||
|
*
|
||||||
|
* Unpauses the clock, making the clock continue to measure the time
|
||||||
|
* This has no effect if the clock is already unpaused
|
||||||
|
*
|
||||||
|
* \see IsPaused, Unpause
|
||||||
|
*/
|
||||||
|
|
||||||
void Clock::Unpause()
|
void Clock::Unpause()
|
||||||
{
|
{
|
||||||
NazaraLock(m_mutex);
|
NazaraLock(m_mutex);
|
||||||
|
|
@ -107,8 +168,6 @@ namespace Nz
|
||||||
m_refTime = GetElapsedMicroseconds();
|
m_refTime = GetElapsedMicroseconds();
|
||||||
m_paused = false;
|
m_paused = false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
NazaraWarning("Clock is not paused, ignoring...");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClockFunction GetElapsedMicroseconds = Detail::GetElapsedMicrosecondsFirstRun;
|
ClockFunction GetElapsedMicroseconds = Detail::GetElapsedMicrosecondsFirstRun;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue