CuteHMI - Data Acquisition (CuteHMI.DataAcquisition.1)
Schema.hpp
1#ifndef H_EXTENSIONS_CUTEHMI_DATAACQUISITION_1_INCLUDE_CUTEHMI_DATAACQUISITION_SCHEMA_HPP
2#define H_EXTENSIONS_CUTEHMI_DATAACQUISITION_1_INCLUDE_CUTEHMI_DATAACQUISITION_SCHEMA_HPP
3
4#include "internal/common.hpp"
5
6#include <cutehmi/shareddatabase/DataObject.hpp>
7
8#include <QQmlEngine>
9
10namespace cutehmi {
11namespace dataacquisition {
12
16class CUTEHMI_DATAACQUISITION_API Schema:
18{
19 Q_OBJECT
20 QML_NAMED_ELEMENT(Schema)
21
22 public:
23 static const char * INITIAL_NAME;
24
35 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
36
37
40 Q_PROPERTY(QString user READ user WRITE setUser NOTIFY userChanged)
41
42 explicit Schema(QObject * parent = nullptr);
43
44 QString name() const;
45
46 void setName(const QString & name);
47
48 QString user() const;
49
50 void setUser(const QString & user);
51
52 public slots:
57 void create();
58
63 void drop();
64
69 void validate();
70
71 signals:
73
75
76 void created(bool success);
77
78 void dropped(bool success);
79
80 void validated(bool positive);
81
82 private:
83 static constexpr const char * SQL_SCRIPTS_SUBDIR = "sql";
84 static constexpr const char * POSTGRESQL_SCRIPTS_SUBDIR = "postgres";
85 static constexpr const char * SQLITE_SCRIPTS_SUBDIR = "sqlite";
86
87 bool validatePostgresTable(const QString & tableName, QSqlQuery & query);
88
89 bool validateSqliteTable(const QString & tableName, QSqlQuery & query);
90
91 QString readScript(const QString & dbms, const QString & scriptName) const;
92
93 struct Members
94 {
95 QString name;
96 QString user;
97 };
98
100};
101
102}
103}
104
105#endif
106
107//(c)C: Copyright © 2022, Michał Policht <michal@policht.pl>. All rights reserved.
108//(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
109//(c)C: This file is a part of CuteHMI.
110//(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.
111//(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.
112//(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/>.
113//(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
114//(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:
115//(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
116//(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.
Database schema.
Definition: Schema.hpp:18
void validated(bool positive)
static const char * INITIAL_NAME
Schema name initial value ("cutehmi_dataacquisition").
Definition: Schema.hpp:23