You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
644 B
C++
41 lines
644 B
C++
#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;
|
|
}
|
|
}
|
|
|
|
}
|