aboutsummaryrefslogtreecommitdiff
path: root/src/cachestorenids.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-01-27 21:45:03 +0000
committerMike Buland <eichlan@xagasoft.com>2009-01-27 21:45:03 +0000
commit67ec9d667ab0c3f2258f6f69308d0731e74a74d0 (patch)
treeeaaccf38aeecbb22b06b0156a40cf0dbb66c7bdc /src/cachestorenids.h
parent00bb8c39b97638c872ebccc6aee7f3c5fb57d7d6 (diff)
downloadlibbu++-67ec9d667ab0c3f2258f6f69308d0731e74a74d0.tar.gz
libbu++-67ec9d667ab0c3f2258f6f69308d0731e74a74d0.tar.bz2
libbu++-67ec9d667ab0c3f2258f6f69308d0731e74a74d0.tar.xz
libbu++-67ec9d667ab0c3f2258f6f69308d0731e74a74d0.zip
Nids is even better, all fixed, no problems. And you can define you're own
creator functions for the cache store...soon, you'll also be able to define you're own loader/writer functions, but the default will still work exactly like this. I also did more work on nidstool, I think I may actually have to create a tools dir that will just compile some executables for the libbu++ root, because this thing is handy. You can get info on the system, trace streams' blocks, and I'm working on an analysis function that will help you figure out how to optomize your nids files. Plus, it'll have a function soon for re-writing a nids stream, which will let you change the block size, defragment, and remove unused blocks.
Diffstat (limited to 'src/cachestorenids.h')
-rw-r--r--src/cachestorenids.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/cachestorenids.h b/src/cachestorenids.h
index 9288008..a5fa402 100644
--- a/src/cachestorenids.h
+++ b/src/cachestorenids.h
@@ -9,14 +9,18 @@
9 9
10#include "bu/file.h" 10#include "bu/file.h"
11 11
12static int iCnt = 0;
13
14namespace Bu 12namespace Bu
15{ 13{
16 template<class obtype, class keytype> 14 template<class obtype, class keytype>
17 keytype __cacheGetKey( const obtype *pObj ); 15 keytype __cacheGetKey( const obtype *pObj );
18 16
19 template<class obtype, class keytype> 17 template<class obtype, class keytype>
18 obtype *__cacheStoreNidsAlloc( const keytype &key )
19 {
20 return new obtype();
21 }
22
23 template<class obtype, class keytype>
20 class CacheStoreNids : public CacheStore<obtype, keytype> 24 class CacheStoreNids : public CacheStore<obtype, keytype>
21 { 25 {
22 public: 26 public:
@@ -55,7 +59,7 @@ namespace Bu
55 int iStream = hId.get( key ); 59 int iStream = hId.get( key );
56 NidsStream ns = nStore.openStream( iStream ); 60 NidsStream ns = nStore.openStream( iStream );
57 Bu::Archive ar( ns, Bu::Archive::load ); 61 Bu::Archive ar( ns, Bu::Archive::load );
58 obtype *pOb = new obtype(); 62 obtype *pOb = __cacheStoreNidsAlloc<obtype, keytype>( key );
59 ar >> (*pOb); 63 ar >> (*pOb);
60 return pOb; 64 return pOb;
61 } 65 }
@@ -76,8 +80,7 @@ namespace Bu
76 hId.insert( key, iStream ); 80 hId.insert( key, iStream );
77 NidsStream ns = nStore.openStream( iStream ); 81 NidsStream ns = nStore.openStream( iStream );
78 Bu::Archive ar( ns, Bu::Archive::save ); 82 Bu::Archive ar( ns, Bu::Archive::save );
79 obtype *pOb = new obtype(); 83 ar << (*pSrc);
80 ar << (*pOb);
81 return key; 84 return key;
82 } 85 }
83 86