X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FTimer.cc;fp=src%2Ftimer.cc;h=4eea488ad7f43d29af7280f63ea3371f2380f4b2;hp=d73d94f1bbedb7d11c0d9bc76a558a316d26d05c;hb=c2321281bf12a7efaedde930422c7ddbc92080d4;hpb=87bc17e55b0c1dc73ecc66df856d3f08fd7a7724 diff --git a/src/timer.cc b/src/Moof/Timer.cc similarity index 86% rename from src/timer.cc rename to src/Moof/Timer.cc index d73d94f..4eea488 100644 --- a/src/timer.cc +++ b/src/Moof/Timer.cc @@ -26,18 +26,18 @@ *******************************************************************************/ -#include -#include #include +#include +#include + +#include "Timer.hh" #if HAVE_CONFIG_H #include "config.h" #endif -#include "timer.hh" - -namespace dc { +namespace Mf { #if HAVE_CLOCK_GETTIME @@ -49,7 +49,7 @@ namespace dc { // program starts). Of course this isn't much of an issue if scalar is a // double-precision number. -static time_t setReference() +static time_t setReference_() { struct timespec ts; @@ -61,10 +61,10 @@ static time_t setReference() return ts.tv_sec; } -static const time_t reference = setReference(); +static const time_t reference = setReference_(); -scalar ticks() +Scalar getTicks() { struct timespec ts; @@ -73,7 +73,7 @@ scalar ticks() throw std::runtime_error("cannot access monotonic clock"); } - return scalar(ts.tv_sec - reference) + scalar(ts.tv_nsec) / 1000000000.0; + return Scalar(ts.tv_sec - reference) + Scalar(ts.tv_nsec) / 1000000000.0; } @@ -86,24 +86,24 @@ scalar ticks() #include -scalar ticks() +Scalar getTicks() { Uint32 ms = SDL_GetTicks(); - return scalar(ms / 1000) + scalar(ms % 1000) / 1000.0; + return Scalar(ms / 1000) + Scalar(ms % 1000) / 1000.0; } #endif // HAVE_CLOCK_GETTIME -void sleep(scalar seconds, bool absolute) +void sleep(Scalar seconds, bool absolute) { struct timespec ts; int ret; - if (absolute) seconds -= ticks(); + if (absolute) seconds -= getTicks(); ts.tv_sec = time_t(seconds); - ts.tv_nsec = long((seconds - scalar(ts.tv_sec)) * 1000000000.0); + ts.tv_nsec = long((seconds - Scalar(ts.tv_sec)) * 1000000000.0); do { @@ -113,7 +113,7 @@ void sleep(scalar seconds, bool absolute) } -} // namespace dc +} // namespace Mf /** vim: set ts=4 sw=4 tw=80: *************************************************/