From 306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 15 May 2010 07:44:10 +0000 Subject: mkunit.sh was a little dumb, it didn't handle a number of things correctly. I've written a new program that basically does the same thing, only it's much more clever, and does many more of the translations and conversions better, including the #line directives. Also, I dropped nids, we don't need it anymore. But now I'm ready to write some serious tests for myriad. --- src/cachestorenids.h | 158 --------------------------------------------------- 1 file changed, 158 deletions(-) delete mode 100644 src/cachestorenids.h (limited to 'src/cachestorenids.h') diff --git a/src/cachestorenids.h b/src/cachestorenids.h deleted file mode 100644 index 293f521..0000000 --- a/src/cachestorenids.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (C) 2007-2010 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#ifndef BU_CACHE_STORE_NIDS_H -#define BU_CACHE_STORE_NIDS_H - -#include "bu/fstring.h" -#include "bu/stream.h" -#include "bu/nids.h" -#include "bu/nidsstream.h" -#include "bu/cachestore.h" - -#include "bu/file.h" -#include "bu/archive.h" - -namespace Bu -{ - template - keytype __cacheGetKey( const obtype *pObj ); - - template - obtype *__cacheStoreNidsAlloc( const keytype &key ) - { - return new obtype(); - } - - template - void __cacheStoreNidsStore( Bu::Stream &s, obtype &rObj, - const keytype & ) - { - Bu::Archive ar( s, Bu::Archive::save ); - ar << rObj; - } - - template - obtype *__cacheStoreNidsLoad( Bu::Stream &s, const keytype &key ) - { - obtype *pObj = __cacheStoreNidsAlloc( key ); - Bu::Archive ar( s, Bu::Archive::load ); - ar >> (*pObj); - return pObj; - } - - template - class CacheStoreNids : public CacheStore - { - public: - CacheStoreNids( Bu::Stream &sArch, - int iBlockSize=1024, int iPreAllocate=1 ) : - nStore( sArch ) - { - try - { - nStore.initialize(); - NidsStream ns = nStore.openStream( 0 ); - Bu::Archive ar( ns, Bu::Archive::load ); - ar >> hId; - } - catch( Bu::NidsException &e ) - { - nStore.initialize( iBlockSize, iPreAllocate ); - int iStream = nStore.createStream(); - if( iStream != 0 ) - throw Bu::ExceptionBase("That's...horrible...id = %d.\n\n", iStream ); - NidsStream ns = nStore.openStream( 0 ); - Bu::Archive ar( ns, Bu::Archive::save ); - ar << hId; - } - } - - virtual ~CacheStoreNids() - { - NidsStream ns = nStore.openStream( 0 ); - Bu::Archive ar( ns, Bu::Archive::save ); - ar << hId; - } - - virtual obtype *load( const keytype &key ) - { - int iStream = hId.get( key ); - NidsStream ns = nStore.openStream( iStream ); - obtype *pOb = __cacheStoreNidsLoad( ns, key ); - return pOb; - } - - virtual void unload( obtype *pObj, const keytype &key ) - { - delete pObj; - } - - virtual keytype create( obtype *pSrc ) - { - keytype key = __cacheGetKey( pSrc ); - int iStream = nStore.createStream(); - hId.insert( key, iStream ); - NidsStream ns = nStore.openStream( iStream ); - __cacheStoreNidsStore( ns, *pSrc, key ); - return key; - } - - virtual void sync() - { - NidsStream ns = nStore.openStream( 0 ); - Bu::Archive ar( ns, Bu::Archive::save ); - ar << hId; - } - - virtual void sync( obtype *pSrc, const keytype &key ) - { - int iStream = hId.get( key ); - NidsStream ns = nStore.openStream( iStream ); - __cacheStoreNidsStore( ns, *pSrc, key ); - } - - virtual void destroy( obtype *pObj, const keytype &key ) - { - int iStream = hId.get( key ); - nStore.deleteStream( iStream ); - hId.erase( key ); - delete pObj; - sync(); - } - - virtual void destroy( const keytype &key ) - { - int iStream = hId.get( key ); - nStore.deleteStream( iStream ); - hId.erase( key ); - sync(); - } - - virtual bool has( const keytype &key ) - { - return hId.has( key ); - } - - virtual Bu::List getKeys() - { - return hId.getKeys(); - } - - virtual int getSize() - { - return hId.getSize(); - } - - private: - Nids nStore; - typedef Bu::Hash NidHash; - NidHash hId; - }; -}; - -#endif -- cgit v1.2.3