1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtScxml module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QSCXMLINVOKABLESERVICE_H
41#define QSCXMLINVOKABLESERVICE_H
42
43#include <QtScxml/qscxmldatamodel.h>
44#include <QtCore/qstring.h>
45
46QT_BEGIN_NAMESPACE
47
48class QScxmlEvent;
49class QScxmlStateMachine;
50
51class QScxmlInvokableServiceFactory;
52class QScxmlInvokableServicePrivate;
53class Q_SCXML_EXPORT QScxmlInvokableService : public QObject
54{
55 Q_OBJECT
56 Q_DECLARE_PRIVATE(QScxmlInvokableService)
57 Q_PROPERTY(QScxmlStateMachine *parentStateMachine READ parentStateMachine CONSTANT)
58 Q_PROPERTY(QString id READ id CONSTANT)
59 Q_PROPERTY(QString name READ name CONSTANT)
60
61public:
62 QScxmlInvokableService(QScxmlStateMachine *parentStateMachine,
63 QScxmlInvokableServiceFactory *parent);
64
65 QScxmlStateMachine *parentStateMachine() const;
66
67 virtual bool start() = 0;
68 virtual QString id() const = 0;
69 virtual QString name() const = 0;
70 virtual void postEvent(QScxmlEvent *event) = 0;
71};
72
73class QScxmlInvokableServiceFactoryPrivate;
74class Q_SCXML_EXPORT QScxmlInvokableServiceFactory : public QObject
75{
76 Q_OBJECT
77 Q_DECLARE_PRIVATE(QScxmlInvokableServiceFactory)
78 Q_PROPERTY(QScxmlExecutableContent::InvokeInfo invokeInfo READ invokeInfo CONSTANT)
79 Q_PROPERTY(QVector<QScxmlExecutableContent::ParameterInfo> parameters READ parameters CONSTANT)
80 Q_PROPERTY(QVector<QScxmlExecutableContent::StringId> names READ names CONSTANT)
81
82public:
83 QScxmlInvokableServiceFactory(
84 const QScxmlExecutableContent::InvokeInfo &invokeInfo,
85 const QVector<QScxmlExecutableContent::StringId> &names,
86 const QVector<QScxmlExecutableContent::ParameterInfo> &parameters,
87 QObject *parent = nullptr);
88
89 virtual QScxmlInvokableService *invoke(QScxmlStateMachine *parentStateMachine) = 0;
90 const QScxmlExecutableContent::InvokeInfo &invokeInfo() const;
91 const QVector<QScxmlExecutableContent::ParameterInfo> &parameters() const;
92 const QVector<QScxmlExecutableContent::StringId> &names() const;
93
94protected:
95 QScxmlInvokableServiceFactory(QScxmlInvokableServiceFactoryPrivate &dd, QObject *parent);
96};
97
98class QScxmlStaticScxmlServiceFactoryPrivate;
99class Q_SCXML_EXPORT QScxmlStaticScxmlServiceFactory: public QScxmlInvokableServiceFactory
100{
101 Q_OBJECT
102 Q_DECLARE_PRIVATE(QScxmlStaticScxmlServiceFactory)
103public:
104 QScxmlStaticScxmlServiceFactory(
105 const QMetaObject *metaObject,
106 const QScxmlExecutableContent::InvokeInfo &invokeInfo,
107 const QVector<QScxmlExecutableContent::StringId> &nameList,
108 const QVector<QScxmlExecutableContent::ParameterInfo> &parameters,
109 QObject *parent = nullptr);
110
111 QScxmlInvokableService *invoke(QScxmlStateMachine *parentStateMachine) override;
112};
113
114class Q_SCXML_EXPORT QScxmlDynamicScxmlServiceFactory: public QScxmlInvokableServiceFactory
115{
116 Q_OBJECT
117public:
118 QScxmlDynamicScxmlServiceFactory(
119 const QScxmlExecutableContent::InvokeInfo &invokeInfo,
120 const QVector<QScxmlExecutableContent::StringId> &names,
121 const QVector<QScxmlExecutableContent::ParameterInfo> &parameters,
122 QObject *parent = nullptr);
123
124 QScxmlInvokableService *invoke(QScxmlStateMachine *parentStateMachine) override;
125};
126
127QT_END_NAMESPACE
128
129Q_DECLARE_METATYPE(QScxmlInvokableService *)
130
131#endif // QSCXMLINVOKABLESERVICE_H
132

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