diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-20 17:46:10 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-21 09:18:50 +0200 |
commit | 0c1f6da51631c0a573a44e2f93eb4012d52dfe5c (patch) | |
tree | cf3cd3bec9fabd44a7107f47e7b0b057880ecb61 /common/typeindex.h | |
parent | 9a03eb1a54c6289773bc1b8eb96181ed01553927 (diff) | |
download | sink-0c1f6da51631c0a573a44e2f93eb4012d52dfe5c.tar.gz sink-0c1f6da51631c0a573a44e2f93eb4012d52dfe5c.zip |
Get access to properties in indexes.
Diffstat (limited to 'common/typeindex.h')
-rw-r--r-- | common/typeindex.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/common/typeindex.h b/common/typeindex.h index 041e04a..3cffb1e 100644 --- a/common/typeindex.h +++ b/common/typeindex.h | |||
@@ -25,6 +25,12 @@ | |||
25 | #include "indexer.h" | 25 | #include "indexer.h" |
26 | #include <QByteArray> | 26 | #include <QByteArray> |
27 | 27 | ||
28 | namespace Sink { | ||
29 | namespace Storage { | ||
30 | class EntityStore; | ||
31 | } | ||
32 | } | ||
33 | |||
28 | class TypeIndex | 34 | class TypeIndex |
29 | { | 35 | { |
30 | public: | 36 | public: |
@@ -66,13 +72,13 @@ public: | |||
66 | QVector<QByteArray> lookup(const QByteArray &property, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction); | 72 | QVector<QByteArray> lookup(const QByteArray &property, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction); |
67 | 73 | ||
68 | template <typename Left, typename Right> | 74 | template <typename Left, typename Right> |
69 | QVector<QByteArray> secondaryLookup(const QVariant &value, Sink::Storage::DataStore::Transaction &transaction) | 75 | QVector<QByteArray> secondaryLookup(const QVariant &value) |
70 | { | 76 | { |
71 | return secondaryLookup<typename Left::Type>(Left::name, Right::name, value, transaction); | 77 | return secondaryLookup<typename Left::Type>(Left::name, Right::name, value); |
72 | } | 78 | } |
73 | 79 | ||
74 | template <typename Type> | 80 | template <typename Type> |
75 | QVector<QByteArray> secondaryLookup(const QByteArray &leftName, const QByteArray &rightName, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction); | 81 | QVector<QByteArray> secondaryLookup(const QByteArray &leftName, const QByteArray &rightName, const QVariant &value); |
76 | 82 | ||
77 | template <typename Left, typename Right> | 83 | template <typename Left, typename Right> |
78 | void index(const QVariant &leftValue, const QVariant &rightValue, Sink::Storage::DataStore::Transaction &transaction) | 84 | void index(const QVariant &leftValue, const QVariant &rightValue, Sink::Storage::DataStore::Transaction &transaction) |
@@ -85,6 +91,7 @@ public: | |||
85 | 91 | ||
86 | 92 | ||
87 | private: | 93 | private: |
94 | friend class Sink::Storage::EntityStore; | ||
88 | QByteArray indexName(const QByteArray &property, const QByteArray &sortProperty = QByteArray()) const; | 95 | QByteArray indexName(const QByteArray &property, const QByteArray &sortProperty = QByteArray()) const; |
89 | QByteArray mType; | 96 | QByteArray mType; |
90 | SINK_DEBUG_COMPONENT(mType) | 97 | SINK_DEBUG_COMPONENT(mType) |
@@ -93,6 +100,7 @@ private: | |||
93 | //<Property, ResultProperty> | 100 | //<Property, ResultProperty> |
94 | QMap<QByteArray, QByteArray> mSecondaryProperties; | 101 | QMap<QByteArray, QByteArray> mSecondaryProperties; |
95 | QList<Sink::Indexer::Ptr> mCustomIndexer; | 102 | QList<Sink::Indexer::Ptr> mCustomIndexer; |
103 | Sink::Storage::DataStore::Transaction *mTransaction; | ||
96 | QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction)>> mIndexer; | 104 | QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction)>> mIndexer; |
97 | QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, const QVariant &sortValue, Sink::Storage::DataStore::Transaction &transaction)>> mSortIndexer; | 105 | QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, const QVariant &sortValue, Sink::Storage::DataStore::Transaction &transaction)>> mSortIndexer; |
98 | }; | 106 | }; |