From 9e6ee692090511f1cf9beaf9d95936ccd258878d Mon Sep 17 00:00:00 2001
From: Joseph Walton-Rivers <joseph@walton-rivers.uk>
Date: Sat, 23 Jul 2022 14:54:55 +0100
Subject: [PATCH] remove old template-based service code

---
 demo/demo/rollball.cpp        |  1 -
 demo/include/GameScene.h      |  1 -
 fggl/app.cpp                  |  1 -
 fggl/audio/openal/audio.cpp   |  2 -
 fggl/gfx/ogl/renderer.cpp     |  1 -
 fggl/gfx/ogl4/canvas.cpp      |  1 -
 fggl/scenes/game.cpp          |  1 -
 fggl/scenes/menu.cpp          |  1 -
 include/fggl/gui/fonts.hpp    |  1 -
 include/fggl/util/service.hpp | 77 -----------------------------------
 10 files changed, 87 deletions(-)
 delete mode 100644 include/fggl/util/service.hpp

diff --git a/demo/demo/rollball.cpp b/demo/demo/rollball.cpp
index 24f188c..9967e30 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 db20119..84ab5e6 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 5e70f94..b2b4ee4 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 b72816a..3a64cd0 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 f4fe812..8b45eed 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 fc0a38f..fae0466 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 e90819b..f5f7746 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 d5071ec..9b6dec8 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 a944cb5..00cae27 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 a22bd92..0000000
--- 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
-- 
GitLab