add accessor functions and default constructor to WeekCron
authorGerd von Egidy <gerd.von.egidy@intra2net.com>
Tue, 3 Feb 2009 11:00:41 +0000 (12:00 +0100)
committerGerd von Egidy <gerd.von.egidy@intra2net.com>
Tue, 3 Feb 2009 11:00:41 +0000 (12:00 +0100)
src/cron.cpp
src/cron.hpp

index ee63c23..6ccb234 100644 (file)
@@ -18,6 +18,17 @@ namespace Time {
 const time_t WeekCron::StNimmerleinsDay = static_cast<time_t>(-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
index 4563ae4..791a08f 100644 (file)
@@ -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;