From 85dbe479903ab6f54c18bd145985cb6d35cfb45b Mon Sep 17 00:00:00 2001 From: light7734 Date: Wed, 1 Oct 2025 17:29:04 +0330 Subject: [PATCH] chore(asset_manager): delete unused module --- modules/asset_manager/CMakeLists.txt | 9 -- .../asset_manager/private/asset_manager.cpp | 92 ------------------- .../asset_manager/public/asset_manager.hpp | 78 ---------------- 3 files changed, 179 deletions(-) delete mode 100644 modules/asset_manager/CMakeLists.txt delete mode 100644 modules/asset_manager/private/asset_manager.cpp delete mode 100644 modules/asset_manager/public/asset_manager.hpp diff --git a/modules/asset_manager/CMakeLists.txt b/modules/asset_manager/CMakeLists.txt deleted file mode 100644 index 10eeb32..0000000 --- a/modules/asset_manager/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -add_library_module(asset_manager - asset_manager.cpp -) - -target_link_libraries( - asset_manager - PUBLIC asset_parser - PRIVATE logger -) diff --git a/modules/asset_manager/private/asset_manager.cpp b/modules/asset_manager/private/asset_manager.cpp deleted file mode 100644 index 1fb68f5..0000000 --- a/modules/asset_manager/private/asset_manager.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -namespace lt { - -/* static */ auto AssetManager::instance() -> AssetManager & -{ - static auto instance = AssetManager {}; - return instance; -} - -void AssetManager::load_shader_impl( - const std::string &name, - const std::filesystem::path &vertex_path, - const std::filesystem::path &pixel_path -) -{ - try - { - log_trc("Loading shader:"); - log_trc("\tname : {}", name); - log_trc("\tvertex path: {}", vertex_path.string()); - log_trc("\tpixel path : {}", pixel_path.string()); - - m_shaders[name] = Ref(Shader::create( - get_or_load_text_asset(vertex_path.string()), - get_or_load_text_asset(pixel_path), - GraphicsContext::get_shared_context() - )); - } - catch (const std::exception &exp) - { - log_err("Failed to load shader:"); - log_err("\tname : {}", name); - log_err("\tvertex path: {}", vertex_path.string()); - log_err("\tpixel path : {}", pixel_path.string()); - log_err("\texception : {}", exp.what()); - } -} - -void AssetManager::load_texture_impl(const std::string &name, const std::filesystem::path &path) -{ - try - { - log_trc("Loading texture:"); - log_trc("\tname: {}", name); - log_trc("\tpath: {}", path.string()); - - m_textures[name] = Ref( - Texture::create(get_or_load_texture_asset(path), GraphicsContext::get_shared_context()) - ); - } - catch (const std::exception &exp) - { - log_err("Failed to load texture:"); - log_err("\tname : {}", name); - log_err("\tpath : {}", path.string()); - log_err("\texception: {}", exp.what()); - } -} - -auto AssetManager::get_or_load_text_asset(const std::filesystem::path &path) - -> Ref -{ - const auto key = std::filesystem::canonical(path).string(); - if (!m_text_assets.contains(key)) - { - m_text_assets.emplace(key, create_ref(path)); - } - - return m_text_assets[key]; -} - -auto AssetManager::get_or_load_texture_asset(const std::filesystem::path &path) - -> Ref -{ - const auto key = std::filesystem::canonical(path).string(); - if (!m_texture_assets.contains(key)) - { - m_texture_assets.emplace(key, create_ref(path)); - } - - return m_texture_assets[key]; -} - - -} // namespace lt diff --git a/modules/asset_manager/public/asset_manager.hpp b/modules/asset_manager/public/asset_manager.hpp deleted file mode 100644 index 55b2b53..0000000 --- a/modules/asset_manager/public/asset_manager.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once - -#include - -namespace Assets { - -class TextAsset; - -class TextureAsset; - -} // namespace Assets - -namespace lt { - -class Shader; -class Texture; - -/** - * Asset is the data on the disk. - * Resource is the data on the gpu/cpu - * - * eg. TextureAsset is the file on the disk - * eg. Texture is the representation of it in the GPU - */ -class AssetManager -{ -public: - static void load_shader( - const std::string &name, - const std::filesystem::path &vertex_path, - const std::filesystem::path &pixel_path - ) - { - instance().load_shader_impl(name, vertex_path, pixel_path); - } - - static void load_texture(const std::string &name, const std::filesystem::path &path) - { - instance().load_texture_impl(name, path); - } - - static auto get_shader(const std::string &name) -> Ref - { - return instance().m_shaders[name]; - } - - static auto get_texture(const std::string &name) -> Ref - { - return instance().m_textures[name]; - } - -private: - AssetManager() = default; - - static auto instance() -> AssetManager &; - - void load_shader_impl( - const std::string &name, - const std::filesystem::path &vertex_path, - const std::filesystem::path &pixel_path - ); - - void load_texture_impl(const std::string &name, const std::filesystem::path &path); - - auto get_or_load_text_asset(const std::filesystem::path &path) -> Ref; - - auto get_or_load_texture_asset(const std::filesystem::path &path) -> Ref; - - std::unordered_map> m_text_assets; - - std::unordered_map> m_texture_assets; - - std::unordered_map> m_shaders; - - std::unordered_map> m_textures; -}; - -} // namespace lt