aboutsummaryrefslogtreecommitdiff
path: root/src/cptr.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-12-01 23:10:44 +0000
committerMike Buland <eichlan@xagasoft.com>2008-12-01 23:10:44 +0000
commit6f3b85c5af1855e1695885fb28220c34f6a0673f (patch)
tree07fc5d4f955bc6c58eb7ad88bcce7a8294c53158 /src/cptr.h
parent350b052cfd866e3b3c7c4626551b49f8b75e55a1 (diff)
downloadlibbu++-6f3b85c5af1855e1695885fb28220c34f6a0673f.tar.gz
libbu++-6f3b85c5af1855e1695885fb28220c34f6a0673f.tar.bz2
libbu++-6f3b85c5af1855e1695885fb28220c34f6a0673f.tar.xz
libbu++-6f3b85c5af1855e1695885fb28220c34f6a0673f.zip
Wow, that's a lot of changes. You can use anything as a key now, as long as it
can be hashed. And we're about to test actually loading and saving persistant cache items. Fun.
Diffstat (limited to 'src/cptr.h')
-rw-r--r--src/cptr.h18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/cptr.h b/src/cptr.h
index 6e54fdd..8f35a03 100644
--- a/src/cptr.h
+++ b/src/cptr.h
@@ -3,31 +3,29 @@
3 3
4namespace Bu 4namespace Bu
5{ 5{
6 template<class obtype> class Cache; 6 template<class obtype, class keytype> class Cache;
7 7
8 /** 8 /**
9 * Cache Pointer - Provides access to data that is held within the cache. 9 * Cache Pointer - Provides access to data that is held within the cache.
10 * This provides safe, refcounting access to data stored in the cache, with 10 * This provides safe, refcounting access to data stored in the cache, with
11 * support for lazy loading. 11 * support for lazy loading.
12 */ 12 */
13 template<class obtype> 13 template<class obtype, class keytype>
14 class CPtr 14 class CPtr
15 { 15 {
16 friend class Bu::Cache<obtype>; 16 friend class Bu::Cache<obtype, keytype>;
17 public:
18 typedef long cid_t; /**< Cache ID type. Unique cache entry ID. */
19 private: 17 private:
20 CPtr( Cache<obtype> &rCache, obtype *pData ) : 18 CPtr( Cache<obtype, keytype> &rCache, obtype *pData ) :
21 rCache( rCache ), 19 rCache( rCache ),
22 pData( pData ) 20 pData( pData )
23 { 21 {
24 rCache.incRef( cId ); 22 rCache.incRef( kId );
25 } 23 }
26 24
27 public: 25 public:
28 virtual ~CPtr() 26 virtual ~CPtr()
29 { 27 {
30 rCache.decRef( cId ); 28 rCache.decRef( kId );
31 } 29 }
32 30
33 obtype &operator*() 31 obtype &operator*()
@@ -41,9 +39,9 @@ namespace Bu
41 } 39 }
42 40
43 private: 41 private:
44 Bu::Cache<obtype> &rCache; 42 Bu::Cache<obtype, keytype> &rCache;
45 obtype *pData; 43 obtype *pData;
46 cid_t cId; 44 keytype kId;
47 }; 45 };
48}; 46};
49 47