aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/manager/Mediator.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-29 12:21:26 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-29 12:21:26 +0100
commitc2ef6a36532c8c078fd7836325d6be277b946cbf (patch)
treebcac24106220ad626aca5dfcd3576e7d60ac3af2 /src/crepe/manager/Mediator.h
parent74bffd3e466c342ca80811146a536716fb6437cb (diff)
parent7a07c56d572a6f30d0aa611bd566197bc04c3b33 (diff)
merge `loek/scripts`
Diffstat (limited to 'src/crepe/manager/Mediator.h')
-rw-r--r--src/crepe/manager/Mediator.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/crepe/manager/Mediator.h b/src/crepe/manager/Mediator.h
new file mode 100644
index 0000000..475aed9
--- /dev/null
+++ b/src/crepe/manager/Mediator.h
@@ -0,0 +1,35 @@
+#pragma once
+
+#include "../util/OptionalRef.h"
+
+// TODO: remove these singletons:
+#include "SaveManager.h"
+#include "EventManager.h"
+
+namespace crepe {
+
+class ComponentManager;
+class SceneManager;
+class ResourceManager;
+
+/**
+ * Struct to pass references to classes that would otherwise need to be singletons down to
+ * other classes within the engine hierarchy. Made to prevent constant changes to subclasses to
+ * pass specific references through dependency injection. All references on this struct
+ * *should* be explicitly checked for availability as this struct does not guarantee anything.
+ *
+ * \note Dereferencing members of this struct should be deferred. If you are a user of this
+ * class, keep a reference to this mediator instead of just picking references from it when you
+ * receive an instance.
+ *
+ * \warning This class should never be directly accessible from the API
+ */
+struct Mediator {
+ OptionalRef<ComponentManager> component_manager;
+ OptionalRef<SceneManager> scene_manager;
+ OptionalRef<SaveManager> save_manager = SaveManager::get_instance();
+ OptionalRef<EventManager> event_manager = EventManager::get_instance();
+ OptionalRef<ResourceManager> resource_manager;
+};
+
+}