Clock Class Reference

Clock to get date/time from a specific clock type or wait for certain durations or until certain date/times in a given clock. More...

#include <ArmarXCore/core/time/Clock.h>

Public Member Functions

 Clock (ClockType clockType=ClockType::Virtual)
 Constructs a new clock of given clock type (virtual by default). More...
 
DateTime now () const
 Current date/time of the clock. More...
 
void waitFor (const Duration &duration) const
 Wait for a certain duration. More...
 
Duration waitUntil (const DateTime &dateTime) const
 Wait and block until the given date/time is surpassed. More...
 

Static Public Member Functions

static DateTime Now ()
 Current time on the virtual clock. More...
 
static void WaitFor (const Duration &duration)
 Wait for a certain duration on the virtual clock. More...
 
static Duration WaitUntil (const DateTime &dateTime)
 Wait and block until the given date/time is surpassed on the virtual clock. More...
 

Detailed Description

Clock to get date/time from a specific clock type or wait for certain durations or until certain date/times in a given clock.

In most cases, using the virtual clock is the desired behaviour. The virtual clock reports the current time according to the configured time server, or (as a fallback) the operating systems real time clock. The virtual clock can be accessed through the static methods of this clock.

For other cases, i.e., where the actual operating system real time clock is needed (ClockType::Realtime), or a monotonic clock is required (ClockType::Monotonic), a clock with the needed clock type as constructor parameter can be instantiated. The API is then similar to those of the virtual clock using the corresponding non-static member functions.

Definition at line 26 of file Clock.h.

Constructor & Destructor Documentation

◆ Clock()

Constructs a new clock of given clock type (virtual by default).

Parameters
clockTypeClock type.

Definition at line 16 of file Clock.cpp.

Member Function Documentation

◆ Now()

DateTime Now ( )
static

Current time on the virtual clock.

Returns
Current date/time.

Definition at line 97 of file Clock.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ now()

DateTime now ( ) const

Current date/time of the clock.

Returns
Current date/time.

Definition at line 23 of file Clock.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WaitFor()

void WaitFor ( const Duration duration)
static

Wait for a certain duration on the virtual clock.

Parameters
durationHow long to wait.

Definition at line 104 of file Clock.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ waitFor()

void waitFor ( const Duration duration) const

Wait for a certain duration.

Parameters
durationHow long to wait.

Definition at line 75 of file Clock.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WaitUntil()

Duration WaitUntil ( const DateTime dateTime)
static

Wait and block until the given date/time is surpassed on the virtual clock.

Parameters
dateTimeDate/time to wait until.
Returns
Waiting duration.

Definition at line 111 of file Clock.cpp.

+ Here is the call graph for this function:

◆ waitUntil()

Duration waitUntil ( const DateTime dateTime) const

Wait and block until the given date/time is surpassed.

Parameters
dateTimeDate/time to wait until.
Returns
Waiting duration.

Definition at line 82 of file Clock.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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