Update to 5.0.0-beta1
[profile/ivi/qtdeclarative.git] / tools / qmlprofiler / qmlprofilerclient.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtQml module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QMLPROFILERCLIENT_H
43 #define QMLPROFILERCLIENT_H
44
45 #include "qqmldebugclient.h"
46 #include <QtQml/private/qqmlprofilerservice_p.h>
47 #include "qmlprofilereventlocation.h"
48
49 class ProfilerClientPrivate;
50 class ProfilerClient : public QQmlDebugClient
51 {
52     Q_OBJECT
53
54     Q_PROPERTY(bool enabled READ isEnabled NOTIFY enabledChanged)
55     Q_PROPERTY(bool recording READ isRecording WRITE setRecording
56                NOTIFY recordingChanged)
57
58 public:
59     ProfilerClient(const QString &clientName,
60                   QQmlDebugConnection *client);
61     ~ProfilerClient();
62
63     bool isEnabled() const;
64     bool isRecording() const;
65
66 public slots:
67     void setRecording(bool);
68     virtual void clearData();
69     virtual void sendRecordingStatus();
70
71 signals:
72     void complete();
73     void recordingChanged(bool arg);
74     void enabledChanged();
75     void cleared();
76
77 protected:
78     virtual void stateChanged(State);
79
80 protected:
81     bool m_recording;
82     bool m_enabled;
83 };
84
85 class QmlProfilerClient : public ProfilerClient
86 {
87     Q_OBJECT
88
89 public:
90     QmlProfilerClient(QQmlDebugConnection *client);
91     ~QmlProfilerClient();
92
93 public slots:
94     void clearData();
95     void sendRecordingStatus();
96
97 signals:
98     void traceFinished( qint64 time );
99     void traceStarted( qint64 time );
100     void range(QQmlProfilerService::RangeType type,
101                QQmlProfilerService::BindingType bindingType,
102                qint64 startTime, qint64 length,
103                const QStringList &data,
104                const QmlEventLocation &location);
105     void frame(qint64 time, int frameRate, int animationCount);
106
107 protected:
108     virtual void messageReceived(const QByteArray &);
109
110 private:
111     class QmlProfilerClientPrivate *d;
112 };
113
114 class V8ProfilerClient : public ProfilerClient
115 {
116     Q_OBJECT
117
118 public:
119     enum Message {
120         V8Entry,
121         V8Complete,
122
123         V8MaximumMessage
124     };
125
126     V8ProfilerClient(QQmlDebugConnection *client);
127     ~V8ProfilerClient();
128
129 public slots:
130     void sendRecordingStatus();
131
132 signals:
133     void range(int depth, const QString &function, const QString &filename,
134                int lineNumber, double totalTime, double selfTime);
135
136 protected:
137     virtual void messageReceived(const QByteArray &);
138 };
139
140 #endif // QMLPROFILERCLIENT_H