diff options
Diffstat (limited to 'common/facade.cpp')
-rw-r--r-- | common/facade.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/common/facade.cpp b/common/facade.cpp index 1219887..803f85c 100644 --- a/common/facade.cpp +++ b/common/facade.cpp | |||
@@ -32,31 +32,29 @@ using namespace Sink; | |||
32 | #undef DEBUG_AREA | 32 | #undef DEBUG_AREA |
33 | #define DEBUG_AREA "client.facade" | 33 | #define DEBUG_AREA "client.facade" |
34 | 34 | ||
35 | template<class DomainType> | 35 | template <class DomainType> |
36 | GenericFacade<DomainType>::GenericFacade(const QByteArray &resourceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &adaptorFactory , const QSharedPointer<Sink::ResourceAccessInterface> resourceAccess) | 36 | GenericFacade<DomainType>::GenericFacade( |
37 | : Sink::StoreFacade<DomainType>(), | 37 | const QByteArray &resourceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &adaptorFactory, const QSharedPointer<Sink::ResourceAccessInterface> resourceAccess) |
38 | mResourceAccess(resourceAccess), | 38 | : Sink::StoreFacade<DomainType>(), mResourceAccess(resourceAccess), mDomainTypeAdaptorFactory(adaptorFactory), mResourceInstanceIdentifier(resourceIdentifier) |
39 | mDomainTypeAdaptorFactory(adaptorFactory), | ||
40 | mResourceInstanceIdentifier(resourceIdentifier) | ||
41 | { | 39 | { |
42 | if (!mResourceAccess) { | 40 | if (!mResourceAccess) { |
43 | mResourceAccess = ResourceAccessFactory::instance().getAccess(resourceIdentifier); | 41 | mResourceAccess = ResourceAccessFactory::instance().getAccess(resourceIdentifier); |
44 | } | 42 | } |
45 | } | 43 | } |
46 | 44 | ||
47 | template<class DomainType> | 45 | template <class DomainType> |
48 | GenericFacade<DomainType>::~GenericFacade() | 46 | GenericFacade<DomainType>::~GenericFacade() |
49 | { | 47 | { |
50 | } | 48 | } |
51 | 49 | ||
52 | template<class DomainType> | 50 | template <class DomainType> |
53 | QByteArray GenericFacade<DomainType>::bufferTypeForDomainType() | 51 | QByteArray GenericFacade<DomainType>::bufferTypeForDomainType() |
54 | { | 52 | { |
55 | //We happen to have a one to one mapping | 53 | // We happen to have a one to one mapping |
56 | return Sink::ApplicationDomain::getTypeName<DomainType>(); | 54 | return Sink::ApplicationDomain::getTypeName<DomainType>(); |
57 | } | 55 | } |
58 | 56 | ||
59 | template<class DomainType> | 57 | template <class DomainType> |
60 | KAsync::Job<void> GenericFacade<DomainType>::create(const DomainType &domainObject) | 58 | KAsync::Job<void> GenericFacade<DomainType>::create(const DomainType &domainObject) |
61 | { | 59 | { |
62 | if (!mDomainTypeAdaptorFactory) { | 60 | if (!mDomainTypeAdaptorFactory) { |
@@ -68,7 +66,7 @@ KAsync::Job<void> GenericFacade<DomainType>::create(const DomainType &domainObje | |||
68 | return mResourceAccess->sendCreateCommand(bufferTypeForDomainType(), BufferUtils::extractBuffer(entityFbb)); | 66 | return mResourceAccess->sendCreateCommand(bufferTypeForDomainType(), BufferUtils::extractBuffer(entityFbb)); |
69 | } | 67 | } |
70 | 68 | ||
71 | template<class DomainType> | 69 | template <class DomainType> |
72 | KAsync::Job<void> GenericFacade<DomainType>::modify(const DomainType &domainObject) | 70 | KAsync::Job<void> GenericFacade<DomainType>::modify(const DomainType &domainObject) |
73 | { | 71 | { |
74 | if (!mDomainTypeAdaptorFactory) { | 72 | if (!mDomainTypeAdaptorFactory) { |
@@ -80,16 +78,16 @@ KAsync::Job<void> GenericFacade<DomainType>::modify(const DomainType &domainObje | |||
80 | return mResourceAccess->sendModifyCommand(domainObject.identifier(), domainObject.revision(), bufferTypeForDomainType(), QByteArrayList(), BufferUtils::extractBuffer(entityFbb)); | 78 | return mResourceAccess->sendModifyCommand(domainObject.identifier(), domainObject.revision(), bufferTypeForDomainType(), QByteArrayList(), BufferUtils::extractBuffer(entityFbb)); |
81 | } | 79 | } |
82 | 80 | ||
83 | template<class DomainType> | 81 | template <class DomainType> |
84 | KAsync::Job<void> GenericFacade<DomainType>::remove(const DomainType &domainObject) | 82 | KAsync::Job<void> GenericFacade<DomainType>::remove(const DomainType &domainObject) |
85 | { | 83 | { |
86 | return mResourceAccess->sendDeleteCommand(domainObject.identifier(), domainObject.revision(), bufferTypeForDomainType()); | 84 | return mResourceAccess->sendDeleteCommand(domainObject.identifier(), domainObject.revision(), bufferTypeForDomainType()); |
87 | } | 85 | } |
88 | 86 | ||
89 | template<class DomainType> | 87 | template <class DomainType> |
90 | QPair<KAsync::Job<void>, typename ResultEmitter<typename DomainType::Ptr>::Ptr> GenericFacade<DomainType>::load(const Sink::Query &query) | 88 | QPair<KAsync::Job<void>, typename ResultEmitter<typename DomainType::Ptr>::Ptr> GenericFacade<DomainType>::load(const Sink::Query &query) |
91 | { | 89 | { |
92 | //The runner lives for the lifetime of the query | 90 | // The runner lives for the lifetime of the query |
93 | auto runner = new QueryRunner<DomainType>(query, mResourceAccess, mResourceInstanceIdentifier, mDomainTypeAdaptorFactory, bufferTypeForDomainType()); | 91 | auto runner = new QueryRunner<DomainType>(query, mResourceAccess, mResourceInstanceIdentifier, mDomainTypeAdaptorFactory, bufferTypeForDomainType()); |
94 | runner->setResultTransformation(mResultTransformation); | 92 | runner->setResultTransformation(mResultTransformation); |
95 | return qMakePair(KAsync::null<void>(), runner->emitter()); | 93 | return qMakePair(KAsync::null<void>(), runner->emitter()); |