Tidied structure of all classes within the entire code base

Also some other small bits of tidying
This commit is contained in:
Nav
2021-10-06 21:12:31 +01:00
parent 1aef5bba79
commit 6edfb7376a
179 changed files with 3446 additions and 3493 deletions

View File

@@ -1,6 +1,5 @@
#include "InsightWorker.hpp"
#include <filesystem>
#include <QObject>
#include <QTimer>
@@ -12,6 +11,16 @@ using namespace Bloom::Exceptions;
using Bloom::Targets::TargetState;
InsightWorker::InsightWorker(EventManager& eventManager): eventManager(eventManager) {}
void InsightWorker::queueTask(InsightWorkerTask* task) {
auto taskQueueLock = this->queuedTasks.acquireLock();
task->moveToThread(this->thread());
task->setParent(this);
this->queuedTasks.getReference().push(task);
emit this->taskQueued();
}
void InsightWorker::startup() {
Logger::debug("Starting InsightWorker thread");
this->eventManager.registerListener(this->eventListener);
@@ -43,12 +52,8 @@ void InsightWorker::startup() {
);
}
void InsightWorker::queueTask(InsightWorkerTask* task) {
auto taskQueueLock = this->queuedTasks.acquireLock();
task->moveToThread(this->thread());
task->setParent(this);
this->queuedTasks.getReference().push(task);
emit this->taskQueued();
void InsightWorker::requestPinStates(int variantId) {
this->targetControllerConsole.requestPinStates(variantId);
}
std::optional<InsightWorkerTask*> InsightWorker::getQueuedTask() {
@@ -65,18 +70,6 @@ std::optional<InsightWorkerTask*> InsightWorker::getQueuedTask() {
return task;
}
void InsightWorker::executeTasks() {
auto task = std::optional<InsightWorkerTask*>();
while ((task = this->getQueuedTask()).has_value()) {
task.value()->execute(this->targetControllerConsole);
}
}
void InsightWorker::requestPinStates(int variantId) {
this->targetControllerConsole.requestPinStates(variantId);
}
void InsightWorker::onTargetStoppedEvent(const Events::TargetExecutionStopped& event) {
/*
* When we report a target halt to Insight, Insight will immediately seek more data from the target (such as GPIO
@@ -135,3 +128,11 @@ void InsightWorker::onTargetControllerStateReportedEvent(const Events::TargetCon
}
this->lastTargetControllerState = event.state;
}
void InsightWorker::executeTasks() {
auto task = std::optional<InsightWorkerTask*>();
while ((task = this->getQueuedTask()).has_value()) {
task.value()->execute(this->targetControllerConsole);
}
}

View File

@@ -20,7 +20,29 @@ namespace Bloom
*/
class InsightWorker: public QObject
{
Q_OBJECT
Q_OBJECT
public:
explicit InsightWorker(EventManager& eventManager);
void queueTask(InsightWorkerTask* task);
void dispatchEvents() {
this->eventListener->dispatchCurrentEvents();
}
public slots:
void startup();
void requestPinStates(int variantId);
signals:
void taskQueued();
void targetStateUpdated(Bloom::Targets::TargetState newState);
void targetProgramCounterUpdated(quint32 programCounter);
void targetControllerSuspended();
void targetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor);
void targetRegistersWritten(const Bloom::Targets::TargetRegisters& targetRegisters, const QDateTime& timestamp);
private:
EventManager& eventManager;
EventListenerPointer eventListener = std::make_shared<EventListener>("InsightWorkerEventListener");
@@ -44,26 +66,5 @@ namespace Bloom
private slots:
void executeTasks();
public:
explicit InsightWorker(EventManager& eventManager): eventManager(eventManager) {};
void dispatchEvents() {
this->eventListener->dispatchCurrentEvents();
}
void queueTask(InsightWorkerTask* task);
public slots:
void startup();
void requestPinStates(int variantId);
signals:
void taskQueued();
void targetStateUpdated(Bloom::Targets::TargetState newState);
void targetProgramCounterUpdated(quint32 programCounter);
void targetControllerSuspended();
void targetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor);
void targetRegistersWritten(const Bloom::Targets::TargetRegisters& targetRegisters, const QDateTime& timestamp);
};
}

View File

@@ -1,5 +1,7 @@
#include "InsightWorkerTask.hpp"
#include "src/Logger/Logger.hpp"
using namespace Bloom;
void InsightWorkerTask::execute(TargetControllerConsole& targetControllerConsole) {

View File

@@ -17,9 +17,7 @@ namespace Bloom
class InsightWorkerTask: public QObject
{
Q_OBJECT
protected:
virtual void run(TargetControllerConsole& targetControllerConsole) = 0;
Q_OBJECT
public:
InsightWorkerTaskState state;
@@ -32,5 +30,8 @@ namespace Bloom
void started();
void failed(QString errorMessage);
void completed();
protected:
virtual void run(TargetControllerConsole& targetControllerConsole) = 0;
};
}

View File

@@ -7,12 +7,7 @@ namespace Bloom
{
class ReadTargetRegisters: public InsightWorkerTask
{
Q_OBJECT
private:
Targets::TargetRegisterDescriptors descriptors;
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
Q_OBJECT
public:
ReadTargetRegisters(const Targets::TargetRegisterDescriptors& descriptors):
@@ -20,5 +15,11 @@ namespace Bloom
signals:
void targetRegistersRead(Targets::TargetRegisters registers);
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
private:
Targets::TargetRegisterDescriptors descriptors;
};
}

View File

@@ -8,17 +8,18 @@ namespace Bloom
{
class RefreshTargetPinStates: public InsightWorkerTask
{
Q_OBJECT
private:
int variantId;
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
Q_OBJECT
public:
RefreshTargetPinStates(int variantId): InsightWorkerTask(), variantId(variantId) {}
signals:
void targetPinStatesRetrieved(Bloom::Targets::TargetPinStateMappingType pinStatesByNumber);
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
private:
int variantId;
};
}

View File

@@ -7,16 +7,17 @@ namespace Bloom
{
class SetTargetPinState: public InsightWorkerTask
{
Q_OBJECT
private:
Targets::TargetPinDescriptor pinDescriptor;
Targets::TargetPinState pinState;
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
Q_OBJECT
public:
SetTargetPinState(const Targets::TargetPinDescriptor& pinDescriptor, const Targets::TargetPinState& pinState):
InsightWorkerTask(), pinDescriptor(pinDescriptor), pinState(pinState) {}
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
private:
Targets::TargetPinDescriptor pinDescriptor;
Targets::TargetPinState pinState;
};
}

View File

@@ -7,15 +7,16 @@ namespace Bloom
{
class WriteTargetRegister: public InsightWorkerTask
{
Q_OBJECT
private:
Targets::TargetRegister targetRegister;
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
Q_OBJECT
public:
WriteTargetRegister(const Targets::TargetRegister& targetRegister):
InsightWorkerTask(), targetRegister(targetRegister) {}
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
private:
Targets::TargetRegister targetRegister;
};
}