diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-05 17:14:29 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-05 17:14:29 +0100 |
commit | b9a79ed514e7ab6bab0d6dedfcb9a78387d2b7c1 (patch) | |
tree | f3b51a296dd09ca0c0cd78c880c893de315a5a59 /common/queryrunner.h | |
parent | 36a742c33f0a3144ed8d5dbaf56d7b4ef4e4e3d3 (diff) | |
download | sink-b9a79ed514e7ab6bab0d6dedfcb9a78387d2b7c1.tar.gz sink-b9a79ed514e7ab6bab0d6dedfcb9a78387d2b7c1.zip |
Support result property transformations
This can be used to modify each result before reporting it to the
client. Alternatively this could also be done in the DomainTypeAdaptor,
which would perhaps be the cleaner solution...
Diffstat (limited to 'common/queryrunner.h')
-rw-r--r-- | common/queryrunner.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/common/queryrunner.h b/common/queryrunner.h index 0ee6a81..04e4587 100644 --- a/common/queryrunner.h +++ b/common/queryrunner.h | |||
@@ -32,6 +32,9 @@ | |||
32 | class QueryRunnerBase : public QObject | 32 | class QueryRunnerBase : public QObject |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | ||
36 | typedef std::function<void(Sink::ApplicationDomain::ApplicationDomainType &domainObject)> ResultTransformation; | ||
37 | |||
35 | protected: | 38 | protected: |
36 | typedef std::function<KAsync::Job<void>()> QueryFunction; | 39 | typedef std::function<KAsync::Job<void>()> QueryFunction; |
37 | 40 | ||
@@ -43,7 +46,6 @@ protected: | |||
43 | queryFunction = query; | 46 | queryFunction = query; |
44 | } | 47 | } |
45 | 48 | ||
46 | |||
47 | protected slots: | 49 | protected slots: |
48 | /** | 50 | /** |
49 | * Rerun query with new revision | 51 | * Rerun query with new revision |
@@ -82,10 +84,17 @@ public: | |||
82 | QueryRunner(const Sink::Query &query, const Sink::ResourceAccessInterface::Ptr &, const QByteArray &instanceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &, const QByteArray &bufferType); | 84 | QueryRunner(const Sink::Query &query, const Sink::ResourceAccessInterface::Ptr &, const QByteArray &instanceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &, const QByteArray &bufferType); |
83 | virtual ~QueryRunner(); | 85 | virtual ~QueryRunner(); |
84 | 86 | ||
87 | /** | ||
88 | * Allows you to run a transformation on every result. | ||
89 | * This transformation is executed in the query thread. | ||
90 | */ | ||
91 | void setResultTransformation(const ResultTransformation &transformation); | ||
92 | |||
85 | typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr emitter(); | 93 | typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr emitter(); |
86 | 94 | ||
87 | private: | 95 | private: |
88 | QSharedPointer<Sink::ResourceAccessInterface> mResourceAccess; | 96 | QSharedPointer<Sink::ResourceAccessInterface> mResourceAccess; |
89 | QSharedPointer<Sink::ResultProvider<typename DomainType::Ptr> > mResultProvider; | 97 | QSharedPointer<Sink::ResultProvider<typename DomainType::Ptr> > mResultProvider; |
98 | ResultTransformation mResultTransformation; | ||
90 | }; | 99 | }; |
91 | 100 | ||