|
| | ResourceCache (const std::function< std::optional< Resource >(const std::string &)> &loadFunction, const std::function< void(Resource)> &unloadFunction) |
| | Constructs a cache with the given load and unload functions.
|
|
| ResourceCache (const ResourceCache &)=delete |
|
ResourceCache & | operator= (const ResourceCache &)=delete |
| std::shared_ptr< Resource > | Get (const std::string &name) |
| | Looks up a cached resource by name without loading it.
|
| std::shared_ptr< Resource > | Load (const std::string &path) |
| | Loads a resource from disk and caches it under its path.
|
| std::shared_ptr< Resource > | Add (Resource &&object, const std::string &name) |
| | Stores an already-constructed resource under an arbitrary name.
|
| void | Remove (const std::string &path) |
| | Removes a resource from the cache.
|
template<class Resource>
class ResourceCache< Resource >
Thread-safe cache for a single resource type.
Resources are loaded on demand, stored by path, and automatically unloaded when the last shared_ptr to them is released.
All public methods are safe to call from multiple threads concurrently.
- Template Parameters
-
| Resource | The resource type to cache (e.g. Texture2D, Sound) |