mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-11-25 19:55:54 +01:00
24cb244d43
This was a _ton_ of changes, made 15 years ago, so there are probably some problems to work out still. Among others: Engine/Base/Stream.* was mostly abandoned and will need to be re-ported. Still, this is a pretty good start, and probably holds a world record for lines of changes or something. :)
58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
#ifndef SE_INCL_TIMER_INL
|
|
#define SE_INCL_TIMER_INL
|
|
#ifdef PRAGMA_ONCE
|
|
#pragma once
|
|
#endif
|
|
|
|
/* Constructor from seconds. */
|
|
inline CTimerValue::CTimerValue(double fSeconds)
|
|
{
|
|
tv_llValue = (__int64) (fSeconds*_pTimer->tm_llPerformanceCounterFrequency);
|
|
}
|
|
/* Clear timer value (set it to zero). */
|
|
inline void CTimerValue::Clear(void)
|
|
{
|
|
tv_llValue = 0;
|
|
}
|
|
/* Addition. */
|
|
inline CTimerValue &CTimerValue::operator+=(const CTimerValue &tvOther) {
|
|
tv_llValue+=tvOther.tv_llValue;
|
|
return *this;
|
|
};
|
|
inline CTimerValue CTimerValue::operator+(const CTimerValue &tvOther) const {
|
|
return CTimerValue(*this)+=tvOther;
|
|
};
|
|
/* Substraction. */
|
|
inline CTimerValue &CTimerValue::operator-=(const CTimerValue &tvOther) {
|
|
tv_llValue-=tvOther.tv_llValue;
|
|
return *this;
|
|
};
|
|
inline CTimerValue CTimerValue::operator-(const CTimerValue &tvOther) const {
|
|
return CTimerValue(*this)-=tvOther;
|
|
};
|
|
/* Comparisons. */
|
|
inline BOOL CTimerValue::operator<(const CTimerValue &tvOther) const {
|
|
return tv_llValue<tvOther.tv_llValue;
|
|
}
|
|
inline BOOL CTimerValue::operator>(const CTimerValue &tvOther) const {
|
|
return tv_llValue>tvOther.tv_llValue;
|
|
}
|
|
inline BOOL CTimerValue::operator<=(const CTimerValue &tvOther) const {
|
|
return tv_llValue<=tvOther.tv_llValue;
|
|
}
|
|
inline BOOL CTimerValue::operator>=(const CTimerValue &tvOther) const {
|
|
return tv_llValue>=tvOther.tv_llValue;
|
|
}
|
|
/* Get the timer value in seconds. - use for time spans only! */
|
|
inline double CTimerValue::GetSeconds(void) {
|
|
return ((double)tv_llValue)/_pTimer->tm_llPerformanceCounterFrequency;
|
|
};
|
|
/* Get the timer value in milliseconds as integral value. */
|
|
inline __int64 CTimerValue::GetMilliseconds(void) {
|
|
return tv_llValue/(_pTimer->tm_llPerformanceCounterFrequency/1000);
|
|
};
|
|
|
|
|
|
#endif /* include-once check. */
|
|
|