Removed unnecessary use of std::string for event management, in an attempt to reduce memory consumption.
Now using 16 bit enums for event types.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
using namespace Bloom;
|
||||
using namespace Bloom::Events;
|
||||
|
||||
std::set<std::string> EventListener::getRegisteredEventTypeNames() {
|
||||
std::set<Events::EventType> EventListener::getRegisteredEventTypes() {
|
||||
return this->registeredEventTypes.getValue();
|
||||
}
|
||||
|
||||
@@ -13,13 +13,12 @@ void EventListener::clearAllCallbacks() {
|
||||
}
|
||||
|
||||
void EventListener::registerEvent(SharedGenericEventPointer event) {
|
||||
auto eventType = event->getName();
|
||||
Logger::debug("Event \"" + eventType + "\" (" + std::to_string(event->id)
|
||||
Logger::debug("Event \"" + event->getName() + "\" (" + std::to_string(event->id)
|
||||
+ ") registered for listener " + this->name);
|
||||
auto queueLock = this->eventQueueByEventType.acquireLock();
|
||||
auto& eventQueueByType = this->eventQueueByEventType.getReference();
|
||||
|
||||
eventQueueByType[eventType].push(std::move(event));
|
||||
eventQueueByType[event->getType()].push(std::move(event));
|
||||
this->eventQueueByEventTypeCV.notify_all();
|
||||
|
||||
if (this->interruptEventNotifier != nullptr && this->interruptEventNotifier->isInitialised()) {
|
||||
@@ -47,11 +46,10 @@ std::vector<SharedGenericEventPointer> EventListener::getEvents() {
|
||||
}
|
||||
|
||||
void EventListener::dispatchEvent(const SharedGenericEventPointer& event) {
|
||||
auto eventName = event->getName();
|
||||
Logger::debug("Dispatching event " + eventName + " (" + std::to_string(event->id) + ").");
|
||||
Logger::debug("Dispatching event " + event->getName() + " (" + std::to_string(event->id) + ").");
|
||||
// Dispatch the event to all registered handlers
|
||||
auto mappingLock = this->eventTypeToCallbacksMapping.acquireLock();
|
||||
auto& callbacks = this->eventTypeToCallbacksMapping.getReference().find(eventName)->second;
|
||||
auto& callbacks = this->eventTypeToCallbacksMapping.getReference().find(event->getType())->second;
|
||||
mappingLock.unlock();
|
||||
|
||||
for (auto& callback : callbacks) {
|
||||
@@ -70,14 +68,12 @@ void EventListener::dispatchCurrentEvents() {
|
||||
void EventListener::waitAndDispatch(int msTimeout) {
|
||||
auto queueLock = this->eventQueueByEventType.acquireLock();
|
||||
auto& eventQueueByType = this->eventQueueByEventType.getReference();
|
||||
auto registeredEventTypes = this->getRegisteredEventTypeNames();
|
||||
auto registeredEventTypes = this->getRegisteredEventTypes();
|
||||
std::optional<SharedGenericEventPointer> event;
|
||||
|
||||
auto eventsFound = [®isteredEventTypes, &event, &eventQueueByType]() -> bool {
|
||||
for (auto& eventQueue: eventQueueByType) {
|
||||
if (registeredEventTypes.find(eventQueue.first) != registeredEventTypes.end()
|
||||
&& !eventQueue.second.empty()
|
||||
) {
|
||||
if (registeredEventTypes.contains(eventQueue.first) && !eventQueue.second.empty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,22 +56,22 @@ namespace Bloom
|
||||
/**
|
||||
* Holds all events registered to this listener.
|
||||
*
|
||||
* Events are grouped by event type name, and removed from their queue just *before* the dispatching to
|
||||
* Events are grouped by event type, and removed from their queue just *before* the dispatching to
|
||||
* registered handlers begins.
|
||||
*/
|
||||
SyncSafe<std::map<std::string, std::queue<Events::SharedGenericEventPointer>>> eventQueueByEventType;
|
||||
SyncSafe<std::map<Events::EventType, std::queue<Events::SharedGenericEventPointer>>> eventQueueByEventType;
|
||||
std::condition_variable eventQueueByEventTypeCV;
|
||||
|
||||
/**
|
||||
* A mapping of event type names to a vector of callback functions. Events will be dispatched to these
|
||||
* A mapping of event types to a vector of callback functions. Events will be dispatched to these
|
||||
* callback functions, during a call to EventListener::dispatchEvent().
|
||||
*
|
||||
* Each callback will be passed a reference to the event (we wrap all registered callbacks in a lambda, where
|
||||
* we perform a downcast before invoking the callback. See EventListener::registerCallbackForEventType()
|
||||
* for more)
|
||||
*/
|
||||
SyncSafe<std::map<std::string, std::vector<std::function<void(const Events::Event&)>>>> eventTypeToCallbacksMapping;
|
||||
SyncSafe<std::set<std::string>> registeredEventTypes;
|
||||
SyncSafe<std::map<Events::EventType, std::vector<std::function<void(const Events::Event&)>>>> eventTypeToCallbacksMapping;
|
||||
SyncSafe<std::set<Events::EventType>> registeredEventTypes;
|
||||
|
||||
std::shared_ptr<EventNotifier> interruptEventNotifier = nullptr;
|
||||
|
||||
@@ -85,11 +85,41 @@ namespace Bloom
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates a list of event types names currently registered in the listener.
|
||||
* Generates a list of event types currently registered in the listener.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
std::set<std::string> getRegisteredEventTypeNames();
|
||||
std::set<Events::EventType> getRegisteredEventTypes();
|
||||
|
||||
template <class EventType>
|
||||
bool isEventTypeRegistered() {
|
||||
return this->registeredEventTypes.getReference().contains(EventType::type);
|
||||
}
|
||||
|
||||
bool isEventTypeRegistered(Events::EventType eventType) {
|
||||
return this->registeredEventTypes.getReference().contains(eventType);
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers an event type for the listener.
|
||||
*
|
||||
* Any events of EventType that are triggered from the point of calling this function, will be stored in
|
||||
* listener queue until they are dispatched to a callback, or retrieved via a call to this->waitForEvent() or
|
||||
* similar.
|
||||
*
|
||||
* @tparam EventType
|
||||
*/
|
||||
template<class EventType>
|
||||
void registerEventType() {
|
||||
auto registeredEventTypesLock = this->registeredEventTypes.acquireLock();
|
||||
this->registeredEventTypes.getReference().insert(EventType::type);
|
||||
}
|
||||
|
||||
template<class EventType>
|
||||
void deRegisterEventType() {
|
||||
auto registeredEventTypesLock = this->registeredEventTypes.acquireLock();
|
||||
this->registeredEventTypes.getReference().erase(EventType::type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an event with the event listener
|
||||
@@ -122,9 +152,8 @@ namespace Bloom
|
||||
auto mappingLock = this->eventTypeToCallbacksMapping.acquireLock();
|
||||
auto& mapping = this->eventTypeToCallbacksMapping.getReference();
|
||||
|
||||
mapping[EventType::name].push_back(parentCallback);
|
||||
auto registeredEventTypesLock = this->registeredEventTypes.acquireLock();
|
||||
this->registeredEventTypes.getReference().insert(EventType::name);
|
||||
mapping[EventType::type].push_back(parentCallback);
|
||||
this->template registerEventType<EventType>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,21 +172,21 @@ namespace Bloom
|
||||
auto mappingLock = this->eventTypeToCallbacksMapping.acquireLock();
|
||||
auto& mapping = this->eventTypeToCallbacksMapping.getReference();
|
||||
|
||||
if (mapping.contains(EventType::name)) {
|
||||
mapping.at(EventType::name).clear();
|
||||
if (mapping.contains(EventType::type)) {
|
||||
mapping.at(EventType::type).clear();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto registeredEventTypesLock = this->registeredEventTypes.acquireLock();
|
||||
this->registeredEventTypes.getReference().erase(EventType::name);
|
||||
this->registeredEventTypes.getReference().erase(EventType::type);
|
||||
}
|
||||
|
||||
auto queueLock = this->eventQueueByEventType.acquireLock();
|
||||
auto& eventQueueByType = this->eventQueueByEventType.getReference();
|
||||
|
||||
if (eventQueueByType.contains(EventType::name)) {
|
||||
eventQueueByType.erase(EventType::name);
|
||||
if (eventQueueByType.contains(EventType::type)) {
|
||||
eventQueueByType.erase(EventType::type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,15 +246,15 @@ namespace Bloom
|
||||
auto queueLock = this->eventQueueByEventType.acquireLock();
|
||||
auto& eventQueueByType = this->eventQueueByEventType.getReference();
|
||||
|
||||
auto eventTypeNames = std::set<std::string>({EventTypeA::name});
|
||||
auto eventTypeNamesToDeRegister = std::set<std::string>();
|
||||
auto eventTypes = std::set<Events::EventType>({EventTypeA::type});
|
||||
auto eventTypesToDeRegister = std::set<Events::EventType>();
|
||||
|
||||
if constexpr (!std::is_same_v<EventTypeA, EventTypeB>) {
|
||||
static_assert(
|
||||
std::is_base_of_v<Events::Event, EventTypeB>,
|
||||
"All event types must be derived from the Event base class."
|
||||
);
|
||||
eventTypeNames.insert(EventTypeB::name);
|
||||
eventTypes.insert(EventTypeB::type);
|
||||
}
|
||||
|
||||
if constexpr (!std::is_same_v<EventTypeB, EventTypeC>) {
|
||||
@@ -233,28 +262,28 @@ namespace Bloom
|
||||
std::is_base_of_v<Events::Event, EventTypeC>,
|
||||
"All event types must be derived from the Event base class."
|
||||
);
|
||||
eventTypeNames.insert(EventTypeC::name);
|
||||
eventTypes.insert(EventTypeC::type);
|
||||
}
|
||||
|
||||
{
|
||||
auto registeredEventTypesLock = this->registeredEventTypes.acquireLock();
|
||||
auto& registeredEventTypes = this->registeredEventTypes.getReference();
|
||||
|
||||
for (const auto& eventTypeName : eventTypeNames) {
|
||||
if (registeredEventTypes.find(eventTypeName) == registeredEventTypes.end()) {
|
||||
registeredEventTypes.insert(eventTypeName);
|
||||
eventTypeNamesToDeRegister.insert(eventTypeName);
|
||||
for (const auto& eventType : eventTypes) {
|
||||
if (!registeredEventTypes.contains(eventType)) {
|
||||
registeredEventTypes.insert(eventType);
|
||||
eventTypesToDeRegister.insert(eventType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Events::SharedGenericEventPointer foundEvent = nullptr;
|
||||
auto eventsFound = [&eventTypeNames, &eventQueueByType, &correlationId, &foundEvent]() -> bool {
|
||||
for (const auto& eventTypeName : eventTypeNames) {
|
||||
if (eventQueueByType.find(eventTypeName) != eventQueueByType.end()
|
||||
&& !eventQueueByType.find(eventTypeName)->second.empty()
|
||||
auto eventsFound = [&eventTypes, &eventQueueByType, &correlationId, &foundEvent]() -> bool {
|
||||
for (const auto& eventType : eventTypes) {
|
||||
if (eventQueueByType.find(eventType) != eventQueueByType.end()
|
||||
&& !eventQueueByType.find(eventType)->second.empty()
|
||||
) {
|
||||
auto& queue = eventQueueByType.find(eventTypeName)->second;
|
||||
auto& queue = eventQueueByType.find(eventType)->second;
|
||||
while (!queue.empty()) {
|
||||
auto event = queue.front();
|
||||
|
||||
@@ -266,7 +295,7 @@ namespace Bloom
|
||||
return true;
|
||||
}
|
||||
|
||||
// Events that match in type but not correlation ID are disregarded
|
||||
// Events that match in type but not correlation ID are discarded
|
||||
queue.pop();
|
||||
}
|
||||
}
|
||||
@@ -282,25 +311,25 @@ namespace Bloom
|
||||
this->eventQueueByEventTypeCV.wait(queueLock, eventsFound);
|
||||
}
|
||||
|
||||
if (!eventTypeNamesToDeRegister.empty()) {
|
||||
if (!eventTypesToDeRegister.empty()) {
|
||||
auto registeredEventTypesLock = this->registeredEventTypes.acquireLock();
|
||||
auto& registeredEventTypes = this->registeredEventTypes.getReference();
|
||||
|
||||
for (const auto& eventTypeName : eventTypeNamesToDeRegister) {
|
||||
registeredEventTypes.erase(eventTypeName);
|
||||
for (const auto& eventType : eventTypesToDeRegister) {
|
||||
registeredEventTypes.erase(eventType);
|
||||
}
|
||||
}
|
||||
|
||||
if (foundEvent != nullptr) {
|
||||
// If we're looking for multiple event types, use an std::variant.
|
||||
if constexpr (!std::is_same_v<EventTypeA, EventTypeB> || !std::is_same_v<EventTypeB, EventTypeC>) {
|
||||
if (foundEvent->getName() == EventTypeA::name) {
|
||||
if (foundEvent->getType() == EventTypeA::type) {
|
||||
output = std::optional<typename decltype(output)::value_type>(
|
||||
std::dynamic_pointer_cast<const EventTypeA>(foundEvent)
|
||||
);
|
||||
|
||||
} else if constexpr (!std::is_same_v<EventTypeA, EventTypeB>) {
|
||||
if (foundEvent->getName() == EventTypeB::name) {
|
||||
if (foundEvent->getType() == EventTypeB::type) {
|
||||
output = std::optional<typename decltype(output)::value_type>(
|
||||
std::dynamic_pointer_cast<const EventTypeB>(foundEvent)
|
||||
);
|
||||
@@ -308,7 +337,7 @@ namespace Bloom
|
||||
}
|
||||
|
||||
if constexpr (!std::is_same_v<EventTypeB, EventTypeC>) {
|
||||
if (foundEvent->getName() == EventTypeC::name) {
|
||||
if (foundEvent->getType() == EventTypeC::type) {
|
||||
output = std::optional<typename decltype(output)::value_type>(
|
||||
std::dynamic_pointer_cast<const EventTypeC>(foundEvent)
|
||||
);
|
||||
@@ -316,7 +345,7 @@ namespace Bloom
|
||||
}
|
||||
|
||||
} else {
|
||||
if (foundEvent->getName() == EventTypeA::name) {
|
||||
if (foundEvent->getType() == EventTypeA::type) {
|
||||
output = std::dynamic_pointer_cast<const EventTypeA>(foundEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,9 @@ void EventManager::deregisterListener(size_t listenerId) {
|
||||
|
||||
void EventManager::triggerEvent(const std::shared_ptr<const Events::Event>& event) {
|
||||
auto registerListenersLock = std::unique_lock(this->registerListenerMutex);
|
||||
for(auto const& [listenerId, listener] : this->registeredListeners) {
|
||||
auto registeredEventTypes = listener->getRegisteredEventTypeNames();
|
||||
|
||||
if (registeredEventTypes.contains(event->getName())) {
|
||||
for(auto const& [listenerId, listener] : this->registeredListeners) {
|
||||
if (listener->isEventTypeRegistered(event->getType())) {
|
||||
listener->registerEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,13 @@ namespace Bloom::Events
|
||||
class BreakpointRemovedOnTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::BREAKPOINT_REMOVED_ON_TARGET;
|
||||
static inline const std::string name = "BreakpointRemovedOnTarget";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return BreakpointRemovedOnTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return BreakpointRemovedOnTarget::name;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,13 @@ namespace Bloom::Events
|
||||
class BreakpointSetOnTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::BREAKPOINT_SET_ON_TARGET;
|
||||
static inline const std::string name = "BreakpointSetOnTarget";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return BreakpointSetOnTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return BreakpointSetOnTarget::name;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,14 @@ namespace Bloom::Events
|
||||
private:
|
||||
ThreadState state;
|
||||
public:
|
||||
static inline EventType type = EventType::DEBUG_SERVER_THREAD_STATE_CHANGED;
|
||||
static inline const std::string name = "DebugServerThreadStateChanged";
|
||||
|
||||
explicit DebugServerThreadStateChanged(ThreadState state): state(state) {};
|
||||
|
||||
static inline const std::string name = "DebugServerThreadStateChanged";
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return DebugServerThreadStateChanged::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return DebugServerThreadStateChanged::name;
|
||||
|
||||
@@ -9,8 +9,13 @@ namespace Bloom::Events
|
||||
class DebugSessionFinished: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::DEBUG_SESSION_FINISHED;
|
||||
static inline const std::string name = "DebugSessionFinished";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return DebugSessionFinished::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return DebugSessionFinished::name;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,13 @@ namespace Bloom::Events
|
||||
class DebugSessionStarted: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::DEBUG_SESSION_STARTED;
|
||||
static inline const std::string name = "DebugSessionStarted";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return DebugSessionStarted::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return DebugSessionStarted::name;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <memory>
|
||||
#include <atomic>
|
||||
#include <optional>
|
||||
#include <cstdint>
|
||||
|
||||
#include "src/Helpers/DateTime.hpp"
|
||||
|
||||
@@ -11,6 +12,48 @@ namespace Bloom::Events
|
||||
{
|
||||
static_assert(std::atomic<int>::is_always_lock_free);
|
||||
|
||||
enum EventType: std::uint16_t
|
||||
{
|
||||
GENERIC,
|
||||
STOP_TARGET_EXECUTION,
|
||||
RESUME_TARGET_EXECUTION,
|
||||
RESET_TARGET,
|
||||
DEBUG_SESSION_STARTED,
|
||||
DEBUG_SESSION_FINISHED,
|
||||
TARGET_CONTROLLER_THREAD_STATE_CHANGED,
|
||||
REPORT_TARGET_CONTROLLER_STATE,
|
||||
TARGET_CONTROLLER_STATE_REPORTED,
|
||||
SHUTDOWN_TARGET_CONTROLLER,
|
||||
TARGET_CONTROLLER_ERROR_OCCURRED,
|
||||
SHUTDOWN_APPLICATION,
|
||||
DEBUG_SERVER_THREAD_STATE_CHANGED,
|
||||
SHUTDOWN_DEBUG_SERVER,
|
||||
RETRIEVE_REGISTERS_FROM_TARGET,
|
||||
REGISTERS_RETRIEVED_FROM_TARGET,
|
||||
WRITE_REGISTERS_TO_TARGET,
|
||||
REGISTERS_WRITTEN_TO_TARGET,
|
||||
TARGET_EXECUTION_RESUMED,
|
||||
TARGET_EXECUTION_STOPPED,
|
||||
RETRIEVE_MEMORY_FROM_TARGET,
|
||||
MEMORY_RETRIEVED_FROM_TARGET,
|
||||
WRITE_MEMORY_TO_TARGET,
|
||||
MEMORY_WRITTEN_TO_TARGET,
|
||||
SET_BREAKPOINT_ON_TARGET,
|
||||
REMOVE_BREAKPOINT_ON_TARGET,
|
||||
BREAKPOINT_SET_ON_TARGET,
|
||||
BREAKPOINT_REMOVED_ON_TARGET,
|
||||
STEP_TARGET_EXECUTION,
|
||||
SET_PROGRAM_COUNTER_ON_TARGET,
|
||||
PROGRAM_COUNTER_SET_ON_TARGET,
|
||||
EXTRACT_TARGET_DESCRIPTOR,
|
||||
TARGET_DESCRIPTOR_EXTRACTED,
|
||||
INSIGHT_THREAD_STATE_CHANGED,
|
||||
RETRIEVE_TARGET_PIN_STATES,
|
||||
TARGET_PIN_STATES_RETRIEVED,
|
||||
SET_TARGET_PIN_STATE,
|
||||
TARGET_IO_PORTS_UPDATED,
|
||||
};
|
||||
|
||||
class Event
|
||||
{
|
||||
private:
|
||||
@@ -21,10 +64,15 @@ namespace Bloom::Events
|
||||
QDateTime createdTimestamp = DateTime::currentDateTime();
|
||||
std::optional<int> correlationId;
|
||||
|
||||
static inline EventType type = EventType::GENERIC;
|
||||
static inline const std::string name = "GenericEvent";
|
||||
|
||||
[[nodiscard]] virtual std::string getName() const {
|
||||
return Event::name;
|
||||
}
|
||||
|
||||
[[nodiscard]] virtual EventType getType() const {
|
||||
return Event::type;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,5 +46,8 @@ namespace Bloom::Events
|
||||
template <class EventType>
|
||||
using SharedEventPointer = std::shared_ptr<const EventType>;
|
||||
|
||||
template <class EventType>
|
||||
using SharedEventPointerNonConst = std::shared_ptr<EventType>;
|
||||
|
||||
using SharedGenericEventPointer = SharedEventPointer<Event>;
|
||||
}
|
||||
|
||||
@@ -4,13 +4,22 @@
|
||||
|
||||
#include "Event.hpp"
|
||||
|
||||
#include "TargetDescriptorExtracted.hpp"
|
||||
|
||||
namespace Bloom::Events
|
||||
{
|
||||
class ExtractTargetDescriptor: public Event
|
||||
{
|
||||
public:
|
||||
using TargetControllerResponseType = TargetDescriptorExtracted;
|
||||
|
||||
static inline EventType type = EventType::EXTRACT_TARGET_DESCRIPTOR;
|
||||
static inline const std::string name = "ExtractTargetDescriptor";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return ExtractTargetDescriptor::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return ExtractTargetDescriptor::name;
|
||||
}
|
||||
|
||||
@@ -11,11 +11,17 @@ namespace Bloom::Events
|
||||
{
|
||||
private:
|
||||
ThreadState state;
|
||||
|
||||
public:
|
||||
explicit InsightThreadStateChanged(ThreadState state): state(state) {};
|
||||
|
||||
static inline EventType type = EventType::INSIGHT_THREAD_STATE_CHANGED;
|
||||
static inline const std::string name = "InsightThreadStateChanged";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return InsightThreadStateChanged::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return InsightThreadStateChanged::name;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,14 @@ namespace Bloom::Events
|
||||
class MemoryRetrievedFromTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::MEMORY_RETRIEVED_FROM_TARGET;
|
||||
static inline const std::string name = "MemoryRetrievedFromTarget";
|
||||
Targets::TargetMemoryBuffer data;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return MemoryRetrievedFromTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return MemoryRetrievedFromTarget::name;
|
||||
}
|
||||
|
||||
@@ -10,12 +10,17 @@ namespace Bloom::Events
|
||||
class MemoryWrittenToTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::MEMORY_WRITTEN_TO_TARGET;
|
||||
static inline const std::string name = "MemoryWrittenToTarget";
|
||||
|
||||
MemoryWrittenToTarget() = default;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return MemoryWrittenToTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return MemoryWrittenToTarget::name;
|
||||
}
|
||||
|
||||
MemoryWrittenToTarget() = default;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,8 +9,13 @@ namespace Bloom::Events
|
||||
class ProgramCounterSetOnTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::PROGRAM_COUNTER_SET_ON_TARGET;
|
||||
static inline const std::string name = "ProgramCounterSetOnTarget";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return ProgramCounterSetOnTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return ProgramCounterSetOnTarget::name;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,14 @@ namespace Bloom::Events
|
||||
class RegistersRetrievedFromTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::REGISTERS_RETRIEVED_FROM_TARGET;
|
||||
static inline const std::string name = "RegistersRetrievedFromTarget";
|
||||
Targets::TargetRegisters registers;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return RegistersRetrievedFromTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return RegistersRetrievedFromTarget::name;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,13 @@ namespace Bloom::Events
|
||||
class RegistersWrittenToTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::REGISTERS_WRITTEN_TO_TARGET;
|
||||
static inline const std::string name = "RegistersWrittenToTarget";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return RegistersWrittenToTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return RegistersWrittenToTarget::name;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,14 @@ namespace Bloom::Events
|
||||
class RemoveBreakpointOnTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::REMOVE_BREAKPOINT_ON_TARGET;
|
||||
static inline const std::string name = "RemoveBreakpointOnTarget";
|
||||
Targets::TargetBreakpoint breakpoint;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return RemoveBreakpointOnTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return RemoveBreakpointOnTarget::name;
|
||||
}
|
||||
|
||||
@@ -9,9 +9,14 @@ namespace Bloom::Events
|
||||
class ReportTargetControllerState: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::REPORT_TARGET_CONTROLLER_STATE;
|
||||
static inline const std::string name = "ReportTargetControllerState";
|
||||
|
||||
ReportTargetControllerState() {};
|
||||
|
||||
static inline const std::string name = "ReportTargetControllerState";
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return ReportTargetControllerState::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return ReportTargetControllerState::name;
|
||||
|
||||
@@ -9,8 +9,13 @@ namespace Bloom::Events
|
||||
class ResetTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::RESET_TARGET;
|
||||
static inline const std::string name = "ResetTargetEvent";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return ResetTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return ResetTarget::name;
|
||||
}
|
||||
|
||||
@@ -10,14 +10,19 @@ namespace Bloom::Events
|
||||
class ResumeTargetExecution: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::RESUME_TARGET_EXECUTION;
|
||||
static inline const std::string name = "ResumeTargetExecutionEvent";
|
||||
std::optional<std::uint32_t> fromProgramCounter;
|
||||
|
||||
ResumeTargetExecution() = default;
|
||||
explicit ResumeTargetExecution(std::uint32_t fromProgramCounter): fromProgramCounter(fromProgramCounter) {};
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return ResumeTargetExecution::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return ResumeTargetExecution::name;
|
||||
}
|
||||
|
||||
ResumeTargetExecution() = default;
|
||||
explicit ResumeTargetExecution(std::uint32_t fromProgramCounter): fromProgramCounter(fromProgramCounter) {};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,11 +11,16 @@ namespace Bloom::Events
|
||||
class RetrieveMemoryFromTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::RETRIEVE_MEMORY_FROM_TARGET;
|
||||
static inline const std::string name = "RetrieveMemoryFromTarget";
|
||||
Targets::TargetMemoryType memoryType = Targets::TargetMemoryType::RAM;
|
||||
std::uint32_t startAddress = 0;
|
||||
std::uint32_t bytes = 0;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return RetrieveMemoryFromTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return RetrieveMemoryFromTarget::name;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,14 @@ namespace Bloom::Events
|
||||
class RetrieveRegistersFromTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::RETRIEVE_REGISTERS_FROM_TARGET;
|
||||
static inline const std::string name = "RetrieveRegistersFromTarget";
|
||||
Targets::TargetRegisterDescriptors descriptors;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return RetrieveRegistersFromTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return RetrieveRegistersFromTarget::name;
|
||||
}
|
||||
|
||||
@@ -9,9 +9,14 @@ namespace Bloom::Events
|
||||
class RetrieveTargetPinStates: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::RETRIEVE_TARGET_PIN_STATES;
|
||||
static inline const std::string name = "RetrieveTargetPinStates";
|
||||
int variantId = 0;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return RetrieveTargetPinStates::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return RetrieveTargetPinStates::name;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,14 @@ namespace Bloom::Events
|
||||
class SetBreakpointOnTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::SET_BREAKPOINT_ON_TARGET;
|
||||
static inline const std::string name = "SetBreakpointOnTarget";
|
||||
Targets::TargetBreakpoint breakpoint;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return SetBreakpointOnTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return SetBreakpointOnTarget::name;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,14 @@ namespace Bloom::Events
|
||||
class SetProgramCounterOnTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::SET_PROGRAM_COUNTER_ON_TARGET;
|
||||
static inline const std::string name = "SetProgramCounterOnTarget";
|
||||
std::uint32_t address = 0;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return SetProgramCounterOnTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return SetProgramCounterOnTarget::name;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,16 @@ namespace Bloom::Events
|
||||
class SetTargetPinState: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::SET_TARGET_PIN_STATE;
|
||||
static inline const std::string name = "SetTargetPinState";
|
||||
int variantId = 0;
|
||||
Targets::TargetPinDescriptor pinDescriptor;
|
||||
Targets::TargetPinState pinState;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return SetTargetPinState::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return SetTargetPinState::name;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,13 @@ namespace Bloom::Events
|
||||
class ShutdownApplication: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::SHUTDOWN_APPLICATION;
|
||||
static inline const std::string name = "ShutdownApplicationEvent";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return ShutdownApplication::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return ShutdownApplication::name;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,13 @@ namespace Bloom::Events
|
||||
class ShutdownDebugServer: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::SHUTDOWN_DEBUG_SERVER;
|
||||
static inline const std::string name = "ShutdownDebugServer";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return ShutdownDebugServer::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return ShutdownDebugServer::name;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,13 @@ namespace Bloom::Events
|
||||
class ShutdownTargetController: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::SHUTDOWN_TARGET_CONTROLLER;
|
||||
static inline const std::string name = "ShutdownTargetControllerEvent";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return ShutdownTargetController::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return ShutdownTargetController::name;
|
||||
}
|
||||
|
||||
@@ -10,14 +10,19 @@ namespace Bloom::Events
|
||||
class StepTargetExecution: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::STEP_TARGET_EXECUTION;
|
||||
static inline const std::string name = "StepTargetExecution";
|
||||
std::optional<std::uint32_t> fromProgramCounter;
|
||||
|
||||
StepTargetExecution() = default;
|
||||
explicit StepTargetExecution(std::uint32_t fromProgramCounter): fromProgramCounter(fromProgramCounter) {};
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return StepTargetExecution::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return StepTargetExecution::name;
|
||||
}
|
||||
|
||||
StepTargetExecution() = default;
|
||||
explicit StepTargetExecution(std::uint32_t fromProgramCounter): fromProgramCounter(fromProgramCounter) {};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,7 +9,12 @@ namespace Bloom::Events
|
||||
class StopTargetExecution: public Event
|
||||
{
|
||||
public:
|
||||
static inline const std::string name = "StopTargetEvent";
|
||||
static inline EventType type = EventType::STOP_TARGET_EXECUTION;
|
||||
static inline const std::string name = "StopTargetExecution";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return StopTargetExecution::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return StopTargetExecution::name;
|
||||
|
||||
@@ -9,10 +9,15 @@ namespace Bloom::Events
|
||||
class TargetControllerErrorOccurred: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::TARGET_CONTROLLER_ERROR_OCCURRED;
|
||||
static inline const std::string name = "TargetControllerErrorOccurred";
|
||||
|
||||
TargetControllerErrorOccurred() = default;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return TargetControllerErrorOccurred::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return TargetControllerErrorOccurred::name;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,15 @@ namespace Bloom::Events
|
||||
class TargetControllerStateReported: public Event
|
||||
{
|
||||
public:
|
||||
TargetControllerState state;
|
||||
static inline EventType type = EventType::TARGET_CONTROLLER_STATE_REPORTED;
|
||||
static inline const std::string name = "TargetControllerStateReported";
|
||||
|
||||
TargetControllerState state;
|
||||
explicit TargetControllerStateReported(TargetControllerState state): state(state) {};
|
||||
|
||||
static inline const std::string name = "TargetControllerStateReported";
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return TargetControllerStateReported::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return TargetControllerStateReported::name;
|
||||
|
||||
@@ -13,9 +13,14 @@ namespace Bloom::Events
|
||||
ThreadState state;
|
||||
|
||||
public:
|
||||
static inline EventType type = EventType::TARGET_CONTROLLER_THREAD_STATE_CHANGED;
|
||||
static inline const std::string name = "TargetControllerThreadStateChanged";
|
||||
|
||||
explicit TargetControllerThreadStateChanged(ThreadState state): state(state) {};
|
||||
|
||||
static inline const std::string name = "TargetControllerThreadStateChanged";
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return TargetControllerThreadStateChanged::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return TargetControllerThreadStateChanged::name;
|
||||
|
||||
@@ -10,9 +10,14 @@ namespace Bloom::Events
|
||||
class TargetDescriptorExtracted: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::TARGET_DESCRIPTOR_EXTRACTED;
|
||||
static inline const std::string name = "TargetDescriptorExtracted";
|
||||
Targets::TargetDescriptor targetDescriptor;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return TargetDescriptorExtracted::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return TargetDescriptorExtracted::name;
|
||||
}
|
||||
|
||||
@@ -9,10 +9,15 @@ namespace Bloom::Events
|
||||
class TargetExecutionResumed: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::TARGET_EXECUTION_RESUMED;
|
||||
static inline const std::string name = "TargetExecutionResumed";
|
||||
|
||||
TargetExecutionResumed() = default;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return TargetExecutionResumed::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return TargetExecutionResumed::name;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Bloom::Events
|
||||
class TargetExecutionStopped: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::TARGET_EXECUTION_STOPPED;
|
||||
static inline const std::string name = "TargetExecutionStopped";
|
||||
std::uint32_t programCounter;
|
||||
Targets::TargetBreakCause breakCause;
|
||||
@@ -18,6 +19,10 @@ namespace Bloom::Events
|
||||
TargetExecutionStopped(std::uint32_t programCounter, Targets::TargetBreakCause breakCause) :
|
||||
programCounter(programCounter), breakCause(breakCause) {}
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return TargetExecutionStopped::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return TargetExecutionStopped::name;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,13 @@ namespace Bloom::Events
|
||||
class TargetIoPortsUpdated: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::TARGET_IO_PORTS_UPDATED;
|
||||
static inline const std::string name = "TargetIoPortsUpdated";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return TargetIoPortsUpdated::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return TargetIoPortsUpdated::name;
|
||||
}
|
||||
|
||||
@@ -11,10 +11,15 @@ namespace Bloom::Events
|
||||
class TargetPinStatesRetrieved: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::TARGET_PIN_STATES_RETRIEVED;
|
||||
static inline const std::string name = "TargetPinStatesRetrieved";
|
||||
int variantId = 0;
|
||||
std::map<int, Targets::TargetPinState> pinSatesByNumber;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return TargetPinStatesRetrieved::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return TargetPinStatesRetrieved::name;
|
||||
}
|
||||
|
||||
@@ -12,20 +12,25 @@ namespace Bloom::Events
|
||||
class WriteMemoryToTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::WRITE_MEMORY_TO_TARGET;
|
||||
static inline const std::string name = "WriteMemoryToTarget";
|
||||
Targets::TargetMemoryType memoryType = Targets::TargetMemoryType::RAM;
|
||||
std::uint32_t startAddress = 0;
|
||||
Targets::TargetMemoryBuffer buffer;
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return WriteMemoryToTarget::name;
|
||||
}
|
||||
|
||||
WriteMemoryToTarget() = default;
|
||||
WriteMemoryToTarget(
|
||||
Targets::TargetMemoryType memoryType,
|
||||
std::uint32_t startAddress,
|
||||
Targets::TargetMemoryBuffer buffer
|
||||
): memoryType(memoryType), startAddress(startAddress), buffer(std::move(buffer)) {};
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return WriteMemoryToTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return WriteMemoryToTarget::name;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,14 +11,19 @@ namespace Bloom::Events
|
||||
class WriteRegistersToTarget: public Event
|
||||
{
|
||||
public:
|
||||
static inline EventType type = EventType::WRITE_REGISTERS_TO_TARGET;
|
||||
static inline const std::string name = "WriteRegistersToTarget";
|
||||
Targets::TargetRegisters registers;
|
||||
|
||||
WriteRegistersToTarget() = default;
|
||||
explicit WriteRegistersToTarget(Targets::TargetRegisters registers): registers(std::move(registers)) {};
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return WriteRegistersToTarget::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return WriteRegistersToTarget::name;
|
||||
}
|
||||
|
||||
WriteRegistersToTarget() = default;
|
||||
explicit WriteRegistersToTarget(Targets::TargetRegisters registers): registers(std::move(registers)) {};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user