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
4#ifndef QQMLABSTRACTPROFILERADAPTER_P_H
5#define QQMLABSTRACTPROFILERADAPTER_P_H
6
7#include <private/qtqmlglobal_p.h>
8#include <private/qqmlprofilerdefinitions_p.h>
9
10#include <QtCore/QObject>
11#include <QtCore/QElapsedTimer>
12
13//
14// W A R N I N G
15// -------------
16//
17// This file is not part of the Qt API. It exists purely as an
18// implementation detail. This header file may change from version to
19// version without notice, or even be removed.
20//
21// We mean it.
22//
23
24QT_BEGIN_NAMESPACE
25
26QT_REQUIRE_CONFIG(qml_debug);
27
28class QQmlProfilerService;
29class Q_QML_PRIVATE_EXPORT QQmlAbstractProfilerAdapter : public QObject, public QQmlProfilerDefinitions {
30 Q_OBJECT
31
32public:
33 static const int s_numMessagesPerBatch = 1000;
34
35 QQmlAbstractProfilerAdapter(QObject *parent = nullptr) :
36 QObject(parent), service(nullptr), waiting(true), featuresEnabled(0) {}
37 ~QQmlAbstractProfilerAdapter() override {}
38 void setService(QQmlProfilerService *new_service) { service = new_service; }
39
40 virtual qint64 sendMessages(qint64 until, QList<QByteArray> &messages) = 0;
41
42 void startProfiling(quint64 features);
43
44 void stopProfiling();
45
46 void reportData() { Q_EMIT dataRequested(); }
47
48 void stopWaiting() { waiting = false; }
49 void startWaiting() { waiting = true; }
50
51 bool isRunning() const { return featuresEnabled != 0; }
52 quint64 features() const { return featuresEnabled; }
53
54 void synchronize(const QElapsedTimer &t) { Q_EMIT referenceTimeKnown(timer: t); }
55
56Q_SIGNALS:
57 void profilingEnabled(quint64 features);
58 void profilingEnabledWhileWaiting(quint64 features);
59
60 void profilingDisabled();
61 void profilingDisabledWhileWaiting();
62
63 void dataRequested();
64 void referenceTimeKnown(const QElapsedTimer &timer);
65
66protected:
67 QQmlProfilerService *service;
68
69private:
70 bool waiting;
71 quint64 featuresEnabled;
72};
73
74class Q_QML_PRIVATE_EXPORT QQmlAbstractProfilerAdapterFactory : public QObject
75{
76 Q_OBJECT
77public:
78 virtual QQmlAbstractProfilerAdapter *create(const QString &key) = 0;
79};
80
81#define QQmlAbstractProfilerAdapterFactory_iid "org.qt-project.Qt.QQmlAbstractProfilerAdapterFactory"
82
83QT_END_NAMESPACE
84
85#endif // QQMLABSTRACTPROFILERADAPTER_P_H
86

source code of qtdeclarative/src/qml/debugger/qqmlabstractprofileradapter_p.h