summaryrefslogtreecommitdiffstats
path: root/common/facadeinterface.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-07-24 17:26:25 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-07-27 23:22:10 +0200
commit7ae8c8719497ec7556f532bab061d3758976f792 (patch)
tree8ace2300cebcf6926c7053e3f23a5f68c304ad98 /common/facadeinterface.h
parent4430eabdfeddf02c20424508a2a4207b6b4a764e (diff)
downloadsink-7ae8c8719497ec7556f532bab061d3758976f792.tar.gz
sink-7ae8c8719497ec7556f532bab061d3758976f792.zip
Mode FacadeFactory to separate file, mutex protected it, and loaded
resource The factory is potentially used from several queries simultaneously, so it's now mutex protected. Additionally we try to load the plugins directly in the factory.
Diffstat (limited to 'common/facadeinterface.h')
-rw-r--r--common/facadeinterface.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/common/facadeinterface.h b/common/facadeinterface.h
new file mode 100644
index 0000000..a88c104
--- /dev/null
+++ b/common/facadeinterface.h
@@ -0,0 +1,51 @@
1/*
2 * Copyright (C) 2014 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 <Async/Async>
24#include <QByteArray>
25#include <QSharedPointer>
26#include "domain/applicationdomaintype.h"
27#include "resultprovider.h"
28
29namespace Akonadi2 {
30class Query;
31
32/**
33 * Interface for the store facade.
34 *
35 * All methods are synchronous.
36 * Facades are stateful (they hold connections to resources and database).
37 *
38 * TODO: would it make sense to split the write, read and notification parts? (we could potentially save some connections)
39 */
40template<class DomainType>
41class StoreFacade {
42public:
43 virtual ~StoreFacade(){};
44 QByteArray type() const { return ApplicationDomain::getTypeName<DomainType>(); }
45 virtual KAsync::Job<void> create(const DomainType &domainObject) = 0;
46 virtual KAsync::Job<void> modify(const DomainType &domainObject) = 0;
47 virtual KAsync::Job<void> remove(const DomainType &domainObject) = 0;
48 virtual KAsync::Job<void> load(const Query &query, const QSharedPointer<async::ResultProvider<typename DomainType::Ptr> > &resultProvider) = 0;
49};
50
51}