diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-16 22:19:43 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-16 22:19:43 +0200 |
commit | 749c4d7da40bf20d240be5ad7948f4be843865cd (patch) | |
tree | 038e54650450f532c2eaafa68a6a3d606928ff8f | |
parent | 3ae86373f2238bcd771392f329b52d7b8923d003 (diff) | |
download | sink-749c4d7da40bf20d240be5ad7948f4be843865cd.tar.gz sink-749c4d7da40bf20d240be5ad7948f4be843865cd.zip |
Simpler facade and domaintypeadaptorfactory instantiation
-rw-r--r-- | common/domainadaptor.h | 3 | ||||
-rw-r--r-- | common/facade.h | 14 |
2 files changed, 15 insertions, 2 deletions
diff --git a/common/domainadaptor.h b/common/domainadaptor.h index 3af0fad..e97c5f5 100644 --- a/common/domainadaptor.h +++ b/common/domainadaptor.h | |||
@@ -35,6 +35,7 @@ | |||
35 | #include "entitybuffer.h" | 35 | #include "entitybuffer.h" |
36 | #include "propertymapper.h" | 36 | #include "propertymapper.h" |
37 | #include "log.h" | 37 | #include "log.h" |
38 | #include "dummy_generated.h" | ||
38 | 39 | ||
39 | /** | 40 | /** |
40 | * Create a buffer from a domain object using the provided mappings | 41 | * Create a buffer from a domain object using the provided mappings |
@@ -130,7 +131,7 @@ public: | |||
130 | * It defines how values are split accross local and resource buffer. | 131 | * It defines how values are split accross local and resource buffer. |
131 | * This is required by the facade the read the value, and by the pipeline preprocessors to access the domain values in a generic way. | 132 | * This is required by the facade the read the value, and by the pipeline preprocessors to access the domain values in a generic way. |
132 | */ | 133 | */ |
133 | template <typename DomainType, typename ResourceBuffer, typename ResourceBuilder> | 134 | template <typename DomainType, typename ResourceBuffer = Sink::ApplicationDomain::Buffer::Dummy, typename ResourceBuilder = Sink::ApplicationDomain::Buffer::DummyBuilder> |
134 | class SINK_EXPORT DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInterface | 135 | class SINK_EXPORT DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInterface |
135 | { | 136 | { |
136 | typedef typename Sink::ApplicationDomain::TypeImplementation<DomainType>::Buffer LocalBuffer; | 137 | typedef typename Sink::ApplicationDomain::TypeImplementation<DomainType>::Buffer LocalBuffer; |
diff --git a/common/facade.h b/common/facade.h index a24ac7a..658ccb8 100644 --- a/common/facade.h +++ b/common/facade.h | |||
@@ -55,7 +55,7 @@ public: | |||
55 | */ | 55 | */ |
56 | GenericFacade(const QByteArray &resourceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &adaptorFactory = DomainTypeAdaptorFactoryInterface::Ptr(), | 56 | GenericFacade(const QByteArray &resourceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &adaptorFactory = DomainTypeAdaptorFactoryInterface::Ptr(), |
57 | const QSharedPointer<Sink::ResourceAccessInterface> resourceAccess = QSharedPointer<Sink::ResourceAccessInterface>()); | 57 | const QSharedPointer<Sink::ResourceAccessInterface> resourceAccess = QSharedPointer<Sink::ResourceAccessInterface>()); |
58 | ~GenericFacade(); | 58 | virtual ~GenericFacade(); |
59 | 59 | ||
60 | static QByteArray bufferTypeForDomainType(); | 60 | static QByteArray bufferTypeForDomainType(); |
61 | KAsync::Job<void> create(const DomainType &domainObject) Q_DECL_OVERRIDE; | 61 | KAsync::Job<void> create(const DomainType &domainObject) Q_DECL_OVERRIDE; |
@@ -70,4 +70,16 @@ protected: | |||
70 | DomainTypeAdaptorFactoryInterface::Ptr mDomainTypeAdaptorFactory; | 70 | DomainTypeAdaptorFactoryInterface::Ptr mDomainTypeAdaptorFactory; |
71 | QByteArray mResourceInstanceIdentifier; | 71 | QByteArray mResourceInstanceIdentifier; |
72 | }; | 72 | }; |
73 | |||
74 | /** | ||
75 | * A default facade implemenation that simply instantiates a generic resource with the given DomainTypeAdaptorFactory | ||
76 | */ | ||
77 | template<typename DomainType, typename DomainTypeAdaptorFactory> | ||
78 | class DefaultFacade : public GenericFacade<DomainType> | ||
79 | { | ||
80 | public: | ||
81 | DefaultFacade(const QByteArray &resourceIdentifier) : GenericFacade<DomainType>(resourceIdentifier, QSharedPointer<DomainTypeAdaptorFactory>::create()) {} | ||
82 | virtual ~DefaultFacade(){} | ||
83 | }; | ||
84 | |||
73 | } | 85 | } |