From 938554f267193b652478fc12343819fa45d76034 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 28 Nov 2016 19:33:01 +0100 Subject: Moved inspection commands to a separate inspector. --- common/commandprocessor.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'common/commandprocessor.cpp') 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 @@ #include "commands.h" #include "messagequeue.h" #include "queuedcommand_generated.h" - +#include "inspector.h" +#include "synchronizer.h" #include "pipeline.h" static int sBatchSize = 100; @@ -42,11 +43,6 @@ void CommandProcessor::setOldestUsedRevision(qint64 revision) mLowerBoundRevision = revision; } -void CommandProcessor::setInspectionCommand(const InspectionFunction &f) -{ - mInspect = f; -} - void CommandProcessor::setFlushCommand(const FlushFunction &f) { mFlush = f; @@ -91,12 +87,9 @@ KAsync::Job CommandProcessor::processQueuedCommand(const Sink::QueuedCom case Sink::Commands::CreateEntityCommand: return mPipeline->newEntity(data, size); case Sink::Commands::InspectionCommand: - if (mInspect) { - return mInspect(data, size) + Q_ASSERT(mInspector); + return mInspector->processCommand(data, size) .syncThen([]() { return -1; }); - } else { - return KAsync::error(-1, "Missing inspection command."); - } case Sink::Commands::FlushCommand: if (mFlush) { return mFlush(data, size) @@ -191,3 +184,15 @@ KAsync::Job CommandProcessor::processPipeline() }); } +void CommandProcessor::setInspector(const QSharedPointer &inspector) +{ + mInspector = inspector; + QObject::connect(mInspector.data(), &Inspector::notify, this, &CommandProcessor::notify); +} + +void CommandProcessor::setSynchronizer(const QSharedPointer &synchronizer) +{ + mSynchronizer = synchronizer; + QObject::connect(mSynchronizer.data(), &Synchronizer::notify, this, &CommandProcessor::notify); +} + -- cgit v1.2.3