summaryrefslogtreecommitdiff
path: root/src/cache.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-11-10 23:10:38 +0000
committerMike Buland <eichlan@xagasoft.com>2008-11-10 23:10:38 +0000
commit4bbeb6208ac33f71a09701cc5251f0412977946e (patch)
tree038a71056f91d7ce3b26f90fde3519d404e7cb63 /src/cache.h
parent61edfe804eb1a1dbf96fcdf2f1b700ed1cfa7ff9 (diff)
downloadlibbu++-4bbeb6208ac33f71a09701cc5251f0412977946e.tar.gz
libbu++-4bbeb6208ac33f71a09701cc5251f0412977946e.tar.bz2
libbu++-4bbeb6208ac33f71a09701cc5251f0412977946e.tar.xz
libbu++-4bbeb6208ac33f71a09701cc5251f0412977946e.zip
Ok, the cache-id officiation is being delegated to the CacheHandlers, this is
just fine, since they can do it any way they want. The Congo CacheHandlers will all have to be specialized versions of the generic ones, but they'll use all the general functionality, just make up IDs differently. It'll rock.
Diffstat (limited to 'src/cache.h')
-rw-r--r--src/cache.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/cache.h b/src/cache.h
index 344d1c6..8ab0659 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -3,6 +3,8 @@
3 3
4#include "bu/cptr.h" 4#include "bu/cptr.h"
5#include "bu/hash.h" 5#include "bu/hash.h"
6#include "bu/list.h"
7#include "bu/cachehandler.h"
6 8
7#define BU_TRACE 9#define BU_TRACE
8#include "bu/trace.h" 10#include "bu/trace.h"
@@ -29,6 +31,21 @@ namespace Bu
29 virtual ~Cache() 31 virtual ~Cache()
30 { 32 {
31 TRACE(); 33 TRACE();
34 for( HandlerList::iterator i = lHandler.begin();
35 i != lHandler.end(); i++ )
36 {
37 delete *i;
38 }
39 }
40
41 void appendHandler( CacheHandler *pHand )
42 {
43 lHandler.append( pHand );
44 }
45
46 void prependHandler( CacheHandler *pHand )
47 {
48 lHandler.prepend( pHand );
32 } 49 }
33 50
34 Ptr insert( obtype *pData ) 51 Ptr insert( obtype *pData )
@@ -39,6 +56,18 @@ namespace Bu
39 return Ptr( *this, pData ); 56 return Ptr( *this, pData );
40 } 57 }
41 58
59 Ptr get( cid cId )
60 {
61 TRACE();
62 return Ptr( *this, hEnt.get( cId ).pData );
63 }
64
65 int getRefCnt( cid cId )
66 {
67 TRACE();
68 return hEnt.get( cId ).iRefs;
69 }
70
42 private: 71 private:
43 void incRef( obtype *pData ) 72 void incRef( obtype *pData )
44 { 73 {
@@ -64,6 +93,8 @@ namespace Bu
64 typedef Bu::Hash<cid, CacheEntry> CidHash; 93 typedef Bu::Hash<cid, CacheEntry> CidHash;
65 //RefHash hRefs; 94 //RefHash hRefs;
66 CidHash hEnt; 95 CidHash hEnt;
96 typedef Bu::List<CacheHandler *> HandlerList;
97 HandlerList lHandler;
67 }; 98 };
68}; 99};
69 100