diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-23 21:54:28 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-23 21:54:28 +0200 |
commit | 9b7be419c9dcc6ebd1e504713c7b2676ca3d2fdf (patch) | |
tree | 97a2fc5ce1ec1345bd6f44889682ea9a2ffafd76 /src/crepe/api/AssetManager.h | |
parent | 080ad535e6fc6666b919b1a21b6986aaf9b678eb (diff) |
`clang-format`
Diffstat (limited to 'src/crepe/api/AssetManager.h')
-rw-r--r-- | src/crepe/api/AssetManager.h | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/crepe/api/AssetManager.h b/src/crepe/api/AssetManager.h index 1b8b86f..f3f1307 100644 --- a/src/crepe/api/AssetManager.h +++ b/src/crepe/api/AssetManager.h @@ -1,22 +1,18 @@ #pragma once - - #include <any> #include <memory> #include <string> #include <unordered_map> #include <utility> +namespace crepe::api { -namespace crepe::api{ - -class AssetManager{ - +class AssetManager { private: - std::unordered_map< std::string, std::any> asset_cache; - + std::unordered_map<std::string, std::any> asset_cache; + private: AssetManager(); virtual ~AssetManager(); @@ -24,27 +20,27 @@ private: public: AssetManager(const AssetManager &) = delete; AssetManager(AssetManager &&) = delete; - AssetManager &operator=(const AssetManager &) = delete; - AssetManager &operator=(AssetManager &&) = delete; - - - static AssetManager& get_instance(); + AssetManager & operator=(const AssetManager &) = delete; + AssetManager & operator=(AssetManager &&) = delete; + static AssetManager & get_instance(); public: - template<typename asset> - std::shared_ptr<asset> cache(const std::string& file_path, bool reload = false){ + template <typename asset> + std::shared_ptr<asset> cache(const std::string & file_path, + bool reload = false) { auto it = asset_cache.find(file_path); if (!reload && it != asset_cache.end()) { return std::any_cast<std::shared_ptr<asset>>(it->second); } - std::shared_ptr<asset> new_asset = std::make_shared<asset>(file_path.c_str()); + std::shared_ptr<asset> new_asset + = std::make_shared<asset>(file_path.c_str()); asset_cache[file_path] = new_asset; return new_asset; } }; -} +} // namespace crepe::api |