|
micro-test-plus 4.1.0
µTest++ Testing Framework
|
A single point-in-time measurement, wrapping a timespec value. More...
#include <micro-os-plus/micro-test-plus.h>
Public Member Functions | |
| timestamp () noexcept | |
| Default constructor. Zero-initialises the internal timespec. | |
| timestamp (const timespec &ts) noexcept | |
| Constructs a timestamp from an existing timespec value. | |
| timestamp (const timestamp &)=default | |
| Defaulted copy constructor. | |
| timestamp (timestamp &&)=default | |
| Defaulted move constructor. | |
| ~timestamp ()=default | |
| Defaulted destructor. | |
| bool | has_clock (void) const noexcept |
| Returns true if a monotonic clock is available on this target. | |
| timestamp & | operator= (const timestamp &)=default |
| Defaulted copy assignment operator. | |
| timestamp & | operator= (timestamp &&)=default |
| Defaulted move assignment operator. | |
| const timespec & | value () const noexcept |
| Returns a const reference to the underlying timespec value. | |
| timespec & | value () noexcept |
| Returns a mutable reference to the underlying timespec value. | |
Protected Attributes | |
| timespec | value_ {} |
| The underlying 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.
|
noexcept |
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.
Definition at line 71 of file timings.cpp.
References value_.
Referenced by timestamp(), timestamp(), operator=(), and operator=().
|
inlinenoexcept |
| ts | The timespec value to store. |
Stores the supplied timespec value in the value_ member.
Definition at line 57 of file timings-inlines.h.
References value_.
|
default |
References timestamp().
|
default |
References timestamp().
|
default |
References value().
|
noexcept |
| 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.
Definition at line 87 of file timings.cpp.
References value_.
|
default |
References timestamp().
References timestamp().
|
inlinenodiscardnoexcept |
Returns a const reference to the value_ member.
Definition at line 76 of file timings-inlines.h.
References value_.
|
inlinenodiscardnoexcept |
Returns a mutable reference to the value_ member.
Definition at line 66 of file timings-inlines.h.
References value_.
Referenced by ~timestamp().
|
protected |
Definition at line 176 of file timings.h.
Referenced by timestamp(), timestamp(), has_clock(), value(), and value().