diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-01-05 15:58:22 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-01-05 15:58:22 +0000 |
commit | d96fe229e79f9b1947cbd24ff52d6bf7bb9bf80d (patch) | |
tree | 525fb0a3a693bc21132622aa3d272a15d875c829 /src/cptr.h | |
parent | 3893cb63e034180eab0764ee18567a56e8307a80 (diff) | |
download | libbu++-d96fe229e79f9b1947cbd24ff52d6bf7bb9bf80d.tar.gz libbu++-d96fe229e79f9b1947cbd24ff52d6bf7bb9bf80d.tar.bz2 libbu++-d96fe229e79f9b1947cbd24ff52d6bf7bb9bf80d.tar.xz libbu++-d96fe229e79f9b1947cbd24ff52d6bf7bb9bf80d.zip |
I mergered Bu::CPtr into Bu::Cache as Bu::Cache::Ptr. This makes more sense to
me, is much less messy, and makes the syntax work a little better for me as
well. What the hell was a CPtr? Who knows, but a Cache::Ptr, that makes sense.
Also, fewer includes to deal with now, just need Cache and you're set.
Oh, also, made Cache::Ptr behave much more like a regular pointer, they can be
assigned now, as well as created empty (NULL).
Diffstat (limited to '')
-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 | ||