aboutsummaryrefslogtreecommitdiff
path: root/src/cachecalc.h
blob: 7fdb16eab0dc9f73e1cc2d86f56ff3a48db255d1 (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
51
52
53
54
#ifndef BU_CACHE_CALC_H
#define BU_CACHE_CALC_H

#include "bu/trace.h"

#include <time.h>

namespace Bu
{
	template<class obtype, class keytype> class Cache;

	template<class obtype, class keytype>
	class CacheCalc
	{
	friend class Cache<obtype, keytype>;
	private:
		typedef Cache<obtype, keytype> MyCache;
	public:
		CacheCalc() :
			pCache( (MyCache *)0 )
		{
			TRACE();
		}

		virtual ~CacheCalc()
		{
			TRACE();
		}

		virtual void onLoad( obtype *pSrc, const keytype &key )=0;
		virtual void onUnload( obtype *pSrc, const keytype &key )=0;
		virtual bool shouldSync( obtype *pSrc, const keytype &key,
			time_t tLastSync )=0;
		virtual void onTick() { };

	protected:
		MyCache *getCache()
		{
			TRACE();
			return pCache;
		}

	private:
		void setCache( MyCache *pCache )
		{
			TRACE();
			this->pCache = pCache;
		}

		MyCache *pCache;
	};
};

#endif