2020-03-22 00:45:04 +01:00
|
|
|
#pragma once
|
2016-03-25 13:28:07 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-06-04 18:17:42 +02:00
|
|
|
#include "Library/Chrono.hpp"
|
2016-03-25 13:28:07 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class Timer
|
|
|
|
{
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
explicit Timer(int64_t t)
|
2016-03-25 13:28:07 +01:00
|
|
|
: m_Timestamp(t)
|
|
|
|
{
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timer();
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Timer(const Timer & o) = default;
|
2016-03-25 13:28:07 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
~Timer() = default;
|
2016-03-25 13:28:07 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timer & operator = (const Timer o)
|
|
|
|
{
|
|
|
|
m_Timestamp = o.m_Timestamp;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD int32_t Cmp(const Timer & b) const;
|
2016-03-25 13:28:07 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD String ToString() const;
|
2016-03-25 13:28:07 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp Restart();
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
int64_t RestartRaw();
|
2016-03-25 13:28:07 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD Timestamp GetElapsedTime() const;
|
2016-03-25 13:28:07 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD int64_t GetElapsedTimeRaw() const;
|
2016-03-25 13:28:07 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int64_t m_Timestamp;
|
2016-03-25 13:28:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|