diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-06 09:57:51 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-06 09:57:51 +0200 |
commit | a9f3692a0bceb796d10952307f87fdb77abadbf7 (patch) | |
tree | dc66407c956cdf7538a6fb9f4dd17334ae3530e2 /common/resourcefacade.h | |
parent | e03eac8ef4337a9aa538b7cefc803a6abd4acf24 (diff) | |
download | sink-a9f3692a0bceb796d10952307f87fdb77abadbf7.tar.gz sink-a9f3692a0bceb796d10952307f87fdb77abadbf7.zip |
Apply the status to resources
Diffstat (limited to 'common/resourcefacade.h')
-rw-r--r-- | common/resourcefacade.h | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/common/resourcefacade.h b/common/resourcefacade.h index 989375d..2573b31 100644 --- a/common/resourcefacade.h +++ b/common/resourcefacade.h | |||
@@ -56,6 +56,22 @@ signals: | |||
56 | }; | 56 | }; |
57 | 57 | ||
58 | template <typename DomainType> | 58 | template <typename DomainType> |
59 | class LocalStorageQueryRunner | ||
60 | { | ||
61 | public: | ||
62 | LocalStorageQueryRunner(const Sink::Query &query, const QByteArray &identifier, ConfigNotifier &configNotifier); | ||
63 | typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr emitter(); | ||
64 | void setStatusUpdater(const std::function<void(DomainType &)> &); | ||
65 | void statusChanged(const QByteArray &identifier); | ||
66 | |||
67 | private: | ||
68 | void updateStatus(DomainType &entity); | ||
69 | std::function<void(DomainType &)> mStatusUpdater; | ||
70 | QSharedPointer<Sink::ResultProvider<typename DomainType::Ptr>> mResultProvider; | ||
71 | ConfigStore mConfigStore; | ||
72 | }; | ||
73 | |||
74 | template <typename DomainType> | ||
59 | class LocalStorageFacade : public Sink::StoreFacade<DomainType> | 75 | class LocalStorageFacade : public Sink::StoreFacade<DomainType> |
60 | { | 76 | { |
61 | public: | 77 | public: |
@@ -65,13 +81,14 @@ public: | |||
65 | virtual KAsync::Job<void> modify(const DomainType &resource) Q_DECL_OVERRIDE; | 81 | virtual KAsync::Job<void> modify(const DomainType &resource) Q_DECL_OVERRIDE; |
66 | virtual KAsync::Job<void> remove(const DomainType &resource) Q_DECL_OVERRIDE; | 82 | virtual KAsync::Job<void> remove(const DomainType &resource) Q_DECL_OVERRIDE; |
67 | virtual QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr> load(const Sink::Query &query) Q_DECL_OVERRIDE; | 83 | virtual QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr> load(const Sink::Query &query) Q_DECL_OVERRIDE; |
84 | |||
85 | protected: | ||
86 | QByteArray mIdentifier; | ||
87 | static ConfigNotifier sConfigNotifier; | ||
88 | |||
68 | private: | 89 | private: |
69 | typename DomainType::Ptr readFromConfig(const QByteArray &id, const QByteArray &type); | 90 | typename DomainType::Ptr readFromConfig(const QByteArray &id, const QByteArray &type); |
70 | static typename DomainType::Ptr readFromConfig(ConfigStore &store, const QByteArray &id, const QByteArray &type); | ||
71 | |||
72 | ConfigStore mConfigStore; | 91 | ConfigStore mConfigStore; |
73 | static ConfigNotifier sConfigNotifier; | ||
74 | QByteArray mResourceInstanceIdentifier; | ||
75 | }; | 92 | }; |
76 | 93 | ||
77 | class ResourceFacade : public LocalStorageFacade<Sink::ApplicationDomain::SinkResource> | 94 | class ResourceFacade : public LocalStorageFacade<Sink::ApplicationDomain::SinkResource> |
@@ -80,6 +97,7 @@ public: | |||
80 | ResourceFacade(); | 97 | ResourceFacade(); |
81 | virtual ~ResourceFacade(); | 98 | virtual ~ResourceFacade(); |
82 | virtual KAsync::Job<void> remove(const Sink::ApplicationDomain::SinkResource &resource) Q_DECL_OVERRIDE; | 99 | virtual KAsync::Job<void> remove(const Sink::ApplicationDomain::SinkResource &resource) Q_DECL_OVERRIDE; |
100 | virtual QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename Sink::ApplicationDomain::SinkResource::Ptr>::Ptr> load(const Sink::Query &query) Q_DECL_OVERRIDE; | ||
83 | }; | 101 | }; |
84 | 102 | ||
85 | class AccountFacade : public LocalStorageFacade<Sink::ApplicationDomain::SinkAccount> | 103 | class AccountFacade : public LocalStorageFacade<Sink::ApplicationDomain::SinkAccount> |