source: trunk/source/processes/hadronic/cross_sections/src/G4CrossSectionDataSetRegistry.cc@ 1201

Last change on this file since 1201 was 1196, checked in by garnier, 16 years ago

update CVS release candidate geant4.9.3.01

File size: 3.2 KB
Line 
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: G4CrossSectionDataSetRegistry.cc,v 1.5 2009/08/12 20:25:10 vnivanch Exp $
28// GEANT4 tag $Name: geant4-09-03-cand-01 $
29//
30// -------------------------------------------------------------------
31//
32// GEANT4 Class file
33//
34//
35// File name: G4CrossSectionDataSetRegistry
36//
37// Author V.Ivanchenko 24.01.2009
38//
39// Modifications:
40//
41
42#include "G4CrossSectionDataSetRegistry.hh"
43#include "G4VCrossSectionDataSet.hh"
44
45G4CrossSectionDataSetRegistry* G4CrossSectionDataSetRegistry::theInstance = 0;
46
47G4CrossSectionDataSetRegistry* G4CrossSectionDataSetRegistry::Instance()
48{
49 if(0 == theInstance) {
50 static G4CrossSectionDataSetRegistry manager;
51 theInstance = &manager;
52 }
53 return theInstance;
54}
55
56G4CrossSectionDataSetRegistry::G4CrossSectionDataSetRegistry()
57{}
58
59G4CrossSectionDataSetRegistry::~G4CrossSectionDataSetRegistry()
60{
61 Clean();
62}
63
64void G4CrossSectionDataSetRegistry::Clean()
65{
66 size_t n = xSections.size();
67 if(n > 0) {
68 for (size_t i=0; i<n; ++i) {
69 if(xSections[i]) delete xSections[i];
70 }
71 xSections.clear();
72 }
73}
74
75void G4CrossSectionDataSetRegistry::Register(G4VCrossSectionDataSet* p)
76{
77 if(!p) return;
78 size_t n = xSections.size();
79 if(n > 0) {
80 for (size_t i=0; i<n; ++i) {
81 if(xSections[i] == p) return;
82 }
83 }
84 xSections.push_back(p);
85}
86
87void G4CrossSectionDataSetRegistry::DeRegister(G4VCrossSectionDataSet* p)
88{
89 if(!p) return;
90 size_t n = xSections.size();
91 if(n > 0) {
92 for (size_t i=0; i<n; ++i) {
93 if(xSections[i] == p) {
94 xSections[i] = 0;
95 if(i == n-1) xSections.pop_back();
96 return;
97 }
98 }
99 }
100}
101
102
Note: See TracBrowser for help on using the repository browser.