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 QSCXMLINVOKABLESERVICE_H |
5 | #define QSCXMLINVOKABLESERVICE_H |
6 | |
7 | #include <QtScxml/qscxmldatamodel.h> |
8 | #include <QtCore/qstring.h> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | class QScxmlEvent; |
13 | class QScxmlStateMachine; |
14 | |
15 | class QScxmlInvokableServiceFactory; |
16 | class QScxmlInvokableServicePrivate; |
17 | class Q_SCXML_EXPORT QScxmlInvokableService : public QObject |
18 | { |
19 | Q_OBJECT |
20 | Q_DECLARE_PRIVATE(QScxmlInvokableService) |
21 | Q_PROPERTY(QScxmlStateMachine *parentStateMachine READ parentStateMachine CONSTANT) |
22 | Q_PROPERTY(QString id READ id CONSTANT) |
23 | Q_PROPERTY(QString name READ name CONSTANT) |
24 | |
25 | public: |
26 | QScxmlInvokableService(QScxmlStateMachine *parentStateMachine, |
27 | QScxmlInvokableServiceFactory *parent); |
28 | |
29 | QScxmlStateMachine *parentStateMachine() const; |
30 | |
31 | virtual bool start() = 0; |
32 | virtual QString id() const = 0; |
33 | virtual QString name() const = 0; |
34 | virtual void postEvent(QScxmlEvent *event) = 0; |
35 | }; |
36 | |
37 | class QScxmlInvokableServiceFactoryPrivate; |
38 | class Q_SCXML_EXPORT QScxmlInvokableServiceFactory : public QObject |
39 | { |
40 | Q_OBJECT |
41 | Q_DECLARE_PRIVATE(QScxmlInvokableServiceFactory) |
42 | Q_PROPERTY(QScxmlExecutableContent::InvokeInfo invokeInfo READ invokeInfo CONSTANT) |
43 | Q_PROPERTY(QList<QScxmlExecutableContent::ParameterInfo> parameters READ parameters CONSTANT) |
44 | Q_PROPERTY(QList<QScxmlExecutableContent::StringId> names READ names CONSTANT) |
45 | |
46 | public: |
47 | QScxmlInvokableServiceFactory( |
48 | const QScxmlExecutableContent::InvokeInfo &invokeInfo, |
49 | const QList<QScxmlExecutableContent::StringId> &names, |
50 | const QList<QScxmlExecutableContent::ParameterInfo> ¶meters, |
51 | QObject *parent = nullptr); |
52 | |
53 | virtual QScxmlInvokableService *invoke(QScxmlStateMachine *parentStateMachine) = 0; |
54 | const QScxmlExecutableContent::InvokeInfo &invokeInfo() const; |
55 | const QList<QScxmlExecutableContent::ParameterInfo> ¶meters() const; |
56 | const QList<QScxmlExecutableContent::StringId> &names() const; |
57 | |
58 | protected: |
59 | QScxmlInvokableServiceFactory(QScxmlInvokableServiceFactoryPrivate &dd, QObject *parent); |
60 | }; |
61 | |
62 | class QScxmlStaticScxmlServiceFactoryPrivate; |
63 | class Q_SCXML_EXPORT QScxmlStaticScxmlServiceFactory: public QScxmlInvokableServiceFactory |
64 | { |
65 | Q_OBJECT |
66 | Q_DECLARE_PRIVATE(QScxmlStaticScxmlServiceFactory) |
67 | public: |
68 | QScxmlStaticScxmlServiceFactory( |
69 | const QMetaObject *metaObject, |
70 | const QScxmlExecutableContent::InvokeInfo &invokeInfo, |
71 | const QList<QScxmlExecutableContent::StringId> &nameList, |
72 | const QList<QScxmlExecutableContent::ParameterInfo> ¶meters, |
73 | QObject *parent = nullptr); |
74 | |
75 | QScxmlInvokableService *invoke(QScxmlStateMachine *parentStateMachine) override; |
76 | }; |
77 | |
78 | class Q_SCXML_EXPORT QScxmlDynamicScxmlServiceFactory: public QScxmlInvokableServiceFactory |
79 | { |
80 | Q_OBJECT |
81 | public: |
82 | QScxmlDynamicScxmlServiceFactory( |
83 | const QScxmlExecutableContent::InvokeInfo &invokeInfo, |
84 | const QList<QScxmlExecutableContent::StringId> &names, |
85 | const QList<QScxmlExecutableContent::ParameterInfo> ¶meters, |
86 | QObject *parent = nullptr); |
87 | |
88 | QScxmlInvokableService *invoke(QScxmlStateMachine *parentStateMachine) override; |
89 | }; |
90 | |
91 | QT_END_NAMESPACE |
92 | |
93 | Q_DECLARE_METATYPE(QScxmlInvokableService *) |
94 | |
95 | #endif // QSCXMLINVOKABLESERVICE_H |
96 | |