CuteHMI - Data Acquisition (CuteHMI.DataAcquisition.0)
AbstractWriter.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_DATAACQUISITION_0_INCLUDE_CUTEHMI_DATAACQUISITION_ABSTRACTWRITER_HPP
2 #define H_EXTENSIONS_CUTEHMI_DATAACQUISITION_0_INCLUDE_CUTEHMI_DATAACQUISITION_ABSTRACTWRITER_HPP
3 
4 #include "internal/common.hpp"
5 #include "internal/DbServiceableMixin.hpp"
6 #include "TagValue.hpp"
7 #include "Schema.hpp"
8 
9 #include <cutehmi/services/Serviceable.hpp>
10 
11 #include <QObject>
12 #include <QQmlListProperty>
13 
14 namespace cutehmi {
15 namespace dataacquisition {
16 
20 class CUTEHMI_DATAACQUISITION_API AbstractWriter:
21  public QObject,
23 {
24  Q_OBJECT
25 
26  public:
27  Q_PROPERTY(QQmlListProperty<cutehmi::dataacquisition::TagValue> values READ valueList)
28  Q_CLASSINFO("DefaultProperty", "values")
29 
30  Q_PROPERTY(cutehmi::dataacquisition::Schema * schema READ schema WRITE setSchema NOTIFY schemaChanged)
31 
32  AbstractWriter(QObject * parent = nullptr);
33 
34  QQmlListProperty<TagValue> valueList();
35 
36  Schema * schema() const;
37 
38  void setSchema(Schema * schema);
39 
40  Q_INVOKABLE TagValue * getValue(int index);
41 
42  Q_INVOKABLE void appendValue(cutehmi::dataacquisition::TagValue * value);
43 
44  Q_INVOKABLE void clearValues();
45 
46  signals:
47  void schemaChanged();
48 
49  CUTEHMI_PROTECTED_SIGNALS:
50  void broke();
51 
52  void started();
53 
54  void stopped();
55 
56  void databaseConnected();
57 
58  void schemaValidated();
59 
60  protected:
62 
63  const TagValueContainer & values() const;
64 
65  private slots:
66  void onSchemaValidated(bool result);
67 
68  private:
69  static int ValueListCount(QQmlListProperty<TagValue> * property);
70 
71  static TagValue * ValueListAt(QQmlListProperty<TagValue> * property, int index);
72 
73  static void ValueListClear(QQmlListProperty<TagValue> * property);
74 
75  static void ValuesListAppend(QQmlListProperty<TagValue> * property, TagValue * value);
76 
77  struct Members
78  {
79  TagValueContainer values;
81  Schema * schema;
82 
83  Members(AbstractWriter * p_parent):
84  valueList(p_parent, & values, & AbstractWriter::ValuesListAppend, & AbstractWriter::ValueListCount, & AbstractWriter::ValueListAt, & AbstractWriter::ValueListClear),
85  schema(nullptr)
86  {
87  }
88  };
89 
90  MPtr<Members> m;
91 };
92 
93 }
94 }
95 
96 #endif
97 
98 //(c)C: Copyright © 2020-2021, Michał Policht <michal@policht.pl>. All rights reserved.
99 //(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
100 //(c)C: This file is a part of CuteHMI.
101 //(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.
102 //(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.
103 //(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/>.
104 //(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
105 //(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:
106 //(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
107 //(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.
QList
cutehmi::MPtr< Members >
QObject
cutehmi
cutehmi::dataacquisition::TagValue
Tag value.
Definition: TagValue.hpp:15
cutehmi::services::Serviceable
QQmlListProperty< cutehmi::dataacquisition::TagValue >
cutehmi::dataacquisition::AbstractWriter
Abstract database writer.
Definition: AbstractWriter.hpp:20
cutehmi::dataacquisition::Schema
Database schema.
Definition: Schema.hpp:14