57 lines
848 B
C++
57 lines
848 B
C++
/*
|
|
* Schedule.h
|
|
*
|
|
* Created on: 12.06.2010
|
|
* Author: gmueller
|
|
*/
|
|
|
|
#ifndef SCHEDULE_H_
|
|
#define SCHEDULE_H_
|
|
|
|
class Schedule {
|
|
double last;
|
|
double interval;
|
|
bool exact;
|
|
bool paused;
|
|
public:
|
|
Schedule() :
|
|
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;
|
|
}
|
|
}
|
|
};
|
|
#endif /* SCHEDULE_H_ */
|