Moved away from shared pointers in event handlers - didn't make sense to expose the event management implementation to handlers.

Also some other bits of tidying.
This commit is contained in:
Nav
2021-06-22 03:06:20 +01:00
parent 139e880646
commit a7df862d36
19 changed files with 193 additions and 212 deletions

View File

@@ -119,7 +119,7 @@ void Insight::shutdown() {
this->setThreadState(ThreadState::STOPPED);
}
void Insight::onShutdownApplicationEvent(EventPointer<ShutdownApplication>) {
void Insight::onShutdownApplicationEvent(EventRef<ShutdownApplication>) {
/*
* Once Insight shuts down, control of the main thread will be returned to Application::run(), which
* will pickup the ShutdownApplication event and proceed with the shutdown.
@@ -127,8 +127,8 @@ void Insight::onShutdownApplicationEvent(EventPointer<ShutdownApplication>) {
this->shutdown();
}
void Insight::onTargetControllerThreadStateChangedEvent(EventPointer<TargetControllerThreadStateChanged> event) {
if (event->getState() == ThreadState::STOPPED) {
void Insight::onTargetControllerThreadStateChangedEvent(EventRef<TargetControllerThreadStateChanged> event) {
if (event.getState() == ThreadState::STOPPED) {
// Something horrible has happened with the TargetController - Insight is useless without the TargetController
this->shutdown();
}

View File

@@ -81,7 +81,7 @@ namespace Bloom
*
* @param event
*/
void onShutdownApplicationEvent(Events::EventPointer<Events::ShutdownApplication> event);
void onShutdownApplicationEvent(Events::EventRef<Events::ShutdownApplication> event);
/**
* If the something horrible was to happen and the TC dies unexpectedly, Insight will shutdown in response.
@@ -89,7 +89,7 @@ namespace Bloom
* @param event
*/
void onTargetControllerThreadStateChangedEvent(
Events::EventPointer<Events::TargetControllerThreadStateChanged> event
Events::EventRef<Events::TargetControllerThreadStateChanged> event
);
/**

View File

@@ -60,7 +60,7 @@ void InsightWorker::requestPinStateUpdate(
this->targetControllerConsole.setPinState(variantId, pinDescriptor, pinState);
}
void InsightWorker::onTargetStoppedEvent(EventPointer<TargetExecutionStopped> event) {
void InsightWorker::onTargetStoppedEvent(EventRef<TargetExecutionStopped> event) {
/*
* When we report a target halt to Insight, Insight will immediately seek more data from the target (such as GPIO
* pin states). This can be problematic for cases where the target had halted due to a conditional breakpoint.
@@ -88,30 +88,30 @@ void InsightWorker::onTargetStoppedEvent(EventPointer<TargetExecutionStopped> ev
if (!resumedEvent.has_value()) {
emit this->targetStateUpdated(TargetState::STOPPED);
emit this->targetProgramCounterUpdated(event->programCounter);
emit this->targetProgramCounterUpdated(event.programCounter);
}
}
void InsightWorker::onTargetResumedEvent(EventPointer<TargetExecutionResumed> event) {
void InsightWorker::onTargetResumedEvent(EventRef<TargetExecutionResumed> event) {
emit this->targetStateUpdated(TargetState::RUNNING);
}
void InsightWorker::onTargetPinStatesRetrievedEvent(EventPointer<TargetPinStatesRetrieved> event) {
emit this->targetPinStatesUpdated(event->variantId, event->pinSatesByNumber);
void InsightWorker::onTargetPinStatesRetrievedEvent(EventRef<TargetPinStatesRetrieved> event) {
emit this->targetPinStatesUpdated(event.variantId, event.pinSatesByNumber);
}
void InsightWorker::onTargetIoPortsUpdatedEvent(EventPointer<TargetIoPortsUpdated> event) {
void InsightWorker::onTargetIoPortsUpdatedEvent(EventRef<TargetIoPortsUpdated> event) {
emit this->targetIoPortsUpdated();
}
void InsightWorker::onTargetControllerStateReported(EventPointer<TargetControllerStateReported> event) {
void InsightWorker::onTargetControllerStateReported(EventRef<TargetControllerStateReported> event) {
if (this->lastTargetControllerState == TargetControllerState::ACTIVE
&& event->state == TargetControllerState::SUSPENDED
&& event.state == TargetControllerState::SUSPENDED
) {
emit this->targetControllerSuspended();
} else if (this->lastTargetControllerState == TargetControllerState::SUSPENDED
&& event->state == TargetControllerState::ACTIVE
&& event.state == TargetControllerState::ACTIVE
) {
try {
emit this->targetControllerResumed(this->targetControllerConsole.getTargetDescriptor());
@@ -120,5 +120,5 @@ void InsightWorker::onTargetControllerStateReported(EventPointer<TargetControlle
Logger::error("Insight resume failed - " + exception.getMessage());
}
}
this->lastTargetControllerState = event->state;
this->lastTargetControllerState = event.state;
}

View File

@@ -33,11 +33,11 @@ namespace Bloom
QTimer* eventDispatchTimer = nullptr;
void onTargetStoppedEvent(Events::EventPointer<Events::TargetExecutionStopped> event);
void onTargetResumedEvent(Events::EventPointer<Events::TargetExecutionResumed> event);
void onTargetPinStatesRetrievedEvent(Events::EventPointer<Events::TargetPinStatesRetrieved> event);
void onTargetIoPortsUpdatedEvent(Events::EventPointer<Events::TargetIoPortsUpdated> event);
void onTargetControllerStateReported(Events::EventPointer<Events::TargetControllerStateReported> event);
void onTargetStoppedEvent(Events::EventRef<Events::TargetExecutionStopped> event);
void onTargetResumedEvent(Events::EventRef<Events::TargetExecutionResumed> event);
void onTargetPinStatesRetrievedEvent(Events::EventRef<Events::TargetPinStatesRetrieved> event);
void onTargetIoPortsUpdatedEvent(Events::EventRef<Events::TargetIoPortsUpdated> event);
void onTargetControllerStateReported(Events::EventRef<Events::TargetControllerStateReported> event);
public:
explicit InsightWorker(EventManager& eventManager): eventManager(eventManager) {};
@@ -62,6 +62,5 @@ namespace Bloom
void targetIoPortsUpdated();
void targetControllerSuspended();
void targetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor);
};
}