summaryrefslogtreecommitdiffstats
path: root/common/commandprocessor.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-11-28 19:33:01 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-11-28 19:33:01 +0100
commit938554f267193b652478fc12343819fa45d76034 (patch)
tree1c027f97f3209571740377f1d4b7e6721d8de777 /common/commandprocessor.cpp
parent885f185f55249a2e97e9c7c238f89a5d0d99d1df (diff)
downloadsink-938554f267193b652478fc12343819fa45d76034.tar.gz
sink-938554f267193b652478fc12343819fa45d76034.zip
Moved inspection commands to a separate inspector.
Diffstat (limited to 'common/commandprocessor.cpp')
-rw-r--r--common/commandprocessor.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/common/commandprocessor.cpp b/common/commandprocessor.cpp
index c9fca37..4ff352b 100644
--- a/common/commandprocessor.cpp
+++ b/common/commandprocessor.cpp
@@ -22,7 +22,8 @@
22#include "commands.h" 22#include "commands.h"
23#include "messagequeue.h" 23#include "messagequeue.h"
24#include "queuedcommand_generated.h" 24#include "queuedcommand_generated.h"
25 25#include "inspector.h"
26#include "synchronizer.h"
26#include "pipeline.h" 27#include "pipeline.h"
27 28
28static int sBatchSize = 100; 29static int sBatchSize = 100;
@@ -42,11 +43,6 @@ void CommandProcessor::setOldestUsedRevision(qint64 revision)
42 mLowerBoundRevision = revision; 43 mLowerBoundRevision = revision;
43} 44}
44 45
45void CommandProcessor::setInspectionCommand(const InspectionFunction &f)
46{
47 mInspect = f;
48}
49
50void CommandProcessor::setFlushCommand(const FlushFunction &f) 46void CommandProcessor::setFlushCommand(const FlushFunction &f)
51{ 47{
52 mFlush = f; 48 mFlush = f;
@@ -91,12 +87,9 @@ KAsync::Job<qint64> CommandProcessor::processQueuedCommand(const Sink::QueuedCom
91 case Sink::Commands::CreateEntityCommand: 87 case Sink::Commands::CreateEntityCommand:
92 return mPipeline->newEntity(data, size); 88 return mPipeline->newEntity(data, size);
93 case Sink::Commands::InspectionCommand: 89 case Sink::Commands::InspectionCommand:
94 if (mInspect) { 90 Q_ASSERT(mInspector);
95 return mInspect(data, size) 91 return mInspector->processCommand(data, size)
96 .syncThen<qint64>([]() { return -1; }); 92 .syncThen<qint64>([]() { return -1; });
97 } else {
98 return KAsync::error<qint64>(-1, "Missing inspection command.");
99 }
100 case Sink::Commands::FlushCommand: 93 case Sink::Commands::FlushCommand:
101 if (mFlush) { 94 if (mFlush) {
102 return mFlush(data, size) 95 return mFlush(data, size)
@@ -191,3 +184,15 @@ KAsync::Job<void> CommandProcessor::processPipeline()
191 }); 184 });
192} 185}
193 186
187void CommandProcessor::setInspector(const QSharedPointer<Inspector> &inspector)
188{
189 mInspector = inspector;
190 QObject::connect(mInspector.data(), &Inspector::notify, this, &CommandProcessor::notify);
191}
192
193void CommandProcessor::setSynchronizer(const QSharedPointer<Synchronizer> &synchronizer)
194{
195 mSynchronizer = synchronizer;
196 QObject::connect(mSynchronizer.data(), &Synchronizer::notify, this, &CommandProcessor::notify);
197}
198