summaryrefslogtreecommitdiffstats
path: root/common/facade.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-16 14:55:20 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-21 09:02:21 +0200
commit237b9ae4113e7a9f489632296941becb71afdb45 (patch)
tree01cde58f495944f01cad9d282391d4efd2897141 /common/facade.h
parent95d11bf0be98a4e3c08502fe23417b800233ce14 (diff)
downloadsink-237b9ae4113e7a9f489632296941becb71afdb45.tar.gz
sink-237b9ae4113e7a9f489632296941becb71afdb45.zip
Refactor how the storage is used.
This is the initial refactoring to improve how we deal with the storage. It does a couple of things: * Rename Sink::Storage to Sink::Storage::DataStore to free up the Sink::Storage namespace * Introduce a Sink::ResourceContext to have a single object that can be passed around containing everything that is necessary to operate on a resource. This is a lot better than the multiple separate parameters that we used to pass around all over the place, while still allowing for dependency injection for tests. * Tie storage access together using the new EntityStore that directly works with ApplicationDomainTypes. This gives us a central place where main storage, indexes and buffer adaptors are tied together, which will also give us a place to implement external indexes, such as a fulltextindex using xapian. * Use ApplicationDomainTypes as the default way to pass around entities. Instead of using various ways to pass around entities (buffers, buffer adaptors, ApplicationDomainTypes), only use a single way. The old approach was confusing, and was only done as: * optimization; really shouldn't be necessary and otherwise I'm sure we can find better ways to optimize ApplicationDomainType itself. * a way to account for entities that have multiple buffers, a concept that I no longer deem relevant. While this commit does the bulk of the work to get there, the following commits will refactor more stuff to get things back to normal.
Diffstat (limited to 'common/facade.h')
-rw-r--r--common/facade.h18
1 files changed, 8 insertions, 10 deletions
diff --git a/common/facade.h b/common/facade.h
index b193580..50d93e0 100644
--- a/common/facade.h
+++ b/common/facade.h
@@ -28,6 +28,7 @@
28#include "resourceaccess.h" 28#include "resourceaccess.h"
29#include "domaintypeadaptorfactoryinterface.h" 29#include "domaintypeadaptorfactoryinterface.h"
30#include "storage.h" 30#include "storage.h"
31#include "resourcecontext.h"
31 32
32namespace Sink { 33namespace Sink {
33 34
@@ -48,7 +49,7 @@ class SINK_EXPORT GenericFacade : public Sink::StoreFacade<DomainType>
48{ 49{
49protected: 50protected:
50 SINK_DEBUG_AREA("facade") 51 SINK_DEBUG_AREA("facade")
51 SINK_DEBUG_COMPONENT(mResourceInstanceIdentifier) 52 SINK_DEBUG_COMPONENT(mResourceContext.resourceInstanceIdentifier)
52public: 53public:
53 /** 54 /**
54 * Create a new GenericFacade 55 * Create a new GenericFacade
@@ -56,8 +57,7 @@ public:
56 * @param resourceIdentifier is the identifier of the resource instance 57 * @param resourceIdentifier is the identifier of the resource instance
57 * @param adaptorFactory is the adaptor factory used to generate the mappings from domain to resource types and vice versa 58 * @param adaptorFactory is the adaptor factory used to generate the mappings from domain to resource types and vice versa
58 */ 59 */
59 GenericFacade(const QByteArray &resourceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &adaptorFactory = DomainTypeAdaptorFactoryInterface::Ptr(), 60 GenericFacade(const ResourceContext &context);
60 const QSharedPointer<Sink::ResourceAccessInterface> resourceAccess = QSharedPointer<Sink::ResourceAccessInterface>());
61 virtual ~GenericFacade(); 61 virtual ~GenericFacade();
62 62
63 static QByteArray bufferTypeForDomainType(); 63 static QByteArray bufferTypeForDomainType();
@@ -68,20 +68,18 @@ public:
68 68
69protected: 69protected:
70 std::function<void(Sink::ApplicationDomain::ApplicationDomainType &domainObject)> mResultTransformation; 70 std::function<void(Sink::ApplicationDomain::ApplicationDomainType &domainObject)> mResultTransformation;
71 // TODO use one resource access instance per application & per resource 71 ResourceContext mResourceContext;
72 QSharedPointer<Sink::ResourceAccessInterface> mResourceAccess; 72 Sink::ResourceAccessInterface::Ptr mResourceAccess;
73 DomainTypeAdaptorFactoryInterface::Ptr mDomainTypeAdaptorFactory;
74 QByteArray mResourceInstanceIdentifier;
75}; 73};
76 74
77/** 75/**
78 * A default facade implemenation that simply instantiates a generic resource with the given DomainTypeAdaptorFactory 76 * A default facade implemenation that simply instantiates a generic resource
79 */ 77 */
80template<typename DomainType, typename DomainTypeAdaptorFactory> 78template<typename DomainType>
81class DefaultFacade : public GenericFacade<DomainType> 79class DefaultFacade : public GenericFacade<DomainType>
82{ 80{
83public: 81public:
84 DefaultFacade(const QByteArray &resourceIdentifier) : GenericFacade<DomainType>(resourceIdentifier, QSharedPointer<DomainTypeAdaptorFactory>::create()) {} 82 DefaultFacade(const ResourceContext &context) : GenericFacade<DomainType>(context) {}
85 virtual ~DefaultFacade(){} 83 virtual ~DefaultFacade(){}
86}; 84};
87 85