summaryrefslogtreecommitdiff
path: root/src/tests/cache.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-12-01 17:20:26 +0000
committerMike Buland <eichlan@xagasoft.com>2008-12-01 17:20:26 +0000
commit350b052cfd866e3b3c7c4626551b49f8b75e55a1 (patch)
treeb957f0dea70a7a2527ec78b32cdfc3e00712ff4d /src/tests/cache.cpp
parentc1229c50baa4816924e1914f3b4c78177749b73d (diff)
downloadlibbu++-350b052cfd866e3b3c7c4626551b49f8b75e55a1.tar.gz
libbu++-350b052cfd866e3b3c7c4626551b49f8b75e55a1.tar.bz2
libbu++-350b052cfd866e3b3c7c4626551b49f8b75e55a1.tar.xz
libbu++-350b052cfd866e3b3c7c4626551b49f8b75e55a1.zip
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.
Diffstat (limited to 'src/tests/cache.cpp')
-rw-r--r--src/tests/cache.cpp52
1 files changed, 41 insertions, 11 deletions
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 @@
1#include <stdio.h> 1#include <stdio.h>
2 2
3#include "bu/cache.h" 3#include "bu/cache.h"
4#include "bu/cachable.h"
5 4
6class Bob : public Bu::Cachable 5class Bob
7{ 6{
8public: 7public:
9 Bob() 8 Bob()
@@ -36,24 +35,55 @@ public:
36 int iInt; 35 int iInt;
37}; 36};
38 37
39DECL_CACHABLE( Bob ); 38class BobHandler : public Bu::CacheHandler<Bob>
40DEF_CACHABLE( Bob ); 39{
40public:
41 BobHandler() :
42 cLastId( 0 )
43 {
44 }
45
46 ~BobHandler()
47 {
48 }
49
50 virtual Bu::CPtr<Bob> load()
51 {
52 }
53
54 virtual void unload( Bu::CPtr<Bob> pObj )
55 {
56 }
57
58 virtual Bu::CPtr<Bob> create()
59 {
60 }
61
62 virtual Bu::CPtr<Bob> create( Bob &rSrc )
63 {
64 }
65
66 virtual void destroy( Bu::CPtr<Bob> pObj )
67 {
68 }
69
70private:
71 Bu::Cache<Bob>::cid_t cLastId;
72};
41 73
42int main() 74int main()
43{ 75{
44 Bu::Cache<Bob> bobCache; 76 typedef Bu::Cache<Bob> BobCache;
77 typedef Bu::CPtr<Bob> BobPtr;
45 78
46 Bu::CPtr<Bob> pB1 = bobCache.insert( new Bob() ); 79 BobCache bobCache;
47 80
81 BobPtr pB1 = bobCache.insert( new Bob() );
48 (*pB1).setInt( 44 ); 82 (*pB1).setInt( 44 );
49
50 printf("RefCnt = %d\n", bobCache.getRefCnt( 0 ) ); 83 printf("RefCnt = %d\n", bobCache.getRefCnt( 0 ) );
51 84
52 Bu::CPtr<Bob> pB2 = bobCache.get( 0 ); 85 BobPtr pB2 = bobCache.get( 0 );
53
54 printf("RefCnt = %d\n", bobCache.getRefCnt( 0 ) ); 86 printf("RefCnt = %d\n", bobCache.getRefCnt( 0 ) );
55
56 printf("Int = %d\n", pB2->getInt() ); 87 printf("Int = %d\n", pB2->getInt() );
57
58} 88}
59 89