// Copyright (C) 2021 Jérôme "Lynix" Leclercq (lynix680@gmail.com) // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_CORE_RESOURCEMANAGER_HPP #define NAZARA_CORE_RESOURCEMANAGER_HPP #include #include #include #include namespace Nz { template class ResourceManager { public: using Loader = ResourceLoader; ResourceManager(Loader& loader); explicit ResourceManager(const ResourceManager&) = default; ResourceManager(ResourceManager&&) noexcept = default; ~ResourceManager() = default; void Clear(); std::shared_ptr Get(const std::filesystem::path& filePath); const Parameters& GetDefaultParameters(); void Register(const std::filesystem::path& filePath, std::shared_ptr resource); void SetDefaultParameters(Parameters params); void Unregister(const std::filesystem::path& filePath); ResourceManager& operator=(const ResourceManager&) = delete; ResourceManager& operator=(ResourceManager&&) = delete; private: // https://stackoverflow.com/questions/51065244/is-there-no-standard-hash-for-stdfilesystempath struct PathHash { std::size_t operator()(const std::filesystem::path& p) const { return hash_value(p); } }; std::unordered_map, PathHash> m_resources; Loader& m_loader; Parameters m_defaultParameters; }; } #include #endif // NAZARA_CORE_RESOURCEMANAGER_HPP