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 QQMLDEBUGCONNECTOR_H |
5 | #define QQMLDEBUGCONNECTOR_H |
6 | |
7 | #include <QtQml/qtqmlglobal.h> |
8 | #include <QtQml/qjsengine.h> |
9 | #include <QtCore/QVariantList> |
10 | |
11 | #if QT_CONFIG(qml_debug) |
12 | #include <private/qqmldebugservice_p.h> |
13 | #endif |
14 | |
15 | // |
16 | // W A R N I N G |
17 | // ------------- |
18 | // |
19 | // This file is not part of the Qt API. It exists purely as an |
20 | // implementation detail. This header file may change from version to |
21 | // version without notice, or even be removed. |
22 | // |
23 | // We mean it. |
24 | // |
25 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | #if !QT_CONFIG(qml_debug) |
29 | |
30 | class Q_QML_PRIVATE_EXPORT QQmlDebugConnector |
31 | { |
32 | virtual ~QQmlDebugConnector() = default; // don't break 'override' on ~QQmlDebugServer |
33 | public: |
34 | static QQmlDebugConnector *instance() { return nullptr; } |
35 | |
36 | template<class Service> |
37 | static Service *service() { return nullptr; } |
38 | |
39 | bool hasEngine(QJSEngine *) const { return false; } |
40 | void addEngine(QJSEngine *) {} |
41 | void removeEngine(QJSEngine *) {} |
42 | |
43 | bool open(const QVariantHash &configuration = QVariantHash()) |
44 | { |
45 | Q_UNUSED(configuration); |
46 | return false; |
47 | } |
48 | }; |
49 | |
50 | #else |
51 | |
52 | class QQmlDebugService; |
53 | class Q_QML_PRIVATE_EXPORT QQmlDebugConnector : public QObject |
54 | { |
55 | Q_OBJECT |
56 | public: |
57 | static void setPluginKey(const QString &key); |
58 | static void setServices(const QStringList &services); |
59 | static QQmlDebugConnector *instance(); |
60 | static int dataStreamVersion() |
61 | { |
62 | return s_dataStreamVersion; |
63 | } |
64 | |
65 | virtual bool blockingMode() const = 0; |
66 | |
67 | virtual QQmlDebugService *service(const QString &name) const = 0; |
68 | |
69 | virtual void addEngine(QJSEngine *engine) = 0; |
70 | virtual void removeEngine(QJSEngine *engine) = 0; |
71 | virtual bool hasEngine(QJSEngine *engine) const = 0; |
72 | |
73 | virtual bool addService(const QString &name, QQmlDebugService *service) = 0; |
74 | virtual bool removeService(const QString &name) = 0; |
75 | |
76 | virtual bool open(const QVariantHash &configuration = QVariantHash()) = 0; |
77 | |
78 | template<class Service> |
79 | static Service *service() |
80 | { |
81 | QQmlDebugConnector *inst = instance(); |
82 | return inst ? static_cast<Service *>(inst->service(Service::s_key)) : nullptr; |
83 | } |
84 | |
85 | protected: |
86 | static QString commandLineArguments(); |
87 | static int s_dataStreamVersion; |
88 | }; |
89 | |
90 | class Q_QML_PRIVATE_EXPORT QQmlDebugConnectorFactory : public QObject { |
91 | Q_OBJECT |
92 | public: |
93 | virtual QQmlDebugConnector *create(const QString &key) = 0; |
94 | ~QQmlDebugConnectorFactory() override; |
95 | }; |
96 | |
97 | #define QQmlDebugConnectorFactory_iid "org.qt-project.Qt.QQmlDebugConnectorFactory" |
98 | |
99 | #endif |
100 | |
101 | QT_END_NAMESPACE |
102 | |
103 | #endif // QQMLDEBUGCONNECTOR_H |
104 | |