aboutsummaryrefslogtreecommitdiff
path: root/src/experimental/cachecalc.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-03-25 20:00:08 +0000
committerMike Buland <eichlan@xagasoft.com>2012-03-25 20:00:08 +0000
commit469bbcf0701e1eb8a6670c23145b0da87357e178 (patch)
treeb5b062a16e46a6c5d3410b4e574cd0cc09057211 /src/experimental/cachecalc.h
parentee1b79396076edc4e30aefb285fada03bb45e80d (diff)
downloadlibbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.gz
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.bz2
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.xz
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.zip
Code is all reorganized. We're about ready to release. I should write up a
little explenation of the arrangement.
Diffstat (limited to 'src/experimental/cachecalc.h')
-rw-r--r--src/experimental/cachecalc.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/experimental/cachecalc.h b/src/experimental/cachecalc.h
new file mode 100644
index 0000000..89cfadc
--- /dev/null
+++ b/src/experimental/cachecalc.h
@@ -0,0 +1,63 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#ifndef BU_CACHE_CALC_H
9#define BU_CACHE_CALC_H
10
11#include "bu/trace.h"
12
13#include <time.h>
14
15namespace Bu
16{
17 template<class keytype, class obtype> class Cache;
18
19 template<class keytype, class obtype>
20 class CacheCalc
21 {
22 friend class Cache<keytype, obtype>;
23 private:
24 typedef Cache<keytype, obtype> MyCache;
25 public:
26 CacheCalc() :
27 pCache( (MyCache *)0 )
28 {
29 TRACE();
30 }
31
32 virtual ~CacheCalc()
33 {
34 TRACE();
35 }
36
37 virtual void onLoad( obtype *pSrc, const keytype &key )=0;
38 virtual void onUnload( obtype *pSrc, const keytype &key )=0;
39 virtual void onDestroy( obtype *pSrc, const keytype &key )=0;
40 virtual void onDestroy( const keytype &key )=0;
41 virtual bool shouldSync( obtype *pSrc, const keytype &key,
42 time_t tLastSync )=0;
43 virtual void onTick() { };
44
45 protected:
46 MyCache *getCache()
47 {
48 TRACE();
49 return pCache;
50 }
51
52 private:
53 void setCache( MyCache *pCache )
54 {
55 TRACE();
56 this->pCache = pCache;
57 }
58
59 MyCache *pCache;
60 };
61};
62
63#endif