summaryrefslogtreecommitdiffstats
path: root/common/typeindex.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-09-26 11:58:38 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-09-26 11:58:38 +0200
commitbe8dba1827ec54ec11d9a3ef143db9ad7f7f38df (patch)
tree4c441927d9e1851126143e5f8170d48fa87df17b /common/typeindex.h
parent52ad48c8bd755a2fde249296d6017853538f478f (diff)
downloadsink-be8dba1827ec54ec11d9a3ef143db9ad7f7f38df.tar.gz
sink-be8dba1827ec54ec11d9a3ef143db9ad7f7f38df.zip
The threading reduction is working.
Diffstat (limited to 'common/typeindex.h')
-rw-r--r--common/typeindex.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/common/typeindex.h b/common/typeindex.h
index f5a32b9..7266f02 100644
--- a/common/typeindex.h
+++ b/common/typeindex.h
@@ -34,16 +34,55 @@ public:
34 template <typename T, typename S> 34 template <typename T, typename S>
35 void addPropertyWithSorting(const QByteArray &property, const QByteArray &sortProperty); 35 void addPropertyWithSorting(const QByteArray &property, const QByteArray &sortProperty);
36 36
37 template <typename T>
38 void addProperty()
39 {
40 addProperty<typename T::Type>(T::name);
41 }
42
43 template <typename T>
44 void addPropertyWithSorting()
45 {
46 addPropertyWithSorting<typename T::Type>(T::name);
47 }
48
49 template <typename Left, typename Right>
50 void addSecondaryProperty()
51 {
52 mSecondaryProperties.insert(Left::name, Right::name);
53 }
37 void add(const QByteArray &identifier, const Sink::ApplicationDomain::BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction); 54 void add(const QByteArray &identifier, const Sink::ApplicationDomain::BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction);
38 void remove(const QByteArray &identifier, const Sink::ApplicationDomain::BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction); 55 void remove(const QByteArray &identifier, const Sink::ApplicationDomain::BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction);
39 56
40 QVector<QByteArray> query(const Sink::Query &query, QSet<QByteArray> &appliedFilters, QByteArray &appliedSorting, Sink::Storage::Transaction &transaction); 57 QVector<QByteArray> query(const Sink::Query &query, QSet<QByteArray> &appliedFilters, QByteArray &appliedSorting, Sink::Storage::Transaction &transaction);
58 QVector<QByteArray> lookup(const QByteArray &property, const QVariant &value, Sink::Storage::Transaction &transaction);
59
60 template <typename Left, typename Right>
61 QVector<QByteArray> secondaryLookup(const QVariant &value, Sink::Storage::Transaction &transaction)
62 {
63 return secondaryLookup<typename Left::Type>(Left::name, Right::name, value, transaction);
64 }
65
66 template <typename Type>
67 QVector<QByteArray> secondaryLookup(const QByteArray &leftName, const QByteArray &rightName, const QVariant &value, Sink::Storage::Transaction &transaction);
68
69 template <typename Left, typename Right>
70 void index(const QVariant &leftValue, const QVariant &rightValue, Sink::Storage::Transaction &transaction)
71 {
72 index<typename Left::Type, typename Right::Type>(Left::name, Right::name, leftValue, rightValue, transaction);
73 }
74
75 template <typename LeftType, typename RightType>
76 void index(const QByteArray &leftName, const QByteArray &rightName, const QVariant &leftValue, const QVariant &rightValue, Sink::Storage::Transaction &transaction);
77
41 78
42private: 79private:
43 QByteArray indexName(const QByteArray &property, const QByteArray &sortProperty = QByteArray()) const; 80 QByteArray indexName(const QByteArray &property, const QByteArray &sortProperty = QByteArray()) const;
44 QByteArray mType; 81 QByteArray mType;
45 QByteArrayList mProperties; 82 QByteArrayList mProperties;
46 QMap<QByteArray, QByteArray> mSortedProperties; 83 QMap<QByteArray, QByteArray> mSortedProperties;
84 //<Property, ResultProperty>
85 QMap<QByteArray, QByteArray> mSecondaryProperties;
47 QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction)>> mIndexer; 86 QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction)>> mIndexer;
48 QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, const QVariant &sortValue, Sink::Storage::Transaction &transaction)>> mSortIndexer; 87 QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, const QVariant &sortValue, Sink::Storage::Transaction &transaction)>> mSortIndexer;
49}; 88};