This repository has been archived on 2023-10-28. You can view files and clone it, but cannot push or open issues or pull requests.
frostbite/snowlib/LmpRepository.h
2020-02-06 00:23:46 +00:00

39 lines
670 B
C++

#pragma once
#include <unordered_map>
#include "LmpFile.h"
using namespace std;
class LmpRepository
{
public:
virtual LmpFile* getLmp(string lmpName) = 0;
};
/// Stores Lmp Files
class LmpRepositoryImpl : public LmpRepository
{
unordered_map<string, LmpFile*> lmpFileMap;
string dataPath;
GameType gameType;
LmpFile* readLmpFile(string lmpName);
public:
LmpRepositoryImpl(string dataPath, GameType gameType)
{
this->dataPath = dataPath;
this->gameType = gameType;
}
~LmpRepositoryImpl();
LmpFile* getLmp(string lmpName)
{
if (lmpFileMap.count(lmpName) == 0){
lmpFileMap[lmpName] = readLmpFile(lmpName);
}
return lmpFileMap[lmpName];
}
};