Class template for a resource container.
More...
#include <ResourceHolder.h>
|
using | Ptr = std::shared_ptr< T > |
| Shared T pointer. More...
|
|
|
| ResourceHolder (const std::string &filePath) |
| Construct a resource holder. More...
|
|
void | setPath (const std::string &filepath) |
| Change the path where resources are located on the disk. More...
|
|
const std::string & | getPath () const |
| Get the path to the resources being held. More...
|
|
bool | loadFromFile (const std::string &filename) |
| Load a resource from the disk and store it in a buffer. More...
|
|
bool | unload (const std::string &filename) |
| Remove a resource from the resource holder. More...
|
|
bool | unloadAll () |
| Remove all resources from the resource holder. More...
|
|
ResourceHolder::Ptr | get (const std::string &filename) |
| Get a resource. More...
|
|
unsigned int | getSize () const |
| Get the number of resources in the resource holder. More...
|
|
bool | hasResource (const std::string &filename) const |
| Check if a resource exists or not. More...
|
|
template<class T>
class ime::ResourceHolder< T >
Class template for a resource container.
Definition at line 41 of file ResourceHolder.h.
◆ Ptr
◆ ResourceHolder()
Construct a resource holder.
- Parameters
-
filePath | Path to the resource to store |
◆ get()
Get a resource.
- Parameters
-
filename | Filename of the resource to be retrieved |
- Exceptions
-
- Returns
- Shared pointer to a resource in a buffer
If the specified resource does not exist in the resource holder, an attempt will be made to load it from the disk. If it cannot be loaded from the disk, a "FileNotFound" exception will be raised. This means that the returned pointer can never be a nullptr
◆ getPath()
Get the path to the resources being held.
- Returns
- The path to the resource on the disk
This path is where the program looks for the specified resources when loading them
◆ getSize()
Get the number of resources in the resource holder.
- Returns
- The number of resources in the resource holder
◆ hasResource()
Check if a resource exists or not.
- Parameters
-
filename | Filename of the resource to check |
- Returns
- True if the resource exists, otherwise false
◆ loadFromFile()
Load a resource from the disk and store it in a buffer.
- Parameters
-
filename | Filename of the resource to load |
- Exceptions
-
- Returns
- True if resource was loaded successfully, otherwise false
This function will look for the resource in the file path specified during instantiation. A FileNotFound exception will be raised if the resource with the specified filename cannot be found
◆ setPath()
Change the path where resources are located on the disk.
- Parameters
-
filepath | Path to the resources to store |
This new path is where the program will search for resources when loading them
◆ unload()
Remove a resource from the resource holder.
- Parameters
-
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
◆ unloadAll()
Remove all resources from the resource holder.
- Returns
- True if all the resource were removed or false if the resource holder is already empty
The documentation for this class was generated from the following file: