summaryrefslogtreecommitdiff
path: root/cache.h
blob: 3734293df8a3b1deb8c06bf5702dfcfe96b432e3 (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
/*
 * $Id: cache.h,v 1.1.1.1 2004/11/19 16:45:31 lordjaxom Exp $
 */

#ifndef VDR_TEXT2SKIN_CACHE_HPP
#define VDR_TEXT2SKIN_CACHE_HPP

#include "common.h"
#include <map>
#include <vector>
#include <vdr/tools.h>

class cText2SkinBitmap;

class cText2SkinCache {
private:
	typedef std::string       key_type;
	typedef cText2SkinBitmap* data_type;

	typedef std::map<key_type,data_type> item_map;
	typedef item_map::iterator item_iterator;
	typedef std::vector<key_type> usage_list;
	typedef usage_list::iterator usage_iterator;

	item_map   mItems;
	usage_list mUsage;
	int        mMaxItems;

protected:
	void Delete(const key_type &Key, data_type &Data);

public:
	cText2SkinCache(int MaxItems);
	~cText2SkinCache();

	void Reset(void);
	void Flush(void);
	bool Contains(const key_type &Key);
	data_type &operator[](const key_type &Key);
	uint Count(void) { return mItems.size(); }
};

inline bool cText2SkinCache::Contains(const key_type &Key) {
	return mItems.find(Key) != mItems.end();
}

#endif // VDR_TEXT2SKIN_CACHE_HPP