summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/cache.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/tests/cache.cpp b/src/tests/cache.cpp
index dc5dbd0..20b384e 100644
--- a/src/tests/cache.cpp
+++ b/src/tests/cache.cpp
@@ -125,54 +125,54 @@ Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const SubSomethingB &s )
125 125
126namespace Bu 126namespace Bu
127{ 127{
128template<> 128 template<>
129void _cacheObjectSave<const Something>( Bu::Stream &s, const Something *pObject ) 129 void _cacheObjectSave<const Something>( Bu::Stream &s, const Something *pObject )
130{
131 Bu::Archive ar( s, Bu::Archive::save );
132 if( typeid(*pObject) == typeid(SubSomethingA) )
133 {
134 ar << (uint8_t)1 << (SubSomethingA &)*pObject;
135 }
136 else if( typeid(*pObject) == typeid(SubSomethingB) )
137 { 130 {
138 ar << (uint8_t)2 << (SubSomethingB &)*pObject; 131 Bu::Archive ar( s, Bu::Archive::save );
132 if( typeid(*pObject) == typeid(SubSomethingA) )
133 {
134 ar << (uint8_t)1 << (SubSomethingA &)*pObject;
135 }
136 else if( typeid(*pObject) == typeid(SubSomethingB) )
137 {
138 ar << (uint8_t)2 << (SubSomethingB &)*pObject;
139 }
140 else
141 {
142 Bu::println("Not a recognized type!");
143 throw Bu::ExceptionBase("Not recognized type!");
144 }
139 } 145 }
140 else
141 {
142 Bu::println("Not a recognized type!");
143 throw Bu::ExceptionBase("Not recognized type!");
144 }
145}
146 146
147template<> 147 template<>
148Something *_cacheObjectLoad<Something>( Bu::Stream &s ) 148 Something *_cacheObjectLoad<Something>( Bu::Stream &s )
149{
150 Bu::Archive ar( s, Bu::Archive::load );
151 uint8_t uType;
152 ar >> uType;
153 switch( uType )
154 { 149 {
155 case 1: 150 Bu::Archive ar( s, Bu::Archive::load );
156 { 151 uint8_t uType;
157 SubSomethingA *ret = new SubSomethingA(); 152 ar >> uType;
158 ar >> *ret; 153 switch( uType )
159 return ret; 154 {
160 } 155 case 1:
161 break; 156 {
162 157 SubSomethingA *ret = new SubSomethingA();
163 case 2: 158 ar >> *ret;
164 { 159 return ret;
165 SubSomethingB *ret = new SubSomethingB(); 160 }
166 ar >> *ret; 161 break;
167 return ret; 162
168 } 163 case 2:
169 break; 164 {
170 165 SubSomethingB *ret = new SubSomethingB();
171 default: 166 ar >> *ret;
172 throw Bu::ExceptionBase("Flagrant error! Invalid type!"); 167 return ret;
168 }
169 break;
170
171 default:
172 throw Bu::ExceptionBase("Flagrant error! Invalid type!");
173 }
173 } 174 }
174} 175}
175}
176 176
177typedef Bu::CachePtr<Bu::Uuid, Something> SomethingPtr; 177typedef Bu::CachePtr<Bu::Uuid, Something> SomethingPtr;
178typedef Bu::CachePtr<Bu::Uuid, SubSomethingA, Something> SomethingAPtr; 178typedef Bu::CachePtr<Bu::Uuid, SubSomethingA, Something> SomethingAPtr;