diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-20 13:34:38 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-21 09:18:50 +0200 |
commit | da0c37dbad121252effa85941de4d49222176179 (patch) | |
tree | 6ea9831e80fc18dcae00cdf2788680bb8f4d1935 /common/typeindex.h | |
parent | 0dcc8e2985acbff52c497648e4fbb54e47bf3b51 (diff) | |
download | sink-da0c37dbad121252effa85941de4d49222176179.tar.gz sink-da0c37dbad121252effa85941de4d49222176179.zip |
A new indexer subsystem that can be used for indexes that are more
complex than a simple key-value pair.
Diffstat (limited to 'common/typeindex.h')
-rw-r--r-- | common/typeindex.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/common/typeindex.h b/common/typeindex.h index e11e673..041e04a 100644 --- a/common/typeindex.h +++ b/common/typeindex.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "storage.h" | 22 | #include "storage.h" |
23 | #include "query.h" | 23 | #include "query.h" |
24 | #include "log.h" | 24 | #include "log.h" |
25 | #include "indexer.h" | ||
25 | #include <QByteArray> | 26 | #include <QByteArray> |
26 | 27 | ||
27 | class TypeIndex | 28 | class TypeIndex |
@@ -51,6 +52,13 @@ public: | |||
51 | { | 52 | { |
52 | mSecondaryProperties.insert(Left::name, Right::name); | 53 | mSecondaryProperties.insert(Left::name, Right::name); |
53 | } | 54 | } |
55 | |||
56 | template <typename Left, typename Right, typename CustomIndexer> | ||
57 | void addSecondaryPropertyIndexer() | ||
58 | { | ||
59 | mCustomIndexer << CustomIndexer::Ptr::create(); | ||
60 | } | ||
61 | |||
54 | void add(const QByteArray &identifier, const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Storage::DataStore::Transaction &transaction); | 62 | void add(const QByteArray &identifier, const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Storage::DataStore::Transaction &transaction); |
55 | void remove(const QByteArray &identifier, const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Storage::DataStore::Transaction &transaction); | 63 | void remove(const QByteArray &identifier, const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Storage::DataStore::Transaction &transaction); |
56 | 64 | ||
@@ -84,6 +92,7 @@ private: | |||
84 | QMap<QByteArray, QByteArray> mSortedProperties; | 92 | QMap<QByteArray, QByteArray> mSortedProperties; |
85 | //<Property, ResultProperty> | 93 | //<Property, ResultProperty> |
86 | QMap<QByteArray, QByteArray> mSecondaryProperties; | 94 | QMap<QByteArray, QByteArray> mSecondaryProperties; |
95 | QList<Sink::Indexer::Ptr> mCustomIndexer; | ||
87 | QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction)>> mIndexer; | 96 | QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction)>> mIndexer; |
88 | QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, const QVariant &sortValue, Sink::Storage::DataStore::Transaction &transaction)>> mSortIndexer; | 97 | QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, const QVariant &sortValue, Sink::Storage::DataStore::Transaction &transaction)>> mSortIndexer; |
89 | }; | 98 | }; |