/* The software in this package is distributed under the GNU General Public License version 2 (with a special exception described below). A copy of GNU General Public License (GPL) is included in this distribution, in the file COPYING.GPL. As a special exception, if other files instantiate templates or use macros or inline functions from this file, or you compile this file and link it with other works to produce a work based on this file, this file does not by itself cause the resulting work to be covered by the GNU General Public License. However the source code for this file must still be made available in accordance with section (3) of the GNU General Public License. This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. */ /** @file * @brief repeating time-points and intervals * * @copyright Copyright © 2009 by Intra2net AG * */ #ifndef __CRON_HPP #define __CRON_HPP #include #include namespace I2n { namespace Time { /** @brief Time points and intervals repeating each week This class represents recurring time points and intervals which can be repeated on configurable days of the week. */ class WeekCron { public: static const time_t StNimmerleinsDay; private: /// Start point of time in seconds since the start of the day int Begin; /// End point of time in seconds since the start of the day. Only used when #Every != -1 int End; /// Repeat event every xxx seconds in the half-open interval of #Begin and #End. -1 is disabled int Every; /// Stores the active days this WeekCron is valid for I2n::Time::Week Week; time_t get_next_point(const time_t calc_from, const int daysec, const bool todaycheck) const; time_t get_previousnow_point(const time_t calc_from, const int daysec, const bool todaycheck) const; void fill_tm_with_wallclock(struct tm *ft, const int daysec) const; public: WeekCron(); WeekCron(const std::string& daystring, const int begin); WeekCron(const std::string& daystring, const int begin, const int end, const int every); WeekCron(const I2n::Time::Week& week, const int begin); WeekCron(const I2n::Time::Week& week, const int begin, const int end, const int every); // accessor functions I2n::Time::Week get_week(void) const { return Week; } void set_week(const I2n::Time::Week& week) { Week=week; } int get_begin(void) const { return Begin; } void set_begin(const int begin) { Begin=begin; } int get_end(void) const { return End; } void set_end(const int end) { End=end; } int get_every(void) const { return Every; } void set_every(const int every) { Every=every; } bool is_sane() const; time_t get_next_run(time_t calc_from=0) const; }; } } #endif