From 0861fdb652408dcdbd2e7b60513f3fa24696e610 Mon Sep 17 00:00:00 2001
From: Mike Buland <eichlan@xagasoft.com>
Date: Mon, 25 Jan 2010 16:42:40 +0000
Subject: The order of key, object in all of the cache related systems has beed
 fixed, key just belongs first, that's all there is to it.

---
 src/cache.h          | 16 ++++++++--------
 src/cachecalc.h      |  8 ++++----
 src/cachestore.h     |  2 +-
 src/cachestorenids.h | 24 ++++++++++++------------
 src/tests/cache.cpp  |  6 +++---
 5 files changed, 28 insertions(+), 28 deletions(-)

(limited to 'src')

diff --git a/src/cache.h b/src/cache.h
index 87037f7..c738d28 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -18,10 +18,10 @@
 
 namespace Bu
 {
-//	template<class obtype, class keytype>
+//	template<class keytype, class obtype>
 //	keytype __cacheGetKey( obtype *&pObj );
 
-	template<class obtype, class keytype>
+	template<class keytype, class obtype>
 	class Cache
 	{
 	public:
@@ -32,9 +32,9 @@ namespace Bu
 		 */
 		class Ptr
 		{
-		friend class Bu::Cache<obtype, keytype>;
+		friend class Bu::Cache<keytype, obtype>;
 		private:
-			Ptr( Cache<obtype, keytype> *pCache, obtype *pData,
+			Ptr( Cache<keytype, obtype> *pCache, obtype *pData,
 				const keytype &kId ) :
 				pCache( pCache ),
 				pData( pData ),
@@ -44,7 +44,7 @@ namespace Bu
 					pCache->incRef( kId );
 			}
 			
-			Ptr( Cache<obtype, keytype> *pCache, const keytype &kId ) :
+			Ptr( Cache<keytype, obtype> *pCache, const keytype &kId ) :
 				pCache( pCache ),
 				pData( NULL ),
 				kId( kId )
@@ -168,15 +168,15 @@ namespace Bu
 			}
 
 		private:
-			Bu::Cache<obtype, keytype> *pCache;
+			Bu::Cache<keytype, obtype> *pCache;
 			mutable obtype *pData;
 			mutable keytype kId;
 		};
 
 	private:
-		typedef Bu::CacheStore<obtype, keytype> Store;
+		typedef Bu::CacheStore<keytype, obtype> Store;
 		typedef Bu::List<Store *> StoreList;
-		typedef Bu::CacheCalc<obtype, keytype> Calc;
+		typedef Bu::CacheCalc<keytype, obtype> Calc;
 		
 		typedef struct CacheEntry
 		{
diff --git a/src/cachecalc.h b/src/cachecalc.h
index dd6add1..27680b9 100644
--- a/src/cachecalc.h
+++ b/src/cachecalc.h
@@ -14,14 +14,14 @@
 
 namespace Bu
 {
-	template<class obtype, class keytype> class Cache;
+	template<class keytype, class obtype> class Cache;
 
-	template<class obtype, class keytype>
+	template<class keytype, class obtype>
 	class CacheCalc
 	{
-	friend class Cache<obtype, keytype>;
+	friend class Cache<keytype, obtype>;
 	private:
-		typedef Cache<obtype, keytype> MyCache;
+		typedef Cache<keytype, obtype> MyCache;
 	public:
 		CacheCalc() :
 			pCache( (MyCache *)0 )
diff --git a/src/cachestore.h b/src/cachestore.h
index 6ce42b8..d44326d 100644
--- a/src/cachestore.h
+++ b/src/cachestore.h
@@ -16,7 +16,7 @@ namespace Bu
 	 * Handles I/O for data in the cache.  This also assigns ID's to the newly
 	 * created objects that are requested through this system.
 	 */
-	template<class obtype, class keytype>
+	template<class keytype, class obtype>
 	class CacheStore
 	{
 	public:
diff --git a/src/cachestorenids.h b/src/cachestorenids.h
index ae2b9a2..0d104cf 100644
--- a/src/cachestorenids.h
+++ b/src/cachestorenids.h
@@ -19,16 +19,16 @@
 
 namespace Bu
 {
-	template<class obtype, class keytype>
+	template<class keytype, class obtype>
 	keytype __cacheGetKey( const obtype *pObj );
 
-	template<class obtype, class keytype>
+	template<class keytype, class obtype>
 	obtype *__cacheStoreNidsAlloc( const keytype &key )
 	{
 		return new obtype();
 	}
 
-	template<class obtype, class keytype>
+	template<class keytype, class obtype>
 	void __cacheStoreNidsStore( Bu::Stream &s, obtype &rObj,
 			const keytype & )
 	{
@@ -36,17 +36,17 @@ namespace Bu
 		ar << rObj;
 	}
 
-	template<class obtype, class keytype>
+	template<class keytype, class obtype>
 	obtype *__cacheStoreNidsLoad( Bu::Stream &s, const keytype &key )
 	{
-		obtype *pObj = __cacheStoreNidsAlloc<obtype, keytype>( key );
+		obtype *pObj = __cacheStoreNidsAlloc<keytype, obtype>( key );
 		Bu::Archive ar( s, Bu::Archive::load );
 		ar >> (*pObj);
 		return pObj;
 	}
 
-	template<class obtype, class keytype>
-	class CacheStoreNids : public CacheStore<obtype, keytype>
+	template<class keytype, class obtype>
+	class CacheStoreNids : public CacheStore<keytype, obtype>
 	{
 	public:
 		CacheStoreNids( Bu::Stream &sArch,
@@ -83,7 +83,7 @@ namespace Bu
 		{
 			int iStream = hId.get( key );
 			NidsStream ns = nStore.openStream( iStream );
-			obtype *pOb = __cacheStoreNidsLoad<obtype, keytype>( ns, key );
+			obtype *pOb = __cacheStoreNidsLoad<keytype, obtype>( ns, key );
 			return pOb;
 		}
 
@@ -91,17 +91,17 @@ namespace Bu
 		{
 			int iStream = hId.get( key );
 			NidsStream ns = nStore.openStream( iStream );
-			__cacheStoreNidsStore<obtype, keytype>( ns, *pObj, key );
+			__cacheStoreNidsStore<keytype, obtype>( ns, *pObj, key );
 			delete pObj;
 		}
 
 		virtual keytype create( obtype *pSrc )
 		{
-			keytype key = __cacheGetKey<obtype,keytype>( pSrc );
+			keytype key = __cacheGetKey<keytype, obtype>( pSrc );
 			int iStream = nStore.createStream();
 			hId.insert( key, iStream );
 			NidsStream ns = nStore.openStream( iStream );
-			__cacheStoreNidsStore<obtype, keytype>( ns, *pSrc, key );
+			__cacheStoreNidsStore<keytype, obtype>( ns, *pSrc, key );
 			return key;
 		}
 
@@ -118,7 +118,7 @@ namespace Bu
 		{
 			int iStream = hId.get( key );
 			NidsStream ns = nStore.openStream( iStream );
-			__cacheStoreNidsStore<obtype, keytype>( ns, *pSrc, key );
+			__cacheStoreNidsStore<keytype, obtype>( ns, *pSrc, key );
 		}
 
 		virtual void destroy( obtype *pObj, const keytype &key )
diff --git a/src/tests/cache.cpp b/src/tests/cache.cpp
index a098145..11a4215 100644
--- a/src/tests/cache.cpp
+++ b/src/tests/cache.cpp
@@ -58,7 +58,7 @@ namespace Bu {
 	}
 }
 
-class BobStore : public Bu::CacheStore<Bob, long>
+class BobStore : public Bu::CacheStore<long, Bob>
 {
 public:
 	BobStore() :
@@ -158,7 +158,7 @@ private:
 	long cLastId;
 };
 
-class BobCalc : public Bu::CacheCalc<Bob, long>
+class BobCalc : public Bu::CacheCalc<long, Bob>
 {
 public:
 	BobCalc()
@@ -189,7 +189,7 @@ private:
 int main( int argc, char *argv[] )
 {
 	TRACE( argc, argv );
-	typedef Bu::Cache<Bob, long> BobCache;
+	typedef Bu::Cache<long, Bob> BobCache;
 	typedef BobCache::Ptr BobPtr;
 
 	if( argc < 3 )
-- 
cgit v1.2.3