summaryrefslogtreecommitdiffstats
path: root/common/facade.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-07-27 23:00:23 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-07-27 23:22:10 +0200
commit7bd184460952932a237dc6f8bea7a8cd220afadf (patch)
treedd520096627edd9c7c06d7d1a52b30bb0876be22 /common/facade.h
parent60514ebd866c8c49e90e501198588e2806c5fe7b (diff)
downloadsink-7bd184460952932a237dc6f8bea7a8cd220afadf.tar.gz
sink-7bd184460952932a237dc6f8bea7a8cd220afadf.zip
Abstracted the storage so the facade can be tested.
Diffstat (limited to 'common/facade.h')
-rw-r--r--common/facade.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/common/facade.h b/common/facade.h
index ef3bbbc..254f671 100644
--- a/common/facade.h
+++ b/common/facade.h
@@ -112,9 +112,10 @@ public:
112 * @param resourceIdentifier is the identifier of the resource instance 112 * @param resourceIdentifier is the identifier of the resource instance
113 * @param adaptorFactory is the adaptor factory used to generate the mappings from domain to resource types and vice versa 113 * @param adaptorFactory is the adaptor factory used to generate the mappings from domain to resource types and vice versa
114 */ 114 */
115 GenericFacade(const QByteArray &resourceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &adaptorFactory = DomainTypeAdaptorFactoryInterface::Ptr()) 115 GenericFacade(const QByteArray &resourceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &adaptorFactory = DomainTypeAdaptorFactoryInterface::Ptr(), const QSharedPointer<EntityStorage<DomainType> > storage = QSharedPointer<EntityStorage<DomainType> >())
116 : Akonadi2::StoreFacade<DomainType>(), 116 : Akonadi2::StoreFacade<DomainType>(),
117 mResourceAccess(new ResourceAccess(resourceIdentifier)), 117 mResourceAccess(new ResourceAccess(resourceIdentifier)),
118 mStorage(storage ? storage : QSharedPointer<EntityStorage<DomainType> >::create(resourceIdentifier, adaptorFactory)),
118 mDomainTypeAdaptorFactory(adaptorFactory), 119 mDomainTypeAdaptorFactory(adaptorFactory),
119 mResourceInstanceIdentifier(resourceIdentifier) 120 mResourceInstanceIdentifier(resourceIdentifier)
120 { 121 {
@@ -257,11 +258,11 @@ protected:
257 } 258 }
258 259
259 260
261private:
260 virtual KAsync::Job<qint64> load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > &resultProvider, qint64 oldRevision, qint64 newRevision) 262 virtual KAsync::Job<qint64> load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > &resultProvider, qint64 oldRevision, qint64 newRevision)
261 { 263 {
262 return KAsync::start<qint64>([=]() -> qint64 { 264 return KAsync::start<qint64>([=]() -> qint64 {
263 EntityStorage<DomainType> storage(mResourceInstanceIdentifier, mDomainTypeAdaptorFactory); 265 mStorage->read(query, qMakePair(oldRevision, newRevision), resultProvider);
264 storage.read(query, qMakePair(oldRevision, newRevision), resultProvider);
265 return newRevision; 266 return newRevision;
266 }); 267 });
267 } 268 }
@@ -269,6 +270,7 @@ protected:
269protected: 270protected:
270 //TODO use one resource access instance per application & per resource 271 //TODO use one resource access instance per application & per resource
271 QSharedPointer<Akonadi2::ResourceAccess> mResourceAccess; 272 QSharedPointer<Akonadi2::ResourceAccess> mResourceAccess;
273 QSharedPointer<EntityStorage<DomainType> > mStorage;
272 DomainTypeAdaptorFactoryInterface::Ptr mDomainTypeAdaptorFactory; 274 DomainTypeAdaptorFactoryInterface::Ptr mDomainTypeAdaptorFactory;
273 QByteArray mResourceInstanceIdentifier; 275 QByteArray mResourceInstanceIdentifier;
274}; 276};