aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/manager/Mediator.h
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-06 10:44:42 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-06 10:44:42 +0100
commitd5f63024ebed7df2fff8e016bd1c7c26f8fdfa27 (patch)
treeb26e35cb0482d04a33cc96d97ba21c21d0012229 /src/crepe/manager/Mediator.h
parent9cde6875186b335c75eafa6402f0957cd4252c76 (diff)
parent1f4e961d7f9d6887c807cac1a362f2d178b0860b (diff)
Merge branch 'master' into decoupling
Diffstat (limited to 'src/crepe/manager/Mediator.h')
-rw-r--r--src/crepe/manager/Mediator.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/crepe/manager/Mediator.h b/src/crepe/manager/Mediator.h
new file mode 100644
index 0000000..71bd1c9
--- /dev/null
+++ b/src/crepe/manager/Mediator.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include "../util/OptionalRef.h"
+
+// TODO: remove these singletons:
+#include "EventManager.h"
+#include "SaveManager.h"
+
+namespace crepe {
+
+class ComponentManager;
+class SceneManager;
+
+/**
+ * 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();
+};
+
+} // namespace crepe