CuteHMI - Services (CuteHMI.Services.3)
SelfService.hpp
1#ifndef H_EXTENSIONS_CUTEHMI_SERVICES_3_INCLUDE_CUTEHMI_SERVICES_SELFSERVICE_HPP
2#define H_EXTENSIONS_CUTEHMI_SERVICES_3_INCLUDE_CUTEHMI_SERVICES_SELFSERVICE_HPP
3
4#include "internal/common.hpp"
5
6#include "AbstractService.hpp"
7#include "Serviceable.hpp"
8
9namespace cutehmi {
10namespace services {
11
12namespace internal {
15}
16
18
27class CUTEHMI_SERVICES_API SelfService:
29 public QQmlParserStatus,
30 public Serviceable
31{
32 Q_OBJECT
34 QML_NAMED_ELEMENT(SelfService)
35 Q_INTERFACES(QQmlParserStatus)
36
37 public:
38 Q_PROPERTY(QAbstractState * startingState READ startingState WRITE setStartingState NOTIFY startingStateChanged)
39
40 Q_PROPERTY(QAbstractState * activeState READ activeState WRITE setActiveState NOTIFY activeStateChanged)
41
42 Q_PROPERTY(QAbstractState * stoppingState READ stoppingState WRITE setStoppingState NOTIFY stoppingStateChanged)
43
44 Q_PROPERTY(QAbstractState * brokenState READ brokenState WRITE setBrokenState NOTIFY brokenStateChanged)
45
46 Q_PROPERTY(QAbstractState * repairingState READ repairingState WRITE setRepairingState NOTIFY repairingStateChanged)
47
48 Q_PROPERTY(QAbstractState * evacuatingState READ evacuatingState WRITE setEvacuatingState NOTIFY evacuatingStateChanged)
49
50 Q_PROPERTY(QJSValue signalToStarted READ signalToStarted WRITE setSignalToStarted NOTIFY signalToStartedChanged)
51
52 Q_PROPERTY(QJSValue signalToStopped READ signalToStopped WRITE setSignalToStopped NOTIFY signalToStoppedChanged)
53
54 Q_PROPERTY(QJSValue signalToBroken READ signalToBroken WRITE setSignalToBroken NOTIFY signalToBrokenChanged)
55
56 Q_PROPERTY(QJSValue signalToIdling READ signalToIdling WRITE setSignalToIdling NOTIFY signalToIdlingChanged)
57
58 Q_PROPERTY(QJSValue signalToYielding READ signalToYielding WRITE setSignalToYielding NOTIFY signalToYieldingChanged)
59
60 explicit SelfService(QObject * parent = nullptr);
61
62 ~SelfService() override;
63
64 static cutehmi::services::SelfServiceAttachedType * qmlAttachedProperties(QObject * object);
65
66 QAbstractState * startingState() const;
67
68 void setStartingState(QAbstractState * startingState);
69
70 QAbstractState * activeState() const;
71
72 void setActiveState(QAbstractState * activeState);
73
74 QAbstractState * stoppingState() const;
75
76 void setStoppingState(QAbstractState * stoppingState);
77
78 QAbstractState * repairingState() const;
79
80 void setBrokenState(QAbstractState * brokenState);
81
82 QAbstractState * brokenState() const;
83
84 void setRepairingState(QAbstractState * repairingState);
85
86 QAbstractState * evacuatingState() const;
87
88 void setEvacuatingState(QAbstractState * evacuatingState);
89
90 QJSValue signalToStarted() const;
91
92 void setSignalToStarted(const QJSValue & signal);
93
94 QJSValue signalToStopped() const;
95
96 void setSignalToStopped(const QJSValue & signal);
97
98 QJSValue signalToBroken() const;
99
100 void setSignalToBroken(const QJSValue & signal);
101
102 QJSValue signalToIdling() const;
103
104 void setSignalToIdling(const QJSValue & signal);
105
106 QJSValue signalToYielding() const;
107
108 void setSignalToYielding(const QJSValue & signal);
109
110 void configureStarting(QState * starting, AssignStatusFunction assignStatus) override;
111
112 void configureStarted(QState * active, const QState * idling, const QState * yielding, AssignStatusFunction assignStatus) override;
113
114 void configureStopping(QState * stopping, AssignStatusFunction assignStatus) override;
115
116 void configureBroken(QState * broken, AssignStatusFunction assignStatus) override;
117
118 void configureRepairing(QState * repairing, AssignStatusFunction assignStatus) override;
119
120 void configureEvacuating(QState * evacuating, AssignStatusFunction assignStatus) override;
121
122 std::unique_ptr<QAbstractTransition> transitionToStarted() const override;
123
124 std::unique_ptr<QAbstractTransition> transitionToStopped() const override;
125
126 std::unique_ptr<QAbstractTransition> transitionToBroken() const override;
127
128 std::unique_ptr<QAbstractTransition> transitionToYielding() const override;
129
130 std::unique_ptr<QAbstractTransition> transitionToIdling() const override;
131
132 void classBegin() override;
133
134 void componentComplete() override;
135
136 signals:
138
140
142
144
146
148
150
152
154
156
158
159 private:
160 static const char * DSM_IMPORT_STATEMENT;
161
162 static QString & DefaultStatus();
163
164 internal::ServiceStateInterface * stateInterface() const;
165
166 void assignStateStatuses(QState & state, AssignStatusFunction assignStatus);
167
168 void assignStateStatus(QState & state, AssignStatusFunction assignStatus, const SelfServiceAttachedType * soAttachedType);
169
170 //<CuteHMI.Services-4.workaround target="Qt" cause="missing">
171
181 virtual std::pair<const QObject *, QByteArray> senderSignalPair(const QJSValue & qmlSignal) const;
182
183 QQmlEngine * helperQmlEngine() const;
184
185 QSignalTransition * helperSignalTransition() const;
186
187 QJSValue helperSignalTransitionJSValue() const;
188
189 //</CuteHMI.Services-4.workaround>
190
191 void configureStateInterface();
192
193 struct Members
194 {
195 //<CuteHMI.Services-3.workaround target="Qt" cause="design">
196 QStateMachine surrogateSM;
197 //</CuteHMI.Services-3.workaround>
198 QAbstractState * activeState;
199 QAbstractState * startingState;
200 QAbstractState * stoppingState;
201 QAbstractState * brokenState;
202 QAbstractState * repairingState;
203 QAbstractState * evacuatingState;
204 QSignalTransition * transitionToStartedState;
205 QAbstractTransition * transitionToStoppedState;
206 QAbstractTransition * transitionToBrokenState;
207 QAbstractTransition * transitionToYieldingState;
208 QAbstractTransition * transitionToIdlingState;
209 QJSValue signalToStarted;
210 QJSValue signalToStopped;
211 QJSValue signalToBroken;
212 QJSValue signalToIdling;
213 QJSValue signalToYielding;
214 bool qmlBeingParsed;
215
216 //<CuteHMI.Services-4.workaround target="Qt" cause="missing">
217 mutable struct
218 {
219 mutable QQmlEngine * helperQmlEngine;
220 mutable QSignalTransition * helperSignalTransition;
221 mutable QJSValue helperSignalTransitionJSValue;
222 } cache;
223 //</CuteHMI.Services-4.workaround>
224 };
225
227};
228
229}
230}
231
232#endif
233
234//(c)C: Copyright © 2022, Michał Policht <michal@policht.pl>. All rights reserved.
235//(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
236//(c)C: This file is a part of CuteHMI.
237//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
238//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
239//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see <https://www.gnu.org/licenses/>.
240//(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
241//(c)C: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
242//(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
243//(c)C: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Abstract service.
Definition: AbstractService.hpp:49
Definition: SelfServiceAttachedType.hpp:14
Self service.
Definition: SelfService.hpp:31
Serviceable interface.
Definition: Serviceable.hpp:33
Definition: ServiceStateInterface.hpp:24
Service state machine.
Definition: ServiceStateMachine.hpp:24