From fcc6b959edf5f53d545301d974523752747a1c6b Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <joseph@walton-rivers.uk> Date: Sat, 20 Aug 2022 11:27:51 +0100 Subject: [PATCH] clean up header, cpp seperation --- fggl/CMakeLists.txt | 3 ++ fggl/assets/CMakeLists.txt | 3 ++ fggl/assets/module.cpp | 36 +++++++++++++++++++ .../procedure.hpp => fggl/data/module.cpp | 27 +++++++------- include/fggl/assets/manager.hpp | 2 +- include/fggl/assets/module.hpp | 14 -------- include/fggl/data/module.hpp | 11 ------ 7 files changed, 58 insertions(+), 38 deletions(-) create mode 100644 fggl/assets/CMakeLists.txt create mode 100644 fggl/assets/module.cpp rename include/fggl/data/procedure.hpp => fggl/data/module.cpp (62%) diff --git a/fggl/CMakeLists.txt b/fggl/CMakeLists.txt index 64fa463..22cbcbe 100644 --- a/fggl/CMakeLists.txt +++ b/fggl/CMakeLists.txt @@ -35,6 +35,8 @@ endif () add_subdirectory(math) add_subdirectory(util) +add_subdirectory(assets) + target_sources(${PROJECT_NAME} PRIVATE app.cpp @@ -42,6 +44,7 @@ target_sources(${PROJECT_NAME} data/model.cpp data/procedural.cpp data/heightmap.cpp + data/module.cpp scenes/menu.cpp scenes/game.cpp diff --git a/fggl/assets/CMakeLists.txt b/fggl/assets/CMakeLists.txt new file mode 100644 index 0000000..4f1eb0d --- /dev/null +++ b/fggl/assets/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(fggl PRIVATE + module.cpp +) \ No newline at end of file diff --git a/fggl/assets/module.cpp b/fggl/assets/module.cpp new file mode 100644 index 0000000..73034f5 --- /dev/null +++ b/fggl/assets/module.cpp @@ -0,0 +1,36 @@ +/* + * 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/08/22. +// + +#include "fggl/assets/module.hpp" + +namespace fggl::assets { + + bool AssetFolders::factory(modules::ModuleService service, modules::Services& services) { + if ( service == Loader::service) { + auto storage = services.get<data::Storage>(); + services.create<Loader>(storage); + return true; + } + if (service == AssetManager::service) { + services.create<AssetManager>(); + return true; + } + return false; + } + +} // namespace fggl::assets \ No newline at end of file diff --git a/include/fggl/data/procedure.hpp b/fggl/data/module.cpp similarity index 62% rename from include/fggl/data/procedure.hpp rename to fggl/data/module.cpp index a0bc279..d621707 100644 --- a/include/fggl/data/procedure.hpp +++ b/fggl/data/module.cpp @@ -12,19 +12,22 @@ * If not, see <https://www.gnu.org/licenses/>. */ -#ifndef FGGL_DATA_PROCEDURE_HPP -#define FGGL_DATA_PROCEDURE_HPP +// +// Created by webpigeon on 20/08/22. +// -namespace fggl::data { - - class DataRegistry { +#include "fggl/data/module.hpp" - public: - DataRegistry(); - ~DataRegistry(); - - }; +namespace fggl::data { -} + bool LocalStorage::factory(modules::ModuleService service, modules::Services& data) { + if (service == SERVICE_STORAGE) { + // FIXME: no easy way to set the application name + auto pathConfig = fggl::platform::calc_engine_paths("fggl-demo"); + data.create<Storage>(pathConfig); + return true; + } + return false; + } -#endif +} // namespace fggl::data \ No newline at end of file diff --git a/include/fggl/assets/manager.hpp b/include/fggl/assets/manager.hpp index 9963ec4..400a473 100644 --- a/include/fggl/assets/manager.hpp +++ b/include/fggl/assets/manager.hpp @@ -56,7 +56,7 @@ namespace fggl::assets { m_registry.at(guid).refCount++; } - void release(const AssetGUID& guid) { + inline void release(const AssetGUID& guid) { m_registry.at(guid).refCount--; } diff --git a/include/fggl/assets/module.hpp b/include/fggl/assets/module.hpp index e3942f3..206c537 100644 --- a/include/fggl/assets/module.hpp +++ b/include/fggl/assets/module.hpp @@ -35,23 +35,9 @@ namespace fggl::assets { constexpr static const std::array<modules::ModuleService, 1> depends = { data::Storage::service }; - static bool factory(modules::ModuleService name, modules::Services& serviceManager); }; - bool AssetFolders::factory(modules::ModuleService service, modules::Services& services) { - if ( service == Loader::service) { - auto storage = services.get<data::Storage>(); - services.create<Loader>(storage); - return true; - } - if (service == AssetManager::service) { - services.create<AssetManager>(); - return true; - } - return false; - } - } // namespace fggl::assets #endif //FGGL_ASSETS_MODULE_HPP diff --git a/include/fggl/data/module.hpp b/include/fggl/data/module.hpp index 97986b4..b9f51c1 100644 --- a/include/fggl/data/module.hpp +++ b/include/fggl/data/module.hpp @@ -25,26 +25,15 @@ namespace fggl::data { - struct LocalStorage { constexpr static const char* name = "fggl::data::Storage"; constexpr static const std::array<modules::ModuleService, 1> provides = { SERVICE_STORAGE }; constexpr static const std::array<modules::ModuleService, 0> depends = {}; - static bool factory(modules::ModuleService service, modules::Services& serviceManager); }; - bool LocalStorage::factory(modules::ModuleService service, modules::Services& data) { - if (service == SERVICE_STORAGE) { - // FIXME: no easy way to set the application name - auto pathConfig = fggl::platform::calc_engine_paths("fggl-demo"); - data.create<Storage>(pathConfig); - return true; - } - return false; - } } // namespace fggl::data -- GitLab