// Copyright (c) 2022 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #pragma once #include "Asset.hpp" namespace Dawn { class AssetManager { private: /** List of pointers to assets, mapped by their asset key. */ std::map assets; std::map assetsNotLoaded; public: void init(); void update(); /** * Creates and queue an asset to load. * * @param name Name of the asset to load. * @return The asset element to be loaded. */ template T * load(std::string name) { assertTrue(name.size() > 0); auto existing = this->assets.find(name); if(existing != this->assets.end()) { return (T*)existing->second; } auto asset = new T(this, name); this->assets[name] = asset; this->assetsNotLoaded[name] = asset; return asset; } template void unload(std::string name) { assertUnreachable(); //should delete the asset for you } ~AssetManager(); }; }