Serious-Engine/Sources/Engine/Base/Timer.inl
Ryan C. Gordon 24cb244d43 First attempt to hand-merge Ryan's Linux and Mac OS X port.
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.  :)
2016-03-28 23:46:13 -04:00

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. */