Load resources from the disk into the program.
More...
#include <ResourceLoader.h>
|
using | FileNameList = std::initializer_list< std::string > |
| List of filenames to be loaded. More...
|
|
using | Callback = std::function< void(const std::string &)> |
| Resource load completion callback. More...
|
|
Load resources from the disk into the program.
Definition at line 37 of file ResourceLoader.h.
◆ Callback
◆ FileNameList
◆ getPath()
static std::string ime::ResourceLoader::getPath |
( |
ResourceType |
type | ) |
|
|
static |
Get the path of a resource type.
- Parameters
-
type | The type to get the path for |
- Returns
- The path for the specified resource type type
The path is where the engine looks when loading a resource of the specified type from the disk
- See also
- setPath
◆ loadFromFile() [1/2]
load multiple resources of the same type from the disk
- Parameters
-
type | Type of the resources to be loaded |
filenames | Filenames of the resources to be loaded |
callback | Function to execute after successful load of each resource |
- Exceptions
-
The callback is passed the name of the resource that was loaded
◆ loadFromFile() [2/2]
static bool ime::ResourceLoader::loadFromFile |
( |
ResourceType |
type, |
|
|
const std::string & |
filename |
|
) |
| |
|
static |
Load a resource from the disk.
- Parameters
-
type | Type of the resource to be loaded |
filename | Filename of the resource to be loaded |
- Exceptions
-
- Returns
- Returns true when the resource was loaded successfully
This function will cache any resource that is successfully loaded from the disk into the program such that is is not reloaded the next time it is required
◆ setPath()
static void ime::ResourceLoader::setPath |
( |
ResourceType |
type, |
|
|
const std::string & |
path |
|
) |
| |
|
static |
Set the path where the engine looks when loading a resource type from disk.
- Parameters
-
type | The type to set the path for |
path | The new path for the resource type |
Note that changing the path of either ime::ResourceType::Image or ime::ResourceType::Texture changes the other
- See also
- getPath
◆ unload()
static bool ime::ResourceLoader::unload |
( |
ResourceType |
type, |
|
|
const std::string & |
filename |
|
) |
| |
|
static |
Unload a resource from the program.
- Parameters
-
type | The type of the resource to be unloaded |
filename | Filename of the resource to be removed |
- Returns
- True if the resource was successfully removed, or false if the resource with the given filename does not exist
- Note
- The resource will only be removed from the program once its not being used. In other words, if the resource is currently being used, this function only flags it for removal at a later time
◆ unloadAll() [1/2]
static void ime::ResourceLoader::unloadAll |
( |
| ) |
|
|
static |
Remove all resources from the resource holder.
- Note
- The resources will only be removed from the program once they are no longer being used. In other words, if the resource is currently being used, this function only flags it for removal at a later time
◆ unloadAll() [2/2]
static void ime::ResourceLoader::unloadAll |
( |
ResourceType |
type | ) |
|
|
static |
Unload all resources of a given type from the program.
- Parameters
-
type | The type of the resources to be unloaded |
- Note
- The resources will only be removed from the program once they are no longer being used. In other words, if the resource is currently being used, this function only flags it for removal at a later time
The documentation for this class was generated from the following file: