aboutsummaryrefslogtreecommitdiff
path: root/src/cachestorenids.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/cachestorenids.h27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/cachestorenids.h b/src/cachestorenids.h
index a5fa402..40213cd 100644
--- a/src/cachestorenids.h
+++ b/src/cachestorenids.h
@@ -21,6 +21,23 @@ namespace Bu
21 } 21 }
22 22
23 template<class obtype, class keytype> 23 template<class obtype, class keytype>
24 void __cacheStoreNidsStore( Bu::Stream &s, obtype &rObj,
25 const keytype & )
26 {
27 Bu::Archive ar( s, Bu::Archive::save );
28 ar << rObj;
29 }
30
31 template<class obtype, class keytype>
32 obtype *__cacheStoreNidsLoad( Bu::Stream &s, const keytype &key )
33 {
34 obtype *pObj = __cacheStoreNidsAlloc<obtype, keytype>( key );
35 Bu::Archive ar( s, Bu::Archive::load );
36 ar >> (*pObj);
37 return pObj;
38 }
39
40 template<class obtype, class keytype>
24 class CacheStoreNids : public CacheStore<obtype, keytype> 41 class CacheStoreNids : public CacheStore<obtype, keytype>
25 { 42 {
26 public: 43 public:
@@ -58,9 +75,7 @@ namespace Bu
58 { 75 {
59 int iStream = hId.get( key ); 76 int iStream = hId.get( key );
60 NidsStream ns = nStore.openStream( iStream ); 77 NidsStream ns = nStore.openStream( iStream );
61 Bu::Archive ar( ns, Bu::Archive::load ); 78 obtype *pOb = __cacheStoreNidsLoad<obtype, keytype>( ns, key );
62 obtype *pOb = __cacheStoreNidsAlloc<obtype, keytype>( key );
63 ar >> (*pOb);
64 return pOb; 79 return pOb;
65 } 80 }
66 81
@@ -68,8 +83,7 @@ namespace Bu
68 { 83 {
69 int iStream = hId.get( key ); 84 int iStream = hId.get( key );
70 NidsStream ns = nStore.openStream( iStream ); 85 NidsStream ns = nStore.openStream( iStream );
71 Bu::Archive ar( ns, Bu::Archive::save ); 86 __cacheStoreNidsStore<obtype, keytype>( ns, *pObj, key );
72 ar << (*pObj);
73 delete pObj; 87 delete pObj;
74 } 88 }
75 89
@@ -79,8 +93,7 @@ namespace Bu
79 int iStream = nStore.createStream(); 93 int iStream = nStore.createStream();
80 hId.insert( key, iStream ); 94 hId.insert( key, iStream );
81 NidsStream ns = nStore.openStream( iStream ); 95 NidsStream ns = nStore.openStream( iStream );
82 Bu::Archive ar( ns, Bu::Archive::save ); 96 __cacheStoreNidsStore<obtype, keytype>( ns, *pSrc, key );
83 ar << (*pSrc);
84 return key; 97 return key;
85 } 98 }
86 99