summaryrefslogtreecommitdiff
path: root/SkinEngine/src/xml_cache.h
blob: 50e30e0bb7f1791f0d8b073924c47fbfe0add223 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef xml_cache_h__
#define xml_cache_h__

class CXmlCache
{
private:
	struct CachedFile
	{
		TCHAR *path;
		HXML hXmlRoot;

		CachedFile(const TCHAR *path, bool load=true);
		~CachedFile();

		static int cmp(const CachedFile *p1, const CachedFile *p2)
		{
			return lstrcmp(p1->path, p2->path);
		}
	};

	struct CachedClass
	{
		const TCHAR *name;
		CachedFile *file;
		HXML hXml;

		static int cmp(const CachedClass *p1, const CachedClass *p2)
		{
			return lstrcmp(p1->name, p2->name);
		}
	};

	OBJLIST<CachedClass> m_classes;
	OBJLIST<CachedFile> m_files;

	void RegisterClass(const TCHAR *name, CachedFile *file, HXML hXmlClass);

public:
	CXmlCache();
	~CXmlCache();

	void LoadXmlFile(const TCHAR *path);
	void UnloadXmlFile(const TCHAR *path);

	ISkinElement *CreateObject(const TCHAR *name);
};

extern CXmlCache g_XmlCache;

#endif // xml_cache_h__