summaryrefslogtreecommitdiff
path: root/src/unstable/cacheobject.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/unstable/cacheobject.h34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/unstable/cacheobject.h b/src/unstable/cacheobject.h
index e83f706..ca70bb4 100644
--- a/src/unstable/cacheobject.h
+++ b/src/unstable/cacheobject.h
@@ -21,6 +21,7 @@ namespace Bu
21 class CacheObject 21 class CacheObject
22 { 22 {
23 friend class CacheBase<keytype, obtype>; 23 friend class CacheBase<keytype, obtype>;
24 //friend class CacheObject<keytype, obtype>::Initializer;
24 public: 25 public:
25 CacheObject() : 26 CacheObject() :
26 pCache( NULL ), 27 pCache( NULL ),
@@ -35,6 +36,7 @@ namespace Bu
35 36
36 typedef CacheObject<keytype, obtype> MyType; 37 typedef CacheObject<keytype, obtype> MyType;
37 typedef CacheBase<keytype, obtype> CacheType; 38 typedef CacheBase<keytype, obtype> CacheType;
39 typedef CacheEntry<keytype, obtype> EntryType;
38 40
39 virtual keytype getKey() const=0; 41 virtual keytype getKey() const=0;
40 virtual int getPersistenceScore() const { return 0; } 42 virtual int getPersistenceScore() const { return 0; }
@@ -94,18 +96,44 @@ namespace Bu
94 { 96 {
95 return pCache; 97 return pCache;
96 } 98 }
99
100 public:
101 class Initializer
102 {
103 friend class CacheBase<keytype,obtype>;
104 private:
105 Initializer( CacheBase<keytype,obtype> *pCache ) :
106 pCache( pCache )
107 {
108 }
109
110 public:
111 template<typename subtype>
112 subtype *operator()( subtype *pNewObj )
113 {
114 pNewObj->setCache( pCache );
115 return pNewObj;
116 }
117
118 private:
119 CacheBase<keytype,obtype> *pCache;
120 };
121
97 122
98 private: 123 private:
99 typedef CacheEntry<keytype, obtype> Entry; 124 void setCache( CacheType *pCache )
100 void setCache( CacheType *pCache, Entry *pEntry )
101 { 125 {
102 this->pCache = pCache; 126 this->pCache = pCache;
127 }
128
129 void setCacheEntry( EntryType *pEntry )
130 {
103 this->pEntry = pEntry; 131 this->pEntry = pEntry;
104 } 132 }
105 133
106 private: 134 private:
107 CacheType *pCache; 135 CacheType *pCache;
108 Entry *pEntry; 136 EntryType *pEntry;
109 bool bChanged; 137 bool bChanged;
110 }; 138 };
111} 139}