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