aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/manager/Mediator.h
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-05 00:03:10 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-05 00:03:10 +0100
commit8aa43f634c1a89f05681ffc5f3cd0a3477e50e71 (patch)
treea1321d75328da0952ba7bf294a8036f50debb60f /src/crepe/manager/Mediator.h
parentd9e46281c1e24a5f23d779d314e5df87fa3317a3 (diff)
parentcfb67ffddb9f4bb0357c2b9df4239bfee7364c5a (diff)
added loopTimer to mediator and fixed update loop
Diffstat (limited to 'src/crepe/manager/Mediator.h')
-rw-r--r--src/crepe/manager/Mediator.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/crepe/manager/Mediator.h b/src/crepe/manager/Mediator.h
new file mode 100644
index 0000000..cd96614
--- /dev/null
+++ b/src/crepe/manager/Mediator.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include "../util/OptionalRef.h"
+
+// TODO: remove these singletons:
+#include "EventManager.h"
+#include "SaveManager.h"
+
+namespace crepe {
+
+class ComponentManager;
+class SceneManager;
+class LoopTimer;
+/**
+ * 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<LoopTimer> loop_timer;
+};
+
+} // namespace crepe