summary refs log blame commit diff stats
path: root/src/timer.h
blob: 65d5a50d72c08d3b2b6341f96c784265f0a0b348 (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;
  }

  int getDt() const { return dt_; }

private:

  int dt_;
  int acc_ = 0;
};

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