/** \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 <sys/time.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/cstdint.hpp>
+#include "../config.hh"
#include "../Utils/singleton.hh"
+#include "../Utils/Console/Parse.hh"
//#include "ClockService.mpp"
///////////////////////////////hh.p////////////////////////////////////////
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
*/
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
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.
#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:
+
+ <table class="senf fixedcolumn">
+ <tr><td>\c d</td><td>days</td></tr>
+ <tr><td>\c h</td><td>hours</td></tr>
+ <tr><td>\c m</td><td>minutes</td></tr>
+ <tr><td>\c s</td><td>seconds</td></tr>
+ </table>
+
+ Additionally, the unit may be prefixed by an SI scale:
+
+ <table class="senf fixedcolumn">
+ <tr><td>\c m</td><td>milli</td></tr>
+ <tr><td>\c u</td><td>micro</td></tr>
+ <tr><td>\c n</td><td>nano</td></tr>
+ </table>
+
+ An optional decimal point is also supported. A single timer interval may combine any number
+ of these specifications. The following are all valid intervals:
+
+ <table class="senf fixedcolumn">
+ <tr><td><code>10d</code></td><td>10 days</td></tr>
+ <tr><td><code>5d5d</code></td><td>10 days</td></tr>
+ <tr><td><code>1d2h100m3.5s</code></td><td>27 hours, 30 minutes and 3.5 seconds</td></tr>
+ <tr><td><code>1s100ms</code></td><td>1.1 seconds</td></tr>
+ <tr><td><code>1.1s</code></td><td>1.1 seconds</td></tr>
+ <tr><td><code>123.456us</code></td><td>123.456 microseconds</td></tr>
+ <tr><td><code>2md</code></td><td>(very unusual) 2 milli-days</td></tr>
+ </table>
+ */
+ void parseClockServiceInterval(console::ParseCommandInfo::TokensRange const & tokens,
+ ClockService::clock_type & out);
}
///////////////////////////////hh.e////////////////////////////////////////