Switch from Nz prefix to namespace Nz

What a huge commit


Former-commit-id: 38ac5eebf70adc1180f571f6006192d28fb99897
This commit is contained in:
Lynix
2015-09-25 19:20:05 +02:00
parent c214251ecf
commit df8da275c4
609 changed files with 68265 additions and 66534 deletions

View File

@@ -7,95 +7,98 @@
#include <Nazara/Core/Log.hpp>
#include <Nazara/Core/Debug.hpp>
template<typename Type, typename Parameters>
void NzResourceManager<Type, Parameters>::Clear()
namespace Nz
{
Type::s_managerMap.clear();
}
template<typename Type, typename Parameters>
NzObjectRef<Type> NzResourceManager<Type, Parameters>::Get(const NzString& filePath)
{
NzString absolutePath = NzFile::AbsolutePath(filePath);
auto it = Type::s_managerMap.find(absolutePath);
if (it == Type::s_managerMap.end())
template<typename Type, typename Parameters>
void ResourceManager<Type, Parameters>::Clear()
{
NzObjectRef<Type> resource = Type::New();
if (!resource)
{
NazaraError("Failed to create resource");
return NzObjectRef<Type>();
}
if (!resource->LoadFromFile(absolutePath, GetDefaultParameters()))
{
NazaraError("Failed to load resource from file: " + absolutePath);
return NzObjectRef<Type>();
}
NazaraDebug("Loaded resource from file " + absolutePath);
it = Type::s_managerMap.insert(std::make_pair(absolutePath, resource)).first;
Type::s_managerMap.clear();
}
return it->second;
}
template<typename Type, typename Parameters>
const Parameters& NzResourceManager<Type, Parameters>::GetDefaultParameters()
{
return Type::s_managerParameters;
}
template<typename Type, typename Parameters>
void NzResourceManager<Type, Parameters>::Purge()
{
auto it = Type::s_managerMap.begin();
while (it != Type::s_managerMap.end())
template<typename Type, typename Parameters>
ObjectRef<Type> ResourceManager<Type, Parameters>::Get(const String& filePath)
{
const NzObjectRef<Type>& ref = it->second;
if (ref.GetReferenceCount() == 1) // Sommes-nous les seuls à détenir la ressource ?
String absolutePath = File::AbsolutePath(filePath);
auto it = Type::s_managerMap.find(absolutePath);
if (it == Type::s_managerMap.end())
{
NazaraDebug("Purging resource from file " + ref->GetFilePath());
Type::s_managerMap.erase(it++); // Alors on la supprime
ObjectRef<Type> resource = Type::New();
if (!resource)
{
NazaraError("Failed to create resource");
return ObjectRef<Type>();
}
if (!resource->LoadFromFile(absolutePath, GetDefaultParameters()))
{
NazaraError("Failed to load resource from file: " + absolutePath);
return ObjectRef<Type>();
}
NazaraDebug("Loaded resource from file " + absolutePath);
it = Type::s_managerMap.insert(std::make_pair(absolutePath, resource)).first;
}
else
++it;
return it->second;
}
}
template<typename Type, typename Parameters>
void NzResourceManager<Type, Parameters>::Register(const NzString& filePath, NzObjectRef<Type> resource)
{
NzString absolutePath = NzFile::AbsolutePath(filePath);
template<typename Type, typename Parameters>
const Parameters& ResourceManager<Type, Parameters>::GetDefaultParameters()
{
return Type::s_managerParameters;
}
Type::s_managerMap[absolutePath] = resource;
}
template<typename Type, typename Parameters>
void ResourceManager<Type, Parameters>::Purge()
{
auto it = Type::s_managerMap.begin();
while (it != Type::s_managerMap.end())
{
const ObjectRef<Type>& ref = it->second;
if (ref.GetReferenceCount() == 1) // Sommes-nous les seuls à détenir la ressource ?
{
NazaraDebug("Purging resource from file " + ref->GetFilePath());
Type::s_managerMap.erase(it++); // Alors on la supprime
}
else
++it;
}
}
template<typename Type, typename Parameters>
void NzResourceManager<Type, Parameters>::SetDefaultParameters(const Parameters& params)
{
Type::s_managerParameters = params;
}
template<typename Type, typename Parameters>
void ResourceManager<Type, Parameters>::Register(const String& filePath, ObjectRef<Type> resource)
{
String absolutePath = File::AbsolutePath(filePath);
template<typename Type, typename Parameters>
void NzResourceManager<Type, Parameters>::Unregister(const NzString& filePath)
{
NzString absolutePath = NzFile::AbsolutePath(filePath);
Type::s_managerMap[absolutePath] = resource;
}
Type::s_managerMap.erase(absolutePath);
}
template<typename Type, typename Parameters>
void ResourceManager<Type, Parameters>::SetDefaultParameters(const Parameters& params)
{
Type::s_managerParameters = params;
}
template<typename Type, typename Parameters>
bool NzResourceManager<Type, Parameters>::Initialize()
{
return true;
}
template<typename Type, typename Parameters>
void ResourceManager<Type, Parameters>::Unregister(const String& filePath)
{
String absolutePath = File::AbsolutePath(filePath);
template<typename Type, typename Parameters>
void NzResourceManager<Type, Parameters>::Uninitialize()
{
Clear();
Type::s_managerMap.erase(absolutePath);
}
template<typename Type, typename Parameters>
bool ResourceManager<Type, Parameters>::Initialize()
{
return true;
}
template<typename Type, typename Parameters>
void ResourceManager<Type, Parameters>::Uninitialize()
{
Clear();
}
}
#include <Nazara/Core/DebugOff.hpp>