X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Ftimer.hh;fp=src%2FMoof%2FTimer.hh;h=d7a411bc48e82089891795db5602d2cfb42e4326;hp=4cc848048c5655d38aabe2e89b47d9a9bc9669e4;hb=831f04d4bc19a390415ac0bbac4331c7a65509bc;hpb=299af4f2047e767e5d79501c26444473bda64c64 diff --git a/src/Moof/Timer.hh b/src/moof/timer.hh similarity index 55% rename from src/Moof/Timer.hh rename to src/moof/timer.hh index 4cc8480..d7a411b 100644 --- a/src/Moof/Timer.hh +++ b/src/moof/timer.hh @@ -13,7 +13,7 @@ #define _MOOF_TIMER_HH_ /** - * @file Timer.hh + * \file timer.hh * Functions for measuring time in a friendly unit. */ @@ -22,60 +22,58 @@ #include #include -#include +#include -namespace Mf { +namespace moof { -class Timer +class timer { public: - enum Mode + enum mode { - INVALID = -1, - NORMAL = 0, - ACTUAL = 1, - REPEAT = 2 + invalid = -1, + normal = 0, + absolute = 1, + repeat = 2 }; - typedef boost::function Function; + typedef boost::function function; - Timer() : - mMode(INVALID) {} + timer() : + mode_(invalid) {} - Timer(const Function& function, Scalar seconds, Mode mode = NORMAL) + timer(const function& function, scalar seconds, mode mode = normal) { init(function, seconds, mode); } - ~Timer() + ~timer() { invalidate(); } - void init(const Function& function, Scalar seconds, - Mode mode = NORMAL); + void init(const function& function, scalar seconds, mode mode = normal); - bool isValid() const; + bool is_valid() const; void invalidate(); void fire(); - Scalar getSecondsRemaining() const; - bool isExpired() const; - bool isRepeating() const; + scalar seconds_remaining() const; + bool is_expired() const; + bool is_repeating() const; /** * Get the number of seconds since a fixed, arbitrary point in the * past. - * @return Seconds. + * \return Seconds. */ - - static Scalar getTicks(); + static scalar ticks(); /** @@ -86,36 +84,38 @@ public: * sleep if sleep was interrupted by a signal. Therefore, calling this * function is guaranteed to sleep for the requested amount of time * (and maybe longer). + * \param seconds Number of seconds. + * \param mode The timer mode. */ - - static void sleep(Scalar seconds, Mode mode = NORMAL); + static void sleep(scalar seconds, mode mode = normal); - static Scalar getNextFire() + static scalar next_expiration() { return gNextFire; } - static void fireIfExpired(); - static void fireIfExpired(Scalar t); + static void fire_expired_timers(); + static void fire_expired_timers(scalar t); + private: - static unsigned getNewID(); - static Scalar findNextFire(); + static unsigned new_identifier(); + static scalar find_next_expiration(); - Function mFunction; - Mode mMode; - Scalar mAbsolute; - Scalar mInterval; - unsigned mId; + function function_; + mode mode_; + scalar absolute_; + scalar interval_; + unsigned id_; - static Scalar gNextFire; - static std::map gTimers; + static scalar gNextFire; + static std::map gTimers; }; -} // namespace Mf +} // namespace moof #endif // _MOOF_TIMER_HH_