64 #ifndef G4CacheDetails_hh
65 #define G4CacheDetails_hh
84 inline VALTYPE&
GetCache(
unsigned int id)
const;
109 inline VALTYPE*&
GetCache(
unsigned int id)
const;
113 static cache_container*&
cache();
146 std::cout <<
"Generic template container..." << std::endl;
150 if ( cache()->size() <=
id )
152 cache()->resize(
id+1,static_cast<V*>(0));
154 if ( (*cache())[
id] == 0 )
156 (*cache())[
id]=
new V;
166 std::cout <<
"V: Destroying element "<<
id
167 <<
" is last? " << last << std::endl;
169 if ( cache()->size() <
id )
172 msg <<
"Internal fatal error. Invalid G4Cache size (requested id: "
173 <<
id <<
" but cache has size: "<< cache()->size();
174 msg <<
" Possibly client created G4Cache object in a thread and"
175 <<
" tried to delete it from another thread!";
176 G4Exception(
"G4CacheReference<V>::Destroy",
"Cache001",
180 if ( cache()->size() >
id && (*cache())[
id] )
183 std::cout <<
"V: Destroying element " <<
id
184 <<
" size: " << cache()->size() << std::endl;
186 delete (*cache())[
id];
192 std::cout <<
"V: Destroying LAST element!" << std::endl;
203 return *(cache()->operator[](id));
223 std::cout <<
"Pointer template container..." << std::endl;
225 cache() =
new cache_container;
227 if ( cache()->size() <=
id )
229 cache()->resize(
id+1,static_cast<V*>(0));
239 std::cout <<
"V*: Destroying element " <<
id <<
" is last? " << last
242 if ( cache()->size() <
id )
245 msg <<
"Internal fatal error. Invalid G4Cache size (requested id: "
246 <<
id <<
" but cache has size: " << cache()->size();
247 msg <<
" Possibly client created G4Cache object in a thread and"
248 <<
" tried to delete it from another thread!";
249 G4Exception(
"G4CacheReference<V*>::Destroy",
"Cache001",
253 if ( cache()->size() >
id && (*cache())[
id] )
258 std::cout <<
"V*: Resetting element " <<
id
259 <<
" size: " << cache()->size() << std::endl;
266 std::cout <<
"V*: Deleting LAST element!" << std::endl;
277 return (cache()->
operator[](
id));
296 std::cout <<
"Specialized template for G4double container..." << std::endl;
300 if (
cache()->size() <=
id )
302 cache()->resize(
id+1,static_cast<G4double>(0));
308 if (
cache() && last )
311 std::cout <<
"DB: Destroying LAST element! Is it last? " << last
321 return cache()->operator[](id);