Documentation for Resource

Former-commit-id: 7da8bc4261566c89030eb0226a29b1a70183e68a
This commit is contained in:
Gawaboumga
2016-02-21 14:27:29 +01:00
parent e311dcb5d3
commit f16857fc6a
3 changed files with 175 additions and 9 deletions

View File

@@ -9,12 +9,28 @@
namespace Nz
{
/*!
* \class Nz::ResourceManager<Type, Parameters>
* \brief Core class that represents a resource manager
*/
/*!
* \brief Clears the content of the manager
*/
template<typename Type, typename Parameters>
void ResourceManager<Type, Parameters>::Clear()
{
Type::s_managerMap.clear();
}
/*!
* \brief Gets a reference to the object loaded from file
* \return Reference to the object
*
* \param filePath Path to the asset that will be loaded
*/
template<typename Type, typename Parameters>
ObjectRef<Type> ResourceManager<Type, Parameters>::Get(const String& filePath)
{
@@ -43,12 +59,21 @@ namespace Nz
return it->second;
}
/*!
* \brief Gets the defaults parameters for the load
* \return Default parameters for loading from file
*/
template<typename Type, typename Parameters>
const Parameters& ResourceManager<Type, Parameters>::GetDefaultParameters()
{
return Type::s_managerParameters;
}
/*!
* \brief Purges the resource manager from every asset whose it is the only owner
*/
template<typename Type, typename Parameters>
void ResourceManager<Type, Parameters>::Purge()
{
@@ -56,16 +81,23 @@ namespace Nz
while (it != Type::s_managerMap.end())
{
const ObjectRef<Type>& ref = it->second;
if (ref.GetReferenceCount() == 1) // Sommes-nous les seuls à détenir la ressource ?
if (ref.GetReferenceCount() == 1) // Are we the only ones to own the resource ?
{
NazaraDebug("Purging resource from file " + ref->GetFilePath());
Type::s_managerMap.erase(it++); // Alors on la supprime
Type::s_managerMap.erase(it++); // Then we erase it
}
else
++it;
}
}
/*!
* \brief Registers the resource under the filePath
*
* \param filePath Path for the resource
* \param resource Object to associate with
*/
template<typename Type, typename Parameters>
void ResourceManager<Type, Parameters>::Register(const String& filePath, ObjectRef<Type> resource)
{
@@ -74,12 +106,24 @@ namespace Nz
Type::s_managerMap[absolutePath] = resource;
}
/*!
* \brief Sets the defaults parameters for the load
*
* \param params Default parameters for loading from file
*/
template<typename Type, typename Parameters>
void ResourceManager<Type, Parameters>::SetDefaultParameters(const Parameters& params)
{
Type::s_managerParameters = params;
}
/*!
* \brief Unregisters the resource under the filePath
*
* \param filePath Path for the resource
*/
template<typename Type, typename Parameters>
void ResourceManager<Type, Parameters>::Unregister(const String& filePath)
{
@@ -88,12 +132,21 @@ namespace Nz
Type::s_managerMap.erase(absolutePath);
}
/*!
* \brief Initializes the resource manager
* \return true
*/
template<typename Type, typename Parameters>
bool ResourceManager<Type, Parameters>::Initialize()
{
return true;
}
/*!
* \brief Uninitialize the resource manager
*/
template<typename Type, typename Parameters>
void ResourceManager<Type, Parameters>::Uninitialize()
{