ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Types | Public Static Methods | Public Methods | Protected Fields | Protected Methods | List of all members
TimePointBase< TClock, TDerived >::Duration Class Reference

#include <timepointbase.hpp>

Class Description

template<typename TClock, typename TDerived>
class aworx::lib::time::TimePointBase< TClock, TDerived >::Duration


This inner class of TimePointBase represents durations, hence difference values of two values of the parent class.

Often, objects of this class are generated by the subtraction of TimePointBase values or by using methods TimePointBase::Age and TimePointBase::Since. Furthermore, class CalendarDuration (found in module ALib System) can be used to convert durations to and from human readable units (days, hours, minutes, etc.).

Friends

class TimePointBase

Definition at line 111 of file timepointbase.hpp.

Public Types

using TDuration = typename std::chrono::steady_clock::duration
 

Public Static Methods

static Duration FromAbsoluteDays (int64_t days)
 
static Duration FromAbsoluteHours (int64_t hours)
 
static Duration FromAbsoluteMicroseconds (int64_t microseconds)
 
static Duration FromAbsoluteMilliseconds (int64_t milliseconds)
 
static Duration FromAbsoluteMinutes (int64_t minutes)
 
static Duration FromAbsoluteSeconds (int64_t seconds)
 
static Duration FromDays (double days)
 
static Duration FromHours (double hours)
 
static Duration FromMicroseconds (double microseconds)
 
static Duration FromMilliseconds (double milliseconds)
 
static Duration FromMinutes (double minutes)
 
static Duration FromNanoseconds (int64_t nanoseconds)
 
static Duration FromSeconds (double seconds)
 
static Duration Import (TDuration timeSpan)
 

Public Methods

constexpr Duration ()
 
TDuration Export () const
 
integer InAbsoluteDays () const
 
integer InAbsoluteHours () const
 
int64_t InAbsoluteMicroseconds () const
 
int64_t InAbsoluteMilliseconds () const
 
int64_t InAbsoluteMinutes () const
 
int64_t InAbsoluteSeconds () const
 
double InDays () const
 
double InHertz (int qtyFractionalDigits=-1) const
 
double InHours () const
 
double InMicroseconds () const
 
double InMilliseconds () const
 
double InMinutes () const
 
int64_t InNanoseconds () const
 
double InSeconds () const
 
bool operator!= (const Duration &other) const
 
Duration operator* (double multiplier) const
 
Duration operator* (int64_t multiplier) const
 
Durationoperator*= (double multiplier)
 
Durationoperator*= (int64_t multiplier)
 
Duration operator+ (const Duration &rhs) const
 
Durationoperator+= (const Duration &other)
 
Duration operator- (const Duration &rhs) const
 
Durationoperator-= (const Duration &other)
 
Duration operator/ (double divisor) const
 
Duration operator/ (int64_t divisor) const
 
Durationoperator/= (double divisor)
 
Durationoperator/= (int64_t divisor)
 
bool operator< (const Duration &other) const
 
bool operator<= (const Duration &other) const
 
bool operator== (const Duration &other) const
 
bool operator> (const Duration &other) const
 
bool operator>= (const Duration &other) const
 
DurationSetMaximum (const Duration &other)
 
DurationSetMinimum (const Duration &other)
 

Protected Fields

TDuration span
 

Protected Methods

 Duration (TDuration internalValue)
 

Member Typedef Documentation

◆ TDuration

using TDuration = typename std::chrono::steady_clock::duration

The value type for time spans.

Definition at line 121 of file timepointbase.hpp.

Constructor & Destructor Documentation

◆ Duration() [1/2]

Duration ( TDuration  internalValue)
inlineprotected

Protected constructor.

For construction with C++ library values, see method Import.

Parameters
internalValueThe value to copy into this.

Definition at line 137 of file timepointbase.hpp.

◆ Duration() [2/2]

constexpr Duration ( )
inlineconstexpr

Creates a zero-length time span.

Definition at line 150 of file timepointbase.hpp.

Member Function Documentation

◆ Export()

TDuration Export ( ) const
inline

Returns the internal time span value using the C++ standard library format.

Returns
The internal value.

Definition at line 162 of file timepointbase.hpp.

◆ FromAbsoluteDays()

static Duration FromAbsoluteDays ( int64_t  days)
inlinestatic

Sets the internal value to a time span provided in days.

Parameters
daysThe time span to set in days.
Returns
*this to allow concatenated calls.

Definition at line 527 of file timepointbase.hpp.

◆ FromAbsoluteHours()

static Duration FromAbsoluteHours ( int64_t  hours)
inlinestatic

Sets the internal value to a time span provided in hours.

Parameters
hoursThe time span to set in hours.
Returns
*this to allow concatenated calls.

Definition at line 551 of file timepointbase.hpp.

◆ FromAbsoluteMicroseconds()

static Duration FromAbsoluteMicroseconds ( int64_t  microseconds)
inlinestatic

Sets the internal value to a time span provided in microseconds.

Parameters
microsecondsThe time span to set in microseconds.
Returns
*this to allow concatenated calls.

Definition at line 647 of file timepointbase.hpp.

◆ FromAbsoluteMilliseconds()

static Duration FromAbsoluteMilliseconds ( int64_t  milliseconds)
inlinestatic

Sets the internal value to a time span provided in milliseconds.

Parameters
millisecondsThe time span to set in milliseconds.
Returns
*this to allow concatenated calls.

Definition at line 623 of file timepointbase.hpp.

◆ FromAbsoluteMinutes()

static Duration FromAbsoluteMinutes ( int64_t  minutes)
inlinestatic

Sets the internal value to a time span provided in hours.

Parameters
minutesThe time span to set in minutes.
Returns
*this to allow concatenated calls.

Definition at line 575 of file timepointbase.hpp.

◆ FromAbsoluteSeconds()

static Duration FromAbsoluteSeconds ( int64_t  seconds)
inlinestatic

Sets the internal value to a time span provided in seconds.

Parameters
secondsThe time span to set in seconds.
Returns
*this to allow concatenated calls.

Definition at line 599 of file timepointbase.hpp.

◆ FromDays()

static Duration FromDays ( double  days)
inlinestatic

Sets the internal value to a time span provided in days.

Parameters
daysThe time span to set in days.
Returns
*this to allow concatenated calls.

Definition at line 515 of file timepointbase.hpp.

◆ FromHours()

static Duration FromHours ( double  hours)
inlinestatic

Sets the internal value to a time span provided in hours.

Parameters
hoursThe time span to set in hours.
Returns
*this to allow concatenated calls.

Definition at line 539 of file timepointbase.hpp.

◆ FromMicroseconds()

static Duration FromMicroseconds ( double  microseconds)
inlinestatic

Sets the internal value to a time span provided in microseconds.

Parameters
microsecondsThe time span to set in microseconds.
Returns
*this to allow concatenated calls.

Definition at line 635 of file timepointbase.hpp.

◆ FromMilliseconds()

static Duration FromMilliseconds ( double  milliseconds)
inlinestatic

Sets the internal value to a time span provided in milliseconds.

Parameters
millisecondsThe time span to set in milliseconds.
Returns
*this to allow concatenated calls.

Definition at line 611 of file timepointbase.hpp.

◆ FromMinutes()

static Duration FromMinutes ( double  minutes)
inlinestatic

Sets the internal value to a time span provided in hours.

Parameters
minutesThe time span to set in minutes.
Returns
*this to allow concatenated calls.

Definition at line 563 of file timepointbase.hpp.

◆ FromNanoseconds()

static Duration FromNanoseconds ( int64_t  nanoseconds)
inlinestatic

Sets the internal value to a time span provided in nanoseconds.

Parameters
nanosecondsThe time span to set in nanoseconds.
Returns
*this to allow concatenated calls.

Definition at line 659 of file timepointbase.hpp.

◆ FromSeconds()

static Duration FromSeconds ( double  seconds)
inlinestatic

Sets the internal value to a time span provided in seconds.

Parameters
secondsThe time span to set in seconds.
Returns
*this to allow concatenated calls.

Definition at line 587 of file timepointbase.hpp.

◆ Import()

static Duration Import ( TDuration  timeSpan)
inlinestatic

Creates an instance representing the time span given in C++ standard library format.

Parameters
timeSpanThe C++ stead clock time point value.
Returns
A time span value representing the given externalized timeSpan.

Definition at line 170 of file timepointbase.hpp.

Here is the call graph for this function:

◆ InAbsoluteDays()

integer InAbsoluteDays ( ) const
inline

Converts the internal value to absolute days.

Returns
The internal value converted to days.

Definition at line 371 of file timepointbase.hpp.

◆ InAbsoluteHours()

integer InAbsoluteHours ( ) const
inline

Converts the internal value to absolute hours.

Returns
The internal value converted to hours.

Definition at line 391 of file timepointbase.hpp.

◆ InAbsoluteMicroseconds()

int64_t InAbsoluteMicroseconds ( ) const
inline

Converts the internal value to absolute microseconds.

Returns
The internal value converted to microseconds.

Definition at line 467 of file timepointbase.hpp.

◆ InAbsoluteMilliseconds()

int64_t InAbsoluteMilliseconds ( ) const
inline

Converts the internal value to absolute milliseconds.

Returns
The internal value converted to milliseconds.

Definition at line 448 of file timepointbase.hpp.

◆ InAbsoluteMinutes()

int64_t InAbsoluteMinutes ( ) const
inline

Converts the internal value to absolute minutes.

Returns
The internal value converted to minutes.

Definition at line 410 of file timepointbase.hpp.

◆ InAbsoluteSeconds()

int64_t InAbsoluteSeconds ( ) const
inline

Converts the internal value to absolute seconds.

Returns
The internal value converted to seconds.

Definition at line 429 of file timepointbase.hpp.

◆ InDays()

double InDays ( ) const
inline

Converts the internal value to days.

Returns
The internal value converted to days.

Definition at line 361 of file timepointbase.hpp.

◆ InHertz()

double InHertz ( int  qtyFractionalDigits = -1) const
inline

Returns 1 divided by internal value in seconds, hence the number of Hertz that this object represents when interpreted as a time span.

Parameters
qtyFractionalDigitsNumber of digits that the return value will be rounded to. Defaults to -1 which means no rounding.
Returns
double value representing the frequency in hertz.

Definition at line 489 of file timepointbase.hpp.

Here is the call graph for this function:

◆ InHours()

double InHours ( ) const
inline

Converts the internal value to hours.

Returns
The internal value converted to hours.

Definition at line 381 of file timepointbase.hpp.

◆ InMicroseconds()

double InMicroseconds ( ) const
inline

Converts the internal value to microseconds.

Returns
The internal value converted to microseconds.

Definition at line 457 of file timepointbase.hpp.

◆ InMilliseconds()

double InMilliseconds ( ) const
inline

Converts the internal value to milliseconds.

Returns
The internal value converted to milliseconds.

Definition at line 438 of file timepointbase.hpp.

◆ InMinutes()

double InMinutes ( ) const
inline

Converts the internal value to minutes.

Returns
The internal value converted to minutes.

Definition at line 400 of file timepointbase.hpp.

◆ InNanoseconds()

int64_t InNanoseconds ( ) const
inline

Converts the internal value to nanoseconds.

Returns
The internal value converted to nanoseconds.

Definition at line 476 of file timepointbase.hpp.

◆ InSeconds()

double InSeconds ( ) const
inline

Converts the internal value to seconds.

Returns
The internal value converted to seconds.

Definition at line 419 of file timepointbase.hpp.

◆ operator!=()

bool operator!= ( const Duration other) const
inline

Not equal to operator.

Parameters
otherThe time stamp to compare.
Returns
The result of the comparison.

Definition at line 208 of file timepointbase.hpp.

◆ operator*() [1/2]

Duration operator* ( double  multiplier) const
inline

Multiply operator.

Parameters
multiplierThe multiplier.
Returns
A time span object containing the sum.

Definition at line 271 of file timepointbase.hpp.

◆ operator*() [2/2]

Duration operator* ( int64_t  multiplier) const
inline

Multiply operator.

Parameters
multiplierThe multiplier.
Returns
A time span object containing the sum.

Definition at line 281 of file timepointbase.hpp.

◆ operator*=() [1/2]

Duration& operator*= ( double  multiplier)
inline

Assignment by product operator.

Parameters
multiplierThe multiplier.
Returns
A reference to this object.

Definition at line 291 of file timepointbase.hpp.

◆ operator*=() [2/2]

Duration& operator*= ( int64_t  multiplier)
inline

Assignment by product operator.

Parameters
multiplierThe multiplier.
Returns
A reference to this object.

Definition at line 302 of file timepointbase.hpp.

◆ operator+()

Duration operator+ ( const Duration rhs) const
inline

Addition operator.

Parameters
rhsThe right-hand side time span to add.
Returns
A time span object containing the sum.

Definition at line 243 of file timepointbase.hpp.

Here is the call graph for this function:

◆ operator+=()

Duration& operator+= ( const Duration other)
inline

Assignment by sum operator.

Parameters
otherThe time span object subtract.
Returns
A reference to this object.

Definition at line 250 of file timepointbase.hpp.

◆ operator-()

Duration operator- ( const Duration rhs) const
inline

Subtraction operator.

Parameters
rhsThe right-hand side time span object to subtract.
Returns
A time span object containing the sum.

Definition at line 257 of file timepointbase.hpp.

Here is the call graph for this function:

◆ operator-=()

Duration& operator-= ( const Duration other)
inline

Assignment by difference operator.

Parameters
otherThe time span object subtract.
Returns
A reference to this object.

Definition at line 264 of file timepointbase.hpp.

◆ operator/() [1/2]

Duration operator/ ( double  divisor) const
inline

Divide operator.

Parameters
divisorThe divisor.
Returns
A time span object containing the sum.

Definition at line 313 of file timepointbase.hpp.

◆ operator/() [2/2]

Duration operator/ ( int64_t  divisor) const
inline

Divide operator.

Parameters
divisorThe divisor.
Returns
A time span object containing the sum.

Definition at line 323 of file timepointbase.hpp.

◆ operator/=() [1/2]

Duration& operator/= ( double  divisor)
inline

Assignment by quotient operator.

Parameters
divisorThe divisor.
Returns
A reference to this object.

Definition at line 333 of file timepointbase.hpp.

◆ operator/=() [2/2]

Duration& operator/= ( int64_t  divisor)
inline

Assignment by quotient operator.

Parameters
divisorThe divisor.
Returns
A reference to this object.

Definition at line 345 of file timepointbase.hpp.

◆ operator<()

bool operator< ( const Duration other) const
inline

Less than operator.

Parameters
otherThe time stamp to compare.
Returns
A reference to this object.

Definition at line 215 of file timepointbase.hpp.

◆ operator<=()

bool operator<= ( const Duration other) const
inline

Less than or equal to operator.

Parameters
otherThe time stamp to compare.
Returns
The result of the comparison.

Definition at line 222 of file timepointbase.hpp.

◆ operator==()

bool operator== ( const Duration other) const
inline

Equal to operator.

Parameters
otherThe time stamp to compare.
Returns
The result of the comparison.

Definition at line 200 of file timepointbase.hpp.

◆ operator>()

bool operator> ( const Duration other) const
inline

Greater than operator.

Parameters
otherThe time stamp to compare.
Returns
The result of the comparison.

Definition at line 229 of file timepointbase.hpp.

◆ operator>=()

bool operator>= ( const Duration other) const
inline

Greater than or equal to operator.

Parameters
otherThe time stamp to compare.
Returns
The result of the comparison.

Definition at line 236 of file timepointbase.hpp.

◆ SetMaximum()

Duration& SetMaximum ( const Duration other)
inline

Sets this object's value to the given duration, in the case the given is longer.

Parameters
otherThe time stamp to compare.
Returns
A reference to this object.

Definition at line 189 of file timepointbase.hpp.

◆ SetMinimum()

Duration& SetMinimum ( const Duration other)
inline

Sets this object's value to the given duration, in the case the given is shorter.

Parameters
otherThe time stamp to compare.
Returns
A reference to this object.

Definition at line 178 of file timepointbase.hpp.

Member Data Documentation

◆ span

TDuration span
protected

The internal time value.

Definition at line 129 of file timepointbase.hpp.


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