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
10QT_BEGIN_NAMESPACE
11
12class QScxmlEvent;
13class QScxmlStateMachine;
14
15class QScxmlInvokableServiceFactory;
16class QScxmlInvokableServicePrivate;
17class 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
25public:
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
37class QScxmlInvokableServiceFactoryPrivate;
38class 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
46public:
47 QScxmlInvokableServiceFactory(
48 const QScxmlExecutableContent::InvokeInfo &invokeInfo,
49 const QList<QScxmlExecutableContent::StringId> &names,
50 const QList<QScxmlExecutableContent::ParameterInfo> &parameters,
51 QObject *parent = nullptr);
52
53 virtual QScxmlInvokableService *invoke(QScxmlStateMachine *parentStateMachine) = 0;
54 const QScxmlExecutableContent::InvokeInfo &invokeInfo() const;
55 const QList<QScxmlExecutableContent::ParameterInfo> &parameters() const;
56 const QList<QScxmlExecutableContent::StringId> &names() const;
57
58protected:
59 QScxmlInvokableServiceFactory(QScxmlInvokableServiceFactoryPrivate &dd, QObject *parent);
60};
61
62class QScxmlStaticScxmlServiceFactoryPrivate;
63class Q_SCXML_EXPORT QScxmlStaticScxmlServiceFactory: public QScxmlInvokableServiceFactory
64{
65 Q_OBJECT
66 Q_DECLARE_PRIVATE(QScxmlStaticScxmlServiceFactory)
67public:
68 QScxmlStaticScxmlServiceFactory(
69 const QMetaObject *metaObject,
70 const QScxmlExecutableContent::InvokeInfo &invokeInfo,
71 const QList<QScxmlExecutableContent::StringId> &nameList,
72 const QList<QScxmlExecutableContent::ParameterInfo> &parameters,
73 QObject *parent = nullptr);
74
75 QScxmlInvokableService *invoke(QScxmlStateMachine *parentStateMachine) override;
76};
77
78class Q_SCXML_EXPORT QScxmlDynamicScxmlServiceFactory: public QScxmlInvokableServiceFactory
79{
80 Q_OBJECT
81public:
82 QScxmlDynamicScxmlServiceFactory(
83 const QScxmlExecutableContent::InvokeInfo &invokeInfo,
84 const QList<QScxmlExecutableContent::StringId> &names,
85 const QList<QScxmlExecutableContent::ParameterInfo> &parameters,
86 QObject *parent = nullptr);
87
88 QScxmlInvokableService *invoke(QScxmlStateMachine *parentStateMachine) override;
89};
90
91QT_END_NAMESPACE
92
93Q_DECLARE_METATYPE(QScxmlInvokableService *)
94
95#endif // QSCXMLINVOKABLESERVICE_H
96

source code of qtscxml/src/scxml/qscxmlinvokableservice.h