diff --git a/owlps-positioner/src/timestamp.cc b/owlps-positioner/src/timestamp.cc index 70dcee6..587eef5 100644 --- a/owlps-positioner/src/timestamp.cc +++ b/owlps-positioner/src/timestamp.cc @@ -6,6 +6,7 @@ #include "timestamp.hh" +#include "configuration.hh" #include @@ -92,6 +93,8 @@ inline void Timestamp::set(const uint64_t source_ms) Timestamp Timestamp::get_current_time() { + if (! Configuration::is_configured("replay")) + current_time.now() ; return current_time ; } @@ -100,12 +103,14 @@ Timestamp Timestamp::get_current_time() * @source A pointer to the new time. If NULL, #current_time is updated * to the current time. */ -void Timestamp::set_current_time(const Timestamp *const source) +void Timestamp::update_current_time(const Timestamp &source) { - if (source) - current_time = *source ; - else - current_time.now() ; + // We should never call this function if we are in replay mode: + assert(Configuration::is_configured("replay")) ; + + // According to human perception, time generally goes only forward: + if (current_time < source) + current_time = source ; } diff --git a/owlps-positioner/src/timestamp.hh b/owlps-positioner/src/timestamp.hh index 2b36244..a15167b 100644 --- a/owlps-positioner/src/timestamp.hh +++ b/owlps-positioner/src/timestamp.hh @@ -69,7 +69,7 @@ public: /// Returns a Timestamp containing the current time static Timestamp get_current_time(void) ; /// Sets #current_time to a new timestamp - static void set_current_time(const Timestamp *const source = NULL) ; + static void update_current_time(const Timestamp &source) ; /// \brief Initialises #timestamp at the current time whith a /// nanosecond precision bool now(void) ;