refactor: move event disptacher into service locator

This commit is contained in:
k0t9i
2023-10-16 23:38:01 +04:00
parent b948273172
commit ede55a870e
15 changed files with 160 additions and 94 deletions

View File

@@ -0,0 +1,30 @@
#pragma once
#include <memory>
#include "../Events/EventDispatcher.h"
class ServiceLocator
{
public:
static ServiceLocator& GetInstance() {
static ServiceLocator instance;
return instance;
}
const std::unique_ptr<EventDispatcher>& GetEventDispatcher()
{
return m_EventDispatcher;
}
void SetEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher)
{
m_EventDispatcher = std::move(dispatcher);
}
private:
ServiceLocator() = default;
virtual ~ServiceLocator() = default;
ServiceLocator(const ServiceLocator&) = delete;
ServiceLocator& operator=(const ServiceLocator&) = delete;
private:
std::unique_ptr<EventDispatcher> m_EventDispatcher;
};