Geant4-11
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
G4NavigationHistoryPool Class Reference

#include <G4NavigationHistoryPool.hh>

Public Member Functions

void Clean ()
 
void DeRegister (std::vector< G4NavigationLevel > *pLevels)
 
std::vector< G4NavigationLevel > * GetLevels ()
 
std::vector< G4NavigationLevel > * GetNewLevels ()
 
void Print () const
 
 ~G4NavigationHistoryPool ()
 

Static Public Member Functions

static G4NavigationHistoryPoolGetInstance ()
 

Private Member Functions

 G4NavigationHistoryPool ()
 
void Register (std::vector< G4NavigationLevel > *pLevels)
 
void Reset ()
 

Private Attributes

std::vector< std::vector< G4NavigationLevel > * > fFree
 
std::vector< std::vector< G4NavigationLevel > * > fPool
 

Static Private Attributes

static G4ThreadLocal G4NavigationHistoryPoolfgInstance = nullptr
 

Detailed Description

Definition at line 43 of file G4NavigationHistoryPool.hh.

Constructor & Destructor Documentation

◆ ~G4NavigationHistoryPool()

G4NavigationHistoryPool::~G4NavigationHistoryPool ( )

Definition at line 57 of file G4NavigationHistoryPool.cc.

58{
59 Clean(); fgInstance = nullptr;
60}
static G4ThreadLocal G4NavigationHistoryPool * fgInstance

References Clean(), and fgInstance.

◆ G4NavigationHistoryPool()

G4NavigationHistoryPool::G4NavigationHistoryPool ( )
private

Definition at line 47 of file G4NavigationHistoryPool.cc.

48{
49 fPool.reserve(512);
50 fFree.reserve(512);
51}
std::vector< std::vector< G4NavigationLevel > * > fPool
std::vector< std::vector< G4NavigationLevel > * > fFree

References fFree, and fPool.

Referenced by GetInstance().

Member Function Documentation

◆ Clean()

void G4NavigationHistoryPool::Clean ( )

Definition at line 66 of file G4NavigationHistoryPool.cc.

67{
68 for(size_t i=0; i<fPool.size(); ++i)
69 {
70 delete fPool[i];
71 }
72 fPool.clear();
73 fFree.clear();
74}

References fFree, and fPool.

Referenced by ~G4NavigationHistoryPool().

◆ DeRegister()

void G4NavigationHistoryPool::DeRegister ( std::vector< G4NavigationLevel > *  pLevels)
inline

Definition at line 102 of file G4NavigationHistoryPool.hh.

104{
105 fFree.push_back(pLevels);
106}

References fFree.

Referenced by G4NavigationHistory::~G4NavigationHistory().

◆ GetInstance()

G4NavigationHistoryPool * G4NavigationHistoryPool::GetInstance ( )
static

◆ GetLevels()

std::vector< G4NavigationLevel > * G4NavigationHistoryPool::GetLevels ( )
inline

Definition at line 126 of file G4NavigationHistoryPool.hh.

127{
128 std::vector<G4NavigationLevel> * levels = 0;
129
130 if (fFree.size() !=0)
131 {
132 levels = fFree.back();
133 fFree.pop_back();
134 }
135 else
136 {
137 levels = GetNewLevels();
138 }
139
140 return levels;
141}
std::vector< G4NavigationLevel > * GetNewLevels()

References fFree, and GetNewLevels().

Referenced by G4NavigationHistory::G4NavigationHistory().

◆ GetNewLevels()

std::vector< G4NavigationLevel > * G4NavigationHistoryPool::GetNewLevels ( )
inline

Definition at line 112 of file G4NavigationHistoryPool.hh.

113{
114 std::vector<G4NavigationLevel> * aLevelVec =
115 new std::vector<G4NavigationLevel>(kHistoryMax);
116 Register(aLevelVec);
117
118 return aLevelVec;
119}
void Register(std::vector< G4NavigationLevel > *pLevels)
static const G4int kHistoryMax
Definition: geomdefs.hh:92

References kHistoryMax, and Register().

Referenced by GetLevels().

◆ Print()

void G4NavigationHistoryPool::Print ( ) const

Definition at line 80 of file G4NavigationHistoryPool.cc.

81{
82#ifdef G4VERBOSE
83 G4cout << "Total navigation history collections cleaned: "
84 << fPool.size() << G4endl;
85#endif
86}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout

References fPool, G4cout, and G4endl.

Referenced by G4RunManagerKernel::~G4RunManagerKernel().

◆ Register()

void G4NavigationHistoryPool::Register ( std::vector< G4NavigationLevel > *  pLevels)
inlineprivate

Definition at line 92 of file G4NavigationHistoryPool.hh.

94{
95 fPool.push_back(pLevels);
96}

References fPool.

Referenced by GetNewLevels().

◆ Reset()

void G4NavigationHistoryPool::Reset ( )
private

Definition at line 92 of file G4NavigationHistoryPool.cc.

93{
94 for(size_t i=0; i<fPool.size(); ++i)
95 {
96 fPool[i] = 0;
97 }
98 for(size_t j=0; j<fFree.size(); ++j)
99 {
100 fFree[j] = 0;
101 }
102}

References fFree, and fPool.

Field Documentation

◆ fFree

std::vector<std::vector<G4NavigationLevel> *> G4NavigationHistoryPool::fFree
private

◆ fgInstance

G4ThreadLocal G4NavigationHistoryPool * G4NavigationHistoryPool::fgInstance = nullptr
staticprivate

Definition at line 82 of file G4NavigationHistoryPool.hh.

Referenced by GetInstance(), and ~G4NavigationHistoryPool().

◆ fPool

std::vector<std::vector<G4NavigationLevel> *> G4NavigationHistoryPool::fPool
private

Definition at line 84 of file G4NavigationHistoryPool.hh.

Referenced by Clean(), G4NavigationHistoryPool(), Print(), Register(), and Reset().


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