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).
 
DateTime now () const
 Current date/time of the clock.
 
void waitFor (const Duration &duration) const
 Wait for a certain duration.
 
Duration waitUntil (const DateTime &dateTime) const
 Wait and block until the given date/time is surpassed.
 

Static Public Member Functions

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

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.

Constructor & Destructor Documentation

◆ Clock()

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

Parameters
clockTypeClock type.

Member Function Documentation

◆ Now()

DateTime Now ( )
static

Current time on the virtual clock.

Returns
Current date/time.

◆ now()

DateTime now ( ) const

Current date/time of the clock.

Returns
Current date/time.

◆ WaitFor()

void WaitFor ( const Duration & duration)
static

Wait for a certain duration on the virtual clock.

Parameters
durationHow long to wait.

◆ waitFor()

void waitFor ( const Duration & duration) const

Wait for a certain duration.

Parameters
durationHow long to wait.

◆ 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.

◆ 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.

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