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 88 of file timepointbase.hpp.
#include <timepointbase.hpp>
Inner Type Index: | |
class | Duration |
Public Type Index: | |
using | TRaw = typename TTimePoint::rep |
using | TTimePoint = typename TClock::time_point |
Public Static Method Index: | |
static TDerived | FromRaw (TRaw raw) |
static TDerived | Now () |
Public Method Index: | |
constexpr | TimePointBase (lang::Initialization init=lang::Initialization::Perform) |
constexpr | TimePointBase (TTimePoint internalValue) |
Duration | Age () const |
TTimePoint | Export () const |
void | Import (TTimePoint timePoint) |
bool | IsOlderThan (Duration timeSpan) const |
bool | IsSet () |
TDerived | operator+ (const Duration &timeSpan) const |
TDerived | operator+= (const Duration &timeSpan) |
TDerived | operator- (const Duration &timeSpan) const |
Duration | operator- (const TDerived &other) const |
TDerived | operator-= (const Duration &timeSpan) |
TDerived & | Reset () |
void | SetAs (const TDerived &other) |
void | SetFromRaw (TRaw raw) |
Duration | Since (const TDerived &other) const |
TRaw | ToRaw () const |
void | Unset () |
using TRaw = typename TTimePoint::rep |
Integral type used for exporting and importing values in raw units.
Definition at line 95 of file timepointbase.hpp.
using TTimePoint = typename TClock::time_point |
The internal c++ type for time points.
Definition at line 92 of file timepointbase.hpp.
|
protected |
The internal timer value. This value can be accessed using methods Export and Import.
Definition at line 673 of file timepointbase.hpp.
|
inlineconstexpr |
Creates an instance representing the point in time when this constructor was invoked.
The default invocation measures the current point in time, which introduces some effort. To avoid this in situations where an instance is overwritten by the result of static method Now at a later point in time, parameter init can be used to suppress the initial measurement.
init | If Initialization::Perform , the current time is measured and set. If Initialization::Suppress , the time stamp will be initialized to represent the start of the epoch.Defaults to Initialization::Perform . |
Definition at line 695 of file timepointbase.hpp.
|
inlineconstexpr |
Constructor using native C++ library values.
internalValue | The value to copy into this. |
Definition at line 730 of file timepointbase.hpp.
|
inline |
Returns the time span between 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 883 of file timepointbase.hpp.
|
inline |
Returns the internal time value in the C++ standard library type.
Definition at line 773 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 814 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 782 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 910 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 746 of file timepointbase.hpp.
|
inlinestatic |
Returns an instance representing the actual point in time.
Definition at line 707 of file timepointbase.hpp.
|
inline |
Addition operator.
timeSpan | The time span to add. |
Definition at line 824 of file timepointbase.hpp.
|
inline |
Assignment by sum operator.
timeSpan | The time span to add. |
Definition at line 834 of file timepointbase.hpp.
|
inline |
Subtraction operator.
timeSpan | The time span to subtract. |
Definition at line 845 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 867 of file timepointbase.hpp.
|
inline |
Assignment by difference operator.
timeSpan | The time span to subtract. |
Definition at line 855 of file timepointbase.hpp.
|
inline |
Resets this instance to the current point in time.
this
, (casted to the derived type) to allow concatenated operations. Definition at line 717 of file timepointbase.hpp.
|
inline |
Copies the value from the given object.
other | The point in time to copy from. |
Definition at line 764 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 802 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 897 of file timepointbase.hpp.
|
inline |
Returns the internal time value in the C++ standard library's tick unit.
Definition at line 793 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 755 of file timepointbase.hpp.