65 #ifndef G4CacheDetails_hh
66 #define G4CacheDetails_hh
92 inline VALTYPE&
GetCache(
unsigned int id)
const;
117 inline VALTYPE*&
GetCache(
unsigned int id)
const;
121 static cache_container*&
cache();
156 cout<<
"Generic template"<<endl;
162 if ( cache()->size() <=
id )
163 cache()->resize(
id+1,static_cast<V*>(0));
164 if ( (*cache())[
id] == 0 )
165 (*cache())[
id]=
new V;
174 cout<<
"Destroying element"<<
id<<
" is last?"<<last<<endl;
176 if ( cache()->size() <
id )
179 msg <<
"Internal fatal error. Invalid G4Cache size (requested id: "
180 <<
id <<
" but cache has size: "<< cache()->size();
181 msg <<
" Possibly client created G4Cache object in a thread and"
182 <<
" tried to delete it from another thread!";
183 G4Exception(
"G4CacheReference<V>::Destroy",
"Cache001",
187 if ( cache()->size() >
id && (*cache())[
id] )
189 delete (*cache())[
id];
203 return *(cache()->operator[](id));
222 cout<<
"Pointer template"<<endl;
225 cache() =
new cache_container;
226 if ( cache()->size() <=
id )
227 cache()->resize(
id+1,static_cast<V*>(0));
236 cout <<
"Destroying element" <<
id <<
" is last?" << last
237 <<
"-Pointer template specialization-" << endl;
239 if ( cache()->size() <
id )
242 msg <<
"Internal fatal error. Invalid G4Cache size (requested id: "
243 <<
id <<
" but cache has size: " << cache()->size();
244 msg <<
" Possibly client created G4Cache object in a thread and"
245 <<
" tried to delete it from another thread!";
246 G4Exception(
"G4CacheReference<V*>::Destroy",
"Cache001",
250 if ( cache()->size() >
id && (*cache())[
id] )
267 return (cache()->
operator[](
id));
284 cout<<
"Specialized template for G4double"<<endl;
288 if (
cache()->size() <=
id )
289 cache()->resize(
id+1,static_cast<G4double>(0));
298 if ( cache() && last )
301 cout <<
"Destroying element" <<
id <<
" is last?" << last
302 <<
"-Pointer template specialization-" << endl;
311 return cache()->operator[](id);
void Initialize(unsigned int id)
std::ostringstream G4ExceptionDescription
#define G4ThreadLocalStatic
static cache_container *& cache()
std::vector< G4double > cache_container
VALTYPE & GetCache(unsigned int id) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::vector< VALTYPE * > cache_container
void Destroy(unsigned int id, G4bool last)
std::vector< VALTYPE * > cache_container