This class is a helper class allowing to converter timestamps defined in a specific time domain to unix timestamps.
More...
#include <Timestamp.h>
|
static constexpr int64_t | invalidValue_ = std::numeric_limits<int64_t>::lowest() |
| Definition of an invalid value.
|
|
This class is a helper class allowing to converter timestamps defined in a specific time domain to unix timestamps.
◆ TimeDomain
Definition of individual time domains.
Enumerator |
---|
TD_INVALID | An invalid time domain.
|
TD_MONOTONIC | The monotonically increasing time domain defined in nanoseconds, not increasing during system sleep.
|
TD_BOOTTIME | The monotonically increasing time domain defined in nanoseconds, increasing during system sleep, not available on Windows.
|
TD_UPTIME_RAW | The monotonically increasing time domain defined in nanoseconds, the time the system has been awake since the last time it was restarted.
|
◆ TimestampConverter() [1/3]
Ocean::Timestamp::TimestampConverter::TimestampConverter |
( |
| ) |
|
|
default |
Creates an invalid converter object.
- See also
- isValid().
◆ TimestampConverter() [2/3]
Ocean::Timestamp::TimestampConverter::TimestampConverter |
( |
const TimeDomain |
timeDomain, |
|
|
const size_t |
necessaryMeasurements = 100 |
|
) |
| |
|
explicit |
Creates a new converter object for a specific time domain.
- Parameters
-
timeDomain | The time domain for which the converter will be created |
necessaryMeasurements | The number of measurements necessary to determine the offset between the domain time and the unix time, with range [1, infinity) |
◆ TimestampConverter() [3/3]
Ocean::Timestamp::TimestampConverter::TimestampConverter |
( |
TimestampConverter && |
converter | ) |
|
|
inline |
Move constructor.
- Parameters
-
converter | The converter to be moved |
◆ currentTimestampNs() [1/2]
static int64_t Ocean::Timestamp::TimestampConverter::currentTimestampNs |
( |
const int |
posixClockId | ) |
|
|
static |
Return the current timestamp in a specified POSIX clock id.
- Parameters
-
posixClockId | The POSIX clock id for which the current timestamp will be returned |
- Returns
- The current timestamp in the specified POSIX clock id, in nanoseconds
◆ currentTimestampNs() [2/2]
static int64_t Ocean::Timestamp::TimestampConverter::currentTimestampNs |
( |
const TimeDomain |
timeDomain | ) |
|
|
static |
Returns the current timestamp in a specified time domain.
- Parameters
-
timeDomain | The time domain for which the current timestamp will be returned |
- Returns
- The current timestamp in the specified time domain, in nanoseconds
◆ domainToUnixOffset()
int64_t Ocean::Timestamp::TimestampConverter::domainToUnixOffset |
( |
| ) |
|
Returns the offset between the domain time and the unix time, in nanoseconds.
Unix time = domain time + domainToUnixOffset
- Returns
- The offset between the domain time and the unix time, in nanoseconds, with range (-infinity, infinity)
◆ isValid()
bool Ocean::Timestamp::TimestampConverter::isValid |
( |
| ) |
const |
|
inline |
Returns whether this converter has been initialized with a valid time domain.
- Returns
- True, if so
◆ isWithinRange()
bool Ocean::Timestamp::TimestampConverter::isWithinRange |
( |
const int64_t |
domainTimestampNs, |
|
|
const double |
maxDistance = 1.0 , |
|
|
double * |
distance = nullptr |
|
) |
| |
Returns whether a given domain timestamp is within a specified range of the current domain timestamp.
- Parameters
-
domainTimestampNs | The domain timestamp to check, in nanoseconds, with range (-infinity, infinity) |
maxDistance | The maximal distance between the domain timestamp and the current domain timestamp, in seconds, with range [0, infinity) |
distance | Optional resulting distance between the domain timestamp and the current domain timestamp, in seconds, with range (-infinity, infinity) |
- Returns
- True, if so
◆ operator bool()
Ocean::Timestamp::TimestampConverter::operator bool |
( |
| ) |
const |
|
inline |
Returns whether this converter is valid.
- Returns
- True, if so
◆ operator=()
Move operator.
- Parameters
-
converter | The converter to be moved |
- Returns
- Reference to this object
◆ posixClockId()
static int Ocean::Timestamp::TimestampConverter::posixClockId |
( |
const TimeDomain |
timeDomain | ) |
|
|
staticprotected |
Returns the POSIX clock id associated with a time domain.
- Parameters
-
timeDomain | The time domain for which the associated POSIX clock id will be returned |
- Returns
- The POSIX clock id associated with the specified time domain, -1 if no associated POSIX clock id exists
◆ timeDomain()
Returns the time domain of this converter.
- Returns
- The converter's time domain
◆ toUnix() [1/2]
Timestamp Ocean::Timestamp::TimestampConverter::toUnix |
( |
const double |
domainTimestampSeconds | ) |
|
Converts a timestamp defined in the converter's time domain to a unix timestamp.
- Parameters
-
domainTimestampSeconds | The timestamp in the converter's time domain, in seconds, with range (-infinity, infinity) |
- Returns
- The converted unix timestamp
◆ toUnix() [2/2]
Timestamp Ocean::Timestamp::TimestampConverter::toUnix |
( |
const int64_t |
domainTimestampNs | ) |
|
Converts a timestamp defined in the converter's time domain to a unix timestamp.
- Parameters
-
domainTimestampNs | The timestamp in the converter's time domain, in nanoseconds, with range (-infinity, infinity) |
- Returns
- The converted unix timestamp
◆ domainPosixClockId_
int Ocean::Timestamp::TimestampConverter::domainPosixClockId_ = -1 |
|
protected |
The POSIX clock id associated with the time domain.
◆ domainToUnixOffsetNs_
std::atomic_int64_t Ocean::Timestamp::TimestampConverter::domainToUnixOffsetNs_ = invalidValue_ |
|
protected |
The offset between the domain time and the unix time, in nanoseconds.
◆ initialDomainNs_
int64_t Ocean::Timestamp::TimestampConverter::initialDomainNs_ = invalidValue_ |
|
protected |
The initial domain timestamp, in nanoseconds.
◆ initialUnixNs_
int64_t Ocean::Timestamp::TimestampConverter::initialUnixNs_ = invalidValue_ |
|
protected |
The initial unix timestamp, in nanoseconds.
◆ invalidValue_
constexpr int64_t Ocean::Timestamp::TimestampConverter::invalidValue_ = std::numeric_limits<int64_t>::lowest() |
|
staticconstexpr |
Definition of an invalid value.
◆ lock_
Lock Ocean::Timestamp::TimestampConverter::lock_ |
|
protected |
◆ measurements_
size_t Ocean::Timestamp::TimestampConverter::measurements_ = 0 |
|
protected |
The number of measurements.
◆ necessaryMeasurements_
size_t Ocean::Timestamp::TimestampConverter::necessaryMeasurements_ = 0 |
|
protected |
The number of necessary measurements before the converter keeps the determined offset fixed.
◆ sumDomainToUnixOffsetNs_
int64_t Ocean::Timestamp::TimestampConverter::sumDomainToUnixOffsetNs_ = 0 |
|
protected |
The measured sum of the domain to unix offsets, in nanoseconds.
◆ timeDomain_
The time domain of this converter.
The documentation for this class was generated from the following file: