fixes for ClockService::clock_type -> RestrictedInt change introduced by last commit
tho [Thu, 8 Dec 2011 13:28:17 +0000 (13:28 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1836 270642c3-0616-0410-b53a-bc976706d245

20 files changed:
senf/PPI/ActiveFeeder.test.cc
senf/PPI/IntervalTimer.cc
senf/PPI/RateFilter.test.cc
senf/Scheduler/ClockService.cc
senf/Scheduler/ClockService.cci
senf/Scheduler/ClockService.hh
senf/Scheduler/ClockService.test.cc
senf/Scheduler/Scheduler.cc
senf/Scheduler/TimerEvent.cci
senf/Scheduler/TimerEvent.test.cc
senf/Scheduler/TimerEventProxy.ct
senf/Scheduler/TimerEventProxy.test.cc
senf/Scheduler/TimerSource.cc
senf/Socket/Protocols/DatagramSocketProtocol.cc
senf/Utils/Beeper.cc
senf/Utils/ClockTypeMacros.hh [deleted file]
senf/Utils/IpChecksum.test.cc
senf/Utils/Logger/LogFormat.cc
senf/Utils/Logger/TimeSource.cc
senf/Utils/RestrictedInt.hh

index 06c2d65..ebcbc79 100644 (file)
@@ -71,7 +71,7 @@ SENF_AUTO_UNIT_TEST(activeFeeder)
     senf::ClockService::clock_type start (senf::ClockService::now());
     run( senf::ClockService::seconds(1));
     std::cerr << "\nActiveFeeder: "
-              << (sink.size()*1e9)/ (SENF_CLOCKTYPEVAL(senf::ClockService::now()) - SENF_CLOCKTYPEVAL(start))
+              << (sink.size()*1e9)/ (senf::ClockService::now() - start)
               << " packets/s" << std::endl;
     BOOST_CHECK( sink.size() > 0);
 }
index aacd6de..04ffa4c 100644 (file)
@@ -33,9 +33,7 @@
 
 // Custom includes
 #include "EventManager.hh"
-#include <senf/Utils/ClockTypeMacros.hh>
 
-//#include "IntervalTimer.mpp"
 #define prefix_
 //-/////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -61,7 +59,7 @@ prefix_ void senf::ppi::IntervalTimer::v_disable()
 
 prefix_ void senf::ppi::IntervalTimer::schedule()
 {
-    info_.expected = SENF_INT2CLOCKTYPE(SENF_CLOCKTYPEVAL(info_.intervalStart) + ( SENF_CLOCKTYPEVAL(interval_) * (info_.number+1) ) / eventsPerInterval_);
+    info_.expected = info_.intervalStart + ( interval_ * (info_.number+1) ) / eventsPerInterval_;
     timer_.timeout(info_.expected);
 }
 
index 130908b..1404fa2 100644 (file)
@@ -44,14 +44,16 @@ namespace module = ppi::module;
 namespace debug = module::debug;
 
 namespace {
-    void timeout() {
-        senf::scheduler::terminate();
+    void runPPI(senf::ClockService::clock_type t) {
+        senf::scheduler::TimerEvent timeout(
+                "emulatedDvbInterface test timer", &senf::scheduler::terminate, senf::scheduler::now() + t);
+        senf::ppi::run();
     }
 }
 
 SENF_AUTO_UNIT_TEST(rateFilter)
 {
-    module::RateFilter rateFilter ( senf::ClockService::milliseconds(100) );
+    module::RateFilter rateFilter ( senf::ClockService::milliseconds(200) );
     debug::PassiveSource source;
     debug::PassiveSink sink;
 
@@ -63,13 +65,9 @@ SENF_AUTO_UNIT_TEST(rateFilter)
     for (int i=0; i<10; i++)
         source.submit(p);
 
-    senf::scheduler::TimerEvent timer (
-        "rateFilter test timer", &timeout,
-        senf::ClockService::now() + senf::ClockService::milliseconds(250));
-
-    senf::ppi::run();
+    runPPI( senf::ClockService::milliseconds(500));
 
-    BOOST_CHECK_EQUAL( rateFilter.interval(), senf::ClockService::milliseconds(100) );
+    BOOST_CHECK_EQUAL( rateFilter.interval(), senf::ClockService::milliseconds(200) );
     BOOST_CHECK_EQUAL( sink.size(), 2u );
 }
 
@@ -104,16 +102,12 @@ SENF_AUTO_UNIT_TEST(rateFilter_changeInterval)
     for (int i=0; i<10; i++)
         source.submit(p);
 
-    senf::scheduler::TimerEvent timeoutTimer (
-        "rateFilter test timer", &timeout,
-        senf::ClockService::now() + senf::ClockService::milliseconds(675));
-
     RateFilter_IntervalChanger intervalChanger (rateFilter);
     senf::scheduler::TimerEvent timer ( "RateFilter_IntervalChanger timer",
         senf::membind(&RateFilter_IntervalChanger::changeInterval, intervalChanger),
         senf::ClockService::now() + senf::ClockService::milliseconds(250));
 
-    senf::ppi::run();
+    runPPI( senf::ClockService::milliseconds(675));
 
     BOOST_CHECK_EQUAL( rateFilter.interval(), senf::ClockService::milliseconds(200) );
     if (enabled)
index ec279e6..cd1a420 100644 (file)
@@ -34,8 +34,7 @@
 // Custom includes
 #include <boost/regex.hpp>
 #include <senf/Utils/Console/Traits.hh>
-#include <senf/Utils/ClockTypeMacros.hh>
-//#include "ClockService.mpp"
+
 #define prefix_
 //-/////////////////////////////////////////////////////////////////////////////////////////////////
 
index bf27401..e0a7b95 100644 (file)
 #include <time.h>
 #include <boost/date_time/posix_time/posix_time_types.hpp>
 #include <senf/Utils/Exception.hh>
-#include <senf/Utils/ClockTypeMacros.hh>
 
 #define prefix_ inline
 //-/////////////////////////////////////////////////////////////////////////////////////////////////
 
+#ifdef SENF_DEBUG
+#   define SENF_CLOCKTYPEVAL(clock) (clock).value()
+#else
+#   define SENF_CLOCKTYPEVAL(clock) (clock)
+#endif
+
 //-/////////////////////////////////////////////////////////////////////////////////////////////////
 // senf::ClockService
 
@@ -45,7 +50,7 @@ prefix_ senf::ClockService::clock_type senf::ClockService::now()
     struct timespec spec;
     if (clock_gettime(CLOCK_MONOTONIC, &spec) < 0)
         SENF_THROW_SYSTEM_EXCEPTION("clock_gettime()");
-    return SENF_INT2CLOCKTYPE(spec.tv_sec * 1000000000LL + spec.tv_nsec);
+    return clock_type(spec.tv_sec * 1000000000LL + spec.tv_nsec);
 }
 
 //-/////////////////////////////////////////////////////////////////////////////////////////////////
@@ -69,9 +74,11 @@ prefix_ senf::ClockService::abstime_type senf::ClockService::abstime_m(clock_typ
     if (scheduler::now() - baseClock_ > clock_type(1000000000ll))
         restart_m();
 #ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
-    return baseAbstime_ + boost::posix_time::nanoseconds(clock-baseClock_);
+    return baseAbstime_ + boost::posix_time::nanoseconds(
+            SENF_CLOCKTYPEVAL( clock-baseClock_));
 #else
-    return baseAbstime_ + boost::posix_time::microseconds((clock.value() - baseClock_.value() + 500 )/1000);
+    return baseAbstime_ + boost::posix_time::microseconds(
+            SENF_CLOCKTYPEVAL( (clock-baseClock_+clock_type(500))/1000));
 #endif
 }
 
@@ -96,9 +103,11 @@ prefix_ senf::ClockService::abstime_type senf::ClockService::abstime(clock_type
 prefix_ senf::ClockService::reltime_type senf::ClockService::reltime(clock_type clock)
 {
 #ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
-    return boost::posix_time::nanoseconds(clock);
+    return boost::posix_time::nanoseconds(
+            SENF_CLOCKTYPEVAL( clock));
 #else
-    return  boost::posix_time::microseconds((clock.value() + 500)/1000);
+    return  boost::posix_time::microseconds(
+            SENF_CLOCKTYPEVAL( (clock + clock_type(500))/1000));
 #endif
 }
 
@@ -114,72 +123,72 @@ prefix_ senf::ClockService::clock_type senf::ClockService::from_time_t(time_t co
 
 prefix_ senf::ClockService::clock_type senf::ClockService::nanoseconds(int64_type v)
 {
-    return SENF_INT2CLOCKTYPE(v);
+    return clock_type(v);
 }
 
 prefix_ senf::ClockService::clock_type senf::ClockService::microseconds(int64_type v)
 {
-    return SENF_INT2CLOCKTYPE(v * SENF_CLOCKTYPEVAL(nanoseconds(1000)));
+    return v * nanoseconds(1000);
 }
 
 prefix_ senf::ClockService::clock_type senf::ClockService::milliseconds(int64_type v)
 {
-    return SENF_INT2CLOCKTYPE(v * SENF_CLOCKTYPEVAL(microseconds(1000)));
+    return v * microseconds(1000);
 }
 
 prefix_ senf::ClockService::clock_type senf::ClockService::seconds(int64_type v)
 {
-    return SENF_INT2CLOCKTYPE(v * SENF_CLOCKTYPEVAL(milliseconds(1000)));
+    return v * milliseconds(1000);
 }
 
 prefix_ senf::ClockService::clock_type senf::ClockService::minutes(int64_type v)
 {
-    return SENF_INT2CLOCKTYPE(v * SENF_CLOCKTYPEVAL(seconds(60)));
+    return v * seconds(60);
 }
 
 prefix_ senf::ClockService::clock_type senf::ClockService::hours(int64_type v)
 {
-    return SENF_INT2CLOCKTYPE(v * SENF_CLOCKTYPEVAL(minutes(60)));
+    return v * minutes(60);
 }
 
 prefix_ senf::ClockService::clock_type senf::ClockService::days(int64_type v)
 {
-    return SENF_INT2CLOCKTYPE(v * SENF_CLOCKTYPEVAL(hours(24)));
+    return v * hours(24);
 }
 
 prefix_ senf::ClockService::int64_type senf::ClockService::in_nanoseconds(clock_type v)
 {
-    return SENF_CLOCKTYPEVAL(v);
+    return SENF_CLOCKTYPEVAL( v);
 }
 
 prefix_ senf::ClockService::int64_type senf::ClockService::in_microseconds(clock_type v)
 {
-    return (SENF_CLOCKTYPEVAL(v) / SENF_CLOCKTYPEVAL(nanoseconds(1000)));
+    return SENF_CLOCKTYPEVAL( v / nanoseconds(1000));
 }
 
 prefix_ senf::ClockService::int64_type senf::ClockService::in_milliseconds(clock_type v)
 {
-    return (SENF_CLOCKTYPEVAL(v) / SENF_CLOCKTYPEVAL(microseconds(1000)));
+    return SENF_CLOCKTYPEVAL( v / microseconds(1000));
 }
 
 prefix_ senf::ClockService::int64_type senf::ClockService::in_seconds(clock_type v)
 {
-    return (SENF_CLOCKTYPEVAL(v) / SENF_CLOCKTYPEVAL(milliseconds(1000)));
+    return SENF_CLOCKTYPEVAL( v / milliseconds(1000));
 }
 
 prefix_ senf::ClockService::int64_type senf::ClockService::in_minutes(clock_type v)
 {
-    return (SENF_CLOCKTYPEVAL(v) / SENF_CLOCKTYPEVAL(seconds(60)));
+    return SENF_CLOCKTYPEVAL( v / seconds(60));
 }
 
 prefix_ senf::ClockService::int64_type senf::ClockService::in_hours(clock_type v)
 {
-    return (SENF_CLOCKTYPEVAL(v) / SENF_CLOCKTYPEVAL(minutes(60))) ;
+    return SENF_CLOCKTYPEVAL( v / minutes(60));
 }
 
 prefix_ senf::ClockService::int64_type senf::ClockService::in_days(clock_type v)
 {
-    return (SENF_CLOCKTYPEVAL(v) / SENF_CLOCKTYPEVAL(hours(24))) ;
+    return SENF_CLOCKTYPEVAL( v / hours(24));
 }
 
 prefix_ senf::ClockService::clock_type senf::ClockService::from_timeval(timeval const & time)
@@ -192,6 +201,8 @@ prefix_ void senf::ClockService::restart()
     instance().restart_m();
 }
 
+#undef SENF_CLOCKTYPEVAL
+
 //-/////////////////////////////////////////////////////////////////////////////////////////////////
 #undef prefix_
 
index 40ea765..0041736 100644 (file)
@@ -89,7 +89,6 @@ namespace senf {
 
             This type is used to represent varies supplementary values (e.g. number of microseconds)
          */
-
         typedef boost::int_fast64_t int64_type;
 
         /** \brief Absolute time data type
index 382b908..c6e633d 100644 (file)
@@ -107,6 +107,8 @@ SENF_AUTO_UNIT_TEST(clockService)
                                (t1 + senf::ClockService::milliseconds(200))
                                (senf::ClockService::now())
                                (senf::ClockService::milliseconds(100)) );
+
+    BOOST_CHECK_EQUAL( senf::ClockService::seconds(1),  senf::ClockService::milliseconds(1000) );
 }
 
 //-/////////////////////////////////////////////////////////////////////////////////////////////////
index 97566e7..c7a568b 100644 (file)
@@ -170,7 +170,7 @@ prefix_ void senf::scheduler::hiresTimers()
 prefix_ senf::log::time_type senf::scheduler::LogTimeSource::operator()()
     const
 {
-    return SENF_CLOCKTYPEVAL(scheduler::now());
+    return senf::ClockService::in_nanoseconds( scheduler::now());
 }
 
 //-/////////////////////////////////////////////////////////////////////////////////////////////////
index 201512f..450aa32 100644 (file)
@@ -49,7 +49,7 @@ prefix_ senf::scheduler::TimerEvent::TimerEvent(std::string const & name, Callba
 }
 
 prefix_ senf::scheduler::TimerEvent::TimerEvent(std::string const & name, Callback const & cb)
-    : detail::FIFORunner::TaskInfo (name), cb_ (cb), timeout_ (SENF_INT2CLOCKTYPE(0))
+    : detail::FIFORunner::TaskInfo (name), cb_ (cb), timeout_(ClockService::clock_type(0))
 {}
 
 prefix_ senf::scheduler::TimerEvent::~TimerEvent()
index 88e2f34..f744564 100644 (file)
@@ -105,14 +105,14 @@ namespace {
     }
 
     unsigned count (0);
-    senf::ClockService::clock_type delay (0);
+    senf::ClockService::int64_type delay (0);
     bool haveCb (false);
 
     void jitterCb(senf::scheduler::TimerEvent & tm)
     {
         //std::cerr << "diff:" << senf::ClockService::in_microseconds( senf::scheduler::now() - tm.timeout()) << '\n';
         count ++;
-        delay += SENF_INT2CLOCKTYPE(senf::ClockService::in_microseconds( senf::scheduler::now() - tm.timeout()));
+        delay += senf::ClockService::in_microseconds( senf::scheduler::now() - tm.timeout());
         haveCb = true;
         tm.timeout(randomDelay());
     }
@@ -136,7 +136,7 @@ namespace {
     void jitterTest()
     {
         count = 0;
-        delay = senf::ClockService::clock_type(0);
+        delay = 0;
 //        senf::scheduler::EventHook pre ("jitterTest::preCb", &preCb,
 //                                        senf::scheduler::EventHook::PRE);
 //        senf::scheduler::EventHook post ("jitterTest::postCb", &postCb,
@@ -158,7 +158,7 @@ namespace {
 
         senf::scheduler::process();
 
-        std::cerr << "Average scheduling delay: " << SENF_CLOCKTYPEVAL(delay)/count << " microseconds\n";
+        std::cerr << "Average scheduling delay: " << delay/count << " microseconds\n";
     }
 
 }
index bdad612..b851ba1 100644 (file)
@@ -40,7 +40,7 @@ prefix_ senf::scheduler::TimerEventProxy<IdType>::TimerEventProxy(std::string co
     : entrySetById( entrySet.template get<Id>()),
       entrySetByTimeout( entrySet.template get<Timeout> ()),
       timer( "TimerEventProxy " + description,
-              membind(&TimerEventProxy<IdType>::timerEvent, this), SENF_INT2CLOCKTYPE(0), false)
+              membind(&TimerEventProxy<IdType>::timerEvent, this), ClockService::clock_type(0), false)
 { }
 
 template<typename IdType>
@@ -93,7 +93,7 @@ prefix_ senf::ClockService::clock_type senf::scheduler::TimerEventProxy<IdType>:
     const
 {
     typename EntrySetById_t::const_iterator i ( entrySetById.find( id));
-    return i == entrySetById.end() ? SENF_INT2CLOCKTYPE(0) : i->timeout;
+    return i == entrySetById.end() ? ClockService::clock_type(0) : i->timeout;
 }
 
 
index 60002a3..73e9fd4 100644 (file)
@@ -75,7 +75,7 @@ SENF_AUTO_UNIT_TEST(timerEventProxy)
         timers.add( now + ClockService::milliseconds(200), 1, &handler);
         BOOST_CHECK( timers.remove( 4));
         BOOST_CHECK(! timers.remove( 4));
-        BOOST_CHECK_EQUAL( timers.timeout(4), SENF_INT2CLOCKTYPE(0));
+        BOOST_CHECK_EQUAL( timers.timeout(4), ClockService::clock_type(0));
         timers.add( now + ClockService::milliseconds(700), 2, &handler);
 
         BOOST_CHECK_EQUAL( timers.timeout(1), now + ClockService::milliseconds(200));
index 2050eb7..98f8f7c 100644 (file)
@@ -37,7 +37,6 @@
 #include TIMERFD_H_PATH
 #endif
 #include "senf/Utils/IgnoreValue.hh"
-#include <senf/Utils/ClockTypeMacros.hh>
 
 //#include "TimerSource.mpp"
 #define prefix_
@@ -94,8 +93,8 @@ senf::scheduler::detail::POSIXTimerSource::timeout(ClockService::clock_type time
 {
     if (! timeoutEnabled_ || timeout_ != timeout) {
         timeout_ = timeout;
-        if (SENF_CLOCKTYPEVAL(timeout_) <= 0)
-            timeout_ = SENF_INT2CLOCKTYPE(1);
+        if (timeout_ <= ClockService::clock_type(0))
+            timeout_ = ClockService::clock_type(1);
         timeoutEnabled_ = true;
         reschedule();
     }
@@ -185,7 +184,7 @@ prefix_ void senf::scheduler::detail::PollTimerSource::disable()
 
 #ifdef HAVE_TIMERFD_CREATE
 prefix_ senf::scheduler::detail::TimerFDTimerSource::TimerFDTimerSource()
-    : timerfd_ (-1), timeoutEnabled_ (false), timeout_ (0)
+    : timerfd_ (-1), timeoutEnabled_ (false), timeout_(0)
 {
     timerfd_ = timerfd_create(CLOCK_MONOTONIC, 0);
     if (timerfd_ < 0)
@@ -204,8 +203,8 @@ senf::scheduler::detail::TimerFDTimerSource::timeout(ClockService::clock_type ti
 {
     if (!timeoutEnabled_ || timeout_ != timeout) {
         timeout_ = timeout;
-        if (SENF_CLOCKTYPEVAL(timeout_) <= 0)
-            timeout_ = SENF_INT2CLOCKTYPE(1);
+        if (timeout_ <= ClockService::clock_type(0))
+            timeout_ = ClockService::clock_type(1);
         timeoutEnabled_ = true;
         reschedule();
     }
index 020ec24..48bd1a8 100644 (file)
@@ -35,7 +35,6 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
-#include <senf/Utils/ClockTypeMacros.hh>
 
 //#include "DatagramSocketProtocol.mpp"
 #define prefix_
@@ -57,7 +56,7 @@ prefix_ senf::ClockService::clock_type senf::DatagramSocketProtocol::timestamp_s
     // this may reduce the precision, but we only care about +/- 1ms, for now 
     struct timeval tv;
     ::gettimeofday( &tv, NULL);
-    return SENF_INT2CLOCKTYPE(tv.tv_sec * 1000000000LL + tv.tv_usec * 1000LL);
+    return ClockService::clock_type(tv.tv_sec * 1000000000LL + tv.tv_usec * 1000LL);
 }
 
 
index 6fc5895..298e33a 100644 (file)
@@ -44,7 +44,7 @@
 // senf::Beeper
 
 prefix_ senf::Beeper::Beeper(std::string const & device)
-    : timer_( "senf::Beeper::timer", boost::bind(&Beeper::timeout, this), SENF_INT2CLOCKTYPE(0), false)
+    : timer_( "senf::Beeper::timer", boost::bind(&Beeper::timeout, this), ClockService::clock_type(0), false)
 {
     if ((fd_ = ::open(device.c_str(), O_WRONLY)) == -1) {
         SENF_THROW_SYSTEM_EXCEPTION("Could not open device for Beeper.");
diff --git a/senf/Utils/ClockTypeMacros.hh b/senf/Utils/ClockTypeMacros.hh
deleted file mode 100644 (file)
index 11d64e4..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// $Id: ClockService.hh 1795 2011-07-14 08:42:24Z pba $
-//
-// Copyright (C) 2007
-// Fraunhofer Institute for Open Communication Systems (FOKUS)
-//
-// The contents of this file are subject to the Fraunhofer FOKUS Public License
-// Version 1.0 (the "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-// http://senf.berlios.de/license.html
-//
-// The Fraunhofer FOKUS Public License Version 1.0 is based on,
-// but modifies the Mozilla Public License Version 1.1.
-// See the full license text for the amendments.
-//
-// Software distributed under the License is distributed on an "AS IS" basis,
-// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-// for the specific language governing rights and limitations under the License.
-//
-// The Original Code is Fraunhofer FOKUS code.
-//
-// The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
-// (registered association), Hansastraße 27 c, 80686 Munich, Germany.
-// All Rights Reserved.
-//
-// Contributor(s):
-//   Philipp Batroff <philipp.batroff@fokus.fraunhofer.de>
-
-
-#ifndef HH_SENF_Utils_CLOCKTYPEMACROS
-#define HH_SENF_Utils_CLOCKTYPEMACROS_1
-
-
-#ifdef SENF_DEBUG
-#define SENF_INT2CLOCKTYPE(clock)  \
-    senf::ClockService::clock_type(clock)
-
-#define SENF_CLOCKTYPEVAL(clock) \
-    clock.value()
-#endif
-
-#ifndef SENF_DEBUG
-#define SENF_INT2CLOCKTYPE(clock)  \
-    (clock)
-#define SENF_CLOCKTYPEVAL(clock) \
-    (clock)
-#endif
-
-#endif // CLOCKTYPEMACROS_HH
-
-
-// Local Variables:
-// mode: c++
-// fill-column: 100
-// comment-column: 40
-// c-file-style: "senf"
-// indent-tabs-mode: nil
-// ispell-local-dictionary: "american"
-// compile-command: "scons -u test"
-// End:
index 7f3a56b..ace46cc 100644 (file)
@@ -42,7 +42,7 @@
 
 SENF_AUTO_UNIT_TEST(ipChecksum)
 {
-    char data[] = { 0x45, 0x00, 0x00, 0x28, 0x49, 0x44, 0x40, 0x00,
+    unsigned char data[] = { 0x45, 0x00, 0x00, 0x28, 0x49, 0x44, 0x40, 0x00,
                     0x40, 0x06, 0x00, 0x00, 0x0a, 0xc1, 0x01, 0x06,
                     0xc2, 0x9f, 0xa4, 0xc3 };
 
index 24a28f4..f91696e 100644 (file)
@@ -110,7 +110,7 @@ prefix_ void senf::log::detail::LogFormat::timeFormat(std::string const & format
     timeFormat_ = format;
     if (format.empty()) {
         noformat_ = true;
-        timeBase_ = SENF_CLOCKTYPEVAL(ClockService::now());
+        timeBase_ = senf::ClockService::in_nanoseconds( ClockService::now());
     } else {
         noformat_ = false;
         std::locale const & loc (datestream_.getloc());
@@ -134,7 +134,7 @@ prefix_ std::string senf::log::detail::LogFormat::prefix(time_type timestamp,
                         << std::setw(9) << (delta % 1000000000ll);
         }
         else
-            datestream_ << senf::ClockService::abstime(SENF_INT2CLOCKTYPE(timestamp));
+            datestream_ << senf::ClockService::abstime( senf::ClockService::nanoseconds(timestamp));
         datestream_ << ' ';
     }
     if (!tag_.empty())
index a5aa266..e64fd00 100644 (file)
@@ -51,7 +51,7 @@ prefix_ senf::log::TimeSource::~TimeSource()
 prefix_ senf::log::time_type senf::log::SystemTimeSource::operator()()
     const
 {
-    return SENF_CLOCKTYPEVAL(senf::ClockService::now());
+    return senf::ClockService::in_nanoseconds( senf::ClockService::now());
 }
 
 //-/////////////////////////////////////////////////////////////////////////////////////////////////
index 08714ac..003a850 100644 (file)
@@ -105,41 +105,48 @@ namespace senf {
         bool boolean_test() const
             { return value_; }
 
-        RestrictedInt<Base, Tag> operator*(int i) const
-            { return RestrictedInt<Base, Tag>(value_ * i); }
-
-        RestrictedInt<Base, Tag> operator/(int i) const
-            { return RestrictedInt<Base, Tag>(value_ / i); }
-
-        bool operator>(int i) const
-            { return value_ > i; }
-
-        bool operator>=(int i) const
-            { return value_ >= i; }
+    private:
+        Base value_;
+    };
 
-        bool operator<(int i) const
-            { return value_ < i; }
 
-        bool operator<=(int i) const
-            { return value_ <= i; }
+    template <class Base, class Tag, typename OtherType>
+    RestrictedInt<Base, Tag> operator*(OtherType a, RestrictedInt<Base,Tag> b)
+    {
+        return RestrictedInt<Base, Tag>( a * b.value());
+    }
 
-        bool operator==(int i) const
-            { return value_ == i; }
+    template <class Base, class Tag, typename OtherType>
+    RestrictedInt<Base, Tag> operator*(RestrictedInt<Base,Tag> a, OtherType b)
+    {
+        return RestrictedInt<Base, Tag>( a.value() * b);
+    }
 
-        bool operator!=(int i) const
-            { return value_ != i; }
+    template <class Base, class Tag, typename OtherType>
+    RestrictedInt<Base, Tag> operator/(OtherType a, RestrictedInt<Base,Tag> b)
+    {
+        return RestrictedInt<Base, Tag>( a / b.value());
+    }
 
-    private:
-        Base value_;
-    };
+    template <class Base, class Tag, typename OtherType>
+    RestrictedInt<Base, Tag> operator/(RestrictedInt<Base,Tag> a, OtherType b)
+    {
+        return RestrictedInt<Base, Tag>( a.value() / b);
+    }
 
     template <class Base, class Tag>
     std::ostream & operator<<(std::ostream & os, RestrictedInt<Base, Tag> value)
-        { os << value.value(); return os; }
+    {
+        os << value.value();
+        return os;
+    }
 
     template <class Base, class Tag>
     std::istream & operator>>(std::istream & is, RestrictedInt<Base, Tag> & value)
-        { Base v; is >> v; value = RestrictedInt<Base,Tag>(v); return is; }
+    {
+        Base v; is >> v; value = RestrictedInt<Base,Tag>(v);
+        return is;
+    }
 
 }