diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-06 19:01:03 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-06 19:01:03 +0100 |
commit | 303a3cf5ba48dd9857a1fb9600cedd604c71de8d (patch) | |
tree | b7607eb58b7fbda5dbd49133bb316fe109edc44a /common/typeindex.h | |
parent | 46570dd9684990846cfd4c3dc5be71498c5a6278 (diff) | |
download | sink-303a3cf5ba48dd9857a1fb9600cedd604c71de8d.tar.gz sink-303a3cf5ba48dd9857a1fb9600cedd604c71de8d.zip |
Added TypeIndex
A central location for all types to specify what properties are
indexed, and how to query them.
Diffstat (limited to 'common/typeindex.h')
-rw-r--r-- | common/typeindex.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/common/typeindex.h b/common/typeindex.h new file mode 100644 index 0000000..fb66c2c --- /dev/null +++ b/common/typeindex.h | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | Copyright (c) 2015 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #include "resultset.h" | ||
22 | #include "bufferadaptor.h" | ||
23 | #include "storage.h" | ||
24 | #include "query.h" | ||
25 | #include <QByteArray> | ||
26 | |||
27 | class TypeIndex | ||
28 | { | ||
29 | public: | ||
30 | TypeIndex(const QByteArray &type); | ||
31 | |||
32 | template<typename T> | ||
33 | void addProperty(const QByteArray &property); | ||
34 | |||
35 | void add(const QByteArray &identifier, const Akonadi2::ApplicationDomain::BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction); | ||
36 | void remove(const QByteArray &identifier, const Akonadi2::ApplicationDomain::BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction); | ||
37 | |||
38 | ResultSet query(const Akonadi2::Query &query, QSet<QByteArray> &appliedFilters, Akonadi2::Storage::Transaction &transaction); | ||
39 | |||
40 | private: | ||
41 | QByteArray mType; | ||
42 | QByteArrayList mProperties; | ||
43 | QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, Akonadi2::Storage::Transaction &transaction)> > mIndexer; | ||
44 | }; | ||
45 | |||