Geant4-11
Public Member Functions | Private Types | Static Private Member Functions
G4CacheReference< G4double > Class Reference

#include <G4CacheDetails.hh>

Public Member Functions

void Destroy (unsigned int id, G4bool last)
 
G4doubleGetCache (unsigned int id) const
 
void Initialize (unsigned int id)
 

Private Types

using cache_container = std::vector< G4double >
 

Static Private Member Functions

static G4GLOB_DLL cache_container *& cache ()
 

Detailed Description

Definition at line 116 of file G4CacheDetails.hh.

Member Typedef Documentation

◆ cache_container

using G4CacheReference< G4double >::cache_container = std::vector<G4double>
private

Definition at line 126 of file G4CacheDetails.hh.

Member Function Documentation

◆ cache()

Definition at line 37 of file G4CacheDetails.cc.

38{
39 G4ThreadLocalStatic std::vector<G4double>* _instance = nullptr;
40 return _instance;
41}
#define G4ThreadLocalStatic
Definition: tls.hh:76

References G4ThreadLocalStatic.

◆ Destroy()

void G4CacheReference< G4double >::Destroy ( unsigned int  id,
G4bool  last 
)
inline

Definition at line 298 of file G4CacheDetails.hh.

299{
300 if(cache() != nullptr && last)
301 {
302#ifdef g4cdebug
303 std::cout << "DB: Destroying LAST element! Is it last? " << last
304 << std::endl;
305#endif
306 delete cache();
307 cache() = nullptr;
308 }
309}
static G4GLOB_DLL cache_container *& cache()

References G4CacheReference< VALTYPE >::cache().

◆ GetCache()

G4double & G4CacheReference< G4double >::GetCache ( unsigned int  id) const
inline

Definition at line 311 of file G4CacheDetails.hh.

312{
313 return cache()->operator[](id);
314}

References G4CacheReference< VALTYPE >::cache().

◆ Initialize()

void G4CacheReference< G4double >::Initialize ( unsigned int  id)
inline

Definition at line 283 of file G4CacheDetails.hh.

284{
285 if(cache() == nullptr)
286 {
287#ifdef g4cdebug
288 std::cout << "Specialized template for G4double container..." << std::endl;
289#endif
290 cache() = new cache_container;
291 }
292 if(cache()->size() <= id)
293 {
294 cache()->resize(id + 1, static_cast<G4double>(0));
295 }
296}
double G4double
Definition: G4Types.hh:83
std::vector< G4double > cache_container

References G4CacheReference< VALTYPE >::cache().


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