From 0548266fb6feb7465e75901d45ac35e361f1aa28 Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <joseph@walton-rivers.uk> Date: Mon, 27 Jun 2022 21:28:25 +0100 Subject: [PATCH] remove subsystem code - modules replace it --- fggl/audio/openal/audio.cpp | 1 - include/fggl/audio/audio.hpp | 1 - include/fggl/subsystem/cursed/god_object.hpp | 134 ------------------- include/fggl/subsystem/provider.hpp | 40 ------ include/fggl/subsystem/subsystem.hpp | 32 ----- include/fggl/subsystem/types.hpp | 36 ----- 6 files changed, 244 deletions(-) delete mode 100644 include/fggl/subsystem/cursed/god_object.hpp delete mode 100644 include/fggl/subsystem/provider.hpp delete mode 100644 include/fggl/subsystem/subsystem.hpp delete mode 100644 include/fggl/subsystem/types.hpp diff --git a/fggl/audio/openal/audio.cpp b/fggl/audio/openal/audio.cpp index 2f7295b..b72816a 100644 --- a/fggl/audio/openal/audio.cpp +++ b/fggl/audio/openal/audio.cpp @@ -30,7 +30,6 @@ #include "fggl/util/service.hpp" #include "fggl/data/storage.hpp" -#include "fggl/subsystem/provider.hpp" namespace fggl::audio::openal { diff --git a/include/fggl/audio/audio.hpp b/include/fggl/audio/audio.hpp index ccb3029..12abe71 100644 --- a/include/fggl/audio/audio.hpp +++ b/include/fggl/audio/audio.hpp @@ -16,7 +16,6 @@ #define FGGL_AUDIO_AUDIO_HPP #include <string> -#include "fggl/subsystem/types.hpp" #include "fggl/data/storage.hpp" #include "fggl/modules/module.hpp" diff --git a/include/fggl/subsystem/cursed/god_object.hpp b/include/fggl/subsystem/cursed/god_object.hpp deleted file mode 100644 index 100fa01..0000000 --- a/include/fggl/subsystem/cursed/god_object.hpp +++ /dev/null @@ -1,134 +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 27/06/22. -// This is the 'quick and dirty' subsystem approach, recommended in 'Game Engine Architecture' -// Architecturally, this is an abomination, but it works (at least until I build something dependency-based). -// - -#ifndef FGGL_SUBSYSTEM_CURSED_GOD_OBJECT_HPP -#define FGGL_SUBSYSTEM_CURSED_GOD_OBJECT_HPP - -#include <memory> - -#include "fggl/subsystem/types.hpp" -#include "fggl/subsystem/provider.hpp" - -#include "fggl/audio/null_audio.hpp" - -namespace fggl::subsystem { - - template<typename T> - class ServiceContainer { - T* m_service = nullptr; - - public: - inline void set(T* service) { - m_service = service; - } - - void release() { - if ( m_service != nullptr ) { - delete m_service; - m_service = nullptr; - } - } - - [[nodiscard]] - inline T* getPtr() const { - return m_service; - } - - [[nodiscard]] - inline T& getRef() const { - return *m_service; - } - }; - - class GodObject : public ServiceProvider, - private ServiceContainer<data::Storage>, - private ServiceContainer<audio::AudioService> - { - public: - GodObject() = default; - - inline void setup() { - m_setup = true; - } - inline void teardown() {} - - template<typename T> - inline void provide(T* service) { - assert(service != nullptr); - assert( !m_setup ); - ServiceContainer<T>::set(service); - } - - template<typename T> - [[nodiscard]] - inline T* get() { - return ServiceContainer<T>::get(); - } - - inline audio::AudioService* getAudio() override { - assert(m_setup); - return ServiceContainer<audio::AudioService>::getPtr(); - } - - inline void setFontLibrary(gui::FontLibrary* fontLibrary) { - assert( !m_setup ); - m_fonts = fontLibrary; - } - - inline gui::FontLibrary* getFontLibrary() override { - assert(m_setup); - return m_fonts; - } - - inline void setInput(input::Input* input){ - assert( !m_setup ); - m_input = input; - } - - input::Input* getInput() override { - assert(m_setup); - return m_input; - } - - data::Storage* getStorage() override { - assert(m_setup); - return ServiceContainer<data::Storage>::getPtr(); - } - - inline void setTypeRegistry(ecs3::TypeRegistry* registry) { - assert( !m_setup ); - m_types = registry; - } - - ecs3::TypeRegistry* getTypeRegistry() override { - assert(m_setup); - return m_types; - } - - private: - bool m_setup = false; - gui::FontLibrary* m_fonts = nullptr; - ecs3::TypeRegistry* m_types = nullptr; - input::Input* m_input = nullptr; - }; - -} // namespace fggl::subsystem - -#endif //FGGL_SUBSYSTEM_CURSED_GOD_OBJECT_HPP diff --git a/include/fggl/subsystem/provider.hpp b/include/fggl/subsystem/provider.hpp deleted file mode 100644 index 2367bff..0000000 --- a/include/fggl/subsystem/provider.hpp +++ /dev/null @@ -1,40 +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 27/06/22. -// - -#ifndef FGGL_SUBSYSTEM_PROVIDER_HPP -#define FGGL_SUBSYSTEM_PROVIDER_HPP - -#include "fggl/audio/audio.hpp" -#include "fggl/gui/gui.hpp" -#include "fggl/ecs3/types.hpp" -#include "fggl/input/input.hpp" - -namespace fggl::subsystem { - - class ServiceProvider { - public: - virtual audio::AudioService* getAudio() = 0; - virtual gui::FontLibrary* getFontLibrary() = 0; - virtual input::Input* getInput() = 0; - virtual data::Storage* getStorage() = 0; - virtual ecs3::TypeRegistry* getTypeRegistry() = 0; - }; - -} // namespace fggl::subsystem - -#endif //FGGL_SUBSYSTEM_PROVIDER_HPP diff --git a/include/fggl/subsystem/subsystem.hpp b/include/fggl/subsystem/subsystem.hpp deleted file mode 100644 index 6765f02..0000000 --- a/include/fggl/subsystem/subsystem.hpp +++ /dev/null @@ -1,32 +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 27/06/22. -// - -#ifndef FGGL_SUBSYSTEM_SUBSYSTEM_HPP -#define FGGL_SUBSYSTEM_SUBSYSTEM_HPP - -#include "fggl/subsystem/cursed/god_object.hpp" - -namespace fggl::subsystem { - - using SubsystemManager = GodObject; - - - -} // namespace fggl::subsystem - -#endif //FGGL_SUBSYSTEM_SUBSYSTEM_HPP diff --git a/include/fggl/subsystem/types.hpp b/include/fggl/subsystem/types.hpp deleted file mode 100644 index e9d58cb..0000000 --- a/include/fggl/subsystem/types.hpp +++ /dev/null @@ -1,36 +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 27/06/22. -// - -#ifndef FGGL_SUBSYSTEM_TYPES_HPP -#define FGGL_SUBSYSTEM_TYPES_HPP - - -namespace fggl::subsystem { - - class ServiceProvider; - - class Subsystem { - virtual ~Subsystem() = default; - - virtual void setup(ServiceProvider& provider) = 0; - virtual void teardown(ServiceProvider& provider) = 0; - }; - -} // namespace fggl::subsystem - -#endif //FGGL_SUBSYSTEM_TYPES_HPP -- GitLab