76 template<
class VALTYPE>
86 inline VALTYPE&
GetCache(
unsigned int id)
const;
89 typedef std::vector<VALTYPE*> cache_container;
103 template<
class VALTYPE>
110 inline VALTYPE*&
GetCache(
unsigned int id)
const;
113 typedef std::vector<VALTYPE*> cache_container;
129 typedef std::vector<G4double> cache_container;
145 cout<<
"Generic template"<<endl;
149 cache =
new cache_container;
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;
248 cache =
new cache_container;
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);
void Initialize(unsigned int id)
std::ostringstream G4ExceptionDescription
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)