gremlin/src/common/Schedule.h

52 lines
803 B
C
Raw Normal View History

#ifndef SCHEDULE_H_
#define SCHEDULE_H_
2018-11-26 13:15:41 +01:00
namespace gln {
class Schedule {
double last;
double interval;
bool exact;
bool paused;
public:
Schedule() :
2018-11-26 13:15:41 +01:00
last(0.0), interval(1.0), exact(true), paused(false) {
}
void init(double now) {
last = now;
}
void setInterval(double interval) {
this->interval = interval;
}
double getInterval() {
return interval;
}
void setExact(bool exact) {
this->exact = exact;
}
void setPaused(bool paused) {
this->paused = paused;
}
bool next(double now) {
if (now > (last + interval)) {
if (exact)
last += interval;
else
last = now;
if (paused)
return false;
else
return true;
} else {
return false;
}
}
};
2018-11-26 13:15:41 +01:00
} // namespace grln
#endif /* SCHEDULE_H_ */