The Resource Management Structure will consist in the next management structures:
Resource Registry: Manages the resources currently loaded in project "memory".
Resource Loader: Manages the Resource Loading (ResourceLoader::Load(path));
Resource Importer Manages the Resource Importing (Creating the objects and caching if its necessary)
Pseudocode:
// Resource Loader
Ref<T> ResourceLoader::Load(path)
{
//detect resource type
if(ResourceRegistry::Exist(resource))
{
return resource;
}
else
{
resource r = ResourceImporter....
ResourceRegistry::Add(r)
return r;
}
}
//Resource Importer
//Check if the imported resource is cached...
//If not cache it and load it
if is cached load the cached file
//Usage Example
Ref<Texture> a = ResourceLoader::Load<Texture>(path);
The base of the Resource Management is implemented. Few things that are missing:
[x] Think to move all the Resource Related Classes from .cpp/.h to .h.
[x] Think if SaveToCache and LoadFromCache should be converted to Templates
[ ] Port Model Resource Management and Serialize Models and Meshes
[ ] Think of making the Importer dependant of the Loader
[x] Think of removing the Importer and Instead Manage the Resource Importing from the Loader and the Cache form a ResourceCache class.
[ ] Add A way to check if the cache is old, and re do it.
[ ] Make the system more flexible to be able to choose if the resource will be cached, the caching formatand be able to save the resource in a folder outside of the cached folder (for example for saving a material as a json).
[ ] Create a Resource Saver that allow you to save the resource in the project directory (for example for saving a material as a json).
The Resource Management Structure will consist in the next management structures:
Pseudocode: