aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2013-03-12 02:00:42 +0000
committerMike Buland <eichlan@xagasoft.com>2013-03-12 02:00:42 +0000
commit9700147ab5adaf28eecf931a9c7c096918baaf73 (patch)
tree933c2813b12989c5bc8f75e29ffc9ef9c0ee9b52 /src
parent21f5d80dade777675f10fd393f0a953b36268f9d (diff)
downloadlibbu++-9700147ab5adaf28eecf931a9c7c096918baaf73.tar.gz
libbu++-9700147ab5adaf28eecf931a9c7c096918baaf73.tar.bz2
libbu++-9700147ab5adaf28eecf931a9c7c096918baaf73.tar.xz
libbu++-9700147ab5adaf28eecf931a9c7c096918baaf73.zip
Mostly planning changes, nothing real functional but I want to commit and change
computers.
Diffstat (limited to '')
-rw-r--r--src/tests/cache.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/tests/cache.cpp b/src/tests/cache.cpp
index 00a32dd..5731a6a 100644
--- a/src/tests/cache.cpp
+++ b/src/tests/cache.cpp
@@ -5,6 +5,7 @@
5#include <bu/myriadstream.h> 5#include <bu/myriadstream.h>
6#include <bu/file.h> 6#include <bu/file.h>
7#include <bu/streamstack.h> 7#include <bu/streamstack.h>
8#include <bu/readwritemutex.h>
8 9
9// 10//
10// New Cache Implementation 11// New Cache Implementation
@@ -29,8 +30,8 @@ public:
29 30
30 typedef CacheBase<keytype, obtype> CacheType; 31 typedef CacheBase<keytype, obtype> CacheType;
31 32
32 virtual const keytype getKey() const=0; 33 virtual keytype getKey() const=0;
33 virtual const int getPersistenceScore() const { return 0; } 34 virtual int getPersistenceScore() const { return 0; }
34 35
35 void changed( bool bChanged=true ) 36 void changed( bool bChanged=true )
36 { 37 {
@@ -55,14 +56,31 @@ template<typename keytype, typename obtype, typename basetype=obtype>
55class CachePtr 56class CachePtr
56{ 57{
57friend class CacheBase<keytype, basetype>; 58friend class CacheBase<keytype, basetype>;
58public: 59private:
59 CachePtr() 60 CachePtr( CacheBase<keytype, basetype> *pCache, obtype *pData, const keytype &kId ) :
61 pCache( pCache ),
62 kId( kId ),
63 pData( pData )
60 { 64 {
61 } 65 }
62 66
67 CachePtr( CacheBase<keytype, basetype> *pCache, const keytype &kId ) :
68 pCache( pCache ),
69 kId( kId ),
70 pData( NULL )
71 {
72 }
73
74public:
63 virtual ~CachePtr() 75 virtual ~CachePtr()
64 { 76 {
65 } 77 }
78
79private:
80 CacheBase<keytype, basetype> *pCache;
81 mutable keytype kId;
82 mutable obtype *pData;
83
66}; 84};
67 85
68template<typename keytype, typename obtype> 86template<typename keytype, typename obtype>
@@ -78,6 +96,11 @@ public:
78 } 96 }
79 97
80protected: 98protected:
99 void objectChanged( const keytype &k )
100 {
101 }
102
103protected:
81 virtual void _create( obtype *o )=0; 104 virtual void _create( obtype *o )=0;
82 virtual void _erase( const keytype &k )=0; 105 virtual void _erase( const keytype &k )=0;
83 106
@@ -175,7 +198,7 @@ public:
175 { 198 {
176 } 199 }
177 200
178 virtual const Bu::Uuid getKey() const 201 virtual Bu::Uuid getKey() const
179 { 202 {
180 return uId; 203 return uId;
181 } 204 }