76 template<
class VALTYPE>
86 inline VALTYPE&
GetCache(
unsigned int id)
const;
103 template<
class VALTYPE>
110 inline VALTYPE*&
GetCache(
unsigned int id)
const;
145 cout<<
"Generic template"<<endl;
150 if ( cache->size() <= id )
151 cache->resize(
id+1,static_cast<V*>(0));
152 if ( (*cache)[
id] == 0 ) (*cache)[id]=
new V;
161 cout<<
"Destroying element"<<
id<<
" is last?"<<last<<endl;
163 if ( cache->size() < id ) {
165 msg<<
"Internal fatal error. Invalid G4Cache size (requested id: "<<
id<<
" but cache has size: "<<cache->size();
166 msg<<
" Possibly client created G4Cache object in a thread and tried to delete it from another thread!";
170 if ( cache->size() >
id && (*cache)[id] ) {
184 return *(cache->operator[](id));
196 cout<<
"Pointer template"<<endl;
199 cache =
new cache_container;
200 if ( cache->size() <= id )
201 cache->resize(
id+1,static_cast<V*>(0));
211 cout<<
"Destroying element"<<
id<<
" is last?"<<last<<
"-Pointer template specialization-"<<endl;
213 if ( cache->size() < id ) {
215 msg<<
"Internal fatal error. Invalid G4Cache size (requested id: "<<
id<<
" but cache has size: "<<cache->size();
216 msg<<
" Possibly client created G4Cache object in a thread and tried to delete it from another thread!";
220 if ( cache->size() >
id && (*cache)[id] ) {
235 return (cache->operator[](
id));
245 cout<<
"Specialized template for G4double"<<endl;
249 if (
cache->size() <= id )
250 cache->resize(
id+1,static_cast<G4double>(0));
258 if (
cache && last ) {
260 cout<<
"Destroying element"<<
id<<
" is last?"<<last<<
"-Pointer template specialization-"<<endl;
268 return cache->operator[](id);
std::vector< VALTYPE * > cache_container
void Initialize(unsigned int id)
static G4ThreadLocal cache_container * cache
std::ostringstream G4ExceptionDescription
std::vector< VALTYPE * > cache_container
static G4ThreadLocal cache_container * cache
std::vector< G4double > cache_container
static G4GLOB_DLL G4ThreadLocal std::vector< G4double > * cache
VALTYPE & GetCache(unsigned int id) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void Destroy(unsigned int id, G4bool last)