Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
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 76 of file G4CacheDetails.hh.

Member Function Documentation

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

Definition at line 156 of file G4CacheDetails.hh.

157 {
158  if ( cache ) {
159 #ifdef g4cdebug
160  cout<<"Destroying element"<<id<<" is last?"<<last<<endl;
161 #endif
162  if ( cache->size() <id && (*cache)[id] ) {
163  delete (*cache)[id];
164  (*cache)[id]=0;
165  }
166  if (last ) {
167  delete cache;
168  cache = 0;
169  }
170  }
171 }
template<class V >
V *& G4CacheReference< V >::GetCache ( unsigned int  id) const
inline

Definition at line 174 of file G4CacheDetails.hh.

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

Definition at line 140 of file G4CacheDetails.hh.

141 {
142 #ifdef g4cdebug
143  if ( cache == 0 )
144  cout<<"Generic template"<<endl;
145 #endif
146  //Create cache container
147  if ( cache == 0 )
148  cache = new cache_container;
149  if ( cache->size() <= id )
150  cache->resize(id+1,static_cast<V*>(0));
151  if ( (*cache)[id] == 0 ) (*cache)[id]=new V;
152 
153 }

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