Skip to main content

stopwatch-inlines.h File

C++ header file with inline implementations for the µTest++ stopwatch. More...

Namespaces Index​

namespacemicro_os_plus

The primary namespace for the µOS++ framework. More...

namespacemicro_test_plus

Primary namespace for the µTest++ testing framework. More...

namespacedetail

Internal implementation details for the µTest++ framework. More...

Description​

C++ header file with inline implementations for the µTest++ stopwatch.

This header provides the inline member function bodies of the stopwatch class, separated from the class declaration in stopwatch.h to enforce the project convention that declarations reside in headers and implementations reside in inline files.

All definitions reside within the micro_os_plus::micro_test_plus::detail namespace.

This file is included by stopwatch.h; the applications include micro-os-plus/micro-test-plus.h, not this file.

File Listing​

The file content with the documentation metadata removed is:

1// ----------------------------------------------------------------------------
2/*
3 * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
4 * Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose is hereby granted, under the terms of the MIT license.
8 *
9 * If a copy of the license was not distributed with this file, it can be
10 * obtained from https://opensource.org/licenses/mit.
11 */
12
13// ----------------------------------------------------------------------------
14
32
33#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_STOPWATCH_INLINES_H_
34#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_STOPWATCH_INLINES_H_
35
36// ----------------------------------------------------------------------------
37
38#if defined(__cplusplus)
39
40// ----------------------------------------------------------------------------
41
42#if defined(__GNUC__)
43#pragma GCC diagnostic push
44
45#pragma GCC diagnostic ignored "-Waggregate-return"
46#if defined(__clang__)
47#pragma clang diagnostic ignored "-Wc++98-compat"
48#pragma clang diagnostic ignored "-Wpre-c++17-compat"
49#endif // defined(__clang__)
50#endif // defined(__GNUC__)
51
52// ============================================================================
53
55{
56 // ==========================================================================
57
63 inline bool
64 stopwatch::has_elapsed (void) const noexcept
65 {
67 }
68
74 inline bool
75 stopwatch::is_recorded (const timespec& ts) noexcept
76 {
77 return ts.tv_sec != 0 || ts.tv_nsec != 0;
78 }
79
80 // --------------------------------------------------------------------------
81
82#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
88 // Deprecated since 6.0.0; use has_elapsed().
89 inline bool
90 stopwatch::has_begin (void) const noexcept
91 {
93 }
94
100 // Deprecated since 6.0.0; use has_elapsed().
101 inline bool
102 stopwatch::has_end (void) const noexcept
103 {
104 return is_recorded (stop_time_);
105 }
106
111 // Deprecated since 6.0.0; use has_elapsed().
112 inline bool
113 stopwatch::has_timestamps (void) const noexcept
114 {
115 return has_elapsed ();
116 }
117
124 // Deprecated since 6.0.0; use elapsed().
125 inline void
126 stopwatch::compute_elapsed_time (uint32_t& milliseconds,
127 uint32_t& microseconds) const noexcept
128 {
129 const auto count = elapsed ().count ();
130 milliseconds = static_cast<uint32_t> (count / 1000);
131 microseconds = static_cast<uint32_t> (count % 1000);
132 }
133
138 // Deprecated since 6.0.0; use start().
139 inline void
140 stopwatch::timestamp_begin (const timespec& ts) noexcept
141 {
143 {
144 start_time_ = ts;
145 }
146 }
147
152 // Deprecated since 6.0.0; use stop().
153 inline void
154 stopwatch::timestamp_end (const timespec& ts) noexcept
155 {
157 {
158 stop_time_ = ts;
159 }
160 }
161#endif // defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
162
163 // --------------------------------------------------------------------------
164} // namespace micro_os_plus::micro_test_plus::detail
165
166#if defined(__GNUC__)
167#pragma GCC diagnostic pop
168#endif // defined(__GNUC__)
169
170// ----------------------------------------------------------------------------
171
172#endif // defined(__cplusplus)
173
174// ----------------------------------------------------------------------------
175
176#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_STOPWATCH_INLINES_H_
177
178// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.