|
Engine²
Open-source game engine written in C++.
|
#include <ResourceManager.hpp>
Classes | |
| struct | ResourceLoader |
| ResourceLoader structure is used to load a resource from another resource or from arguments. More... | |
Public Member Functions | |
| ResourceManager ()=default | |
| ~ResourceManager ()=default | |
| ResourceManager (const ResourceManager &)=delete | |
| ResourceManager & | operator= (const ResourceManager &)=delete |
| ResourceManager (ResourceManager &&) noexcept=default | |
| ResourceManager & | operator= (ResourceManager &&) noexcept=default |
| template<typename... Args> | |
| entt::resource< ResourceType > | Add (const entt::hashed_string &id, Args &&...args) |
| Adds a resource to the manager. | |
| ResourceType & | Get (const entt::hashed_string &id) |
| Get the reference to a stored resource. | |
| const ResourceType & | Get (const entt::hashed_string &id) const |
| Get the reference to a stored resource. | |
| void | Remove (const entt::hashed_string &id) |
| Delete an resource from the manager. | |
| bool | Contains (const entt::hashed_string &id) const |
| Check whenever the resource with given id exists in the manager. | |
| void | SetDefault (ResourceType &&resource) |
| Set the default resource that will be used as fallback. | |
| template<typename... Args> | |
| void | SetDefault (Args &&...args) |
| ResourceType & | GetDefault () |
| Get the default resource. | |
| const ResourceType & | GetDefault () const |
| Get the default resource. | |
| ResourceType & | GetOrDefault (const entt::hashed_string &id) |
| Get the reference to a stored resource, or the default resource if it doesn't exist. | |
| const ResourceType & | GetOrDefault (const entt::hashed_string &id) const |
| Get the reference to a stored resource, or the default resource if it doesn't exist. | |
| bool | HasDefault () const |
| Check if a default resource has been set. | |
Private Attributes | |
| entt::resource_cache< ResourceType, ResourceLoader > | cache {} |
| std::optional< ResourceType > | defaultResource = std::nullopt |
ResourceManager is a simple class that store resources. It provides methods to add, get, and remove resources. It should be used to manage resources like textures, shaders, and meshes.
|
default |
|
default |
|
delete |
|
defaultnoexcept |
|
inline |
Adds a resource to the manager.
| id | id of the resource |
| args | arguments to create the resource |
|
inlinenodiscard |
Check whenever the resource with given id exists in the manager.
| id | id of the resource |
|
inlinenodiscard |
Get the reference to a stored resource.
| ResourceManagerError | if the resource with given id doesn't exist. |
| id | id of the resource to get |
|
inlinenodiscard |
Get the reference to a stored resource.
| ResourceManagerError | if the resource with given id doesn't exist. |
| id | id of the resource to get |
|
inlinenodiscard |
Get the default resource.
| ResourceManagerError | if no default resource is set. |
|
inlinenodiscard |
Get the default resource.
| ResourceManagerError | if no default resource is set. |
|
inlinenodiscard |
Get the reference to a stored resource, or the default resource if it doesn't exist.
| ResourceManagerError | if the resource with given id doesn't exist and no default is set. |
| id | id of the resource to get |
|
inlinenodiscard |
Get the reference to a stored resource, or the default resource if it doesn't exist.
| ResourceManagerError | if the resource with given id doesn't exist and no default is set. |
| id | id of the resource to get |
|
inlinenodiscard |
Check if a default resource has been set.
|
delete |
|
defaultnoexcept |
|
inline |
Delete an resource from the manager.
| id | id of the resource to delete |
|
inline |
|
inline |
Set the default resource that will be used as fallback.
| ResourceManagerError | if the resource with given id doesn't exist. |
| id | id of the resource to use as default |
|
private |
|
private |