Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qelapsedtimer.h
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
ifndef
QELAPSEDTIMER_H
6
#
define
QELAPSEDTIMER_H
7
8
#
include
<
QtCore
/
qcompare
.
h
>
9
#
include
<
QtCore
/
qglobal
.
h
>
10
11
#
include
<
chrono
>
12
13
QT_BEGIN_NAMESPACE
14
15
class
Q_CORE_EXPORT
QElapsedTimer
16
{
17
public
:
18
enum
ClockType {
19
SystemTime,
20
MonotonicClock,
21
TickCounter Q_DECL_ENUMERATOR_DEPRECATED_X(
22
"Not supported anymore. Use PerformanceCounter instead."
),
23
MachAbsoluteTime,
24
PerformanceCounter
25
};
26
27
// similar to std::chrono::*_clock
28
using
Duration = std::chrono::nanoseconds;
29
using
TimePoint = std::chrono::time_point<std::chrono::steady_clock, Duration>;
30
31
constexpr
QElapsedTimer() =
default
;
32
33
static
ClockType clockType()
noexcept
;
34
static
bool
isMonotonic()
noexcept
;
35
36
void
start()
noexcept
;
37
qint64 restart()
noexcept
;
38
void
invalidate()
noexcept
;
39
bool
isValid()
const
noexcept
;
40
41
Duration durationElapsed()
const
noexcept
;
42
qint64 nsecsElapsed()
const
noexcept
;
43
qint64 elapsed()
const
noexcept
;
44
bool
hasExpired(qint64 timeout)
const
noexcept
;
45
46
qint64 msecsSinceReference()
const
noexcept
;
47
Duration durationTo(
const
QElapsedTimer &other)
const
noexcept
;
48
qint64 msecsTo(
const
QElapsedTimer &other)
const
noexcept
;
49
qint64 secsTo(
const
QElapsedTimer &other)
const
noexcept
;
50
friend
bool
Q_CORE_EXPORT operator<(
const
QElapsedTimer &lhs,
const
QElapsedTimer &rhs)
noexcept
;
51
52
private
:
53
friend
bool
comparesEqual(
const
QElapsedTimer &lhs,
const
QElapsedTimer &rhs)
noexcept
54
{
55
return
lhs.t1 == rhs.t1 && lhs.t2 == rhs.t2;
56
}
57
Q_DECLARE_EQUALITY_COMPARABLE(QElapsedTimer)
58
59
friend
Qt::strong_ordering compareThreeWay(
const
QElapsedTimer &lhs,
60
const
QElapsedTimer &rhs)
noexcept
61
{
62
return
Qt::compareThreeWay(lhs.t1, rhs.t1);
63
}
64
65
#
if
defined
(
__cpp_lib_three_way_comparison
)
66
friend
std::strong_ordering
67
operator<=>(
const
QElapsedTimer &lhs,
const
QElapsedTimer &rhs)
noexcept
68
{
69
return
compareThreeWay(lhs, rhs);
70
}
71
#
else
72
friend
bool
operator>(
const
QElapsedTimer &lhs,
const
QElapsedTimer &rhs)
noexcept
73
{
74
return
is_gt(compareThreeWay(lhs, rhs));
75
}
76
friend
bool
operator<=(
const
QElapsedTimer &lhs,
const
QElapsedTimer &rhs)
noexcept
77
{
78
return
is_lteq(compareThreeWay(lhs, rhs));
79
}
80
friend
bool
operator>=(
const
QElapsedTimer &lhs,
const
QElapsedTimer &rhs)
noexcept
81
{
82
return
is_gteq(compareThreeWay(lhs, rhs));
83
}
84
#
endif
// defined(__cpp_lib_three_way_comparison)
85
qint64 t1 = Q_INT64_C(0x8000000000000000);
86
qint64 t2 = Q_INT64_C(0x8000000000000000);
87
};
88
89
QT_END_NAMESPACE
90
91
#
endif
// QELAPSEDTIMER_H
QElapsedTimer
\inmodule QtCore
Definition
qelapsedtimer.h:16
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
operator<
bool operator<(const QElapsedTimer &lhs, const QElapsedTimer &rhs) noexcept
Definition
qelapsedtimer.cpp:434
invalidData
static const qint64 invalidData
Definition
qelapsedtimer.cpp:389
qtbase
src
corelib
kernel
qelapsedtimer.h
Generated on
for Qt by
1.18.0