timestamp Class
A single point-in-time measurement, wrapping a timespec value. More...
Declaration
Included Headers
Public Constructors Index
| timestamp () noexcept | |
|
Default constructor. Zero-initialises the internal timespec. More... | |
| timestamp (const timespec &ts) noexcept | |
|
Constructs a timestamp from an existing timespec value. More... | |
| timestamp (const timestamp &)=default | |
|
Defaulted copy constructor. More... | |
| timestamp (timestamp &&)=default | |
|
Defaulted move constructor. More... | |
Public Destructor Index
| ~timestamp ()=default | |
|
Defaulted destructor. More... | |
Public Operators Index
| timestamp & | operator= (const timestamp &)=default |
|
Defaulted copy assignment operator. More... | |
| timestamp & | operator= (timestamp &&)=default |
|
Defaulted move assignment operator. More... | |
Public Member Functions Index
| bool | has_clock (void) const noexcept |
|
Returns true if a monotonic clock is available on this target. More... | |
| const timespec & | value () const noexcept |
|
Returns a const reference to the underlying timespec value. More... | |
| timespec & | value () noexcept |
|
Returns a mutable reference to the underlying timespec value. More... | |
Protected Member Attributes Index
| timespec | value_ {} |
|
The underlying timespec value. More... | |
Description
A single point-in-time measurement, wrapping a timespec value.
timestamp stores one timespec sample obtained from the system clock. It is default-constructible (zero-initialises the timespec), copy-constructible, and move-constructible, so that it can be used efficiently in std::optional<timestamp> containers.
The has_clock() predicate allows callers to determine whether a real-time clock is available on the target platform before relying on the stored value.
Definition at line 93 of file timings.h.
Public Constructors
timestamp()
| noexcept |
Default constructor. Zero-initialises the internal timespec.
On Windows, the current time is captured via timespec_get() with TIME_UTC. On POSIX platforms with CLOCK_MONOTONIC defined, clock_gettime(CLOCK_MONOTONIC) is used to obtain a monotonic timestamp. On platforms where neither macro is defined, value_ remains zero-initialised.
Declaration at line 99 of file timings.h, definition at line 71 of file timings.cpp.
Reference value_.
Referenced by timestamp, timestamp, operator= and operator=.
timestamp()
| inline noexcept |
timestamp()
| default |
timestamp()
Public Operators
operator=()
| default |
operator=()
Public Member Functions
has_clock()
| noexcept |
Returns true if a monotonic clock is available on this target.
- Parameters
None.
- Return Values
-
true A real-time clock is available and timestamps are valid.
false No clock is available; timing data should be ignored.
Returns true if at least one of the tv_sec or tv_nsec fields of the underlying timespec is non-zero, indicating that a valid clock reading was successfully captured.
Declaration at line 150 of file timings.h, definition at line 87 of file timings.cpp.
Reference value_.
value()
| inline nodiscard noexcept |
value()
| inline nodiscard noexcept |
Returns a mutable reference to the underlying timespec value.
- Parameters
None.
- Returns
A reference to the stored timespec.
Returns a mutable reference to the value_ member.
Declaration at line 160 of file timings.h, definition at line 66 of file timings-inlines.h.
Reference value_.
Referenced by ~timestamp.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.