|
Ocean
|
This class implements a timestamp. More...
#include <Timestamp.h>
Public Member Functions | |
| Timestamp ()=default | |
| Creates a new timestamp with invalid time. | |
| Timestamp (const bool toNow) | |
| Creates a new timestamp. | |
| Timestamp (const double timestamp) | |
| Creates a new timestamp with a given value. | |
| Timestamp & | toNow () |
| Sets the timestamp to the current time. | |
| Timestamp & | toInvalid () |
| Sets the timestamp to invalid. | |
| int64_t | nanoseconds () const |
| Returns this timestamp in nanoseconds. | |
| bool | hasTimePassed (const double seconds, const Timestamp ¤tTimestamp=Timestamp(true)) const |
| Returns whether a specified amount of time has passed since this timestamp. | |
| bool | isValid () const |
| Returns whether the timestamp holds a valid time. | |
| bool | isInvalid () const |
| Returns whether the timestamp holds an invalid time. | |
| Timestamp & | operator= (const double timestamp) |
| Assign a new value. | |
| Timestamp | operator+ (const Timestamp &right) const |
| Adds two timestamps. | |
| Timestamp & | operator+= (const Timestamp &right) |
| Adds and assigns two timestamps. | |
| Timestamp | operator+ (const double seconds) const |
| Adds seconds to this timestamps. | |
| Timestamp & | operator+= (const double seconds) |
| Adds and assigns seconds to this timestamps. | |
| Timestamp | operator- (const Timestamp &right) const |
| Subtracts two timestamps. | |
| Timestamp & | operator-= (const Timestamp &right) |
| Subtracts and assigns two timestamps. | |
| Timestamp | operator- (const double seconds) const |
| Subtracts seconds from this timestamp. | |
| Timestamp & | operator-= (const double seconds) |
| Subtracts and assigns seconds from this timestamp. | |
| bool | operator< (const Timestamp &right) const |
| Returns whether the this timestamp is lesser than the right one. | |
| bool | operator<= (const Timestamp &right) const |
| Returns whether the this timestamp is lesser or equal to the right one. | |
| bool | operator> (const Timestamp &right) const |
| Returns whether the this timestamp is greater than the right one. | |
| bool | operator>= (const Timestamp &right) const |
| Returns whether the this timestamp is greater or equal to the right one. | |
| bool | operator== (const Timestamp &right) const |
| Returns whether two timestamps are identical. | |
| bool | operator!= (const Timestamp &right) const |
| Returns whether two timestamps are not identical. | |
| operator double () const | |
| Cast operator for the timestamp value. | |
| size_t | operator() (const Timestamp ×tamp) const |
| Hash function. | |
Static Public Member Functions | |
| static constexpr int64_t | seconds2milliseconds (const double seconds) |
| Converts seconds to milliseconds. | |
| static constexpr int64_t | seconds2microseconds (const double seconds) |
| Converts seconds to microseconds. | |
| static constexpr int64_t | seconds2nanoseconds (const double seconds) |
| Converts seconds to nanoseconds. | |
| static constexpr double | milliseconds2seconds (const int64_t milliseconds) |
| Converts milliseconds to seconds. | |
| static constexpr double | microseconds2seconds (const int64_t microseconds) |
| Converts microseconds to seconds. | |
| static constexpr double | nanoseconds2seconds (const int64_t nanoseconds) |
| Converts nanoseconds to seconds. | |
Static Public Attributes | |
| static constexpr int64_t | millisecondsPerSecond_ = 1000 |
| Definition of the number of milliseconds in one second. | |
| static constexpr int64_t | microsecondsPerSecond_ = millisecondsPerSecond_ * 1000 |
| Definition of the number of microseconds in one second. | |
| static constexpr int64_t | nanosecondsPerSecond_ = microsecondsPerSecond_ * 1000 |
| Definition of the number of nanoseconds in one second. | |
Static Protected Member Functions | |
| static constexpr double | invalidTimestampValue () |
| Returns the of an invalid timestamp. | |
Protected Attributes | |
| double | value_ = invalidTimestampValue() |
| Timestamp value. | |
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 |
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.
|
staticconstexpr |
Definition of the number of microseconds in one second.
|
staticconstexpr |
Definition of the number of milliseconds in one second.
|
staticconstexpr |
Definition of the number of nanoseconds in one second.
|
protected |
Timestamp value.