aboutsummaryrefslogtreecommitdiff
path: root/src/cptr.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-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