CuteHMI - Data Acquisition (CuteHMI.DataAcquisition.1)
AbstractWriter.hpp
1#ifndef H_EXTENSIONS_CUTEHMI_DATAACQUISITION_1_INCLUDE_CUTEHMI_DATAACQUISITION_ABSTRACTWRITER_HPP
2#define H_EXTENSIONS_CUTEHMI_DATAACQUISITION_1_INCLUDE_CUTEHMI_DATAACQUISITION_ABSTRACTWRITER_HPP
3
4#include "TagValue.hpp"
5#include "Schema.hpp"
6
7#include <cutehmi/services/Serviceable.hpp>
8
9//<CuteHMI.Workarounds.Qt5Compatibility-1.workaround target="Qt" cause="Qt5">
10#include <cutehmi/workarounds/qt5compatibility/qsizetype.hpp>
11//</CuteHMI.Workarounds.Qt5Compatibility-1.workaround>
12
13#include <QObject>
14#include <QQmlListProperty>
15#include <QQmlEngine>
16
17namespace cutehmi {
18namespace dataacquisition {
19
20class AbstractWriterAttachedType;
21
25class CUTEHMI_DATAACQUISITION_API AbstractWriter:
26 public QObject,
28{
29 Q_OBJECT
31 QML_NAMED_ELEMENT(AbstractWriter)
32 QML_UNCREATABLE("AbstractWriter is an abstract class")
33
35
36 public:
37 Q_PROPERTY(QQmlListProperty<cutehmi::dataacquisition::TagValue> values READ valueList CONSTANT)
38 Q_CLASSINFO("DefaultProperty", "values")
39
40 Q_PROPERTY(cutehmi::dataacquisition::Schema * schema READ schema WRITE setSchema NOTIFY schemaChanged)
41
42 explicit AbstractWriter(QObject * parent = nullptr);
43
44 static cutehmi::dataacquisition::AbstractWriterAttachedType * qmlAttachedProperties(QObject * object);
45
46 QQmlListProperty<TagValue> valueList();
47
48 Schema * schema() const;
49
50 void setSchema(Schema * schema);
51
52 Q_INVOKABLE cutehmi::dataacquisition::TagValue * getValue(int index);
53
54 Q_INVOKABLE void appendValue(cutehmi::dataacquisition::TagValue * value);
55
56 Q_INVOKABLE void clearValues();
57
58 signals:
59 void schemaChanged();
60
61 protected:
63
64 Q_SIGNAL void broke();
65
66 Q_SIGNAL void started();
67
68 Q_SIGNAL void stopped();
69
70 Q_SIGNAL void databaseConnected();
71
72 Q_SIGNAL void schemaValidated();
73
74 virtual void onValueAppend(TagValue * value) = 0;
75
76 virtual void onValueRemove(TagValue * value) = 0;
77
78 const TagValueContainer & values() const;
79
80 private slots:
81 void onSchemaValidated(bool result);
82
83 private:
84 //<CuteHMI.Workarounds.Qt5Compatibility-1.workaround target="Qt" cause="Qt5">
85 static workarounds::qt5compatibility::sizeType ValueListCount(QQmlListProperty<TagValue> * property);
86
87 static TagValue * ValueListAt(QQmlListProperty<TagValue> * property, workarounds::qt5compatibility::sizeType index);
88 //</CuteHMI.DataAcquisition-2.workaround target="Qt" cause="Qt5">
89
90 static void ValueListClear(QQmlListProperty<TagValue> * property);
91
92 static void ValueListAppend(QQmlListProperty<TagValue> * property, TagValue * value);
93
94 struct Members
95 {
96 TagValueContainer values;
98 Schema * schema;
99
100 Members(AbstractWriter * p_parent):
101 valueList(p_parent, & values, & AbstractWriter::ValueListAppend, & AbstractWriter::ValueListCount, & AbstractWriter::ValueListAt, & AbstractWriter::ValueListClear),
102 schema(nullptr)
103 {
104 }
105 };
106
108};
109
110}
111}
112
113#endif
114
115//(c)C: Copyright © 2022, Michał Policht <michal@policht.pl>. All rights reserved.
116//(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
117//(c)C: This file is a part of CuteHMI.
118//(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.
119//(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.
120//(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/>.
121//(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
122//(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:
123//(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
124//(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.
Definition: AbstractWriterAttachedType.hpp:20
Abstract database writer.
Definition: AbstractWriter.hpp:28
Database schema.
Definition: Schema.hpp:18
Tag value.
Definition: TagValue.hpp:19