diff options
Diffstat (limited to 'common/facadeinterface.h')
-rw-r--r-- | common/facadeinterface.h | 51 |
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 | |||
29 | namespace Akonadi2 { | ||
30 | class 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 | */ | ||
40 | template<class DomainType> | ||
41 | class StoreFacade { | ||
42 | public: | ||
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 | } | ||