#include <ResourceManager.hpp>
|
template<typename T , typename... Args> |
static T & | get (Args &&...args) |
| Get a resource. More...
|
|
template<typename T , typename... Args> |
static T & | getNamed (const std::string &name, Args &&...args) |
| Get a named resource. More...
|
|
template<typename T , typename... Args> |
static T & | getEmpty (Args &&...args) |
| Get an empty resource. More...
|
|
template<typename T > |
static T & | getExisting (const std::string &name) |
| Get an existing resource. More...
|
|
template<typename T > |
static bool | exists (const std::string &name) |
| Check is a resource exists. More...
|
|
template<typename T > |
static T & | copy (const std::string &name, const std::string &newName) |
| Copy a resource. More...
|
|
static void | unload (const std::string &name) |
| Delete resources. More...
|
|
template<typename T > |
static void | unload (const std::string &name) |
| Delete a resource from memory. More...
|
|
static void | unload (const unsigned short persistence=0xFFFF, const bool descending=true) |
| Delete all resources. More...
|
|
static void | beginLoadPhase () |
| Mark the beginning of a resource loading phase. More...
|
|
static void | endLoadPhase (const uint16 persistence) |
| Mark the ending of a resource loading phase. More...
|
|
template<typename T > |
static bool | isDefault (const T &resource) |
| Check is a resource is the default resource. More...
|
|
template<typename T > |
static bool | isError (const T &resource) |
| Check is a resource is the error resource. More...
|
|
Definition at line 54 of file ResourceManager.hpp.
jop::ResourceManager::ResourceManager |
( |
| ) |
|
jop::ResourceManager::~ResourceManager |
( |
| ) |
|
|
override |
static void jop::ResourceManager::beginLoadPhase |
( |
| ) |
|
|
static |
Mark the beginning of a resource loading phase.
This function is provided to make it easier to manage big amounts of resources. When called, every resource that is referenced after, will become flagged. When the load phase is ended, all resources not flagged will be removed, provided they pass the persistence test.
- Warning
- It's very important to call endLoadPhase() after this, right after all the needed resources are loaded
- See also
- endLoadPhase()
template<typename T >
static T& jop::ResourceManager::copy |
( |
const std::string & |
name, |
|
|
const std::string & |
newName |
|
) |
| |
|
static |
Copy a resource.
This function requires that the resource has a valid copy constructor. If the resource is not found or is of the wrong type, the default/error resource will be returned instead.
- Parameters
-
name | Name of the resource to copy |
newName | Name of the copied resource |
- Returns
- Reference to the resource
- See also
- Resource::Resource(const Resource&, const std::string&)
static void jop::ResourceManager::endLoadPhase |
( |
const uint16 |
persistence | ) |
|
|
static |
Mark the ending of a resource loading phase.
If a load phase was previously initiated, calling this function will end it and clear all resources as described on beginLoadPhase().
- Parameters
-
persistence | The maximum persistence level to take into account. Resources with equal or greater persistence level will be removed |
- See also
- beginLoadPhase()
template<typename T >
static bool jop::ResourceManager::exists |
( |
const std::string & |
name | ) |
|
|
static |
Check is a resource exists.
The name and type must both match.
- Parameters
-
- Returns
- True if the resource exists
template<typename T , typename... Args>
static T& jop::ResourceManager::get |
( |
Args &&... |
args | ) |
|
|
static |
Get a resource.
If resource is not found this creates a new one. The first argument must be convertible into std::string, as it's used as a hash map key.
- Parameters
-
args | Arguments passed to resource's constructor |
- Returns
- Reference to the resource
template<typename T , typename... Args>
static T& jop::ResourceManager::getEmpty |
( |
Args &&... |
args | ) |
|
|
static |
Get an empty resource.
This function will not call the resource's load function.
- Parameters
-
args | Arguments to pass to the resource's constructor |
- Returns
- Reference to the resource
template<typename T >
static T& jop::ResourceManager::getExisting |
( |
const std::string & |
name | ) |
|
|
static |
Get an existing resource.
This function will not attempt to create the resource if it's not found or is not of the matching type. Instead a default is returned.
- Parameters
-
- Returns
- Reference to the resource
template<typename T , typename... Args>
static T& jop::ResourceManager::getNamed |
( |
const std::string & |
name, |
|
|
Args &&... |
args |
|
) |
| |
|
static |
Get a named resource.
This is primarily used when the resource is not loaded from a file. After the resource has been loaded once, it can be retrieved by using getExisting().
- Parameters
-
name | Name for the resource |
args | Arguments passed to resource's constructor |
- Returns
- Reference to the resource
template<typename T >
static bool jop::ResourceManager::isDefault |
( |
const T & |
resource | ) |
|
|
static |
Check is a resource is the default resource.
- Parameters
-
resource | Reference to the resource |
- Returns
- True if the resource is the default resource
template<typename T >
static bool jop::ResourceManager::isError |
( |
const T & |
resource | ) |
|
|
static |
Check is a resource is the error resource.
- Parameters
-
resource | Reference to the resource |
- Returns
- True if the resource is the error resource
static void jop::ResourceManager::unload |
( |
const std::string & |
name | ) |
|
|
static |
Delete resources.
This will delete all the resources with the given name, regardless of type.
The resources, if found, will be deleted regardless of the persistence level. Resources with the persistence level of 0 will not be removed, however.
- Parameters
-
name | Name of the resources to unload |
template<typename T >
static void jop::ResourceManager::unload |
( |
const std::string & |
name | ) |
|
|
static |
Delete a resource from memory.
The resource, if found, will be deleted regardless of the persistence level. Resources with the persistence level of 0 will not be removed, however.
When possible, you should prefer this overload. It's possibly magnitudes faster.
- Parameters
-
static void jop::ResourceManager::unload |
( |
const unsigned short |
persistence = 0xFFFF , |
|
|
const bool |
descending = true |
|
) |
| |
|
static |
Delete all resources.
- Parameters
-
persistence | The persistence of the resources to unload |
descending | Set true to unload all resources with the given and greater persistence levels |
The documentation for this class was generated from the following file: