5#include "structure/design_pattern/spk_cached_data.hpp"
6#include "structure/system/time/spk_duration.hpp"
7#include "type/spk_time_unit.hpp"
18 TimeUnit _unit = TimeUnit::Nanosecond;
19 std::variant<double, long long> _value;
25 double _generateSeconds()
const;
26 long long _generateMilliseconds()
const;
27 long long _generateNanoseconds()
const;
29 void _resetCaches()
const;
32 Timestamp _fromNanoseconds(
long long p_nanoseconds)
const;
44 Timestamp(
long double p_value, TimeUnit p_unit);
Lazily generates and caches a value with optional custom destructor.
Definition spk_cached_data.hpp:26
Strongly-typed time span with cached conversions between ns/ms/s.
Definition spk_duration.hpp:15
Timestamp & operator=(const Timestamp &p_other)
Copies timestamp value and caches from another instance.
Definition spk_timestamp.cpp:140
long long nanoseconds() const
Returns the timestamp expressed in nanoseconds.
Definition spk_timestamp.cpp:176
Timestamp & operator-=(const Duration &p_other)
Subtracts a duration from this timestamp in place.
Definition spk_timestamp.cpp:207
bool operator<(const Timestamp &p_other) const
Strictly-less comparison using canonical nanoseconds.
Definition spk_timestamp.cpp:226
bool operator>=(const Timestamp &p_other) const
Greater-or-equal comparison using canonical nanoseconds.
Definition spk_timestamp.cpp:241
bool operator!=(const Timestamp &p_other) const
Inequality comparison using canonical nanoseconds.
Definition spk_timestamp.cpp:221
Timestamp & operator+=(const Duration &p_other)
Adds a duration to this timestamp in place.
Definition spk_timestamp.cpp:198
Timestamp()
Captures current time in nanoseconds.
Definition spk_timestamp.cpp:70
long long milliseconds() const
Returns the timestamp expressed in milliseconds.
Definition spk_timestamp.cpp:171
bool operator==(const Timestamp &p_other) const
Equality comparison using canonical nanoseconds.
Definition spk_timestamp.cpp:216
bool operator>(const Timestamp &p_other) const
Strictly-greater comparison using canonical nanoseconds.
Definition spk_timestamp.cpp:231
Duration operator-(const Timestamp &p_other) const
Computes the duration separating two timestamps.
Definition spk_timestamp.cpp:181
bool operator<=(const Timestamp &p_other) const
Less-or-equal comparison using canonical nanoseconds.
Definition spk_timestamp.cpp:236
Timestamp operator+(const Duration &p_other) const
Shifts the timestamp forward by a duration.
Definition spk_timestamp.cpp:186
double seconds() const
Returns the timestamp expressed in seconds.
Definition spk_timestamp.cpp:166