cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Friends | List of all members
osaTimeServer Class Reference

Class for relative time. More...

#include <osaTimeServer.h>

Inheritance diagram for osaTimeServer:
cmnGenericObject

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
 
- Public Member Functions inherited from cmnGenericObject
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::StreamBufTypeGetLogMultiplexer (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
 

Detailed Description

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.

Constructor & Destructor Documentation

osaTimeServer::osaTimeServer ( )

Default constructor.

osaTimeServer::~osaTimeServer ( )

Destructor

Member Function Documentation

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.

Parameters
absoluteThe absolute time value (input)
Returns
The relative time value in seconds
double osaTimeServer::EstimateDrift ( void  ) const

Estimate drift between synchronized clocks (Windows only)

osaAbsoluteTime osaTimeServer::GetAbsoluteTime ( void  ) const

Get the absolute time since 1970.

Returns
The number of seconds
double osaTimeServer::GetAbsoluteTimeInSeconds ( void  ) const

Get the number of seconds that have elapsed since 1970.

Returns
The number of seconds
double osaTimeServer::GetRelativeTime ( void  ) const

Get the number of seconds that have elapsed since the time origin.

Returns
The number of seconds
bool osaTimeServer::GetTimeOrigin ( osaAbsoluteTime origin) const

Get the time origin that is in effect for the relative time measurements.

Parameters
originReturns 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.

Parameters
relativeThe relative time value in seconds (input)
absoluteThe 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).

Friends And Related Function Documentation

friend class osaTimeServerTest
friend

The documentation for this class was generated from the following file: