Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4CrossSectionDataSetRegistry.cc
Go to the documentation of this file.
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// -------------------------------------------------------------------
28//
29// GEANT4 Class file
30//
31//
32// File name: G4CrossSectionDataSetRegistry
33//
34// Author V.Ivanchenko 24.01.2009
35//
36// Modifications:
37//
38
39#include "G4ios.hh"
40
46
47// Needed for running with 'static' libraries to pull the references of the
48// declared factories
67
68G4ThreadLocal G4CrossSectionDataSetRegistry* G4CrossSectionDataSetRegistry::instance = nullptr;
69
71{
72 if(nullptr == instance) {
74 instance = inst.Instance();
75 }
76 return instance;
77}
78
80{}
81
86
88{
89 std::size_t n = xSections.size();
90 for (std::size_t i=0; i<n; ++i) {
91 G4VCrossSectionDataSet* p = xSections[i];
92 if(nullptr != p) {
93 delete p;
94 xSections[i] = nullptr;
95 }
96 }
97 n = xComponents.size();
98 for (std::size_t i=0; i<n; ++i) {
99 auto p = xComponents[i];
100 if(nullptr != p) {
101 delete p;
102 xComponents[i] = nullptr;
103 }
104 }
105}
106
108{
109 if(nullptr == p) { return; }
110 for (auto & xsec : xSections) {
111 if(xsec == p) { return; }
112 }
113 xSections.push_back(p);
114}
115
117{
118 if(nullptr == p) { return; }
119 std::size_t n = xSections.size();
120 for (std::size_t i=0; i<n; ++i) {
121 if(xSections[i] == p) {
122 xSections[i] = nullptr;
123 return;
124 }
125 }
126}
127
129{
130 if(nullptr == p) { return; }
131 for (auto & xsec : xComponents) {
132 if(xsec == p) { return; }
133 }
134 xComponents.push_back(p);
135}
136
138{
139 if(nullptr == p) { return; }
140 std::size_t n = xComponents.size();
141 for (std::size_t i=0; i<n; ++i) {
142 if(xComponents[i] == p) {
143 xComponents[i] = nullptr;
144 return;
145 }
146 }
147}
148
149void
151{
152 if(nullptr == p) { return; }
153 std::size_t n = xComponents.size();
154 for (std::size_t i=0; i<n; ++i) {
155 if(xComponents[i] == p) {
156 delete p;
157 return;
158 }
159 }
160}
161
164 G4bool warning)
165{
166 for (auto const & xsec : xSections) {
167 if (nullptr != xsec && xsec->GetName() == name) { return xsec; }
168 }
169 // check if factory exists...
170 //
173 // This throws if factory is not found, add second parameter
174 // to false to avoid this
175 G4VBaseXSFactory* factory = factories->GetFactory(name, warning );
176 if (nullptr != factory ) {
177 return factory->Instantiate();
178 } else {
179 G4VCrossSectionDataSet* ptr = nullptr;
180 return ptr;
181 }
182}
183
186{
187 for (auto & xsec : xComponents) {
188 if(nullptr != xsec && xsec->GetName() == name) { return xsec; }
189 }
190 G4VComponentCrossSection* ptr = nullptr;
191 return ptr;
192}
#define G4_REFERENCE_XS_FACTORY(cross_section)
bool G4bool
Definition G4Types.hh:86
void DeRegister(G4VCrossSectionDataSet *)
G4VCrossSectionDataSet * GetCrossSectionDataSet(const G4String &name, G4bool warning=false)
G4VComponentCrossSection * GetComponentCrossSection(const G4String &name)
G4CrossSectionDataSetRegistry(G4CrossSectionDataSetRegistry &)=delete
void Register(G4VCrossSectionDataSet *)
static G4CrossSectionDataSetRegistry * Instance()
void DeleteComponent(G4VComponentCrossSection *)
static G4CrossSectionFactoryRegistry * Instance()
G4VBaseXSFactory * GetFactory(const G4String &name, G4bool abortIfNotFound=true) const
virtual G4VCrossSectionDataSet * Instantiate()=0
#define G4ThreadLocal
Definition tls.hh:77