cisst-saw
|
Class for relative time. More...
#include <osaTimeServer.h>
Public Member Functions | |
osaTimeServer () | |
~osaTimeServer () | |
void | SetTimeOrigin (void) |
void | SetTimeOriginFrom (const osaTimeServer *other) |
bool | GetTimeOrigin (osaAbsoluteTime &origin) const |
double | GetRelativeTime (void) const |
double | GetAbsoluteTimeInSeconds (void) const |
osaAbsoluteTime | GetAbsoluteTime (void) const |
double | EstimateDrift (void) const |
void | RelativeToAbsolute (double relative, osaAbsoluteTime &absolute) const |
double | AbsoluteToRelative (const osaAbsoluteTime &absolute) const |
![]() | |
virtual | ~cmnGenericObject (void) |
virtual const cmnClassServicesBase * | Services (void) const =0 |
bool | ReconstructFrom (const cmnGenericObject &other) |
std::string | ToString (void) const |
virtual void | ToStream (std::ostream &outputStream) const |
virtual void | ToStreamRaw (std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const |
virtual bool | FromStreamRaw (std::istream &inputStream, const char delimiter= ' ') |
virtual void | SerializeRaw (std::ostream &outputStream) const |
virtual void | DeSerializeRaw (std::istream &inputStream) |
virtual cmnLogger::StreamBufType * | GetLogMultiplexer (void) const |
virtual size_t | ScalarNumber (void) const |
virtual bool | ScalarNumberIsFixed (void) const |
virtual double | Scalar (const size_t CMN_UNUSED(index)) const throw (std::out_of_range) |
virtual std::string | ScalarDescription (const size_t CMN_UNUSED(index), const std::string &CMN_UNUSED(userDescription)) const |
Friends | |
class | osaTimeServerTest |
Class for relative time.
The osaRelativeTime class is used to manage the relationship between relative and absolute time. Specifically, the GetRelativeTime method returns the number of seconds that have elapsed since the time origin was set (via a call to SetTimeOrigin).
Although it might seem possible to implement this class without OS dependencies (e.g., by using osaGetAbsoluteTime), this is problematic on some platforms, such as Windows, where it is necessary to synchronize multiple time sources to get a high resolution time that is relative to an absolute time. Also, even on non-Windows platforms, it would not have been as efficient because the native (OS-specific) "absolute time" structure would have to converted to an osaAbsoluteTime structure for every call to GetRelativeTime.
This class has significant overlap with osaStopwatch.
osaTimeServer::osaTimeServer | ( | ) |
Default constructor.
osaTimeServer::~osaTimeServer | ( | ) |
Destructor
double osaTimeServer::AbsoluteToRelative | ( | const osaAbsoluteTime & | absolute | ) | const |
Convert the specified absolute time to a relative time by subtracting from the time origin and converting to seconds.
absolute | The absolute time value (input) |
double osaTimeServer::EstimateDrift | ( | void | ) | const |
Estimate drift between synchronized clocks (Windows only)
osaAbsoluteTime osaTimeServer::GetAbsoluteTime | ( | void | ) | const |
Get the absolute time since 1970.
double osaTimeServer::GetAbsoluteTimeInSeconds | ( | void | ) | const |
Get the number of seconds that have elapsed since 1970.
double osaTimeServer::GetRelativeTime | ( | void | ) | const |
Get the number of seconds that have elapsed since the time origin.
bool osaTimeServer::GetTimeOrigin | ( | osaAbsoluteTime & | origin | ) | const |
Get the time origin that is in effect for the relative time measurements.
origin | Returns the current origin |
void osaTimeServer::RelativeToAbsolute | ( | double | relative, |
osaAbsoluteTime & | absolute | ||
) | const |
Convert the specified relative time (in seconds) to an absolute time by adding it to the time origin.
relative | The relative time value in seconds (input) |
absolute | The absolute time value (output) |
void osaTimeServer::SetTimeOrigin | ( | void | ) |
Set the time origin for the relative time measurements to "now". Subsequent calls to GetRelativeTime will return the number of seconds that have elaspsed since this call was made.
void osaTimeServer::SetTimeOriginFrom | ( | const osaTimeServer * | other | ) |
Set the time origin based on the specified time server. For systems that need to synchronize to the performance counter, this also sets the offset (i.e., does not call Synchronize again).
|
friend |