aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Input/in_wmvdrm/CachedData.h
blob: 8782ead1f5a5ace0ba48de4eb3ffea764d016c83 (plain) (blame)
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
#ifndef CACHEDDATAH
#define CACHEDDATAH

template <class DataType>
class CachedData
{
public:
	CachedData() : cached(false)
	{
	}
	CachedData(DataType _data) : cached(true), data(_data)
	{
	}
	operator DataType()
	{
		return data;
	}

	bool IsCached()
	{
		return cached;
	}
	void ClearCache()
	{
		cached=false;
	}
	DataType *operator &()
	{
		if (cached)
			return &data;
		else
			return 0;
	}

	template <class FromType>
	bool operator =(FromType from)
	{
		data = from;
		cached=true;
		return cached;
	}

private:
	bool cached;
	DataType data;
};

#endif