summaryrefslogtreecommitdiffstats
path: root/tests/hawd/dataset.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hawd/dataset.h')
-rw-r--r--tests/hawd/dataset.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/hawd/dataset.h b/tests/hawd/dataset.h
new file mode 100644
index 0000000..eb18b70
--- /dev/null
+++ b/tests/hawd/dataset.h
@@ -0,0 +1,80 @@
1/*
2 * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#pragma once
21
22#include "datasetdefinition.h"
23
24#include "state.h"
25#include "common/storage.h"
26
27#include <QHash>
28#include <QVariant>
29
30namespace HAWD
31{
32
33class Dataset
34{
35public:
36 class Row
37 {
38 public:
39 Row(const Row &other);
40 Row &operator=(const Row &rhs);
41 void setValue(const QString &column, const QVariant &value);
42 QVariant value(const QString &column);
43 void annotate(const QString &note);
44 qint64 key() const;
45 QByteArray toBinary() const;
46 QString toString() const;
47
48 private:
49 Row();
50 Row(const Dataset &dataset, qint64 key = 0);
51 void fromBinary(QByteArray &binary);
52
53 qint64 m_key;
54 QHash<QString, DataDefinition> m_columns;
55 QHash<QString, QVariant> m_data;
56 QString m_annotation;
57 const Dataset *m_dataset;
58 friend class Dataset;
59 };
60
61 Dataset(const DatasetDefinition &definition);
62 Dataset(const QString &name, const State &state);
63 ~Dataset();
64
65 bool isValid();
66 const DatasetDefinition &definition() const;
67
68 qint64 insertRow(const Row &row);
69 void removeRow(const Row &row);
70 Row row(qint64 key = 0);
71 Row lastRow();
72 //TODO: row cursor
73
74private:
75 DatasetDefinition m_definition;
76 Storage m_storage;
77};
78
79} // namespace HAWD
80