aboutsummaryrefslogtreecommitdiff
path: root/src/cptr.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-12-01 17:20:26 +0000
committerMike Buland <eichlan@xagasoft.com>2008-12-01 17:20:26 +0000
commit350b052cfd866e3b3c7c4626551b49f8b75e55a1 (patch)
treeb957f0dea70a7a2527ec78b32cdfc3e00712ff4d /src/cptr.h
parentc1229c50baa4816924e1914f3b4c78177749b73d (diff)
downloadlibbu++-350b052cfd866e3b3c7c4626551b49f8b75e55a1.tar.gz
libbu++-350b052cfd866e3b3c7c4626551b49f8b75e55a1.tar.bz2
libbu++-350b052cfd866e3b3c7c4626551b49f8b75e55a1.tar.xz
libbu++-350b052cfd866e3b3c7c4626551b49f8b75e55a1.zip
Woo! Very nearly there cache-wise, I'm about to change the name of the handler,
do a few more tests, and hopefully get something loading/saving.
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