From 350b052cfd866e3b3c7c4626551b49f8b75e55a1 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 1 Dec 2008 17:20:26 +0000 Subject: Woo! Very nearly there cache-wise, I'm about to change the name of the handler, do a few more tests, and hopefully get something loading/saving. --- src/tests/cache.cpp | 52 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 11 deletions(-) (limited to 'src/tests') diff --git a/src/tests/cache.cpp b/src/tests/cache.cpp index f05de57..55ec5be 100644 --- a/src/tests/cache.cpp +++ b/src/tests/cache.cpp @@ -1,9 +1,8 @@ #include #include "bu/cache.h" -#include "bu/cachable.h" -class Bob : public Bu::Cachable +class Bob { public: Bob() @@ -36,24 +35,55 @@ public: int iInt; }; -DECL_CACHABLE( Bob ); -DEF_CACHABLE( Bob ); +class BobHandler : public Bu::CacheHandler +{ +public: + BobHandler() : + cLastId( 0 ) + { + } + + ~BobHandler() + { + } + + virtual Bu::CPtr load() + { + } + + virtual void unload( Bu::CPtr pObj ) + { + } + + virtual Bu::CPtr create() + { + } + + virtual Bu::CPtr create( Bob &rSrc ) + { + } + + virtual void destroy( Bu::CPtr pObj ) + { + } + +private: + Bu::Cache::cid_t cLastId; +}; int main() { - Bu::Cache bobCache; + typedef Bu::Cache BobCache; + typedef Bu::CPtr BobPtr; - Bu::CPtr pB1 = bobCache.insert( new Bob() ); + BobCache bobCache; + BobPtr pB1 = bobCache.insert( new Bob() ); (*pB1).setInt( 44 ); - printf("RefCnt = %d\n", bobCache.getRefCnt( 0 ) ); - Bu::CPtr pB2 = bobCache.get( 0 ); - + BobPtr pB2 = bobCache.get( 0 ); printf("RefCnt = %d\n", bobCache.getRefCnt( 0 ) ); - printf("Int = %d\n", pB2->getInt() ); - } -- cgit v1.2.3