ALib C++ Library
Library Version: 2412 R0
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.).

Appending Durations to Class AString

An specialization of struct T_Append for this type exists with the inclusion of camp ALib BaseCamp in the ALib Distribution and the inclusion of alib/lang/system/calendar.hpp.

Friends

class TimePointBase

Definition at line 102 of file timepointbase.hpp.

#include <timepointbase.hpp>

Public Type Index:

using TDuration = sc steady_clock::duration
 The value type for time spans.
 

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 (const TDuration &timeSpan)
 

Public Method Index:

constexpr Duration ()
 Creates a zero-length time span.
 
 Duration (const TDuration &stdLibValue)
 
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 IsPositive () const
 
bool IsZero () const
 
bool operator!= (const Duration &other) const
 
bool operator!= (const TDuration &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
 
Duration operator+ (const TDuration &rhs) const
 
Durationoperator+= (const Duration &other)
 
Durationoperator+= (const TDuration &other)
 
Duration operator- (const Duration &rhs) const
 
Duration operator- (const TDuration &rhs) const
 
Durationoperator-= (const Duration &other)
 
Durationoperator-= (const TDuration &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 TDuration &other) const
 
bool operator<= (const Duration &other) const
 
bool operator<= (const TDuration &other) const
 
Durationoperator= (const TDuration &stdLibValue)
 
bool operator== (const Duration &other) const
 
bool operator== (const TDuration &other) const
 
bool operator> (const Duration &other) const
 
bool operator> (const TDuration &other) const
 
bool operator>= (const Duration &other) const
 
bool operator>= (const TDuration &other) const
 
DurationSetMaximum (const Duration &other)
 
DurationSetMinimum (const Duration &other)
 

Protected Field Index:

TDuration span
 The internal time value.
 

Type Definition Details:

◆ TDuration

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

The value type for time spans.

Definition at line 112 of file timepointbase.hpp.

Field Details:

◆ span

template<typename TClock , typename TDerived >
TDuration span
protected

The internal time value.

Definition at line 120 of file timepointbase.hpp.

Constructor(s) / Destructor Details:

◆ Duration() [1/2]

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

Creates a zero-length time span.

Definition at line 131 of file timepointbase.hpp.

◆ Duration() [2/2]

template<typename TClock , typename TDerived >
Duration ( const TDuration & stdLibValue)
inline

Constructs an instance from C++ library values.

See also
Methods Import/Export.
Parameters
stdLibValueThe value to copy into this.

Definition at line 138 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 156 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 574 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 592 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 664 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 646 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 610 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 628 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 565 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 583 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 655 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 637 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 601 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 673 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 619 of file timepointbase.hpp.

◆ Import()

template<typename TClock , typename TDerived >
static Duration Import ( const TDuration & timeSpan)
inlinestatic

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

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

Definition at line 164 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 421 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 441 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 517 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 498 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 460 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 479 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 411 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 539 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 431 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 507 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 488 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 450 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 526 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 469 of file timepointbase.hpp.

◆ IsPositive()

template<typename TClock , typename TDerived >
bool IsPositive ( ) const
inline
Returns
true if this is a positive duration, false otherwise.

Definition at line 190 of file timepointbase.hpp.

◆ IsZero()

template<typename TClock , typename TDerived >
bool IsZero ( ) const
inline
Returns
true if this is is a zero-length time-span, false otherwise.

Definition at line 193 of file timepointbase.hpp.

◆ operator!=() [1/2]

template<typename TClock , typename TDerived >
bool operator!= ( const Duration & other) const
inline

Not equal to operator.

Parameters
otherThe duration to compare.
Returns
The result of the comparison.

Definition at line 215 of file timepointbase.hpp.

◆ operator!=() [2/2]

template<typename TClock , typename TDerived >
bool operator!= ( const TDuration & other) const
inline

Not equal to operator.

Parameters
otherThe duration to compare.
Returns
The result of the comparison.

Definition at line 222 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 containing the sum.

Definition at line 341 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 containing the sum.

Definition at line 349 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 357 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 365 of file timepointbase.hpp.

◆ operator+() [1/2]

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 containing the sum.

Definition at line 285 of file timepointbase.hpp.

Here is the call graph for this function:

◆ operator+() [2/2]

template<typename TClock , typename TDerived >
Duration operator+ ( const TDuration & rhs) const
inline

Addition operator.

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

Definition at line 292 of file timepointbase.hpp.

Here is the call graph for this function:

◆ operator+=() [1/2]

template<typename TClock , typename TDerived >
Duration & operator+= ( const Duration & other)
inline

Assignment by sum operator.

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

Definition at line 299 of file timepointbase.hpp.

◆ operator+=() [2/2]

template<typename TClock , typename TDerived >
Duration & operator+= ( const TDuration & other)
inline

Assignment by sum operator.

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

Definition at line 306 of file timepointbase.hpp.

◆ operator-() [1/2]

template<typename TClock , typename TDerived >
Duration operator- ( const Duration & rhs) const
inline

Subtraction operator.

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

Definition at line 313 of file timepointbase.hpp.

Here is the call graph for this function:

◆ operator-() [2/2]

template<typename TClock , typename TDerived >
Duration operator- ( const TDuration & rhs) const
inline

Subtraction operator.

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

Definition at line 320 of file timepointbase.hpp.

Here is the call graph for this function:

◆ operator-=() [1/2]

template<typename TClock , typename TDerived >
Duration & operator-= ( const Duration & other)
inline

Assignment by difference operator.

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

Definition at line 327 of file timepointbase.hpp.

◆ operator-=() [2/2]

template<typename TClock , typename TDerived >
Duration & operator-= ( const TDuration & other)
inline

Assignment by difference operator.

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

Definition at line 334 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 containing the sum.

Definition at line 373 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 381 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 389 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 398 of file timepointbase.hpp.

◆ operator<() [1/2]

template<typename TClock , typename TDerived >
bool operator< ( const Duration & other) const
inline

Less than operator.

Parameters
otherThe duration to compare.
Returns
A reference to this object.

Definition at line 229 of file timepointbase.hpp.

◆ operator<() [2/2]

template<typename TClock , typename TDerived >
bool operator< ( const TDuration & other) const
inline

Less than operator.

Parameters
otherThe duration to compare.
Returns
A reference to this object.

Definition at line 236 of file timepointbase.hpp.

◆ operator<=() [1/2]

template<typename TClock , typename TDerived >
bool operator<= ( const Duration & other) const
inline

Less than or equal to operator.

Parameters
otherThe duration to compare.
Returns
The result of the comparison.

Definition at line 243 of file timepointbase.hpp.

◆ operator<=() [2/2]

template<typename TClock , typename TDerived >
bool operator<= ( const TDuration & other) const
inline

Less than or equal to operator.

Parameters
otherThe duration to compare.
Returns
The result of the comparison.

Definition at line 250 of file timepointbase.hpp.

◆ operator=()

template<typename TClock , typename TDerived >
Duration & operator= ( const TDuration & stdLibValue)
inline

Constructs an instance from C++ library values.

See also
Methods Import/Export.
Parameters
stdLibValueThe value to copy into this.
Returns
A reference to this object.

Definition at line 146 of file timepointbase.hpp.

◆ operator==() [1/2]

template<typename TClock , typename TDerived >
bool operator== ( const Duration & other) const
inline

Equal to operator.

Parameters
otherThe duration to compare.
Returns
The result of the comparison.

Definition at line 200 of file timepointbase.hpp.

◆ operator==() [2/2]

template<typename TClock , typename TDerived >
bool operator== ( const TDuration & other) const
inline

Equal to operator.

Parameters
otherThe duration to compare.
Returns
The result of the comparison.

Definition at line 208 of file timepointbase.hpp.

◆ operator>() [1/2]

template<typename TClock , typename TDerived >
bool operator> ( const Duration & other) const
inline

Greater than operator.

Parameters
otherThe duration to compare.
Returns
The result of the comparison.

Definition at line 257 of file timepointbase.hpp.

◆ operator>() [2/2]

template<typename TClock , typename TDerived >
bool operator> ( const TDuration & other) const
inline

Greater than operator.

Parameters
otherThe duration to compare.
Returns
The result of the comparison.

Definition at line 264 of file timepointbase.hpp.

◆ operator>=() [1/2]

template<typename TClock , typename TDerived >
bool operator>= ( const Duration & other) const
inline

Greater than or equal to operator.

Parameters
otherThe duration to compare.
Returns
The result of the comparison.

Definition at line 271 of file timepointbase.hpp.

◆ operator>=() [2/2]

template<typename TClock , typename TDerived >
bool operator>= ( const TDuration & other) const
inline

Greater than or equal to operator.

Parameters
otherThe duration to compare.
Returns
The result of the comparison.

Definition at line 278 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 183 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 172 of file timepointbase.hpp.


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