diff options
Diffstat (limited to 'src/cptr.h')
| -rw-r--r-- | src/cptr.h | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/src/cptr.h b/src/cptr.h deleted file mode 100644 index 97f5e17..0000000 --- a/src/cptr.h +++ /dev/null | |||
| @@ -1,55 +0,0 @@ | |||
| 1 | #ifndef BU_C_PTR_H | ||
| 2 | #define BU_C_PTR_H | ||
| 3 | |||
| 4 | namespace Bu | ||
| 5 | { | ||
| 6 | template<class obtype, class keytype> class Cache; | ||
| 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 | */ | ||
| 13 | template<class obtype, class keytype> | ||
| 14 | class CPtr | ||
| 15 | { | ||
| 16 | friend class Bu::Cache<obtype, keytype>; | ||
| 17 | private: | ||
| 18 | CPtr( Cache<obtype, keytype> &rCache, obtype *pData, | ||
| 19 | const keytype &kId ) : | ||
| 20 | rCache( rCache ), | ||
| 21 | pData( pData ), | ||
| 22 | kId( kId ) | ||
| 23 | { | ||
| 24 | rCache.incRef( kId ); | ||
| 25 | } | ||
| 26 | |||
| 27 | public: | ||
| 28 | virtual ~CPtr() | ||
| 29 | { | ||
| 30 | rCache.decRef( kId ); | ||
| 31 | } | ||
| 32 | |||
| 33 | obtype &operator*() | ||
| 34 | { | ||
| 35 | return *pData; | ||
| 36 | } | ||
| 37 | |||
| 38 | obtype *operator->() | ||
| 39 | { | ||
| 40 | return pData; | ||
| 41 | } | ||
| 42 | |||
| 43 | const keytype &getKey() | ||
| 44 | { | ||
| 45 | return kId; | ||
| 46 | } | ||
| 47 | |||
| 48 | private: | ||
| 49 | Bu::Cache<obtype, keytype> &rCache; | ||
| 50 | obtype *pData; | ||
| 51 | keytype kId; | ||
| 52 | }; | ||
| 53 | }; | ||
| 54 | |||
| 55 | #endif | ||
