CuteHMI - Data Acquisition (CuteHMI.DataAcquisition.0)
Schema.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_DATAACQUISITION_0_INCLUDE_CUTEHMI_DATAACQUISITION_SCHEMA_HPP
2 #define H_EXTENSIONS_CUTEHMI_DATAACQUISITION_0_INCLUDE_CUTEHMI_DATAACQUISITION_SCHEMA_HPP
3 
4 #include "internal/common.hpp"
5 #include "DataObject.hpp"
6 
7 namespace cutehmi {
8 namespace dataacquisition {
9 
13 class CUTEHMI_DATAACQUISITION_API Schema:
14  public DataObject
15 {
16  Q_OBJECT
17 
18  public:
22  Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
23 
24 
27  Q_PROPERTY(QString user READ user WRITE setUser NOTIFY userChanged)
28 
29  explicit Schema(QObject * parent = nullptr);
30 
31  QString name() const;
32 
33  void setName(const QString & name);
34 
35  QString user() const;
36 
37  void setUser(const QString & user);
38 
39  public slots:
40  void create();
41 
42  void drop();
43 
48  void validate();
49 
50  signals:
51  void nameChanged();
52 
53  void userChanged();
54 
55  void validated(bool result);
56 
57  private:
58  static constexpr const char * SQL_SCRIPTS_SUBDIR = "sql";
59  static constexpr const char * POSTGRESQL_SCRIPTS_SUBDIR = "postgres";
60  static constexpr const char * SQLITE_SCRIPTS_SUBDIR = "sqlite";
61 
62  bool validatePostgresTable(const QString & tableName, QSqlQuery & query);
63 
64  bool validateSqliteTable(const QString & tableName, QSqlQuery & query);
65 
66  QString readScript(const QString & dbms, const QString & scriptName) const;
67 
68  struct Members
69  {
70  QString name;
71  QString user;
72  };
73 
74  MPtr<Members> m;
75 };
76 
77 }
78 }
79 
80 #endif
81 
82 //(c)C: Copyright © 2020, Michał Policht <michal@policht.pl>. All rights reserved.
83 //(c)C: This file is a part of CuteHMI.
84 //(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.
85 //(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.
86 //(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/>.
QSqlQuery
cutehmi::dataacquisition::DataObject
Database object.
Definition: DataObject.hpp:21
cutehmi::MPtr< Members >
QObject
cutehmi
QString
cutehmi::dataacquisition::Schema
Database schema.
Definition: Schema.hpp:13