1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtQml module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QQMLPROFILEREVENTTYPE_P_H
41#define QQMLPROFILEREVENTTYPE_P_H
42
43#include "qqmlprofilereventlocation_p.h"
44#include "qqmlprofilerclientdefinitions_p.h"
45
46#include <QtCore/qstring.h>
47#include <QtCore/qmetatype.h>
48#include <QtCore/qhash.h>
49
50//
51// W A R N I N G
52// -------------
53//
54// This file is not part of the Qt API. It exists purely as an
55// implementation detail. This header file may change from version to
56// version without notice, or even be removed.
57//
58// We mean it.
59//
60
61QT_BEGIN_NAMESPACE
62
63class QQmlProfilerEventType {
64public:
65 QQmlProfilerEventType(Message message = MaximumMessage, RangeType rangeType = MaximumRangeType,
66 int detailType = -1,
67 const QQmlProfilerEventLocation &location = QQmlProfilerEventLocation(),
68 const QString &data = QString(), const QString displayName = QString()) :
69 m_displayName(displayName), m_data(data), m_location(location), m_message(message),
70 m_rangeType(rangeType), m_detailType(detailType)
71 {}
72
73 void setDisplayName(const QString &displayName) { m_displayName = displayName; }
74 void setData(const QString &data) { m_data = data; }
75 void setLocation(const QQmlProfilerEventLocation &location) { m_location = location; }
76
77 ProfileFeature feature() const;
78 QString displayName() const { return m_displayName; }
79 QString data() const { return m_data; }
80 QQmlProfilerEventLocation location() const { return m_location; }
81 Message message() const { return m_message; }
82 RangeType rangeType() const { return m_rangeType; }
83 int detailType() const { return m_detailType; }
84
85private:
86 friend QDataStream &operator>>(QDataStream &stream, QQmlProfilerEventType &type);
87 friend QDataStream &operator<<(QDataStream &stream, const QQmlProfilerEventType &type);
88
89 QString m_displayName;
90 QString m_data;
91 QQmlProfilerEventLocation m_location;
92 Message m_message;
93 RangeType m_rangeType;
94 int m_detailType; // can be EventType, BindingType, PixmapEventType or SceneGraphFrameType
95};
96
97QDataStream &operator>>(QDataStream &stream, QQmlProfilerEventType &type);
98QDataStream &operator<<(QDataStream &stream, const QQmlProfilerEventType &type);
99
100inline uint qHash(const QQmlProfilerEventType &type)
101{
102 return qHash(location: type.location())
103 ^ (((type.message() << 12) & 0xf000) // 4 bits message
104 | ((type.rangeType() << 24) & 0xf000000) // 4 bits rangeType
105 | ((static_cast<uint>(type.detailType()) << 28) & 0xf0000000)); // 4 bits detailType
106}
107
108inline bool operator==(const QQmlProfilerEventType &type1, const QQmlProfilerEventType &type2)
109{
110 return type1.message() == type2.message() && type1.rangeType() == type2.rangeType()
111 && type1.detailType() == type2.detailType() && type1.location() == type2.location();
112}
113
114inline bool operator!=(const QQmlProfilerEventType &type1, const QQmlProfilerEventType &type2)
115{
116 return !(type1 == type2);
117}
118
119Q_DECLARE_TYPEINFO(QQmlProfilerEventType, Q_MOVABLE_TYPE);
120
121QT_END_NAMESPACE
122
123Q_DECLARE_METATYPE(QQmlProfilerEventType)
124
125#endif // QQMLPROFILEREVENTTYPE_P_H
126

source code of qtdeclarative/src/qmldebug/qqmlprofilereventtype_p.h