diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-09-19 18:55:21 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-09-19 18:55:21 +0200 |
commit | 4a14a6fade947aa830d3f21598a4a6ba7316b933 (patch) | |
tree | c6b340bf1c6284e5501d371f65b58e3a69391a26 /common/domain/mail.cpp | |
parent | 1deac558af4b1c9f04352ede7f8e172f11a70a6b (diff) | |
download | sink-4a14a6fade947aa830d3f21598a4a6ba7316b933.tar.gz sink-4a14a6fade947aa830d3f21598a4a6ba7316b933.zip |
Refactored the query part of the entity reader into DataStoreQuery.
DataStoreQuery now encapsulates the low-level query that operates
directly on the storage. It no longer has access to the resource
buffers, and is instantiated by the type implementation, so we can
specialize the query alogorithm per type, but not per resource.
This will allow us to implement the threading queries for the mailtype.
Diffstat (limited to 'common/domain/mail.cpp')
-rw-r--r-- | common/domain/mail.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/common/domain/mail.cpp b/common/domain/mail.cpp index 13e1305..bb5ad58 100644 --- a/common/domain/mail.cpp +++ b/common/domain/mail.cpp | |||
@@ -32,6 +32,8 @@ | |||
32 | #include "../query.h" | 32 | #include "../query.h" |
33 | #include "../definitions.h" | 33 | #include "../definitions.h" |
34 | #include "../typeindex.h" | 34 | #include "../typeindex.h" |
35 | #include "entitybuffer.h" | ||
36 | #include "entity_generated.h" | ||
35 | 37 | ||
36 | #include "mail_generated.h" | 38 | #include "mail_generated.h" |
37 | 39 | ||
@@ -110,3 +112,14 @@ QSharedPointer<WritePropertyMapper<TypeImplementation<Mail>::BufferBuilder> > Ty | |||
110 | propertyMapper->addMapping<Mail::Sent>(&BufferBuilder::add_sent); | 112 | propertyMapper->addMapping<Mail::Sent>(&BufferBuilder::add_sent); |
111 | return propertyMapper; | 113 | return propertyMapper; |
112 | } | 114 | } |
115 | |||
116 | DataStoreQuery TypeImplementation<Mail>::prepareQuery(const Sink::Query &query, Sink::Storage::Transaction &transaction) | ||
117 | { | ||
118 | auto mapper = initializeReadPropertyMapper(); | ||
119 | return DataStoreQuery(query, ApplicationDomain::getTypeName<Mail>(), transaction, getIndex(), [mapper](const Sink::Entity &entity, const QByteArray &property) { | ||
120 | |||
121 | const auto localBuffer = Sink::EntityBuffer::readBuffer<Buffer>(entity.local()); | ||
122 | return mapper->getProperty(property, localBuffer); | ||
123 | }); | ||
124 | } | ||
125 | |||