X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Scheduler%2FClockService.hh;h=8fb1341a12d8d56bd24d20c7a205135b782dcbc8;hb=b89e3166f7680755683dccee5e48cb3a820185c0;hp=5b02c19088c3a601464c09d0ccf38709d0e84893;hpb=40fa3e3f1e0f639c68bd15bf469e35045f94abee;p=senf.git diff --git a/Scheduler/ClockService.hh b/Scheduler/ClockService.hh index 5b02c19..8fb1341 100644 --- a/Scheduler/ClockService.hh +++ b/Scheduler/ClockService.hh @@ -23,8 +23,8 @@ /** \file \brief ClockService public header */ -#ifndef HH_ClockService_ -#define HH_ClockService_ 1 +#ifndef HH_SENF_Scheduler_ClockService_ +#define HH_SENF_Scheduler_ClockService_ 1 // Custom includes #include @@ -32,7 +32,9 @@ #include #include #include +#include "../config.hh" #include "../Utils/singleton.hh" +#include "../Utils/Console/Parse.hh" //#include "ClockService.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -71,7 +73,7 @@ namespace senf { Unsigned integer type representing scheduler time. Scheduler time is measured in nanoseconds relative to some implementation defined reference time. */ - typedef boost::int_fast64_t clock_type; + typedef config::time_type clock_type; /** \brief Supplementary integer type @@ -85,6 +87,12 @@ namespace senf { */ typedef boost::posix_time::ptime abstime_type; + /** \brief Relative time data type + + Boost.DateTime datatype used to represent time intervals + */ + typedef boost::posix_time::time_duration reltime_type; + /////////////////////////////////////////////////////////////////////////// static clock_type now(); ///< Return current clock value @@ -97,6 +105,12 @@ namespace senf { monotonous, absolute time may be non-monotonous if the system date/time is changed. */ + static reltime_type reltime(clock_type clock); ///< Convert clock to relative time + /**< This member converts a clock value into a relative + Boost.DateTime time interval + \note The resolution of reltime_type might be smaller + than the clock_type resolution */ + static clock_type clock(abstime_type time); ///< Convert absolute time to clock value /**< This member converst an absolute time value into the corresponding clock value. @@ -150,6 +164,43 @@ namespace senf { #endif }; + /** \brief Console argument parser to parse value as time interval + + This parser will parse a time interval specification into a ClockService::clock_type + value. The following units are supported: + + + + + + +
\c ddays
\c hhours
\c mminutes
\c sseconds
+ + Additionally, the unit may be prefixed by an SI scale: + + + + + +
\c mmilli
\c umicro
\c nnano
+ + An optional decimal point is also supported. A single timer interval may combine any number + of these specifications. The following are all valid intervals: + + + + + + + + + +
10d10 days
5d5d10 days
1d2h100m3.5s27 hours, 30 minutes and 3.5 seconds
1s100ms1.1 seconds
1.1s1.1 seconds
123.456us123.456 microseconds
2md(very unusual) 2 milli-days
+ */ + void parseClockServiceInterval(console::ParseCommandInfo::TokensRange const & tokens, + ClockService::clock_type & out); + + void formatClockServiceInterval(ClockService::clock_type interval, std::ostream & os); } ///////////////////////////////hh.e////////////////////////////////////////