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 QSCXMLDATAMODEL_H
5#define QSCXMLDATAMODEL_H
6
7#include <QtScxml/qscxmlexecutablecontent.h>
8
9#include <QtCore/qobject.h>
10#include <QtCore/qvariant.h>
11
12Q_MOC_INCLUDE(qscxmlstatemachine.h)
13
14QT_BEGIN_NAMESPACE
15
16class QScxmlEvent;
17
18class QScxmlStateMachine;
19
20class QScxmlDataModelPrivate;
21class Q_SCXML_EXPORT QScxmlDataModel : public QObject
22{
23 Q_OBJECT
24 Q_DECLARE_PRIVATE(QScxmlDataModel)
25 Q_PROPERTY(QScxmlStateMachine *stateMachine READ stateMachine WRITE setStateMachine
26 NOTIFY stateMachineChanged BINDABLE bindableStateMachine)
27
28public:
29 class Q_SCXML_EXPORT ForeachLoopBody
30 {
31 Q_DISABLE_COPY(ForeachLoopBody)
32 public:
33 ForeachLoopBody();
34 virtual ~ForeachLoopBody();
35 virtual void run(bool *ok) = 0;
36 };
37
38public:
39 explicit QScxmlDataModel(QObject *parent = nullptr);
40
41 static QScxmlDataModel *createScxmlDataModel(const QString& pluginKey);
42
43 void setStateMachine(QScxmlStateMachine *stateMachine);
44 QScxmlStateMachine *stateMachine() const;
45 QBindable<QScxmlStateMachine*> bindableStateMachine();
46
47 Q_INVOKABLE virtual bool setup(const QVariantMap &initialDataValues) = 0;
48
49 virtual QString evaluateToString(QScxmlExecutableContent::EvaluatorId id, bool *ok) = 0;
50 virtual bool evaluateToBool(QScxmlExecutableContent::EvaluatorId id, bool *ok) = 0;
51 virtual QVariant evaluateToVariant(QScxmlExecutableContent::EvaluatorId id, bool *ok) = 0;
52 virtual void evaluateToVoid(QScxmlExecutableContent::EvaluatorId id, bool *ok) = 0;
53 virtual void evaluateAssignment(QScxmlExecutableContent::EvaluatorId id, bool *ok) = 0;
54 virtual void evaluateInitialization(QScxmlExecutableContent::EvaluatorId id, bool *ok) = 0;
55 virtual void evaluateForeach(QScxmlExecutableContent::EvaluatorId id, bool *ok, ForeachLoopBody *body) = 0;
56
57 virtual void setScxmlEvent(const QScxmlEvent &event) = 0;
58
59 virtual QVariant scxmlProperty(const QString &name) const = 0;
60 virtual bool hasScxmlProperty(const QString &name) const = 0;
61 virtual bool setScxmlProperty(const QString &name, const QVariant &value, const QString &context) = 0;
62
63Q_SIGNALS:
64 void stateMachineChanged(QScxmlStateMachine *stateMachine);
65
66protected:
67 explicit QScxmlDataModel(QScxmlDataModelPrivate &dd, QObject *parent = nullptr);
68};
69
70QT_END_NAMESPACE
71
72Q_DECLARE_METATYPE(QScxmlDataModel *)
73
74#endif // QSCXMLDATAMODEL_H
75

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