X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FTimer.cc;fp=src%2FMoof%2FTimer.cc;h=d17882a9b3e5b13645e75d91650febedb074293f;hp=d28d5e89fd9d8ef39b379459a0b3a51b6009de3f;hb=a31d65a998121df0651c57bfb68782e2a07d2e2f;hpb=31d52677b38d935297d132bdbd956c655cd3feee diff --git a/src/Moof/Timer.cc b/src/Moof/Timer.cc index d28d5e8..d17882a 100644 --- a/src/Moof/Timer.cc +++ b/src/Moof/Timer.cc @@ -59,43 +59,43 @@ void Timer::init(const Function& function, Scalar seconds, Mode mode) { invalidate(); - mode_ = mode; + mMode = mode; - if (mode_ != INVALID) + if (mMode != INVALID) { - function_ = function; + mFunction = function; if (mode == ABSOLUTEE) { - absolute_ = seconds; + mAbsolute = seconds; } else { - absolute_ = seconds - getTicks(); - interval_ = seconds; + mAbsolute = seconds - getTicks(); + mInterval = seconds; } - id_ = getNewID(); - timers_.insert(std::pair(id_, *this)); + mId = getNewID(); + timers_.insert(std::pair(mId, *this)); - if (absolute_ < nextFire_) nextFire_ = absolute_; + if (mAbsolute < nextFire_) nextFire_ = mAbsolute; } } bool Timer::isValid() const { - return mode_ != INVALID; + return mMode != INVALID; } void Timer::invalidate() { - if (mode_ != INVALID) + if (mMode != INVALID) { - timers_.erase(id_); - mode_ = INVALID; + timers_.erase(mId); + mMode = INVALID; - if (isEqual(absolute_, nextFire_)) nextFire_ = findNextFire(); + if (isEqual(mAbsolute, nextFire_)) nextFire_ = findNextFire(); } } @@ -104,14 +104,14 @@ void Timer::fire() { Scalar t = getTicks(); - if (function_) function_(*this, t); + if (mFunction) mFunction(*this, t); if (isRepeating()) { - Scalar absolute = absolute_; + Scalar absolute = mAbsolute; - if (isEqual(absolute_, t, 1.0)) absolute_ += interval_; - else absolute_ = interval_ + t; + if (isEqual(mAbsolute, t, 1.0)) mAbsolute += mInterval; + else mAbsolute = mInterval + t; if (isEqual(absolute, nextFire_)) nextFire_ = findNextFire(); } @@ -129,7 +129,7 @@ Scalar Timer::findNextFire() for (it = timers_.begin(); it != timers_.end(); ++it) { - Scalar absolute = (*it).second.absolute_; + Scalar absolute = (*it).second.mAbsolute; if (absolute < nextFire) nextFire = absolute; } @@ -139,7 +139,7 @@ Scalar Timer::findNextFire() Scalar Timer::getSecondsRemaining() const { - return absolute_ - getTicks(); + return mAbsolute - getTicks(); } bool Timer::isExpired() const @@ -149,7 +149,7 @@ bool Timer::isExpired() const bool Timer::isRepeating() const { - return mode_ == REPEAT; + return mMode == REPEAT; }