Files

52 lines
803 B
C++
Raw Permalink Normal View History

2011-01-08 17:53:45 +01:00
#ifndef SCHEDULE_H_
#define SCHEDULE_H_
2018-11-26 13:15:41 +01:00
namespace gln {
2011-01-08 17:53:45 +01:00
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) {
2011-01-08 17:53:45 +01:00
}
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
2011-01-08 17:53:45 +01:00
#endif /* SCHEDULE_H_ */