2021-04-04 21:04:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <atomic>
|
|
|
|
|
#include <optional>
|
2021-08-19 22:06:59 +01:00
|
|
|
#include <cstdint>
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
#include "src/Helpers/DateTime.hpp"
|
|
|
|
|
|
|
|
|
|
namespace Bloom::Events
|
|
|
|
|
{
|
|
|
|
|
static_assert(std::atomic<int>::is_always_lock_free);
|
|
|
|
|
|
2022-03-01 20:35:56 +00:00
|
|
|
enum class EventType: std::uint8_t
|
2021-08-19 22:06:59 +01:00
|
|
|
{
|
|
|
|
|
GENERIC,
|
|
|
|
|
DEBUG_SESSION_STARTED,
|
|
|
|
|
DEBUG_SESSION_FINISHED,
|
|
|
|
|
TARGET_CONTROLLER_THREAD_STATE_CHANGED,
|
2022-04-27 21:27:59 +01:00
|
|
|
TARGET_CONTROLLER_STATE_CHANGED,
|
2021-08-19 22:06:59 +01:00
|
|
|
SHUTDOWN_TARGET_CONTROLLER,
|
|
|
|
|
TARGET_CONTROLLER_ERROR_OCCURRED,
|
|
|
|
|
SHUTDOWN_APPLICATION,
|
|
|
|
|
DEBUG_SERVER_THREAD_STATE_CHANGED,
|
|
|
|
|
SHUTDOWN_DEBUG_SERVER,
|
|
|
|
|
REGISTERS_WRITTEN_TO_TARGET,
|
|
|
|
|
TARGET_EXECUTION_RESUMED,
|
|
|
|
|
TARGET_EXECUTION_STOPPED,
|
|
|
|
|
MEMORY_WRITTEN_TO_TARGET,
|
|
|
|
|
INSIGHT_THREAD_STATE_CHANGED,
|
2022-04-08 22:14:01 +01:00
|
|
|
TARGET_RESET,
|
2022-06-05 16:15:34 +01:00
|
|
|
PROGRAMMING_MODE_ENABLED,
|
|
|
|
|
PROGRAMMING_MODE_DISABLED,
|
2021-08-19 22:06:59 +01:00
|
|
|
};
|
|
|
|
|
|
2021-04-04 21:04:12 +01:00
|
|
|
class Event
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-06-22 03:06:20 +01:00
|
|
|
int id = ++(Event::lastEventId);
|
|
|
|
|
QDateTime createdTimestamp = DateTime::currentDateTime();
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2021-12-25 21:01:58 +00:00
|
|
|
static constexpr EventType type = EventType::GENERIC;
|
2022-10-12 21:26:09 +01:00
|
|
|
static const inline std::string name = "GenericEvent";
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2022-01-11 21:12:25 +00:00
|
|
|
Event() = default;
|
|
|
|
|
virtual ~Event() = default;
|
|
|
|
|
|
|
|
|
|
Event(const Event& other) = default;
|
|
|
|
|
Event(Event&& other) = default;
|
|
|
|
|
|
|
|
|
|
Event& operator = (const Event& other) = default;
|
|
|
|
|
Event& operator = (Event&& other) = default;
|
|
|
|
|
|
2021-06-22 03:06:20 +01:00
|
|
|
[[nodiscard]] virtual std::string getName() const {
|
2021-04-04 21:04:12 +01:00
|
|
|
return Event::name;
|
|
|
|
|
}
|
2021-08-19 22:06:59 +01:00
|
|
|
|
|
|
|
|
[[nodiscard]] virtual EventType getType() const {
|
|
|
|
|
return Event::type;
|
|
|
|
|
}
|
2021-10-06 21:12:31 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
static inline std::atomic<int> lastEventId = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
};
|
|
|
|
|
}
|