From ab205aa338f1c5150a7974ce3c6b1748ff4a9aa6 Mon Sep 17 00:00:00 2001 From: Gerd von Egidy Date: Tue, 3 Feb 2009 12:00:41 +0100 Subject: [PATCH] add accessor functions and default constructor to WeekCron --- src/cron.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/cron.hpp | 21 +++++++++++++++++++++ 2 files changed, 59 insertions(+), 0 deletions(-) diff --git a/src/cron.cpp b/src/cron.cpp index ee63c23..6ccb234 100644 --- a/src/cron.cpp +++ b/src/cron.cpp @@ -18,6 +18,17 @@ namespace Time { const time_t WeekCron::StNimmerleinsDay = static_cast(-1); /** + * Constructor, leaves object in invalid state + */ +WeekCron::WeekCron() + : Begin(-1) + , End(0) + , Every(-1) + , Week() +{ +} + +/** * Constructor * @param daystring String representing the active weekdays as numbers. 0 is Sunday. * @param begin Start point of time in seconds since the start of the day @@ -45,6 +56,33 @@ WeekCron::WeekCron(const std::string& daystring, const int begin, const int end, { } +/** + * Constructor + * @param week I2n::Time::Week object representing the active days + * @param begin Start point of time in seconds since the start of the day + */ +WeekCron::WeekCron(const I2n::Time::Week& week, const int begin) + : Begin(begin) + , End(0) + , Every(-1) + , Week(week) +{ +} + +/** + * Constructor + * @param week I2n::Time::Week object representing the active days + * @param begin Start point of time in seconds since the start of the day + * @param end End point of time in seconds since the start of the day. Only used when every != -1 + * @param every Repeat event every xxx seconds in the half-open interval of begin and end. -1 is disabled + */ +WeekCron::WeekCron(const I2n::Time::Week& week, const int begin, const int end, const int every) + : Begin(begin) + , End(end) + , Every(every) + , Week(week) +{ +} /** * Checks if the input values are sane diff --git a/src/cron.hpp b/src/cron.hpp index 4563ae4..791a08f 100644 --- a/src/cron.hpp +++ b/src/cron.hpp @@ -40,8 +40,29 @@ class WeekCron time_t get_previousnow_point(const time_t calc_from, const int daysec, const bool todaycheck) 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) + { return Week; } + void set_week(const I2n::Time::Week& week) + { Week=week; } + int get_begin(void) + { return Begin; } + void set_begin(const int begin) + { Begin=begin; } + int get_end(void) + { return End; } + void set_end(const int end) + { End=end; } + int get_every(void) + { return Every; } + void set_every(const int every) + { Every=every; } bool is_sane() const; -- 1.7.1