Practical Tools for Simple Design
Loading...
Searching...
No Matches
AssetStore.hpp
1#ifndef UTIL_ASSET_STORE_HPP
2#define UTIL_ASSET_STORE_HPP
3
4#include "pch.hpp" // IWYU pragma: export
5
6#include <functional>
7
8namespace Util {
19template <typename T>
21public:
29 AssetStore(std::function<T(const std::string &)> loader)
30 : m_Loader(loader) {}
31
40 void Load(const std::string &filepath);
41
52 T Get(const std::string &filepath);
53
64 void Remove(const std::string &filepath);
65
66private:
67 std::function<T(const std::string &)> m_Loader;
68
69 std::unordered_map<std::string, T> m_Map;
70};
71} // namespace Util
72
73#include "Util/AssetStore.inl"
74
75#endif
A class template for managing assets.
Definition: AssetStore.hpp:20
AssetStore(std::function< T(const std::string &)> loader)
Constructs an AssetStore object with the specified loader function.
Definition: AssetStore.hpp:29
void Remove(const std::string &filepath)
Removes the asset associated with the specified filepath from the store.
Definition: AssetStore.inl:22
void Load(const std::string &filepath)
Preload resources for future use.
Definition: AssetStore.inl:5
T Get(const std::string &filepath)
Retrieves the asset associated with the specified filepath.
Definition: AssetStore.inl:10
Useful tools for development.
Definition: Animation.hpp:12