[Positioner] Timestamp: *current_time() use "replay"

Timestamp::get_current_time() now returns the current time if the replay
mode is unactivated, or the most recent request's time in replay mode.
This commit is contained in:
Matteo Cypriani 2012-06-08 12:17:25 +02:00
parent 692571e382
commit d44680751c
2 changed files with 11 additions and 6 deletions

View File

@ -6,6 +6,7 @@
#include "timestamp.hh"
#include "configuration.hh"
#include <boost/functional/hash.hpp>
@ -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 ;
}

View File

@ -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) ;