summaryrefslogtreecommitdiff
path: root/src/cache.h
diff options
context:
space:
mode:
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