summaryrefslogtreecommitdiff
path: root/src/ModuleCache.h
blob: e8a458076d9050818fc3250d0b697edad1a5f9a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <string>
#include <boost/unordered_map.hpp>

/*!
	Caches FileModules based on their filenames
*/
class ModuleCache
{
public:
	static ModuleCache *instance() { if (!inst) inst = new ModuleCache; return inst; }
	class FileModule *evaluate(const std::string &filename);
	class FileModule *lookup(const std::string &filename);
	bool isCached(const std::string &filename);
	size_t size() { return this->entries.size(); }
	void clear();

private:
	ModuleCache() {}
	~ModuleCache() {}

	static ModuleCache *inst;

	struct cache_entry {
		class FileModule *module;
		std::string cache_id;
	};
	boost::unordered_map<std::string, cache_entry> entries;
};
contact: Jan Huwald // Impressum