jabyengine/include/PSX/Timer/timer.hpp

35 lines
825 B
C++

#ifndef __JABYENGINE_TIMER_HPP__
#define __JABYENGINE_TIMER_HPP__
#include "../jabyengine_defines.h"
namespace JabyEngine {
class GlobalTime {
public:
class TimeStamp {
private:
size_t value;
constexpr TimeStamp(size_t value) : value(value) {}
public:
constexpr size_t milliseconds_to(const TimeStamp& ts) const {
return (ts.value - this->value)*10;
}
friend class GlobalTime;
};
private:
static volatile size_t global_counter;
public:
GlobalTime() = delete;
~GlobalTime() = delete;
static TimeStamp get_time_stamp() {
return TimeStamp(GlobalTime::global_counter);
}
};
}
#endif //!__JABYENGINE_TIMER_HPP__