From: tho Date: Thu, 8 Dec 2011 13:28:17 +0000 (+0000) Subject: fixes for ClockService::clock_type -> RestrictedInt change introduced by last commit X-Git-Url: http://g0dil.de/git?p=senf.git;a=commitdiff_plain;h=114131e8774ab05964646992613a98dcedf92434 fixes for ClockService::clock_type -> RestrictedInt change introduced by last commit git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1836 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/PPI/ActiveFeeder.test.cc b/senf/PPI/ActiveFeeder.test.cc index 06c2d65..ebcbc79 100644 --- a/senf/PPI/ActiveFeeder.test.cc +++ b/senf/PPI/ActiveFeeder.test.cc @@ -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); } diff --git a/senf/PPI/IntervalTimer.cc b/senf/PPI/IntervalTimer.cc index aacd6de..04ffa4c 100644 --- a/senf/PPI/IntervalTimer.cc +++ b/senf/PPI/IntervalTimer.cc @@ -33,9 +33,7 @@ // Custom includes #include "EventManager.hh" -#include -//#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); } diff --git a/senf/PPI/RateFilter.test.cc b/senf/PPI/RateFilter.test.cc index 130908b..1404fa2 100644 --- a/senf/PPI/RateFilter.test.cc +++ b/senf/PPI/RateFilter.test.cc @@ -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) diff --git a/senf/Scheduler/ClockService.cc b/senf/Scheduler/ClockService.cc index ec279e6..cd1a420 100644 --- a/senf/Scheduler/ClockService.cc +++ b/senf/Scheduler/ClockService.cc @@ -34,8 +34,7 @@ // Custom includes #include #include -#include -//#include "ClockService.mpp" + #define prefix_ //-///////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/senf/Scheduler/ClockService.cci b/senf/Scheduler/ClockService.cci index bf27401..e0a7b95 100644 --- a/senf/Scheduler/ClockService.cci +++ b/senf/Scheduler/ClockService.cci @@ -32,11 +32,16 @@ #include #include #include -#include #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_ diff --git a/senf/Scheduler/ClockService.hh b/senf/Scheduler/ClockService.hh index 40ea765..0041736 100644 --- a/senf/Scheduler/ClockService.hh +++ b/senf/Scheduler/ClockService.hh @@ -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 diff --git a/senf/Scheduler/ClockService.test.cc b/senf/Scheduler/ClockService.test.cc index 382b908..c6e633d 100644 --- a/senf/Scheduler/ClockService.test.cc +++ b/senf/Scheduler/ClockService.test.cc @@ -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) ); } //-///////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/senf/Scheduler/Scheduler.cc b/senf/Scheduler/Scheduler.cc index 97566e7..c7a568b 100644 --- a/senf/Scheduler/Scheduler.cc +++ b/senf/Scheduler/Scheduler.cc @@ -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()); } //-///////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/senf/Scheduler/TimerEvent.cci b/senf/Scheduler/TimerEvent.cci index 201512f..450aa32 100644 --- a/senf/Scheduler/TimerEvent.cci +++ b/senf/Scheduler/TimerEvent.cci @@ -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() diff --git a/senf/Scheduler/TimerEvent.test.cc b/senf/Scheduler/TimerEvent.test.cc index 88e2f34..f744564 100644 --- a/senf/Scheduler/TimerEvent.test.cc +++ b/senf/Scheduler/TimerEvent.test.cc @@ -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"; } } diff --git a/senf/Scheduler/TimerEventProxy.ct b/senf/Scheduler/TimerEventProxy.ct index bdad612..b851ba1 100644 --- a/senf/Scheduler/TimerEventProxy.ct +++ b/senf/Scheduler/TimerEventProxy.ct @@ -40,7 +40,7 @@ prefix_ senf::scheduler::TimerEventProxy::TimerEventProxy(std::string co : entrySetById( entrySet.template get()), entrySetByTimeout( entrySet.template get ()), timer( "TimerEventProxy " + description, - membind(&TimerEventProxy::timerEvent, this), SENF_INT2CLOCKTYPE(0), false) + membind(&TimerEventProxy::timerEvent, this), ClockService::clock_type(0), false) { } template @@ -93,7 +93,7 @@ prefix_ senf::ClockService::clock_type senf::scheduler::TimerEventProxy: 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; } diff --git a/senf/Scheduler/TimerEventProxy.test.cc b/senf/Scheduler/TimerEventProxy.test.cc index 60002a3..73e9fd4 100644 --- a/senf/Scheduler/TimerEventProxy.test.cc +++ b/senf/Scheduler/TimerEventProxy.test.cc @@ -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)); diff --git a/senf/Scheduler/TimerSource.cc b/senf/Scheduler/TimerSource.cc index 2050eb7..98f8f7c 100644 --- a/senf/Scheduler/TimerSource.cc +++ b/senf/Scheduler/TimerSource.cc @@ -37,7 +37,6 @@ #include TIMERFD_H_PATH #endif #include "senf/Utils/IgnoreValue.hh" -#include //#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(); } diff --git a/senf/Socket/Protocols/DatagramSocketProtocol.cc b/senf/Socket/Protocols/DatagramSocketProtocol.cc index 020ec24..48bd1a8 100644 --- a/senf/Socket/Protocols/DatagramSocketProtocol.cc +++ b/senf/Socket/Protocols/DatagramSocketProtocol.cc @@ -35,7 +35,6 @@ #include #include #include -#include //#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); } diff --git a/senf/Utils/Beeper.cc b/senf/Utils/Beeper.cc index 6fc5895..298e33a 100644 --- a/senf/Utils/Beeper.cc +++ b/senf/Utils/Beeper.cc @@ -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 index 11d64e4..0000000 --- a/senf/Utils/ClockTypeMacros.hh +++ /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 - - -#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: diff --git a/senf/Utils/IpChecksum.test.cc b/senf/Utils/IpChecksum.test.cc index 7f3a56b..ace46cc 100644 --- a/senf/Utils/IpChecksum.test.cc +++ b/senf/Utils/IpChecksum.test.cc @@ -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 }; diff --git a/senf/Utils/Logger/LogFormat.cc b/senf/Utils/Logger/LogFormat.cc index 24a28f4..f91696e 100644 --- a/senf/Utils/Logger/LogFormat.cc +++ b/senf/Utils/Logger/LogFormat.cc @@ -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()) diff --git a/senf/Utils/Logger/TimeSource.cc b/senf/Utils/Logger/TimeSource.cc index a5aa266..e64fd00 100644 --- a/senf/Utils/Logger/TimeSource.cc +++ b/senf/Utils/Logger/TimeSource.cc @@ -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()); } //-///////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/senf/Utils/RestrictedInt.hh b/senf/Utils/RestrictedInt.hh index 08714ac..003a850 100644 --- a/senf/Utils/RestrictedInt.hh +++ b/senf/Utils/RestrictedInt.hh @@ -105,41 +105,48 @@ namespace senf { bool boolean_test() const { return value_; } - RestrictedInt operator*(int i) const - { return RestrictedInt(value_ * i); } - - RestrictedInt operator/(int i) const - { return RestrictedInt(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 + RestrictedInt operator*(OtherType a, RestrictedInt b) + { + return RestrictedInt( a * b.value()); + } - bool operator==(int i) const - { return value_ == i; } + template + RestrictedInt operator*(RestrictedInt a, OtherType b) + { + return RestrictedInt( a.value() * b); + } - bool operator!=(int i) const - { return value_ != i; } + template + RestrictedInt operator/(OtherType a, RestrictedInt b) + { + return RestrictedInt( a / b.value()); + } - private: - Base value_; - }; + template + RestrictedInt operator/(RestrictedInt a, OtherType b) + { + return RestrictedInt( a.value() / b); + } template std::ostream & operator<<(std::ostream & os, RestrictedInt value) - { os << value.value(); return os; } + { + os << value.value(); + return os; + } template std::istream & operator>>(std::istream & is, RestrictedInt & value) - { Base v; is >> v; value = RestrictedInt(v); return is; } + { + Base v; is >> v; value = RestrictedInt(v); + return is; + } }