aboutsummaryrefslogtreecommitdiff
path: root/src/cptr.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/cptr.h')
-rw-r--r--src/cptr.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/cptr.h b/src/cptr.h
index 5aafbd3..6e54fdd 100644
--- a/src/cptr.h
+++ b/src/cptr.h
@@ -5,22 +5,29 @@ namespace Bu
5{ 5{
6 template<class obtype> class Cache; 6 template<class obtype> class Cache;
7 7
8 /**
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
11 * support for lazy loading.
12 */
8 template<class obtype> 13 template<class obtype>
9 class CPtr 14 class CPtr
10 { 15 {
11 friend class Bu::Cache<obtype>; 16 friend class Bu::Cache<obtype>;
17 public:
18 typedef long cid_t; /**< Cache ID type. Unique cache entry ID. */
12 private: 19 private:
13 CPtr( Cache<obtype> &rCache, obtype *pData ) : 20 CPtr( Cache<obtype> &rCache, obtype *pData ) :
14 rCache( rCache ), 21 rCache( rCache ),
15 pData( pData ) 22 pData( pData )
16 { 23 {
17 rCache.incRef( pData ); 24 rCache.incRef( cId );
18 } 25 }
19 26
20 public: 27 public:
21 virtual ~CPtr() 28 virtual ~CPtr()
22 { 29 {
23 rCache.decRef( pData ); 30 rCache.decRef( cId );
24 } 31 }
25 32
26 obtype &operator*() 33 obtype &operator*()
@@ -36,6 +43,7 @@ namespace Bu
36 private: 43 private:
37 Bu::Cache<obtype> &rCache; 44 Bu::Cache<obtype> &rCache;
38 obtype *pData; 45 obtype *pData;
46 cid_t cId;
39 }; 47 };
40}; 48};
41 49