KDStateMachineEditor API Documentation 2.1
Loading...
Searching...
No Matches
state.h
Go to the documentation of this file.
1/*
2 This file is part of the KDAB State Machine Editor Library.
3
4 SPDX-FileCopyrightText: 2014 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5 Author: Kevin Funk <kevin.funk@kdab.com>
6
7 SPDX-License-Identifier: LGPL-2.1-only OR LicenseRef-KDAB-KDStateMachineEditor
8
9 Licensees holding valid commercial KDAB State Machine Editor Library
10 licenses may use this file in accordance with the KDAB State Machine Editor
11 Library License Agreement provided with the Software.
12
13 Contact info@kdab.com if any conditions of this licensing are not clear to you.
14*/
15
16#ifndef KDSME_MODEL_STATE_H
17#define KDSME_MODEL_STATE_H
18
19#include "element.h"
20
21namespace KDSME {
22
23class RuntimeController;
24class Transition;
25class SignalTransition;
26class TimeoutTransition;
27
28class KDSME_CORE_EXPORT State : public Element
29{
30 Q_OBJECT
31 Q_PROPERTY(QString onEntry READ onEntry WRITE setOnEntry NOTIFY onEntryChanged FINAL)
32 Q_PROPERTY(QString onExit READ onExit WRITE setOnExit NOTIFY onExitChanged FINAL)
33 Q_PROPERTY(ChildMode childMode READ childMode WRITE setChildMode NOTIFY childModeChanged FINAL)
34 Q_PROPERTY(bool isComposite READ isComposite NOTIFY isCompositeChanged FINAL)
35 Q_PROPERTY(bool expanded READ isExpanded WRITE setExpanded NOTIFY expandedChanged FINAL)
36
37public:
43 Q_ENUM(ChildMode)
44
45 explicit State(State *parent = nullptr);
46 ~State();
47
48 Type type() const override;
49
50 Q_INVOKABLE KDSME::State *parentState() const;
51
52 State *initialState() const;
53 void setInitialState(State *initialState);
54
55 QList<State *> childStates() const;
56
57 QList<Transition *> transitions() const;
58 void addTransition(Transition *transition);
59 SignalTransition *addSignalTransition(State *target, const QString &silgnal = QString());
60 TimeoutTransition *addTimeoutTransition(State *target, int timeout);
61
65 QString onEntry() const;
66 void setOnEntry(const QString &onEntry);
67
71 QString onExit() const;
72 void setOnExit(const QString &onExit);
73
74 ChildMode childMode() const;
75 void setChildMode(ChildMode childMode);
76
80 bool isComposite() const;
81
82 bool isExpanded() const;
83 void setExpanded(bool expanded);
84
85 Q_INVOKABLE KDSME::StateMachine *machine() const;
86
87protected:
88 bool event(QEvent *event) override;
89
90Q_SIGNALS:
91 void onEntryChanged(const QString &onEntry);
92 void onExitChanged(const QString &onExit);
94 void isCompositeChanged(bool isComposite);
95 void expandedChanged(bool expanded);
96
97private:
98 struct Private;
99 QScopedPointer<Private> d;
100};
101
102class KDSME_CORE_EXPORT HistoryState : public State
103{
104 Q_OBJECT
105 Q_PROPERTY(KDSME::State *defaultState READ defaultState WRITE setDefaultState NOTIFY defaultStateChanged FINAL)
106 Q_PROPERTY(HistoryType historyType READ historyType WRITE setHistoryType NOTIFY historyTypeChanged FINAL)
107
108public:
110 {
112 DeepHistory
113 };
114 Q_ENUM(HistoryType)
115
116 explicit HistoryState(State *parent = nullptr);
117 explicit HistoryState(HistoryType type, State *parent = nullptr);
119
120 Type type() const override;
121 QString toDisplayString() const override;
122
123 State *defaultState() const;
124 void setDefaultState(State *state);
125
126 HistoryType historyType() const;
127 void setHistoryType(HistoryType historyType);
128
129Q_SIGNALS:
132
133private:
134 struct Private;
135 QScopedPointer<Private> d;
136};
137
138KDSME_CORE_EXPORT QDebug operator<<(QDebug dbg, const State *state);
139
140class KDSME_CORE_EXPORT FinalState : public State
141{
142 Q_OBJECT
143
144public:
145 explicit FinalState(State *parent = nullptr);
146 ~FinalState();
147
148 Type type() const override;
149
150private:
151 struct Private;
152 QScopedPointer<Private> d;
153};
154
155class KDSME_CORE_EXPORT StateMachine : public State
156{
157 Q_OBJECT
158 Q_PROPERTY(KDSME::RuntimeController *runtimeController READ runtimeController WRITE setRuntimeController NOTIFY runtimeControllerChanged)
159
160public:
161 explicit StateMachine(QObject *parent = nullptr);
163
164 Type type() const override;
165
166 RuntimeController *runtimeController() const;
167 void setRuntimeController(RuntimeController *runtimeController);
168
169Q_SIGNALS:
171
172private:
173 struct Private;
174 QScopedPointer<Private> d;
175};
176
177class KDSME_CORE_EXPORT PseudoState : public State
178{
179 Q_OBJECT
180 Q_PROPERTY(Kind kind READ kind WRITE setKind NOTIFY kindChanged FINAL)
181
182public:
183 enum Kind
184 {
185 InitialState
186 };
187 Q_ENUM(Kind)
188
189 explicit PseudoState(Kind kind = InitialState, State *parent = nullptr);
190 ~PseudoState();
191
192 Type type() const override;
193
194 Kind kind() const;
195 void setKind(Kind kind);
196
197 QString kindString() const;
198
199 QString toDisplayString() const override;
200
201Q_SIGNALS:
203
204private:
205 struct Private;
206 QScopedPointer<Private> d;
207};
208
209KDSME_CORE_EXPORT QDebug operator<<(QDebug dbg, const PseudoState *state);
210
211}
212
213Q_DECLARE_METATYPE(KDSME::PseudoState::Kind)
214
215#endif
void defaultStateChanged(KDSME::State *state)
void kindChanged(KDSME::PseudoState::Kind kind)
void runtimeControllerChanged(KDSME::RuntimeController *runtimeController)
void onExitChanged(const QString &onExit)
void childModeChanged(KDSME::State::ChildMode childMode)
void onEntryChanged(const QString &onEntry)
@ ExclusiveStates
Definition state.h:40
@ ParallelStates
Definition state.h:41
void isCompositeChanged(bool isComposite)
void expandedChanged(bool expanded)
KDSME_CORE_EXPORT QDebug operator<<(QDebug dbg, const State *state)
Definition state.cpp:408

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDStateMachineEditor
Create Qt State Machine metacode using a graphical user interface
https://github.com/KDAB/KDStateMachineEditor
Generated on Tue Jul 15 2025 15:21:47 for KDStateMachineEditor API Documentation by doxygen 1.9.8