summaryrefslogtreecommitdiffstats
path: root/common/store.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-10 10:47:12 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-10 10:47:12 +0100
commit0991561c9630fcb89b9666b8d57c2b7ea592fec6 (patch)
tree66e12af97c055a62fc15ef1946e3bb166d4c55bf /common/store.h
parentc1c336a9064557bb987c30582bce84bab3f869bc (diff)
downloadsink-0991561c9630fcb89b9666b8d57c2b7ea592fec6.tar.gz
sink-0991561c9630fcb89b9666b8d57c2b7ea592fec6.zip
Moved Store to separate file
Diffstat (limited to 'common/store.h')
-rw-r--r--common/store.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/common/store.h b/common/store.h
new file mode 100644
index 0000000..6696833
--- /dev/null
+++ b/common/store.h
@@ -0,0 +1,101 @@
1/*
2 * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) version 3, or any
8 * later version accepted by the membership of KDE e.V. (or its
9 * successor approved by the membership of KDE e.V.), which shall
10 * act as a proxy defined in Section 6 of version 3 of the license.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include "sink_export.h"
24#include <QString>
25#include <QSharedPointer>
26
27#include <Async/Async>
28
29#include "query.h"
30#include "applicationdomaintype.h"
31
32class QAbstractItemModel;
33
34namespace Sink {
35
36/**
37 * The unified Sink Store.
38 *
39 * This is the primary interface for clients to interact with Sink.
40 * It provides a unified store where all data provided by various resources can be accessed and modified.
41 */
42namespace Store {
43
44QString SINK_EXPORT storageLocation();
45
46enum Roles {
47 DomainObjectRole = Qt::UserRole + 1, //Must be the same as in ModelResult
48 ChildrenFetchedRole,
49 DomainObjectBaseRole
50};
51
52/**
53 * Asynchronusly load a dataset with tree structure information
54 */
55template <class DomainType>
56QSharedPointer<QAbstractItemModel> SINK_EXPORT loadModel(Query query);
57
58/**
59 * Create a new entity.
60 */
61template <class DomainType>
62KAsync::Job<void> SINK_EXPORT create(const DomainType &domainObject);
63
64/**
65 * Modify an entity.
66 *
67 * This includes moving etc. since these are also simple settings on a property.
68 */
69template <class DomainType>
70KAsync::Job<void> SINK_EXPORT modify(const DomainType &domainObject);
71
72/**
73 * Remove an entity.
74 */
75template <class DomainType>
76KAsync::Job<void> SINK_EXPORT remove(const DomainType &domainObject);
77
78/**
79 * Synchronize data to local cache.
80 */
81KAsync::Job<void> SINK_EXPORT synchronize(const Sink::Query &query);
82
83/**
84 * Removes all resource data from disk.
85 *
86 * This will not touch the configuration. All commands that that arrived at the resource before this command will be dropped. All commands that arrived later will be executed.
87 */
88KAsync::Job<void> SINK_EXPORT removeDataFromDisk(const QByteArray &resourceIdentifier);
89
90template <class DomainType>
91KAsync::Job<DomainType> SINK_EXPORT fetchOne(const Sink::Query &query);
92
93template <class DomainType>
94KAsync::Job<QList<typename DomainType::Ptr> > SINK_EXPORT fetchAll(const Sink::Query &query);
95
96template <class DomainType>
97KAsync::Job<QList<typename DomainType::Ptr> > SINK_EXPORT fetch(const Sink::Query &query, int minimumAmount = 0);
98
99 }
100}
101