| 1 | // Copyright (C) 2017 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 | |
| 4 | #ifndef QQMLPROFILEREVENTTYPE_P_H |
| 5 | #define QQMLPROFILEREVENTTYPE_P_H |
| 6 | |
| 7 | #include "qqmlprofilereventlocation_p.h" |
| 8 | #include "qqmlprofilerclientdefinitions_p.h" |
| 9 | |
| 10 | #include <QtCore/qstring.h> |
| 11 | #include <QtCore/qmetatype.h> |
| 12 | #include <QtCore/qhash.h> |
| 13 | |
| 14 | // |
| 15 | // W A R N I N G |
| 16 | // ------------- |
| 17 | // |
| 18 | // This file is not part of the Qt API. It exists purely as an |
| 19 | // implementation detail. This header file may change from version to |
| 20 | // version without notice, or even be removed. |
| 21 | // |
| 22 | // We mean it. |
| 23 | // |
| 24 | |
| 25 | QT_BEGIN_NAMESPACE |
| 26 | |
| 27 | class QQmlProfilerEventType { |
| 28 | public: |
| 29 | QQmlProfilerEventType(Message message = MaximumMessage, RangeType rangeType = MaximumRangeType, |
| 30 | int detailType = -1, |
| 31 | const QQmlProfilerEventLocation &location = QQmlProfilerEventLocation(), |
| 32 | const QString &data = QString(), const QString displayName = QString()) : |
| 33 | m_displayName(displayName), m_data(data), m_location(location), m_message(message), |
| 34 | m_rangeType(rangeType), m_detailType(detailType) |
| 35 | {} |
| 36 | |
| 37 | void setDisplayName(const QString &displayName) { m_displayName = displayName; } |
| 38 | void setData(const QString &data) { m_data = data; } |
| 39 | void setLocation(const QQmlProfilerEventLocation &location) { m_location = location; } |
| 40 | |
| 41 | ProfileFeature feature() const; |
| 42 | QString displayName() const { return m_displayName; } |
| 43 | QString data() const { return m_data; } |
| 44 | QQmlProfilerEventLocation location() const { return m_location; } |
| 45 | Message message() const { return m_message; } |
| 46 | RangeType rangeType() const { return m_rangeType; } |
| 47 | int detailType() const { return m_detailType; } |
| 48 | |
| 49 | private: |
| 50 | friend QDataStream &operator>>(QDataStream &stream, QQmlProfilerEventType &type); |
| 51 | friend QDataStream &operator<<(QDataStream &stream, const QQmlProfilerEventType &type); |
| 52 | |
| 53 | QString m_displayName; |
| 54 | QString m_data; |
| 55 | QQmlProfilerEventLocation m_location; |
| 56 | Message m_message; |
| 57 | RangeType m_rangeType; |
| 58 | int m_detailType; // can be EventType, BindingType, PixmapEventType or SceneGraphFrameType |
| 59 | }; |
| 60 | |
| 61 | QDataStream &operator>>(QDataStream &stream, QQmlProfilerEventType &type); |
| 62 | QDataStream &operator<<(QDataStream &stream, const QQmlProfilerEventType &type); |
| 63 | |
| 64 | inline size_t qHash(const QQmlProfilerEventType &type) |
| 65 | { |
| 66 | return qHash(location: type.location()) |
| 67 | ^ (((type.message() << 12) & 0xf000) // 4 bits message |
| 68 | | ((type.rangeType() << 24) & 0xf000000) // 4 bits rangeType |
| 69 | | ((static_cast<uint>(type.detailType()) << 28) & 0xf0000000)); // 4 bits detailType |
| 70 | } |
| 71 | |
| 72 | inline bool operator==(const QQmlProfilerEventType &type1, const QQmlProfilerEventType &type2) |
| 73 | { |
| 74 | return type1.message() == type2.message() && type1.rangeType() == type2.rangeType() |
| 75 | && type1.detailType() == type2.detailType() && type1.location() == type2.location(); |
| 76 | } |
| 77 | |
| 78 | inline bool operator!=(const QQmlProfilerEventType &type1, const QQmlProfilerEventType &type2) |
| 79 | { |
| 80 | return !(type1 == type2); |
| 81 | } |
| 82 | |
| 83 | Q_DECLARE_TYPEINFO(QQmlProfilerEventType, Q_RELOCATABLE_TYPE); |
| 84 | |
| 85 | QT_END_NAMESPACE |
| 86 | |
| 87 | Q_DECLARE_METATYPE(QQmlProfilerEventType) |
| 88 | |
| 89 | #endif // QQMLPROFILEREVENTTYPE_P_H |
| 90 | |