CuteHMI - Data Acquisition (CuteHMI.DataAcquisition.1)
HistoryCollective.hpp
1#ifndef H_EXTENSIONS_CUTEHMI_DATAACQUISITION_1_INCLUDE_CUTEHMI_DATAACQUISITION_INTERNAL_HISTORYCOLLECTIVE_HPP
2#define H_EXTENSIONS_CUTEHMI_DATAACQUISITION_1_INCLUDE_CUTEHMI_DATAACQUISITION_INTERNAL_HISTORYCOLLECTIVE_HPP
3
4#include "common.hpp"
5#include "TagCache.hpp"
6#include "TableCollective.hpp"
7
8#include <QDateTime>
9
10namespace cutehmi {
11namespace dataacquisition {
12namespace internal {
13
14class CUTEHMI_DATAACQUISITION_PRIVATE HistoryCollective:
15 public TableCollective
16{
17 Q_OBJECT
18
19 public:
20 static const char * TABLE_STEM;
21
23 {
25 QVariantList open;
26 QVariantList close;
27 QVariantList min;
28 QVariantList max;
29 QVariantList openTime;
30 QVariantList closeTime;
31 QVariantList count;
32
33 //<CuteHMI.DataAcquisition-1.workaround target="clang" cause="Bug-28280">
35 //</CuteHMI.DataAcquisition-1.workaround>
36
37 int length() const;
38
39 bool isEqual(int i, const ColumnValues & other);
40
41 void replace(int i, const ColumnValues & other);
42
43 void insert(int i, const ColumnValues & other);
44
45 void eraseFrom(int i);
46
47 void append(const ColumnValues & other, int i);
48 };
49
50 struct Tuple
51 {
58 int count = 0;
59 };
60
62
64
65 void insert(const TuplesContainer & tuples);
66
67 void select(const QStringList & tags, const QDateTime & from, const QDateTime & to);
68
69 signals:
71
72 private:
73 static QVariant::Type TupleVariantType(const Tuple & tuple);
74
75 static void ToColumnValues(ColumnValues & intValues, ColumnValues & boolValues, ColumnValues & realValues, const TuplesContainer & tuples);
76
77 QString insertQuery(const QString & driverName, const QString & schemaName, const QString & tableName);
78
79 QString selectQuery(const QString & driverName, const QString & schemaName, const QString & tableName, const QStringList & tagIdtrings, const QDateTime & from, const QDateTime & to);
80
81 template<typename T>
82 void tableInsert(QSqlDatabase & db, const QString & schemaName, const ColumnValues & columnValues);
83
84 template<typename T>
85 bool tableSelect(QSqlDatabase & db, ColumnValues & columnValues, const QString & schemaName, const QStringList & tags, const QDateTime & from, const QDateTime & to);
86
87 template<typename T>
88 bool tableMinOpenTime(QSqlDatabase & db, QDateTime & minOpenTime, const QString & schemaName);
89
90 template<typename T>
91 bool tableMaxCloseTime(QSqlDatabase & db, QDateTime & maxCloseTime, const QString & schemaName);
92};
93
94}
95}
96}
97
99
100#endif
101
102//(c)C: Copyright © 2022, Michał Policht <michal@policht.pl>. All rights reserved.
103//(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
104//(c)C: This file is a part of CuteHMI.
105//(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.
106//(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.
107//(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/>.
108//(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
109//(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:
110//(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
111//(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: HistoryCollective.hpp:16
void selected(cutehmi::dataacquisition::internal::HistoryCollective::ColumnValues result, QDateTime minOpenTime, QDateTime maxCloseTime)
QHash< QString, Tuple > TuplesContainer
Definition: HistoryCollective.hpp:61
static const char * TABLE_STEM
Definition: HistoryCollective.hpp:20
Definition: TableCollective.hpp:16
T internal(T... args)
QVariantList close
Definition: HistoryCollective.hpp:26
QVariantList min
Definition: HistoryCollective.hpp:27
QStringList tagName
Definition: HistoryCollective.hpp:24
QVariantList openTime
Definition: HistoryCollective.hpp:29
QVariantList max
Definition: HistoryCollective.hpp:28
QVariantList count
Definition: HistoryCollective.hpp:31
QVariantList open
Definition: HistoryCollective.hpp:25
QVariantList closeTime
Definition: HistoryCollective.hpp:30
QVariant max
Definition: HistoryCollective.hpp:55
QVariant min
Definition: HistoryCollective.hpp:54
QDateTime openTime
Definition: HistoryCollective.hpp:56
QVariant open
Definition: HistoryCollective.hpp:52
QDateTime closeTime
Definition: HistoryCollective.hpp:57
QVariant close
Definition: HistoryCollective.hpp:53