From 350b052cfd866e3b3c7c4626551b49f8b75e55a1 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 1 Dec 2008 17:20:26 +0000 Subject: 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. --- src/cptr.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/cptr.h') 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 { template class Cache; + /** + * Cache Pointer - Provides access to data that is held within the cache. + * This provides safe, refcounting access to data stored in the cache, with + * support for lazy loading. + */ template class CPtr { friend class Bu::Cache; + public: + typedef long cid_t; /**< Cache ID type. Unique cache entry ID. */ private: CPtr( Cache &rCache, obtype *pData ) : rCache( rCache ), pData( pData ) { - rCache.incRef( pData ); + rCache.incRef( cId ); } public: virtual ~CPtr() { - rCache.decRef( pData ); + rCache.decRef( cId ); } obtype &operator*() @@ -36,6 +43,7 @@ namespace Bu private: Bu::Cache &rCache; obtype *pData; + cid_t cId; }; }; -- cgit v1.2.3