Geant4 Cross Reference |
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 // File name: G4HadDataHandler 32 // 33 // Author: V. Ivanchenko 34 // 35 // Creation date: 05 July 2022 36 // 37 // Modifications: 38 // 39 // ------------------------------------------------------------------- 40 // 41 // 42 43 #include "G4HadDataHandler.hh" 44 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 46 47 G4HadDataHandler::G4HadDataHandler(std::size_t n) : tLength(n) 48 { 49 data.resize(n, nullptr); 50 } 51 52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 53 54 G4HadDataHandler::~G4HadDataHandler() 55 { 56 for(std::size_t i=0; i<tLength; ++i) { 57 for(std::size_t j = i+1; j<tLength; ++j) { 58 if(data[j] == data[i]) { data[j] = nullptr; } 59 } 60 CleanTable(i); 61 } 62 } 63 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 65 66 void G4HadDataHandler::AddTable(G4PhysicsTable* ptr) 67 { 68 data.push_back(ptr); 69 ++tLength; 70 } 71 72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 73 74 void G4HadDataHandler::UpdateTable(G4PhysicsTable* ptr, std::size_t idx) 75 { 76 // update table pointer but not delete previous 77 if(idx < tLength) { 78 if(ptr != data[idx]) { data[idx] = ptr; } 79 } else { 80 G4cout << "### G4HadDataHandler::UpdateTable fail for idx=" << idx 81 << " length=" << tLength << G4endl; 82 } 83 } 84 85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 86 87 void G4HadDataHandler::CleanTable(std::size_t idx) 88 { 89 if(idx < tLength && nullptr != data[idx]) { 90 data[idx]->clearAndDestroy(); 91 delete data[idx]; 92 data[idx] = nullptr; 93 } 94 } 95 96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 97 98 void G4HadDataHandler::SetMasterProcess(const G4VProcess* ptr) 99 { 100 masterProcess.push_back(ptr); 101 } 102 103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 104 105 const G4VProcess* G4HadDataHandler::GetMasterProcess(const size_t idx) const 106 { 107 return (idx < masterProcess.size()) ? masterProcess[idx] : nullptr; 108 } 109 110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 111