21 #ifndef GF_RESOURCE_MANAGER_H
22 #define GF_RESOURCE_MANAGER_H
34 #ifndef DOXYGEN_SHOULD_SKIP_THIS
53 typedef std::function<std::unique_ptr<T>(
const Path&)>
Loader;
61 : m_loader(std::move(loader))
88 auto it = m_cache.find(filename);
90 if (it != m_cache.end()) {
91 return it->second.get();
96 if (absolutePath.empty()) {
100 auto ptr = m_loader(absolutePath);
106 auto inserted = m_cache.emplace(filename, std::move(ptr));
108 if (inserted.second) {
109 return inserted.first->second.get();
117 std::map<Path, std::unique_ptr<T>> m_cache;
159 #ifndef DOXYGEN_SHOULD_SKIP_THIS
Path getAbsolutePath(const Path &relativePath) const
Search a file in the search directories.
Font * getFont(const Path &path)
Get a font.
Definition: ResourceManager.h:150
ResourceCache(Loader loader)
Constructor.
Definition: ResourceManager.h:60
An asset manager.
Definition: AssetManager.h:44
std::function< std::unique_ptr< T >const Path &)> Loader
A ressource loader.
Definition: ResourceManager.h:53
ResourceCache(const ResourceCache &)=delete
Deleted copy constructor.
A texture for colored images.
Definition: Texture.h:317
T * getResource(AssetManager &assetManager, const Path &filename)
Get a ressource.
Definition: ResourceManager.h:87
ResourceManager()
Default constructor.
A character font.
Definition: Font.h:130
A ressource manager.
Definition: ResourceManager.h:127
A generic cache for ressources.
Definition: ResourceManager.h:48
Texture * getTexture(const Path &path)
Get a texture.
Definition: ResourceManager.h:140
ResourceCache & operator=(const ResourceCache &)=delete
Deleted copy assignment.
#define GF_API
Definition: Portability.h:35