Ocean
|
This class implements a timestamp. More...
Public Member Functions | |
Timestamp ()=default | |
Creates a new timestamp with invalid time. More... | |
Timestamp (const bool toNow) | |
Creates a new timestamp. More... | |
Timestamp (const double timestamp) | |
Creates a new timestamp with a given value. More... | |
Timestamp & | toNow () |
Sets the timestamp to the current time. More... | |
Timestamp & | toInvalid () |
Sets the timestamp to invalid. More... | |
int64_t | nanoseconds () const |
Returns this timestamp in nanoseconds. More... | |
bool | hasTimePassed (const double seconds, const Timestamp ¤tTimestamp=Timestamp(true)) const |
Returns whether a specified amount of time has passed since this timestamp. More... | |
bool | isValid () const |
Returns whether the timestamp holds a valid time. More... | |
bool | isInvalid () const |
Returns whether the timestamp holds an invalid time. More... | |
Timestamp & | operator= (const double timestamp) |
Assign a new value. More... | |
Timestamp | operator+ (const Timestamp &right) const |
Adds two timestamps. More... | |
Timestamp & | operator+= (const Timestamp &right) |
Adds and assigns two timestamps. More... | |
Timestamp | operator+ (const double seconds) const |
Adds seconds to this timestamps. More... | |
Timestamp & | operator+= (const double seconds) |
Adds and assigns seconds to this timestamps. More... | |
Timestamp | operator- (const Timestamp &right) const |
Subtracts two timestamps. More... | |
Timestamp & | operator-= (const Timestamp &right) |
Subtracts and assigns two timestamps. More... | |
Timestamp | operator- (const double seconds) const |
Subtracts seconds from this timestamp. More... | |
Timestamp & | operator-= (const double seconds) |
Subtracts and assigns seconds from this timestamp. More... | |
bool | operator< (const Timestamp &right) const |
Returns whether the this timestamp is lesser than the right one. More... | |
bool | operator<= (const Timestamp &right) const |
Returns whether the this timestamp is lesser or equal to the right one. More... | |
bool | operator> (const Timestamp &right) const |
Returns whether the this timestamp is greater than the right one. More... | |
bool | operator>= (const Timestamp &right) const |
Returns whether the this timestamp is greater or equal to the right one. More... | |
bool | operator== (const Timestamp &right) const |
Returns whether two timestamps are identical. More... | |
bool | operator!= (const Timestamp &right) const |
Returns whether two timestamps are not identical. More... | |
operator double () const | |
Cast operator for the timestamp value. More... | |
size_t | operator() (const Timestamp ×tamp) const |
Hash function. More... | |
Static Public Member Functions | |
static constexpr int64_t | seconds2milliseconds (const double seconds) |
Converts seconds to milliseconds. More... | |
static constexpr int64_t | seconds2microseconds (const double seconds) |
Converts seconds to microseconds. More... | |
static constexpr int64_t | seconds2nanoseconds (const double seconds) |
Converts seconds to nanoseconds. More... | |
static constexpr double | milliseconds2seconds (const int64_t milliseconds) |
Converts milliseconds to seconds. More... | |
static constexpr double | microseconds2seconds (const int64_t microseconds) |
Converts microseconds to seconds. More... | |
static constexpr double | nanoseconds2seconds (const int64_t nanoseconds) |
Converts nanoseconds to seconds. More... | |
Static Protected Member Functions | |
static constexpr double | invalidTimestampValue () |
Returns the of an invalid timestamp. More... | |
Protected Attributes | |
double | value_ = invalidTimestampValue() |
Timestamp value. More... | |
This class implements a timestamp.
The timestamp is specified by the number of seconds since 01.01.1970 00:00:00 in UTC time.
Depending on the underlying hardware the accuracy (update rate) of the timestamps can vary.
The timestamp class wraps a floating value with 64 bit precision.
|
default |
Creates a new timestamp with invalid time.
|
explicit |
Creates a new timestamp.
toNow | Determines whether the timestamp holds the seconds since 01.01.1970 00:00:00 in UTC time, otherwise the timestamp will be initialized as invalid |
|
inlineexplicit |
Creates a new timestamp with a given value.
timestamp | Timestamp value |
|
inline |
Returns whether a specified amount of time has passed since this timestamp.
This function returns 'thisTimestamp + seconds <= currentTimestamp'.
seconds | The number of seconds defining the time to check, with range [0, infinity) |
currentTimestamp | The current timestamp to use for comparison |
|
staticconstexprprotected |
Returns the of an invalid timestamp.
|
inline |
Returns whether the timestamp holds an invalid time.
|
inline |
Returns whether the timestamp holds a valid time.
|
staticconstexpr |
Converts microseconds to seconds.
microseconds | The microseconds to convert, with range (-infinity, infinity) |
|
staticconstexpr |
Converts milliseconds to seconds.
milliseconds | The milliseconds to convert, with range (-infinity, infinity) |
|
inline |
Returns this timestamp in nanoseconds.
|
staticconstexpr |
Converts nanoseconds to seconds.
nanoseconds | The nanoseconds to convert, with range (-infinity, infinity) |
|
inlineexplicit |
Cast operator for the timestamp value.
|
inline |
Returns whether two timestamps are not identical.
right | The right timestamp |
|
inline |
Hash function.
timestamp | The timestamp for which the hash value will be determined |
|
inline |
Adds seconds to this timestamps.
seconds | The number of seconds to add, with range (-infinity, infinity) |
Adds two timestamps.
right | The right timestamp |
|
inline |
Adds and assigns seconds to this timestamps.
seconds | The number of seconds to add, with range (-infinity, infinity) |
Adds and assigns two timestamps.
right | The right timestamp |
|
inline |
Subtracts seconds from this timestamp.
seconds | The number of seconds to subtract, with range (-infinity, infinity) |
Subtracts two timestamps.
right | The right timestamp |
|
inline |
Subtracts and assigns seconds from this timestamp.
seconds | The number of seconds to subtract, with range (-infinity, infinity) |
Subtracts and assigns two timestamps.
right | The right timestamp |
|
inline |
Returns whether the this timestamp is lesser than the right one.
right | The right timestamp |
|
inline |
Returns whether the this timestamp is lesser or equal to the right one.
right | The right timestamp |
|
inline |
|
inline |
Returns whether two timestamps are identical.
right | The right timestamp |
|
inline |
Returns whether the this timestamp is greater than the right one.
right | The right timestamp |
|
inline |
Returns whether the this timestamp is greater or equal to the right one.
right | The right timestamp |
|
staticconstexpr |
Converts seconds to microseconds.
seconds | The seconds to convert, with range (-infinity, infinity) |
|
staticconstexpr |
Converts seconds to milliseconds.
seconds | The seconds to convert, with range (-infinity, infinity) |
|
staticconstexpr |
Converts seconds to nanoseconds.
seconds | The seconds to convert, with range (-infinity, infinity) |
|
inline |
Sets the timestamp to invalid.
Timestamp& Ocean::Timestamp::toNow | ( | ) |
Sets the timestamp to the current time.
The timestamp holds the seconds since 01.01.1970 00:00:00 in UTC time.
|
protected |
Timestamp value.