summaryrefslogtreecommitdiffstats
path: root/common/typeindex.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-20 17:46:10 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-21 09:18:50 +0200
commit0c1f6da51631c0a573a44e2f93eb4012d52dfe5c (patch)
treecf3cd3bec9fabd44a7107f47e7b0b057880ecb61 /common/typeindex.h
parent9a03eb1a54c6289773bc1b8eb96181ed01553927 (diff)
downloadsink-0c1f6da51631c0a573a44e2f93eb4012d52dfe5c.tar.gz
sink-0c1f6da51631c0a573a44e2f93eb4012d52dfe5c.zip
Get access to properties in indexes.
Diffstat (limited to 'common/typeindex.h')
-rw-r--r--common/typeindex.h14
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
28namespace Sink {
29namespace Storage {
30 class EntityStore;
31}
32}
33
28class TypeIndex 34class TypeIndex
29{ 35{
30public: 36public:
@@ -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
87private: 93private:
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};