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

Last change on this file since 1228 was 1228, checked in by garnier, 14 years ago

update geant4.9.3 tag

File size: 3.3 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.6 2009/12/02 15:59:59 vnivanch Exp $
28// GEANT4 tag $Name: geant4-09-03 $
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]) {
70        G4VCrossSectionDataSet* p = xSections[i];
71        xSections[i] = 0;
72        delete p;
73      }
74    }
75    xSections.clear();
76  }
77}
78
79void G4CrossSectionDataSetRegistry::Register(G4VCrossSectionDataSet* p)
80{
81  if(!p) return;
82  size_t n = xSections.size(); 
83  if(n > 0) {
84    for (size_t i=0; i<n; ++i) {
85      if(xSections[i] == p) { return; }
86    }
87  }
88  xSections.push_back(p);
89}
90
91void G4CrossSectionDataSetRegistry::DeRegister(G4VCrossSectionDataSet* p)
92{
93  if(!p) return;
94  size_t n = xSections.size(); 
95  if(n > 0) {
96    for (size_t i=0; i<n; ++i) {
97      if(xSections[i] == p) {
98        xSections[i] = 0;
99        if(i == n-1) { xSections.pop_back(); }
100        return;
101      }
102    }
103  }
104}
105
106
Note: See TracBrowser for help on using the repository browser.