Minecraft Community Edition 0.1.0
Loading...
Searching...
No Matches
IEvent.hpp
1#pragma once
2#include <source_location>
3
4#include <EASTL/optional.h>
5#include <EASTL/shared_ptr.h>
6#include <EASTL/string.h>
7#include "Platform.hpp"
8#ifdef MCE_PLATFORM_WINDOWS
9#undef ERROR
10#endif
11
12namespace mce {
13 namespace core {
14 class Thread;
15 }
16 using core::Thread;
17 struct IEvent {
18 virtual ~IEvent() = default;
19 [[nodiscard]] virtual const char const* name() const = 0;
20 };
21
22 namespace event {
23 struct LoggerOutput : IEvent {
24 enum class Severity {
25 INFO,
26 WARN,
27 ERROR,
28 DEBUG,
29 FATAL //Maybe
30 };
31 Severity severity;
32 std::string msg;
33 eastl::optional<std::source_location> location;
34
35 explicit LoggerOutput(Severity s = Severity::INFO, const std::string m = "", eastl::optional<std::source_location> loc = eastl::nullopt)
36 : severity(s), msg(m), location(loc) {}
37
38 [[nodiscard]] virtual const char const* name() const override { return "mce.core.event.logger_output"; }
39 };
40
41 struct ThreadFinished : IEvent {
42 ThreadFinished(Thread* ptr) : thread(ptr) {}
43 Thread* thread;
44 virtual const char const* name() const override { return "mce.core.event.thread_finished"; }
45 };
46
47 struct ThreadStarted : IEvent {
48 ThreadStarted(Thread const* p, const eastl::string& n) : threadPtr(p), threadName(n) {}
49 Thread const* threadPtr;
50 const eastl::string threadName;
51 virtual const char const* name() const override { return "mce.core.event.thread_started"; }
52 };
53 }
54}
Lightweight high-level thread wrapper.
Definition Thread.hpp:134
Definition IEvent.hpp:17