Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4FieldManagerStore.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4FieldManagerStore.cc 103228 2017-03-22 14:52:32Z gcosmo $
28 //
29 // G4FieldManagerStore
30 //
31 // Implementation for singleton container
32 //
33 // History:
34 // 07.12.07 J.Apostolakis Adapted from G4LogicalVolumeStore
35 // --------------------------------------------------------------------
36 
37 #include "G4Types.hh"
38 #include "G4FieldManagerStore.hh"
39 #include "G4ChordFinder.hh"
40 
41 // ***************************************************************************
42 // Static class variables
43 // ***************************************************************************
44 //
47 
48 // ***************************************************************************
49 // Protected constructor: Construct underlying container with
50 // initial size of 100 entries
51 // ***************************************************************************
52 //
54  : std::vector<G4FieldManager*>()
55 {
56  reserve(100);
57 }
58 
59 // ***************************************************************************
60 // Destructor
61 // ***************************************************************************
62 //
64 {
65  Clean();
66  fgInstance = 0;
67 }
68 
69 // ***************************************************************************
70 // Delete all elements from the store
71 // ***************************************************************************
72 //
74 {
75  // Locks store for deletion of field managers. De-registration will be
76  // performed at this stage. G4FieldManagers will not de-register themselves.
77  //
78  locked = true;
79 
80  size_t i=0;
82 
83  for(iterator pos=store->begin(); pos!=store->end(); pos++)
84  {
85  if (*pos) { delete *pos; }
86  i++;
87  }
88 
89 #ifdef G4GEOMETRY_DEBUG
90  if (store->size() < i-1)
91  { G4cout << "No field managers deleted. Already deleted by user ?" << G4endl; }
92  else
93  { G4cout << i-1 << " field managers deleted !" << G4endl; }
94 #endif
95 
96  locked = false;
97  store->clear();
98 }
99 
100 // ***************************************************************************
101 // Add field manager to container
102 // ***************************************************************************
103 //
105 {
106  GetInstance()->push_back(pFieldManager);
107 }
108 
109 // ***************************************************************************
110 // Remove volume from container
111 // ***************************************************************************
112 //
114 {
115  if (!locked) // Do not de-register if locked !
116  {
117  for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
118  {
119  if (*i==pFieldMgr) // For LogVol was **i == *pLogVolume ... Reason?
120  {
121  GetInstance()->erase(i);
122  break;
123  }
124  }
125  }
126 }
127 
128 // ***************************************************************************
129 // Return ptr to Store, setting if necessary
130 // ***************************************************************************
131 //
133 {
134  if (!fgInstance)
135  {
137  }
138  return fgInstance;
139 }
140 
141 // ***************************************************************************
142 // Return ptr to Store
143 // ***************************************************************************
144 //
146 {
147  return fgInstance;
148 }
149 
150 // ***************************************************************************
151 // Globally reset the state
152 // ***************************************************************************
153 //
154 void
156 {
157  G4ChordFinder *pChordFnd;
158 
159  for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
160  {
161  pChordFnd = (*i)->GetChordFinder();
162  if( pChordFnd )
163  {
164  pChordFnd->ResetStepEstimate();
165  }
166  }
167 }
static G4FieldManagerStore * GetInstanceIfExist()
static const G4double pos
static G4FieldManagerStore * GetInstance()
#define G4endl
Definition: G4ios.hh:61
#define G4ThreadLocal
Definition: tls.hh:69
static G4ThreadLocal G4bool locked
static G4ThreadLocal G4FieldManagerStore * fgInstance
static void Register(G4FieldManager *pVolume)
bool G4bool
Definition: G4Types.hh:79
void ResetStepEstimate()
G4GLOB_DLL std::ostream G4cout
static void DeRegister(G4FieldManager *pVolume)