Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4CacheReference< VALTYPE > Class Template Reference

#include <G4CacheDetails.hh>

Public Member Functions

void Initialize (unsigned int id)
 
void Destroy (unsigned int id, G4bool last)
 
VALTYPE & GetCache (unsigned int id) const
 

Detailed Description

template<class VALTYPE>
class G4CacheReference< VALTYPE >

Definition at line 77 of file G4CacheDetails.hh.

Member Function Documentation

template<class V >
void G4CacheReference< V >::Destroy ( unsigned int  id,
G4bool  last 
)
inline

Definition at line 157 of file G4CacheDetails.hh.

158 {
159  if ( cache ) {
160 #ifdef g4cdebug
161  cout<<"Destroying element"<<id<<" is last?"<<last<<endl;
162 #endif
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!";
167  G4Exception("G4CacheReference<V>::Destroy","Cache001",FatalException,msg);
168  return;
169  }
170  if ( cache->size() > id && (*cache)[id] ) {
171  delete (*cache)[id];
172  (*cache)[id]=0;
173  }
174  if (last ) {
175  delete cache;
176  cache = 0;
177  }
178  }
179 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

template<class V >
V *& G4CacheReference< V >::GetCache ( unsigned int  id) const
inline

Definition at line 182 of file G4CacheDetails.hh.

183 {
184  return *(cache->operator[](id));
185 }
template<class V >
void G4CacheReference< V >::Initialize ( unsigned int  id)
inline

Definition at line 141 of file G4CacheDetails.hh.

142 {
143 #ifdef g4cdebug
144  if ( cache == 0 )
145  cout<<"Generic template"<<endl;
146 #endif
147  //Create cache container
148  if ( cache == 0 )
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;
153 
154 }

The documentation for this class was generated from the following file: