aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-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