21 template <
class Asset,
class... Args>
22 void AssetManager::create(std::string name, Args... args) {
23 auto& type =
typeid(Asset);
24 if (_assets.find(type) == _assets.end()) {
25 _assets[type] = std::map<std::string, Ptr<Resource>>();
28 _assets[type][name] = std::make_shared<Asset>(args...);
31 template <
class Asset>
32 void AssetManager::add(std::string name, Ptr<Asset> asset) {
33 auto& type =
typeid(Asset);
34 if (_assets.find(type) == _assets.end()) {
35 _assets[type] = std::map<std::string, Ptr<Resource>>();
38 _assets[type][name] = asset;
41 template <
class Asset>
42 Ptr<Asset> AssetManager::get(std::string name) {
43 auto& type =
typeid(Asset);
44 if (_assets.find(type) == _assets.end()) {
45 _assets[type] = std::map<std::string, Ptr<Resource>>();
48 if (_assets[type].find(name) == _assets[type].end()) {
49 Log.Error(
"Asset `%s` unknown.", name.c_str());
53 return std::dynamic_pointer_cast<Asset>(_assets[type][name]);