ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
TimePointBase< TClock, TDerived >::Duration Class Reference

Description:

template<typename TClock, typename TDerived>
class alib::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 BaseCamp ) 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.

#include <timepointbase.hpp>

Public Type Index:

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

Public Static Method Index:

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 Method Index:

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)
 

Type Definition Details:

◆ TDuration

template<typename TClock , typename TDerived >
using TDuration = typename std::chrono::steady_clock::duration

The value type for time spans.

Definition at line 121 of file timepointbase.hpp.

Field Details:

◆ span

template<typename TClock , typename TDerived >
TDuration span
protected

The internal time value.

Definition at line 129 of file timepointbase.hpp.

Constructor(s) / Destructor Details::

◆ Duration() [1/2]

template<typename TClock , typename TDerived >
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]

template<typename TClock , typename TDerived >
constexpr Duration ( )
inlineconstexpr

Creates a zero-length time span.

Definition at line 150 of file timepointbase.hpp.

Method Details:

◆ Export()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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!=()

template<typename TClock , typename TDerived >
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]

template<typename TClock , typename TDerived >
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]

template<typename TClock , typename TDerived >
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]

template<typename TClock , typename TDerived >
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]

template<typename TClock , typename TDerived >
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+()

template<typename TClock , typename TDerived >
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+=()

template<typename TClock , typename TDerived >
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-()

template<typename TClock , typename TDerived >
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-=()

template<typename TClock , typename TDerived >
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]

template<typename TClock , typename TDerived >
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]

template<typename TClock , typename TDerived >
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]

template<typename TClock , typename TDerived >
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]

template<typename TClock , typename TDerived >
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<()

template<typename TClock , typename TDerived >
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<=()

template<typename TClock , typename TDerived >
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==()

template<typename TClock , typename TDerived >
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>()

template<typename TClock , typename TDerived >
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>=()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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()

template<typename TClock , typename TDerived >
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.


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