From 249bd63fe88f43032c2b21db45957671fcf317ed Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Wed, 28 Jan 2009 11:01:01 +0100 Subject: [PATCH] Add documentation, cosmetic changes --- doc/Doxyfile.in | 2 +- src/cron.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++++------ src/cron.hpp | 24 +++++++------------- 3 files changed, 66 insertions(+), 23 deletions(-) diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index 8848dfc..e1e62b5 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -302,7 +302,7 @@ EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. -EXTRACT_PRIVATE = NO +EXTRACT_PRIVATE = YES # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. diff --git a/src/cron.cpp b/src/cron.cpp index f31032d..77d9eb4 100644 --- a/src/cron.cpp +++ b/src/cron.cpp @@ -14,8 +14,38 @@ #include /** - @brief checks if the values are usable -*/ + * 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 + */ +WeekCron::WeekCron(const std::string& daystring, int begin) + : Begin(begin) + , End(0) + , Every(-1) + , Week(daystring) +{ +} + +/** + * 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 + * @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 std::string& daystring, int begin, int end, int every) + : Begin(begin) + , End(end) + , Every(every) + , Week(daystring) +{ +} + + +/** + * Checks if the input values are sane + * @return True if sane, false otherweise + */ bool WeekCron::is_sane() const { if (Begin < 0 || Begin > 86399) @@ -33,10 +63,11 @@ bool WeekCron::is_sane() const } /** - @brief returns the next point in time the item is scheduled for - @param calc_from unix-time to start calculating from (0 means now) - @note if it is scheduled for calc_from we return the next schedule, not now! -*/ + * Returns the next point in time the item is scheduled for. Also handles intervals. + * @note if it is scheduled for calc_from we return the next schedule, not now! + * @param calc_from unix-time to start calculating from (0 means now) + * @return Next point in time the item is scheduled for + */ time_t WeekCron::get_next_run(time_t calc_from) { if (!calc_from) @@ -83,6 +114,15 @@ time_t WeekCron::get_next_run(time_t calc_from) } } +/** + * Returns the next point in time the item is scheduled for + * @param calc_from Point of time to start calculations from + * @param daysec Start point of time in seconds since the start of the day + * @param todaycheck If true we check if the calculated time point is before + our #calc_from calcucation start point. + If yes, we will advance to the next day. + * @return Next point in time + */ time_t WeekCron::get_next_point(time_t calc_from, int daysec, bool todaycheck) { struct tm ft; @@ -109,6 +149,16 @@ time_t WeekCron::get_next_point(time_t calc_from, int daysec, bool todaycheck) return target; } +/** + * Returns the last point in time the item is scheduled for + * @param calc_from Point of time to start calculations from + * @param daysec Start point of time in seconds since the start of the day + * @param todaycheck If true we check if the calculated time point is before + our #calc_from calcucation start point. + If yes, we will advance to the next day. + * @return Last point in time + * FIXME: Is the description correct? + */ time_t WeekCron::get_lastnow_point(time_t calc_from, int daysec, bool todaycheck) { struct tm ft; @@ -135,4 +185,3 @@ time_t WeekCron::get_lastnow_point(time_t calc_from, int daysec, bool todaycheck return target; } - diff --git a/src/cron.hpp b/src/cron.hpp index dcc0dbd..91fdc23 100644 --- a/src/cron.hpp +++ b/src/cron.hpp @@ -14,35 +14,29 @@ #include +/// Time points and intervals repeating each week /** - @brief time-points and intervals repeating each week - @note begin and end are given in seconds since start of the day + This class represents recurring time points and intervals + which can be repeated on configurable days of the week. */ class WeekCron { 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 WEEK Week; time_t get_next_point(time_t calc_from, int daysec,bool todaycheck); time_t get_lastnow_point(time_t calc_from, int daysec,bool todaycheck); public: - - WeekCron(void) - : Begin(0), End(0), Every(-1) - { } - - WeekCron(const std::string& daystring, int begin) - : Begin(begin), End(0), Every(-1), Week(daystring) - { } - - WeekCron(const std::string& daystring, int begin, int end, int every) - : Begin(begin), End(end), Every(every), Week(daystring) - { } + WeekCron(const std::string& daystring, int begin); + WeekCron(const std::string& daystring, int begin, int end, int every); bool is_sane() const; -- 1.7.1