#ifndef SCHEDULE_H_
#define SCHEDULE_H_
namespace gln {

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;
		}
	}
};
} // namespace grln
#endif /* SCHEDULE_H_ */
