Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4HCIOcatalog implementation << 26 // File: G4HCIOcatalog.cc 27 // 27 // 28 // Author: Youhei Morita, 12.09.2001 << 28 // History: 29 // ------------------------------------------- << 29 // '01.09.12 Youhei Morita Initial creation 30 30 31 #include "G4HCIOcatalog.hh" 31 #include "G4HCIOcatalog.hh" >> 32 >> 33 // Addtional Include: 32 #include "G4VHCIOentry.hh" 34 #include "G4VHCIOentry.hh" 33 35 34 G4ThreadLocal G4HCIOcatalog* G4HCIOcatalog::f_ << 36 G4HCIOcatalog* G4HCIOcatalog::f_thePointer = 0; 35 37 36 // ------------------------------------------- << 38 // Implementation of Constructor #1 37 G4HCIOcatalog::G4HCIOcatalog() 39 G4HCIOcatalog::G4HCIOcatalog() 38 { << 40 : m_verbose(0) 39 } << 41 {} 40 42 41 // ------------------------------------------- << 43 // Implementation of GetHCIOcatalog 42 G4HCIOcatalog* G4HCIOcatalog::GetHCIOcatalog() 44 G4HCIOcatalog* G4HCIOcatalog::GetHCIOcatalog() 43 { 45 { 44 if(f_thePointer == nullptr) << 46 if ( f_thePointer == 0 ) f_thePointer = new G4HCIOcatalog; 45 f_thePointer = new G4HCIOcatalog; << 46 return f_thePointer; 47 return f_thePointer; 47 } 48 } 48 49 49 // ------------------------------------------- << 50 // Implementation of RegisterEntry 50 void G4HCIOcatalog::RegisterEntry(G4VHCIOentry 51 void G4HCIOcatalog::RegisterEntry(G4VHCIOentry* d) 51 { 52 { 52 if(m_verbose > 0) << 53 if ( m_verbose > 0 ) { 53 { << 54 G4cout << "registering I/O manager entry \"" << d->GetName() 54 G4cout << "registering I/O manager entry \ << 55 << "\" " << d << "." << G4endl; 55 << "." << G4endl; << 56 } 56 } 57 if(theCatalog.find(d->GetName()) != theCatal << 57 if ( theCatalog.find(d->GetName()) != theCatalog.end() ) { 58 { << 59 G4cout << "Redefining I/O Managers list " 58 G4cout << "Redefining I/O Managers list " << d->GetName() << G4endl; 60 } << 59 } else { 61 else << 62 { << 63 theCatalog[d->GetName()] = d; 60 theCatalog[d->GetName()] = d; 64 } 61 } 65 } 62 } 66 63 67 // ------------------------------------------- << 64 // Implementation of RegisterHCIOmanager 68 void G4HCIOcatalog::RegisterHCIOmanager(G4VPHi 65 void G4HCIOcatalog::RegisterHCIOmanager(G4VPHitsCollectionIO* d) 69 { 66 { 70 if(m_verbose > 0) << 67 if ( m_verbose > 0 ) { 71 { << 68 G4cout << "registering I/O manager \"" << d->SDname() 72 G4cout << "registering I/O manager \"" << << 69 << "\" " << d << "." << G4endl; 73 << G4endl; << 74 } 70 } 75 if(theStore.find(d->SDname()) != theStore.ce << 71 if ( theStore.find(d->SDname()) != theStore.end() ) { 76 { << 77 G4cout << "Redefining I/O Manager " << d-> 72 G4cout << "Redefining I/O Manager " << d->SDname() << G4endl; 78 } << 73 } else { 79 else << 80 { << 81 theStore[d->SDname()] = d; 74 theStore[d->SDname()] = d; 82 } 75 } 83 } 76 } 84 77 85 // ------------------------------------------- << 78 // Implementation of GetEntry 86 G4VHCIOentry* G4HCIOcatalog::GetEntry(const G4 << 79 G4VHCIOentry* G4HCIOcatalog::GetEntry(std::string name) 87 { 80 { 88 if(theCatalog.find(name) == theCatalog.end() << 81 if ( theCatalog.find(name) == theCatalog.end() ) { 89 { << 82 G4cout << "Hit Collection I/O manager entry \"" << name 90 G4cout << "Hit Collection I/O manager entr << 83 << "\" not found!" << std::endl; 91 << std::endl; << 84 return 0; 92 return nullptr; << 85 } else { 93 } << 94 else << 95 { << 96 G4VHCIOentry* ds = theCatalog[name]; 86 G4VHCIOentry* ds = theCatalog[name]; 97 return ds; 87 return ds; 98 } 88 } 99 } 89 } 100 90 101 // ------------------------------------------- << 91 // Implementation of GetHCIOmanager 102 G4VPHitsCollectionIO* G4HCIOcatalog::GetHCIOma << 92 G4VPHitsCollectionIO* G4HCIOcatalog::GetHCIOmanager(std::string name) 103 { 93 { 104 if(theStore.find(name) == theStore.cend()) << 94 if ( theStore.find(name) == theStore.end() ) { 105 { << 95 G4cout << "Hit Collection I/O manager \"" << name 106 G4cout << "Hit Collection I/O manager \"" << 96 << "\" not found!" << G4endl; 107 << G4endl; << 97 return 0; 108 return nullptr; << 98 } else { 109 } << 110 else << 111 { << 112 G4VPHitsCollectionIO* ds = theStore[name]; 99 G4VPHitsCollectionIO* ds = theStore[name]; 113 return ds; 100 return ds; 114 } 101 } 115 } 102 } 116 103 117 // ------------------------------------------- << 104 // Implementation of PrintEntries 118 void G4HCIOcatalog::PrintEntries() 105 void G4HCIOcatalog::PrintEntries() 119 { 106 { 120 G4cout << "I/O manager entries: "; 107 G4cout << "I/O manager entries: "; 121 G4cout << theCatalog.size() << G4endl; 108 G4cout << theCatalog.size() << G4endl; 122 for(auto it = theCatalog.cbegin(); it != the << 109 HCIOmap::const_iterator it; 123 { << 110 for ( it=theCatalog.begin(); it != theCatalog.end(); it++ ) { 124 G4cout << " --- " << (*it).first << G4end 111 G4cout << " --- " << (*it).first << G4endl; 125 } 112 } 126 } 113 } 127 114 128 // ------------------------------------------- << 115 // Implementation of CurrentHCIOmanager 129 G4String G4HCIOcatalog::CurrentHCIOmanager() << 116 std::string G4HCIOcatalog::CurrentHCIOmanager() 130 { 117 { 131 G4String list = ""; << 118 std::string list = ""; 132 for(auto it = theStore.cbegin(); it != theSt << 119 HCIOstore::const_iterator it; 133 { << 120 for ( it=theStore.begin(); it != theStore.end(); it++ ) { 134 list += (*it).first + " "; 121 list += (*it).first + " "; 135 } 122 } 136 return list; 123 return list; 137 } 124 } 138 125 139 // ------------------------------------------- << 126 // Implementation of PrintHCIOmanager 140 void G4HCIOcatalog::PrintHCIOmanager() 127 void G4HCIOcatalog::PrintHCIOmanager() 141 { 128 { 142 G4cout << "I/O managers: "; 129 G4cout << "I/O managers: "; 143 G4cout << theStore.size() << G4endl; 130 G4cout << theStore.size() << G4endl; 144 for(auto it = theStore.cbegin(); it != theSt << 131 HCIOstore::const_iterator it; 145 { << 132 for ( it=theStore.begin(); it != theStore.end(); it++ ) { 146 G4cout << " --- " << (*it).first << ", " << 133 G4cout << " --- " << (*it).first >> 134 << ", " << (*it).second << "." << G4endl; 147 } 135 } 148 } 136 } 149 137 150 // ------------------------------------------- << 138 // Implementation of GetHCIOmanager 151 G4VPHitsCollectionIO* G4HCIOcatalog::GetHCIOma << 139 G4VPHitsCollectionIO* G4HCIOcatalog::GetHCIOmanager(int n) 152 { 140 { 153 G4int i = 0; << 141 int i = 0; 154 for(auto it = theStore.cbegin(); it != theSt << 142 HCIOstore::const_iterator it; 155 { << 143 for ( it=theStore.begin(); it != theStore.end(); it++ ) { 156 if(i++ == n) << 144 if (i++ == n) return (*it).second; 157 return (*it).second; << 158 } 145 } 159 return nullptr; << 146 return 0; 160 } 147 } >> 148 >> 149 // End of G4HCIOcatalog.cc >> 150 161 151