micro-test-plus 6.0.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
micro_os_plus::micro_test_plus::detail::timestamp Class Reference

Deprecated clock reading. More...

#include "micro-os-plus/micro-test-plus.h"

Public Member Functions

 timestamp (const timespec &ts) noexcept
 Constructs a timestamp with a given time.
 timestamp (const timestamp &)=default
 Defaulted copy constructor.
 timestamp (timestamp &&)=default
 Defaulted move constructor.
 timestamp (void) noexcept
 Constructs a timestamp with the current time.
 ~timestamp ()=default
 Defaulted destructor.
bool has_clock (void) const noexcept
 Checks whether the value is a clock reading.
timestamp & operator= (const timestamp &)=default
 Defaulted copy assignment operator.
timestamp & operator= (timestamp &&)=default
 Defaulted move assignment operator.
const timespec & value (void) const noexcept
 Returns the stored time.
timespec & value (void) noexcept
 Returns the stored time, for modification.

Protected Attributes

timespec value_ {}
 The stored time.

Detailed Description

The v5.0.1 class of the two readings kept by detail::timestamps, restored for the applications that used it directly; the framework no longer uses it, since stopwatch keeps the readings as timespec members. The timings are internal; use stopwatch instead.

A zero timespec means that the clock was not read, or that the platform has no clock.

The data member is protected, as in v5.0.1, so that the existing derived classes can still access it.

Deprecated
the timings are internal (since 6.0.0)

Definition at line 2335 of file deprecated.h.

Constructor & Destructor Documentation

◆ timestamp() [1/4]

micro_os_plus::micro_test_plus::detail::timestamp::timestamp ( void )
noexcept

Reads the system clock, as stopwatch::start() does; without a clock, the value remains zero.

Reads the system clock into the stored value, with read_clock(), the same clock as stopwatch; without a clock, the value remains zero.

Definition at line 100 of file deprecated.cpp.

101 {
103 }
void read_clock(timespec &ts) noexcept
Reads the system clock.
Definition stopwatch.cpp:66

References micro_os_plus::micro_test_plus::detail::read_clock(), and value_.

Referenced by timestamp(), timestamp(), ~timestamp(), operator=(), and operator=().

◆ timestamp() [2/4]

micro_os_plus::micro_test_plus::detail::timestamp::timestamp ( const timespec & ts)
inlinenoexcept

Not explicit, as in v5.0.1, so that a timespec converts implicitly.

Parameters
tsThe time to be stored.

Copies ts into the stored value.

Definition at line 1297 of file deprecated-inlines.h.

1297 : value_{ ts }
1298 {
1299 }

References timestamp(), and value_.

◆ timestamp() [3/4]

micro_os_plus::micro_test_plus::detail::timestamp::timestamp ( const timestamp & )
default

A timestamp is a plain value, so it may be copied.

◆ timestamp() [4/4]

micro_os_plus::micro_test_plus::detail::timestamp::timestamp ( timestamp && )
default

Equivalent to the copy, since the value is trivially copyable.

References timestamp().

◆ ~timestamp()

micro_os_plus::micro_test_plus::detail::timestamp::~timestamp ( )
default

No resources are owned, so there is nothing to release.

References timestamp().

Member Function Documentation

◆ has_clock()

bool micro_os_plus::micro_test_plus::detail::timestamp::has_clock ( void ) const
inlinenodiscardnoexcept

The value is not a reading if both its members are zero.

Parameters
None.
Return values
trueAt least one of the members is not zero.
falseBoth members are zero.

Returns true if either the seconds or the nanoseconds member is not zero.

Definition at line 1309 of file deprecated-inlines.h.

1310 {
1311 return value_.tv_sec != 0 || value_.tv_nsec != 0;
1312 }

References has_clock(), and value_.

Referenced by has_clock().

◆ operator=() [1/2]

timestamp & micro_os_plus::micro_test_plus::detail::timestamp::operator= ( const timestamp & )
default

A timestamp is a plain value, so it may be assigned.

Returns
A reference to the current object.

References timestamp().

◆ operator=() [2/2]

timestamp & micro_os_plus::micro_test_plus::detail::timestamp::operator= ( timestamp && )
default

Equivalent to the copy assignment, since the value is trivially copyable.

Returns
A reference to the current object.

References timestamp().

◆ value() [1/2]

const timespec & micro_os_plus::micro_test_plus::detail::timestamp::value ( void ) const
inlinenodiscardnoexcept
Parameters
None.
Returns
A constant reference to the stored timespec.

The returned reference is valid as long as the object exists.

Definition at line 1334 of file deprecated-inlines.h.

1335 {
1336 return value_;
1337 }

References value(), and value_.

◆ value() [2/2]

timespec & micro_os_plus::micro_test_plus::detail::timestamp::value ( void )
inlinenodiscardnoexcept
Parameters
None.
Returns
A reference to the stored timespec.

The caller may modify the stored time through the returned reference.

Definition at line 1322 of file deprecated-inlines.h.

1323 {
1324 return value_;
1325 }

References value(), and value_.

Referenced by value(), and value().

Member Data Documentation

◆ value_

timespec micro_os_plus::micro_test_plus::detail::timestamp::value_ {}
protected

Set by the constructors; zero if the clock was not read.

Definition at line 2448 of file deprecated.h.

Referenced by timestamp(), timestamp(), has_clock(), value(), and value().


The documentation for this class was generated from the following files: