summaryrefslogtreecommitdiffstats
path: root/common/queryrunner.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/queryrunner.h')
-rw-r--r--common/queryrunner.h39
1 files changed, 11 insertions, 28 deletions
diff --git a/common/queryrunner.h b/common/queryrunner.h
index 8df0ecd..aba7912 100644
--- a/common/queryrunner.h
+++ b/common/queryrunner.h
@@ -20,7 +20,6 @@
20#pragma once 20#pragma once
21 21
22#include <QObject> 22#include <QObject>
23#include "facadeinterface.h"
24#include "resourceaccess.h" 23#include "resourceaccess.h"
25#include "resultprovider.h" 24#include "resultprovider.h"
26#include "domaintypeadaptorfactoryinterface.h" 25#include "domaintypeadaptorfactoryinterface.h"
@@ -28,15 +27,8 @@
28#include "query.h" 27#include "query.h"
29 28
30/** 29/**
31 * A QueryRunner runs a query and updates the corresponding result set. 30 * Base clase because you can't have the Q_OBJECT macro in template classes
32 *
33 * The lifetime of the QueryRunner is defined by the resut set (otherwise it's doing useless work),
34 * and by how long a result set must be updated. If the query is one off the runner dies after the execution,
35 * otherwise it lives on the react to changes and updates the corresponding result set.
36 *
37 * QueryRunner has to keep ResourceAccess alive in order to keep getting updates.
38 */ 31 */
39
40class QueryRunnerBase : public QObject 32class QueryRunnerBase : public QObject
41{ 33{
42 Q_OBJECT 34 Q_OBJECT
@@ -74,6 +66,15 @@ private:
74 QueryFunction queryFunction; 66 QueryFunction queryFunction;
75}; 67};
76 68
69/**
70 * A QueryRunner runs a query and updates the corresponding result set.
71 *
72 * The lifetime of the QueryRunner is defined by the resut set (otherwise it's doing useless work),
73 * and by how long a result set must be updated. If the query is one off the runner dies after the execution,
74 * otherwise it lives on the react to changes and updates the corresponding result set.
75 *
76 * QueryRunner has to keep ResourceAccess alive in order to keep getting updates.
77 */
77template<typename DomainType> 78template<typename DomainType>
78class QueryRunner : public QueryRunnerBase 79class QueryRunner : public QueryRunnerBase
79{ 80{
@@ -84,25 +85,7 @@ public:
84 typename Akonadi2::ResultEmitter<typename DomainType::Ptr>::Ptr emitter(); 85 typename Akonadi2::ResultEmitter<typename DomainType::Ptr>::Ptr emitter();
85 86
86private: 87private:
87 static void replaySet(ResultSet &resultSet, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider, const QList<QByteArray> &properties);
88
89 void readEntity(const Akonadi2::Storage::NamedDatabase &db, const QByteArray &key, const std::function<void(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &, Akonadi2::Operation)> &resultCallback);
90
91 ResultSet loadInitialResultSet(const Akonadi2::Query &query, Akonadi2::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters);
92 ResultSet loadIncrementalResultSet(qint64 baseRevision, const Akonadi2::Query &query, Akonadi2::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters);
93
94 ResultSet filterSet(const ResultSet &resultSet, const std::function<bool(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject)> &filter, const Akonadi2::Storage::NamedDatabase &db, bool initialQuery);
95 std::function<bool(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject)> getFilter(const QSet<QByteArray> remainingFilters, const Akonadi2::Query &query);
96 qint64 load(const Akonadi2::Query &query, const std::function<ResultSet(Akonadi2::Storage::Transaction &, QSet<QByteArray> &)> &baseSetRetriever, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider, bool initialQuery);
97 qint64 executeIncrementalQuery(const Akonadi2::Query &query, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider);
98 qint64 executeInitialQuery(const Akonadi2::Query &query, const typename DomainType::Ptr &parent, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider);
99
100private:
101 QSharedPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > mResultProvider;
102 QSharedPointer<Akonadi2::ResourceAccessInterface> mResourceAccess; 88 QSharedPointer<Akonadi2::ResourceAccessInterface> mResourceAccess;
103 DomainTypeAdaptorFactoryInterface::Ptr mDomainTypeAdaptorFactory; 89 QSharedPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > mResultProvider;
104 QByteArray mResourceInstanceIdentifier;
105 QByteArray mBufferType;
106 Akonadi2::Query mQuery;
107}; 90};
108 91