summary refs log blame commit diff stats
path: root/src/timer.h
blob: ec34f3ebb389be928eca806dfe5e27e2d7660cd9 (plain) (tree)






























                                                   
#ifndef TIMER_H_45E2F1F9
#define TIMER_H_45E2F1F9

class Timer {
public:

  Timer(int dt) : dt_(dt) {}

  void accumulate(int t) {
    acc_ += t;
  }

  bool step() {
    if (acc_ > dt_) {
      acc_ -= dt_;
      return true;
    } else {
      return false;
    }
  }

  void reset() {
    acc_ = 0;
  }

private:

  int dt_;
  int acc_ = 0;
};

#endif /* end of include guard: TIMER_H_45E2F1F9 */