diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2008-10-09 20:20:34 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2008-10-09 20:20:34 +0000 |
| commit | 4808617ef54d40efcf1a3ed30525898defb74e10 (patch) | |
| tree | e16763eb646fdf3dea7c32a8d57c147356be9299 /src/cptr.h | |
| parent | fecbea5970bb89c15b35f5df5b09914b4c91efe0 (diff) | |
| download | libbu++-4808617ef54d40efcf1a3ed30525898defb74e10.tar.gz libbu++-4808617ef54d40efcf1a3ed30525898defb74e10.tar.bz2 libbu++-4808617ef54d40efcf1a3ed30525898defb74e10.tar.xz libbu++-4808617ef54d40efcf1a3ed30525898defb74e10.zip | |
More cache development. I'm going to have to switch from template functions to
functors. I like template functions a little more, but functors can be at
least as fast. It won't be much of a change.
Diffstat (limited to 'src/cptr.h')
| -rw-r--r-- | src/cptr.h | 14 |
1 files changed, 11 insertions, 3 deletions
| @@ -1,23 +1,31 @@ | |||
| 1 | #ifndef BU_C_PTR_H | 1 | #ifndef BU_C_PTR_H |
| 2 | #define BU_C_PTR_H | 2 | #define BU_C_PTR_H |
| 3 | 3 | ||
| 4 | #include "bu/cache.h" | ||
| 5 | |||
| 6 | namespace Bu | 4 | namespace Bu |
| 7 | { | 5 | { |
| 6 | template<class obtype> class Cache; | ||
| 7 | |||
| 8 | template<class obtype> | 8 | template<class obtype> |
| 9 | class CPtr | 9 | class CPtr |
| 10 | { | 10 | { |
| 11 | friend class Bu::Cache<obtype>; | 11 | friend class Bu::Cache<obtype>; |
| 12 | private: | 12 | private: |
| 13 | CPtr( Cache<obtype> &rCache, obtype &rData ) | 13 | CPtr( Cache<obtype> &rCache, obtype *pData ) : |
| 14 | rCache( rCache ), | ||
| 15 | pData( pData ) | ||
| 14 | { | 16 | { |
| 17 | rCache.incRef( pData ); | ||
| 15 | } | 18 | } |
| 16 | 19 | ||
| 17 | public: | 20 | public: |
| 18 | virtual ~CPtr() | 21 | virtual ~CPtr() |
| 19 | { | 22 | { |
| 23 | rCache.decRef( pData ); | ||
| 20 | } | 24 | } |
| 25 | |||
| 26 | private: | ||
| 27 | Bu::Cache<obtype> &rCache; | ||
| 28 | obtype *pData; | ||
| 21 | }; | 29 | }; |
| 22 | }; | 30 | }; |
| 23 | 31 | ||
