1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 06:49:55 +00:00
openmw-tes3mp/components/nifcache/nifcache.cpp

41 lines
644 B
C++
Raw Normal View History

#include "nifcache.hpp"
namespace Nif
{
Cache* Cache::sThis = 0;
Cache& Cache::getInstance()
{
assert (sThis);
return *sThis;
}
Cache* Cache::getInstancePtr()
{
return sThis;
}
Cache::Cache()
{
assert (!sThis);
sThis = this;
}
NIFFilePtr Cache::load(const std::string &filename)
{
// TODO: normalize file path to make sure we're not loading the same file twice
LoadedMap::iterator it = mLoadedMap.find(filename);
if (it != mLoadedMap.end())
return it->second;
else
{
NIFFilePtr file(new Nif::NIFFile(filename));
mLoadedMap[filename] = file;
return file;
}
}
}