As explained in detail in the documentation of module ALib Time, a steady time model is supported with class Ticks and a non-steady one representing the system clock with class DateTime. Both types share this template class as their generic base.
The common features that this class provides to its descendants are:
std::chrono::time_point
.+-292.27
years before and after the point in time that the system that the software is running on was initialized (bootstrapped). This value results from the following facts for these implementations:0
with the boot of a system.Now, dividing 2^63
by the number of nanoseconds of one year which consists of roughly 365.25 days, this results in 292.27 years.
TClock | The type of clock to use. This will be |
TDerived | The derived type itself, hence either DateTime or Ticks. This template parameter is needed to define the result type of various methods and operators. |
Definition at line 74 of file timepointbase.hpp.
#include <timepointbase.hpp>
Inner Type Index: | |
class | Duration |
Public Type Index: | |
using | TRaw = typename TTimePoint::rep |
Integral type used for exporting and importing values in raw units. | |
using | TTimePoint = typename TClock::time_point |
The internal c++ type for time points. | |
Public Static Method Index: | |
static TDerived | BeginningOfEpoch () |
static TDerived | EndOfEpoch () |
static TDerived | FromRaw (TRaw raw) |
static TDerived | Now () |
Public Method Index: | |
constexpr | TimePointBase (const lang::Initialization init=lang::Initialization::Default) |
constexpr | TimePointBase (TTimePoint internalValue) |
Duration | Age () const |
TTimePoint | Export () const |
void | Import (TTimePoint timePoint) |
bool | IsOlderThan (const Duration &timeSpan) const |
bool | IsSet () |
TDerived | operator+ (const Duration &timeSpan) const |
TDerived | operator+ (const typename Duration::TDuration &timeSpan) const |
TDerived | operator+= (const Duration &timeSpan) |
TDerived | operator+= (const typename Duration::TDuration &timeSpan) |
TDerived | operator- (const Duration &timeSpan) const |
Duration | operator- (const TDerived &other) const |
TDerived | operator- (const typename Duration::TDuration &timeSpan) const |
TDerived | operator-= (const Duration &timeSpan) |
TDerived | operator-= (const typename Duration::TDuration &timeSpan) |
TDerived & | Reset () |
void | SetAs (const TDerived &other) |
void | SetFromRaw (TRaw raw) |
Duration | Since (const TDerived &other) const |
TRaw | ToRaw () const |
void | Unset () |
Protected Field Index: | |
TTimePoint | stamp |
using TRaw = typename TTimePoint::rep |
Integral type used for exporting and importing values in raw units.
Definition at line 81 of file timepointbase.hpp.
using TTimePoint = typename TClock::time_point |
The internal c++ type for time points.
Definition at line 78 of file timepointbase.hpp.
|
protected |
The internal timer value. This value can be accessed using methods Export and Import.
Definition at line 684 of file timepointbase.hpp.
|
inlineconstexpr |
Constructor. With parameter init being defaulted, this constructor acts as the default constructor, which creates an instance representing the point in time when this constructor was invoked. This measures the current point in time, which introduces some effort.
To avoid this in situations where an instance is overwritten after construction (i.e., before it is read), parameter init can be passed to either Suppress or Nulled. Both values set this instance to a nulled state, as complete suppression is not available. Inn many situations the compiler will optimize out a nulled construction.
If not initialized, the method IsSet will return false
.
init | If Initialization::Default , the current time is measured and set. Defaults to Initialization::Default . |
Definition at line 707 of file timepointbase.hpp.
|
inlineconstexpr |
Constructor using native C++ library values.
internalValue | The value to copy into this. |
Definition at line 750 of file timepointbase.hpp.
|
inline |
Returns the time span between the value represented by this instance and the current system time. If the internal value represents a historic point in time, the result is positive.
Definition at line 923 of file timepointbase.hpp.
|
inlinestatic |
Returns an instance representing the beginning of the epoch. No time point represented by this type can be further in the past.
Definition at line 724 of file timepointbase.hpp.
|
inlinestatic |
Returns an instance representing the end of the epoch. No time point represented by this type can be further in the future.
Definition at line 730 of file timepointbase.hpp.
|
inline |
Returns the internal time value in the C++ standard library type.
Definition at line 793 of file timepointbase.hpp.
|
inlinestatic |
Creates an instance from a value of C++ standard library's tick unit type.
raw | The time span to create in raw units. |
Definition at line 830 of file timepointbase.hpp.
|
inline |
Sets the internal time value given by a value of C++ standard library type.
timePoint | The value to set. |
Definition at line 802 of file timepointbase.hpp.
|
inline |
Determines if this object's age is higher than a given time span.
timeSpan | A time span to compare. |
true
if the given time span is smaller equal than the age of this object, hence to the time span passed since the point in time this object represents. false
otherwise. Definition at line 946 of file timepointbase.hpp.
|
inline |
Returns true
if this object is not representing the start of the epoch. An uninitialized object that returns false
can be created with provision of Initialization::Suppress
on construction.
true
if this object is initialized, false
otherwise. Definition at line 766 of file timepointbase.hpp.
|
inlinestatic |
Returns an instance representing the actual point in time.
Definition at line 718 of file timepointbase.hpp.
|
inline |
Addition operator.
timeSpan | The time span to add. |
Definition at line 838 of file timepointbase.hpp.
|
inline |
Addition operator.
timeSpan | The time span to add. |
Definition at line 846 of file timepointbase.hpp.
|
inline |
Assignment by sum operator.
timeSpan | The time span to add. |
Definition at line 854 of file timepointbase.hpp.
|
inline |
Assignment by sum operator.
timeSpan | The time span to add. |
Definition at line 865 of file timepointbase.hpp.
|
inline |
Subtraction operator.
timeSpan | The time span to subtract. |
Definition at line 873 of file timepointbase.hpp.
|
inline |
Subtraction operator with other time span argument. If the given time stamp represents a point in type earlier than the one this object represents, the result is positive.
other | The time stamp to subtract. |
Definition at line 909 of file timepointbase.hpp.
|
inline |
Subtraction operator.
timeSpan | The time span to subtract. |
Definition at line 881 of file timepointbase.hpp.
|
inline |
Assignment by difference operator.
timeSpan | The time span to subtract. |
Definition at line 889 of file timepointbase.hpp.
|
inline |
Assignment by difference operator.
timeSpan | The time span to subtract. |
Definition at line 900 of file timepointbase.hpp.
|
inline |
Resets this instance to the current point in time.
this
, (cast to the derived type) to allow concatenated operations. Definition at line 737 of file timepointbase.hpp.
|
inline |
Copies the value from the given object.
other | The point in time to copy from. |
Definition at line 784 of file timepointbase.hpp.
|
inline |
Sets the value from a value of C++ standard library's tick unit type.
raw | The time span to create in raw units. |
Definition at line 820 of file timepointbase.hpp.
|
inline |
Returns the time span between the value represented by this instance and the given other time stamp. If the given time stamp represents an earlier point in time, the result is positive.
other | The value to compare this instance with |
Definition at line 935 of file timepointbase.hpp.
|
inline |
Returns the internal time value in the C++ standard library's tick unit.
Definition at line 813 of file timepointbase.hpp.
|
inline |
Unsets this object, hence makes this object representing the start of the epoch, as if it was constructed with parameter value Initialization::Suppress
.
Definition at line 775 of file timepointbase.hpp.