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 "TagValue.hpp"
6 #include "Schema.hpp"
7 
8 #include <cutehmi/services/Serviceable.hpp>
9 
10 #include <QObject>
11 #include <QQmlListProperty>
12 
13 namespace cutehmi {
14 namespace dataacquisition {
15 
19 class CUTEHMI_DATAACQUISITION_API AbstractWriter:
20  public QObject,
22 {
23  Q_OBJECT
24 
25  public:
26  Q_PROPERTY(QQmlListProperty<cutehmi::dataacquisition::TagValue> values READ valueList)
27  Q_CLASSINFO("DefaultProperty", "values")
28 
29  Q_PROPERTY(Schema * schema READ schema WRITE setSchema NOTIFY schemaChanged)
30 
31  AbstractWriter(QObject * parent = nullptr);
32 
33  QQmlListProperty<TagValue> valueList();
34 
35  Schema * schema() const;
36 
37  void setSchema(Schema * schema);
38 
39  signals:
40  void schemaChanged();
41 
42  CUTEHMI_PROTECTED_SIGNALS:
43  void broke();
44 
45  void started();
46 
47  void stopped();
48 
49  void databaseConnected();
50 
51  void schemaValidated();
52 
53  protected:
55 
56  const TagValueContainer & values() const;
57 
58  QState * createWaitingForDatabaseConnectedSate(QState * parent, ServiceStatuses * statuses = nullptr, QState * target = nullptr);
59 
60  QState * createValidatingSchemaSate(QState * parent, ServiceStatuses * statuses = nullptr, QState * target = nullptr);
61 
62  private slots:
63  void onSchemaValidated(bool result);
64 
65  private:
66  static int ValueListCount(QQmlListProperty<TagValue> * property);
67 
68  static TagValue * ValueListAt(QQmlListProperty<TagValue> * property, int index);
69 
70  static void ValueListClear(QQmlListProperty<TagValue> * property);
71 
72  static void ValuesListAppend(QQmlListProperty<TagValue> * property, TagValue * value);
73 
74  struct Members
75  {
76  TagValueContainer values;
78  Schema * schema;
79 
80  Members(AbstractWriter * p_parent):
81  valueList(p_parent, & values, & AbstractWriter::ValuesListAppend, & AbstractWriter::ValueListCount, & AbstractWriter::ValueListAt, & AbstractWriter::ValueListClear),
82  schema(nullptr)
83  {
84  }
85  };
86 
87  MPtr<Members> m;
88 };
89 
90 }
91 }
92 
93 #endif
94 
95 //(c)C: Copyright © 2020, Michał Policht <michal@policht.pl>. All rights reserved.
96 //(c)C: This file is a part of CuteHMI.
97 //(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.
98 //(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.
99 //(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/>.
QState
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:19
cutehmi::dataacquisition::Schema
Database schema.
Definition: Schema.hpp:13
QHash