QmlProfiler: Avoid overhead if profiling is not enabled
[profile/ivi/qtdeclarative.git] / src / qml / debugger / qqmlenginedebug_p.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 QQMLENGINEDEBUG_H
43 #define QQMLENGINEDEBUG_H
44
45 //
46 //  W A R N I N G
47 //  -------------
48 //
49 // This file is not part of the Qt API.  It exists purely as an
50 // implementation detail.  This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55
56 #include <QtCore/qobject.h>
57 #include <QtCore/qurl.h>
58 #include <QtCore/qvariant.h>
59
60 #include <private/qtqmlglobal_p.h>
61
62 QT_BEGIN_HEADER
63
64 QT_BEGIN_NAMESPACE
65
66
67 class QQmlDebugConnection;
68 class QQmlDebugWatch;
69 class QQmlDebugPropertyWatch;
70 class QQmlDebugObjectExpressionWatch;
71 class QQmlDebugEnginesQuery;
72 class QQmlDebugRootContextQuery;
73 class QQmlDebugObjectQuery;
74 class QQmlDebugExpressionQuery;
75 class QQmlDebugPropertyReference;
76 class QQmlDebugContextReference;
77 class QQmlDebugObjectReference;
78 class QQmlDebugFileReference;
79 class QQmlDebugEngineReference;
80 class QQmlEngineDebugPrivate;
81 class Q_QML_PRIVATE_EXPORT QQmlEngineDebug : public QObject
82 {
83     Q_OBJECT
84 public:
85     enum State { NotConnected, Unavailable, Enabled };
86
87     explicit QQmlEngineDebug(QQmlDebugConnection *, QObject * = 0);
88     ~QQmlEngineDebug();
89
90     State state() const;
91
92     QQmlDebugPropertyWatch *addWatch(const QQmlDebugPropertyReference &,
93                                              QObject *parent = 0);
94     QQmlDebugWatch *addWatch(const QQmlDebugContextReference &, const QString &,
95                                      QObject *parent = 0);
96     QQmlDebugObjectExpressionWatch *addWatch(const QQmlDebugObjectReference &, const QString &,
97                                                      QObject *parent = 0);
98     QQmlDebugWatch *addWatch(const QQmlDebugObjectReference &,
99                                      QObject *parent = 0);
100     QQmlDebugWatch *addWatch(const QQmlDebugFileReference &,
101                                      QObject *parent = 0);
102
103     void removeWatch(QQmlDebugWatch *watch);
104
105     QQmlDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0);
106     QQmlDebugRootContextQuery *queryRootContexts(const QQmlDebugEngineReference &,
107                                                          QObject *parent = 0);
108     QQmlDebugObjectQuery *queryObject(const QQmlDebugObjectReference &,
109                                               QObject *parent = 0);
110     QQmlDebugObjectQuery *queryObjectRecursive(const QQmlDebugObjectReference &,
111                                                        QObject *parent = 0);
112     QQmlDebugExpressionQuery *queryExpressionResult(int objectDebugId,
113                                                             const QString &expr,
114                                                             QObject *parent = 0);
115     bool setBindingForObject(int objectDebugId, const QString &propertyName,
116                              const QVariant &bindingExpression, bool isLiteralValue,
117                              QString source = QString(), int line = -1);
118     bool resetBindingForObject(int objectDebugId, const QString &propertyName);
119     bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody);
120
121 Q_SIGNALS:
122     void newObjects();
123     void stateChanged(State state);
124
125 private:
126     Q_DECLARE_PRIVATE(QQmlEngineDebug)
127 };
128
129 class Q_QML_PRIVATE_EXPORT QQmlDebugWatch : public QObject
130 {
131     Q_OBJECT
132 public:
133     enum State { Waiting, Active, Inactive, Dead };
134
135     QQmlDebugWatch(QObject *);
136     ~QQmlDebugWatch();
137
138     int queryId() const;
139     int objectDebugId() const;
140     State state() const;
141
142 Q_SIGNALS:
143     void stateChanged(QQmlDebugWatch::State);
144     //void objectChanged(int, const QQmlDebugObjectReference &);
145     //void valueChanged(int, const QVariant &);
146
147     // Server sends value as string if it is a user-type variant
148     void valueChanged(const QByteArray &name, const QVariant &value);
149
150 private:
151     friend class QQmlEngineDebug;
152     friend class QQmlEngineDebugPrivate;
153     void setState(State);
154     State m_state;
155     int m_queryId;
156     QQmlEngineDebug *m_client;
157     int m_objectDebugId;
158 };
159
160 class Q_QML_PRIVATE_EXPORT QQmlDebugPropertyWatch : public QQmlDebugWatch
161 {
162     Q_OBJECT
163 public:
164     QQmlDebugPropertyWatch(QObject *parent);
165
166     QString name() const;
167
168 private:
169     friend class QQmlEngineDebug;
170     QString m_name;
171 };
172
173 class Q_QML_PRIVATE_EXPORT QQmlDebugObjectExpressionWatch : public QQmlDebugWatch
174 {
175     Q_OBJECT
176 public:
177     QQmlDebugObjectExpressionWatch(QObject *parent);
178
179     QString expression() const;
180
181 private:
182     friend class QQmlEngineDebug;
183     QString m_expr;
184     int m_debugId;
185 };
186
187
188 class Q_QML_PRIVATE_EXPORT QQmlDebugQuery : public QObject
189 {
190     Q_OBJECT
191 public:
192     enum State { Waiting, Error, Completed };
193
194     State state() const;
195     bool isWaiting() const;
196
197 Q_SIGNALS:
198     void stateChanged(QQmlDebugQuery::State);
199
200 protected:
201     QQmlDebugQuery(QObject *);
202
203 private:
204     friend class QQmlEngineDebug;
205     friend class QQmlEngineDebugPrivate;
206     void setState(State);
207     State m_state;
208 };
209
210 class Q_QML_PRIVATE_EXPORT QQmlDebugFileReference 
211 {
212 public:
213     QQmlDebugFileReference();
214     QQmlDebugFileReference(const QQmlDebugFileReference &);
215     QQmlDebugFileReference &operator=(const QQmlDebugFileReference &);
216
217     QUrl url() const;
218     void setUrl(const QUrl &);
219     int lineNumber() const;
220     void setLineNumber(int);
221     int columnNumber() const;
222     void setColumnNumber(int);
223
224 private:
225     friend class QQmlEngineDebugPrivate;
226     QUrl m_url;
227     int m_lineNumber;
228     int m_columnNumber;
229 };
230
231 class Q_QML_PRIVATE_EXPORT QQmlDebugEngineReference
232 {
233 public:
234     QQmlDebugEngineReference();
235     QQmlDebugEngineReference(int);
236     QQmlDebugEngineReference(const QQmlDebugEngineReference &);
237     QQmlDebugEngineReference &operator=(const QQmlDebugEngineReference &);
238
239     int debugId() const;
240     QString name() const;
241
242 private:
243     friend class QQmlEngineDebugPrivate;
244     int m_debugId;
245     QString m_name;
246 };
247
248 class Q_QML_PRIVATE_EXPORT QQmlDebugObjectReference
249 {
250 public:
251     QQmlDebugObjectReference();
252     QQmlDebugObjectReference(int);
253     QQmlDebugObjectReference(const QQmlDebugObjectReference &);
254     QQmlDebugObjectReference &operator=(const QQmlDebugObjectReference &);
255
256     int debugId() const;
257     QString className() const;
258     QString idString() const;
259     QString name() const;
260
261     QQmlDebugFileReference source() const;
262     int contextDebugId() const;
263
264     QList<QQmlDebugPropertyReference> properties() const;
265     QList<QQmlDebugObjectReference> children() const;
266
267 private:
268     friend class QQmlEngineDebugPrivate;
269     int m_debugId;
270     QString m_class;
271     QString m_idString;
272     QString m_name;
273     QQmlDebugFileReference m_source;
274     int m_contextDebugId;
275     QList<QQmlDebugPropertyReference> m_properties;
276     QList<QQmlDebugObjectReference> m_children;
277 };
278
279 class Q_QML_PRIVATE_EXPORT QQmlDebugContextReference
280 {
281 public:
282     QQmlDebugContextReference();
283     QQmlDebugContextReference(const QQmlDebugContextReference &);
284     QQmlDebugContextReference &operator=(const QQmlDebugContextReference &);
285
286     int debugId() const;
287     QString name() const;
288
289     QList<QQmlDebugObjectReference> objects() const;
290     QList<QQmlDebugContextReference> contexts() const;
291
292 private:
293     friend class QQmlEngineDebugPrivate;
294     int m_debugId;
295     QString m_name;
296     QList<QQmlDebugObjectReference> m_objects;
297     QList<QQmlDebugContextReference> m_contexts;
298 };
299
300 class Q_QML_PRIVATE_EXPORT QQmlDebugPropertyReference
301 {
302 public:
303     QQmlDebugPropertyReference();
304     QQmlDebugPropertyReference(const QQmlDebugPropertyReference &);
305     QQmlDebugPropertyReference &operator=(const QQmlDebugPropertyReference &);
306
307     int objectDebugId() const;
308     QString name() const;
309     QVariant value() const;
310     QString valueTypeName() const;
311     QString binding() const;
312     bool hasNotifySignal() const;
313
314 private:
315     friend class QQmlEngineDebugPrivate;
316     int m_objectDebugId;
317     QString m_name;
318     QVariant m_value;
319     QString m_valueTypeName;
320     QString m_binding;
321     bool m_hasNotifySignal;
322 };
323
324
325 class Q_QML_PRIVATE_EXPORT QQmlDebugEnginesQuery : public QQmlDebugQuery
326 {
327     Q_OBJECT
328 public:
329     virtual ~QQmlDebugEnginesQuery();
330     QList<QQmlDebugEngineReference> engines() const;
331 private:
332     friend class QQmlEngineDebug;
333     friend class QQmlEngineDebugPrivate;
334     QQmlDebugEnginesQuery(QObject *);
335     QQmlEngineDebug *m_client;
336     int m_queryId;
337     QList<QQmlDebugEngineReference> m_engines;
338 };
339
340 class Q_QML_PRIVATE_EXPORT QQmlDebugRootContextQuery : public QQmlDebugQuery
341 {
342     Q_OBJECT
343 public:
344     virtual ~QQmlDebugRootContextQuery();
345     QQmlDebugContextReference rootContext() const;
346 private:
347     friend class QQmlEngineDebug;
348     friend class QQmlEngineDebugPrivate;
349     QQmlDebugRootContextQuery(QObject *);
350     QQmlEngineDebug *m_client;
351     int m_queryId;
352     QQmlDebugContextReference m_context;
353 };
354
355 class Q_QML_PRIVATE_EXPORT QQmlDebugObjectQuery : public QQmlDebugQuery
356 {
357     Q_OBJECT
358 public:
359     virtual ~QQmlDebugObjectQuery();
360     QQmlDebugObjectReference object() const;
361 private:
362     friend class QQmlEngineDebug;
363     friend class QQmlEngineDebugPrivate;
364     QQmlDebugObjectQuery(QObject *);
365     QQmlEngineDebug *m_client;
366     int m_queryId;
367     QQmlDebugObjectReference m_object;
368
369 };
370
371 class Q_QML_PRIVATE_EXPORT QQmlDebugExpressionQuery : public QQmlDebugQuery
372 {
373     Q_OBJECT
374 public:
375     virtual ~QQmlDebugExpressionQuery();
376     QVariant expression() const;
377     QVariant result() const;
378 private:
379     friend class QQmlEngineDebug;
380     friend class QQmlEngineDebugPrivate;
381     QQmlDebugExpressionQuery(QObject *);
382     QQmlEngineDebug *m_client;
383     int m_queryId;
384     QVariant m_expr;
385     QVariant m_result;
386 };
387
388 QT_END_NAMESPACE
389
390 Q_DECLARE_METATYPE(QQmlDebugEngineReference)
391 Q_DECLARE_METATYPE(QQmlDebugObjectReference)
392 Q_DECLARE_METATYPE(QQmlDebugContextReference)
393 Q_DECLARE_METATYPE(QQmlDebugPropertyReference)
394
395 QT_END_HEADER
396
397 #endif // QQMLENGINEDEBUG_H