diff --git a/demo/demo/rollball.cpp b/demo/demo/rollball.cpp index 24f188cd9fcd05407885e4518fb2ee176a04b19d..9967e3091f8b54475a6c2bfd65ea9e786c05b8bc 100644 --- a/demo/demo/rollball.cpp +++ b/demo/demo/rollball.cpp @@ -23,7 +23,6 @@ #include "fggl/gfx/phong.hpp" #include "fggl/input/camera_input.hpp" -#include "fggl/util/service.hpp" #include "fggl/ecs3/prototype/loader.hpp" #include "fggl/debug/draw.hpp" diff --git a/demo/include/GameScene.h b/demo/include/GameScene.h index db20119d61e2b216aac2511124830d79162b9fff..84ab5e6360ddab877cc02503f8806a9c4e2ecd50 100644 --- a/demo/include/GameScene.h +++ b/demo/include/GameScene.h @@ -36,7 +36,6 @@ #include "fggl/input/input.hpp" #include "fggl/input/camera_input.hpp" -#include "fggl/util/service.hpp" #include "fggl/util/chrono.hpp" #include "PerlinNoise.hpp" diff --git a/fggl/app.cpp b/fggl/app.cpp index 5e70f94b0c014fb5305b12863eaf9121442af222..b2b4ee4b72f10f5bb57d6c7343c0a41e6047d6af 100644 --- a/fggl/app.cpp +++ b/fggl/app.cpp @@ -21,7 +21,6 @@ #include <fggl/ecs3/types.hpp> #include "fggl/ecs/component_fwd.hpp" #include "fggl/ecs3/module/module.hpp" -#include <fggl/util/service.hpp> namespace fggl { diff --git a/fggl/audio/openal/audio.cpp b/fggl/audio/openal/audio.cpp index b72816a321d24803f62687033398fcd0449bc0a1..3a64cd0d469de3941368c07eb934e5e47efc87a8 100644 --- a/fggl/audio/openal/audio.cpp +++ b/fggl/audio/openal/audio.cpp @@ -27,8 +27,6 @@ */ #include "fggl/audio/openal/audio.hpp" - -#include "fggl/util/service.hpp" #include "fggl/data/storage.hpp" namespace fggl::audio::openal { diff --git a/fggl/gfx/ogl/renderer.cpp b/fggl/gfx/ogl/renderer.cpp index f4fe8126c4e63af9f1ead3385150dc97a4fc0e3f..8b45eedef6824d58c00d9da781bb1fde298409e1 100644 --- a/fggl/gfx/ogl/renderer.cpp +++ b/fggl/gfx/ogl/renderer.cpp @@ -12,7 +12,6 @@ * If not, see <https://www.gnu.org/licenses/>. */ -#include <fggl/util/service.hpp> #include "fggl/debug/logging.hpp" #include "fggl/debug/pragmas.hpp" diff --git a/fggl/gfx/ogl4/canvas.cpp b/fggl/gfx/ogl4/canvas.cpp index fc0a38f2523999526ae781e9b9499983b46b7a74..fae046626887c5886eb5cfa868f28cdca367dff4 100644 --- a/fggl/gfx/ogl4/canvas.cpp +++ b/fggl/gfx/ogl4/canvas.cpp @@ -20,7 +20,6 @@ #include <glm/gtc/type_ptr.hpp> #include "fggl/math/triangulation.hpp" -#include "fggl/util/service.hpp" #include "fggl/gui/fonts.hpp" diff --git a/fggl/scenes/game.cpp b/fggl/scenes/game.cpp index e90819bc0eaf5e73a8e094e09509097dad02a19b..f5f7746f02758e7893dad62f3b0fef53b0705f55 100644 --- a/fggl/scenes/game.cpp +++ b/fggl/scenes/game.cpp @@ -17,7 +17,6 @@ // #include "fggl/scenes/game.hpp" -#include "fggl/util/service.hpp" #if __has_include("fggl/phys/bullet/bullet.hpp") #include "fggl/phys/bullet/bullet.hpp" diff --git a/fggl/scenes/menu.cpp b/fggl/scenes/menu.cpp index d5071ec712240f2dfd753df1ffcf8837b8cd6167..9b6dec85d05bd7a90072b3bd9699f479152e68c5 100644 --- a/fggl/scenes/menu.cpp +++ b/fggl/scenes/menu.cpp @@ -13,7 +13,6 @@ */ #include <fggl/scenes/menu.hpp> -#include <fggl/util/service.hpp> #include <fggl/gui/gui.hpp> #include <spdlog/spdlog.h> diff --git a/include/fggl/gui/fonts.hpp b/include/fggl/gui/fonts.hpp index a944cb5885117166a676ed3cdb6fd97b8ac34fb6..00cae278eb518b8e62d821ab7d87b7efa13b73c9 100644 --- a/include/fggl/gui/fonts.hpp +++ b/include/fggl/gui/fonts.hpp @@ -25,7 +25,6 @@ #include "fggl/math/types.hpp" #include "fggl/data/storage.hpp" -#include "fggl/util/service.hpp" #include "fggl/modules/module.hpp" #include <ft2build.h> diff --git a/include/fggl/util/service.hpp b/include/fggl/util/service.hpp deleted file mode 100644 index a22bd926118fa405014606006ed7e2a4029d0b75..0000000000000000000000000000000000000000 --- a/include/fggl/util/service.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file is part of FGGL. - * - * FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any - * later version. - * - * FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with FGGL. - * If not, see <https://www.gnu.org/licenses/>. - */ - -// -// Created by webpigeon on 20/11/2021. -// - -// quick and dirty way to disable the class -#define FGGL_UTIL_SERVICE_HPP - -#ifndef FGGL_UTIL_SERVICE_HPP -#define FGGL_UTIL_SERVICE_HPP - -#include <memory> -#include <typeindex> -#include <unordered_map> -#include <stdexcept> -#include <iostream> - -namespace fggl::util { - - class ServiceLocator { - inline static ServiceLocator *s_instance; - std::unordered_map<std::type_index, std::shared_ptr<void>> m_services; - ServiceLocator() = default; - - public: - // don't allow copying or moving - ServiceLocator(ServiceLocator &other) = delete; - ServiceLocator(ServiceLocator &&other) = delete; - - static ServiceLocator &instance() { - if (s_instance == nullptr) { - s_instance = new ServiceLocator(); - } - return *s_instance; - } - - template<typename T> - std::shared_ptr<T> supply(std::shared_ptr<T> ptr) { - auto info = std::type_index(typeid(T)); - m_services[info] = ptr; - return ptr; - } - - template<typename T> - std::shared_ptr<T> get() { - try { - auto info = std::type_index(typeid(T)); - return std::static_pointer_cast<T>(m_services.at(info)); - } catch ( std::out_of_range& e ){ - std::cerr << "someone requested a service that doesn't exist!" << std::endl; - return nullptr; - } - } - - template<typename T> - std::shared_ptr<T> providePtr() { - return get<T>(); - } - - }; - -} - -#endif //FGGL_UTIL_SERVICE_HPP