summaryrefslogtreecommitdiffstats
path: root/common/facadeinterface.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/facadeinterface.h')
-rw-r--r--common/facadeinterface.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/common/facadeinterface.h b/common/facadeinterface.h
index 17cba5e..7d5dd7d 100644
--- a/common/facadeinterface.h
+++ b/common/facadeinterface.h
@@ -32,17 +32,21 @@ class Query;
32 32
33/** 33/**
34 * Interface for the store facade. 34 * Interface for the store facade.
35 * 35 *
36 * All methods are synchronous. 36 * All methods are synchronous.
37 * Facades are stateful (they hold connections to resources and database). 37 * Facades are stateful (they hold connections to resources and database).
38 * 38 *
39 * TODO: would it make sense to split the write, read and notification parts? (we could potentially save some connections) 39 * TODO: would it make sense to split the write, read and notification parts? (we could potentially save some connections)
40 */ 40 */
41template<class DomainType> 41template <class DomainType>
42class StoreFacade { 42class StoreFacade
43{
43public: 44public:
44 virtual ~StoreFacade(){}; 45 virtual ~StoreFacade(){};
45 QByteArray type() const { return ApplicationDomain::getTypeName<DomainType>(); } 46 QByteArray type() const
47 {
48 return ApplicationDomain::getTypeName<DomainType>();
49 }
46 50
47 /** 51 /**
48 * Create an entity in the store. 52 * Create an entity in the store.
@@ -68,11 +72,12 @@ public:
68 /** 72 /**
69 * Load entities from the store. 73 * Load entities from the store.
70 */ 74 */
71 virtual QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr > load(const Query &query) = 0; 75 virtual QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr> load(const Query &query) = 0;
72}; 76};
73 77
74template<class DomainType> 78template <class DomainType>
75class NullFacade : public StoreFacade<DomainType> { 79class NullFacade : public StoreFacade<DomainType>
80{
76public: 81public:
77 virtual ~NullFacade(){}; 82 virtual ~NullFacade(){};
78 KAsync::Job<void> create(const DomainType &domainObject) 83 KAsync::Job<void> create(const DomainType &domainObject)
@@ -90,10 +95,9 @@ public:
90 return KAsync::error<void>(-1, "Failed to create a facade"); 95 return KAsync::error<void>(-1, "Failed to create a facade");
91 } 96 }
92 97
93 QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr > load(const Query &query) 98 QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr> load(const Query &query)
94 { 99 {
95 return qMakePair(KAsync::null<void>(), typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr()); 100 return qMakePair(KAsync::null<void>(), typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr());
96 } 101 }
97}; 102};
98
99} 103}