CuteHMI - Services (CuteHMI.Services.3)
ServiceDependency.hpp
1#ifndef H_EXTENSIONS_CUTEHMI_SERVICES_3_INCLUDE_CUTEHMI_SERVICES_SERVICEDEPENDENCY_HPP
2#define H_EXTENSIONS_CUTEHMI_SERVICES_3_INCLUDE_CUTEHMI_SERVICES_SERVICEDEPENDENCY_HPP
3
4#include "internal/common.hpp"
5#include "ServiceGroupRule.hpp"
6
7//<CuteHMI.Workarounds.Qt5Compatibility-1.workaround target="Qt" cause="Qt5">
8#include <cutehmi/workarounds/qt5compatibility/qsizetype.hpp>
9//</CuteHMI.Workarounds.Qt5Compatibility-1.workaround>
10
11
12//<CuteHMI.Workarounds.Qt5Compatibility-5.workaround target="Qt" cause="Qt5">
13
14#include <cutehmi/workarounds/qt5compatibility/cutehmiQt6MocInclude.hpp>
15
16namespace cutehmi {
17namespace services {
18
19class AbstractService;
20
21}
22}
23
24CUTEHMI_QT6_MOC_INCLUDE("AbstractService.hpp")
25
26//</CuteHMI.Workarounds.Qt5Compatibility-5.workaround>
27
28#include <QPointer>
29#include <QSignalTransition>
30#include <QQmlEngine>
31#include <QQmlListProperty>
32
33namespace cutehmi {
34namespace services {
35
36class CUTEHMI_SERVICES_API ServiceDependency:
37 public ServiceGroupRule
38{
39 Q_OBJECT
40 QML_NAMED_ELEMENT(ServiceDependency)
41
42 public:
43 Q_PROPERTY(cutehmi::services::AbstractService * service READ service WRITE setService NOTIFY serviceChanged)
44
45 Q_PROPERTY(QQmlListProperty<cutehmi::services::AbstractService> requires READ requiredServiceList CONSTANT)
46
47 ServiceDependency(QObject * parent = nullptr);
48
49 void setService(AbstractService * service);
50
51 cutehmi::services::AbstractService * service() const;
52
54
55 Q_INVOKABLE void appendRequiredService(cutehmi::services::AbstractService * service);
56
57 Q_INVOKABLE void clearRequiredServices();
58
59 std::unique_ptr<QAbstractTransition> conditionalTransition(SlotType type, const AbstractService * service) override;
60
61 signals:
63
64 protected:
66
67 const RequiredServicesContainer & requiredServices() const;
68
69 RequiredServicesContainer & requiredServices();
70
71 private:
72 class StartConditionTransition: public QSignalTransition {
73 public:
74 StartConditionTransition(QPointer<ServiceDependency> serviceDependency);
75
76 protected:
77 bool eventTest(QEvent * event) override;
78
79 private:
80 struct Members {
81 QPointer<ServiceDependency> serviceDependency;
82 };
83
85 };
86
87 class StopConditionTransition: public QSignalTransition {
88 public:
89 StopConditionTransition(QPointer<ServiceDependency> serviceDependency);
90
91 protected:
92 bool eventTest(QEvent * event) override;
93
94 private:
95 struct Members {
96 QPointer<ServiceDependency> serviceDependency;
97 };
98
99 MPtr<Members> m;
100 };
101
102 //<CuteHMI.Workarounds.Qt5Compatibility-1.workaround target="Qt" cause="Qt5">
103 static workarounds::qt5compatibility::sizeType RequiredServiceListCount(QQmlListProperty<AbstractService> * property);
104
105 static AbstractService * RequiredServiceListAt(QQmlListProperty<AbstractService> * property, workarounds::qt5compatibility::sizeType index);
106 //</CuteHMI.DataAcquisition-2.workaround target="Qt" cause="Qt5">
107
108 static void RequiredServiceListClear(QQmlListProperty<AbstractService> * property);
109
110 static void RequiredServiceListAppend(QQmlListProperty<AbstractService> * property, AbstractService * value);
111
112 struct Members
113 {
114 AbstractService * service = nullptr;
115 RequiredServicesContainer requiredServices;
116 QQmlListProperty<AbstractService> requiredServiceList;
117
118 Members(ServiceDependency * p_parent):
119 requiredServiceList(p_parent, & requiredServices, & ServiceDependency::RequiredServiceListAppend, & ServiceDependency::RequiredServiceListCount, & ServiceDependency::RequiredServiceListAt, & ServiceDependency::RequiredServiceListClear)
120 {
121 }
122 };
123
124 MPtr<Members> m;
125};
126
127}
128}
129
130#endif
131
132//(c)C: Copyright © 2022-2023, Michał Policht <michal@policht.pl>. All rights reserved.
133//(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
134//(c)C: This file is a part of CuteHMI.
135//(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.
136//(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.
137//(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/>.
138//(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
139//(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:
140//(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
141//(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: ServiceDependency.hpp:38
QList< AbstractService * > RequiredServicesContainer
Definition: ServiceDependency.hpp:65
Service group rule.
Definition: ServiceGroupRule.hpp:26
SlotType
Definition: ServiceGroupRule.hpp:32