42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
#ifndef WC3RE_RESOURCEPROVIDER_HH__
|
|
#define WC3RE_RESOURCEPROVIDER_HH__
|
|
|
|
#include "Singleton.hh"
|
|
#include "TreFile.hh"
|
|
#include "IffFile.hh"
|
|
|
|
class Resource;
|
|
class MmapFile;
|
|
|
|
class ResourceProvider : public Singleton<ResourceProvider> {
|
|
private:
|
|
ResourceProvider();
|
|
friend class Singleton<ResourceProvider>;
|
|
|
|
public:
|
|
~ResourceProvider();
|
|
|
|
Resource::Handle getResource(std::string const& path);
|
|
|
|
IffFile::Handle getIff(std::string const& path);
|
|
TreFile::Handle getTre(std::string const& path);
|
|
|
|
private:
|
|
void gc_();
|
|
void dumpCache_() const;
|
|
|
|
MmapFile& getMmap_(std::string const& ospath);
|
|
TreFile& getTre_(std::string const& ospath);
|
|
TreFile::Object& getTreObj_(std::string const& path);
|
|
IffFile& getIff_(std::string const& path);
|
|
IffFile::Object& getIffObj_(IffFile& iff, std::string const& nodepath);
|
|
|
|
size_t cacheSize_, cacheLimit_;
|
|
std::unordered_map<std::string, std::unique_ptr<MmapFile> > files_;
|
|
std::unordered_map<std::string, std::unique_ptr<TreFile> > tres_;
|
|
std::unordered_map<std::string, std::unique_ptr<TreFile::Object> > treObjs_;
|
|
std::unordered_map<std::string, std::unique_ptr<IffFile> > iffs_;
|
|
};
|
|
|
|
#endif
|