summaryrefslogtreecommitdiffstats
path: root/common/changereplay.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/changereplay.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/changereplay.h')
-rw-r--r--common/changereplay.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/common/changereplay.h b/common/changereplay.h
index 88d6ce3..e86c4f2 100644
--- a/common/changereplay.h
+++ b/common/changereplay.h
@@ -24,6 +24,7 @@
24#include <Async/Async> 24#include <Async/Async>
25 25
26#include "storage.h" 26#include "storage.h"
27#include "resourcecontext.h"
27 28
28namespace Sink { 29namespace Sink {
29 30
@@ -38,7 +39,7 @@ class SINK_EXPORT ChangeReplay : public QObject
38{ 39{
39 Q_OBJECT 40 Q_OBJECT
40public: 41public:
41 ChangeReplay(const QByteArray &resourceName); 42 ChangeReplay(const ResourceContext &resourceContext);
42 43
43 qint64 getLastReplayedRevision(); 44 qint64 getLastReplayedRevision();
44 bool allChangesReplayed(); 45 bool allChangesReplayed();
@@ -53,20 +54,20 @@ public slots:
53protected: 54protected:
54 virtual KAsync::Job<void> replay(const QByteArray &type, const QByteArray &key, const QByteArray &value) = 0; 55 virtual KAsync::Job<void> replay(const QByteArray &type, const QByteArray &key, const QByteArray &value) = 0;
55 virtual bool canReplay(const QByteArray &type, const QByteArray &key, const QByteArray &value) = 0; 56 virtual bool canReplay(const QByteArray &type, const QByteArray &key, const QByteArray &value) = 0;
56 Sink::Storage mStorage; 57 Sink::Storage::DataStore mStorage;
57 58
58private: 59private:
59 void recordReplayedRevision(qint64 revision); 60 void recordReplayedRevision(qint64 revision);
60 KAsync::Job<void> replayNextRevision(); 61 KAsync::Job<void> replayNextRevision();
61 Sink::Storage mChangeReplayStore; 62 Sink::Storage::DataStore mChangeReplayStore;
62 bool mReplayInProgress; 63 bool mReplayInProgress;
63 Sink::Storage::Transaction mMainStoreTransaction; 64 Sink::Storage::DataStore::Transaction mMainStoreTransaction;
64}; 65};
65 66
66class NullChangeReplay : public ChangeReplay 67class NullChangeReplay : public ChangeReplay
67{ 68{
68public: 69public:
69 NullChangeReplay(const QByteArray &resourceName) : ChangeReplay(resourceName) {} 70 NullChangeReplay(const ResourceContext &resourceContext) : ChangeReplay(resourceContext) {}
70 KAsync::Job<void> replay(const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE { return KAsync::null<void>(); } 71 KAsync::Job<void> replay(const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE { return KAsync::null<void>(); }
71 bool canReplay(const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE { return false; } 72 bool canReplay(const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE { return false; }
72}; 73};