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 // G4PersistencyCenter implementation << 26 // File: G4PersistencyCenter.cc 27 // 27 // 28 // Author: Youhei Morita, 10.08.2001 << 28 // History: 29 // ------------------------------------------- << 29 // '01.08.10 Youhei Morita Initial creation (with "fadsclass3") 30 30 31 #include "G4PersistencyCenter.hh" 31 #include "G4PersistencyCenter.hh" >> 32 >> 33 // Forward Declarations: 32 #include "G4PersistencyCenterMessenger.hh" 34 #include "G4PersistencyCenterMessenger.hh" 33 35 >> 36 // Addtional Include: 34 #include "G4UImanager.hh" 37 #include "G4UImanager.hh" 35 #include "G4PersistencyManager.hh" 38 #include "G4PersistencyManager.hh" 36 #include "G4VHCIOentry.hh" 39 #include "G4VHCIOentry.hh" 37 #include "G4VDCIOentry.hh" 40 #include "G4VDCIOentry.hh" 38 41 39 G4ThreadLocal G4PersistencyCenter* G4Persisten << 42 G4PersistencyCenter* G4PersistencyCenter::f_thePointer=G4PersistencyCenter::GetPersistencyCenter(); 40 43 41 // ------------------------------------------- << 44 // Implementation of Constructor #1 42 G4PersistencyCenter::G4PersistencyCenter() 45 G4PersistencyCenter::G4PersistencyCenter() >> 46 : m_verbose(0) 43 { 47 { 44 f_wrObj[0] = "HepMC"; 48 f_wrObj[0] = "HepMC"; 45 f_wrObj[1] = "MCTruth"; 49 f_wrObj[1] = "MCTruth"; 46 f_wrObj[2] = "Hits"; 50 f_wrObj[2] = "Hits"; 47 f_wrObj[3] = "Digits"; 51 f_wrObj[3] = "Digits"; 48 52 49 f_rdObj[0] = "Hits"; 53 f_rdObj[0] = "Hits"; 50 f_rdObj[1] = "HitsBG"; 54 f_rdObj[1] = "HitsBG"; 51 55 52 for(auto itr = f_wrObj.cbegin(); itr != f_wr << 56 ObjMap::iterator itr; 53 { << 57 >> 58 for ( itr = f_wrObj.begin(); itr != f_wrObj.end(); itr++ ) { 54 f_writeFileName[(*itr).second] = "G4defaul 59 f_writeFileName[(*itr).second] = "G4defaultOutput"; 55 } 60 } 56 61 57 for(auto itr = f_rdObj.cbegin(); itr != f_rd << 62 for ( itr = f_rdObj.begin(); itr != f_rdObj.end(); itr++ ) { 58 { << 59 f_readFileName[(*itr).second] = "G4default 63 f_readFileName[(*itr).second] = "G4defaultInput"; 60 } 64 } 61 65 62 f_writeFileMode["HepMC"] = kRecycle; 66 f_writeFileMode["HepMC"] = kRecycle; 63 f_writeFileMode["MCTruth"] = kOn; 67 f_writeFileMode["MCTruth"] = kOn; 64 f_writeFileMode["Hits"] = kOn; 68 f_writeFileMode["Hits"] = kOn; 65 f_writeFileMode["Digits"] = kOff; 69 f_writeFileMode["Digits"] = kOff; 66 70 67 f_readFileMode["Hits"] = false; 71 f_readFileMode["Hits"] = false; 68 f_readFileMode["HitsBG"] = false; 72 f_readFileMode["HitsBG"] = false; 69 73 70 f_theMessenger = new G4PersistencyCenterMe << 74 f_theMessenger = new G4PersistencyCenterMessenger(this); 71 f_currentManager = new G4PersistencyManager( 75 f_currentManager = new G4PersistencyManager(this, "Default"); 72 } 76 } 73 77 74 // ------------------------------------------- << 78 // Fake implementation of Copy Constructor >> 79 G4PersistencyCenter::G4PersistencyCenter(const G4PersistencyCenter& c) >> 80 : f_theMessenger(0), f_currentManager(0), m_verbose(0) >> 81 { >> 82 *this = c; >> 83 } >> 84 >> 85 // Implementation of Destructor #1 75 G4PersistencyCenter::~G4PersistencyCenter() 86 G4PersistencyCenter::~G4PersistencyCenter() 76 { 87 { 77 delete f_theMessenger; 88 delete f_theMessenger; 78 delete f_currentManager; 89 delete f_currentManager; 79 } 90 } 80 91 81 // ------------------------------------------- << 92 // Implementation of GetPersistencyCenter 82 G4PersistencyCenter* G4PersistencyCenter::GetP 93 G4PersistencyCenter* G4PersistencyCenter::GetPersistencyCenter() 83 { 94 { 84 if(f_thePointer == nullptr) << 95 if ( f_thePointer == 0 ) f_thePointer = new G4PersistencyCenter; 85 f_thePointer = new G4PersistencyCenter; << 86 return f_thePointer; 96 return f_thePointer; 87 } 97 } 88 98 89 // ------------------------------------------- << 99 90 void G4PersistencyCenter::SelectSystem(const G << 100 // Implementation of SelectSystem >> 101 void G4PersistencyCenter::SelectSystem(std::string systemName) 91 { 102 { 92 G4int st = 0; << 103 int st = 0; 93 104 94 if(f_currentManager != nullptr) << 105 if (f_currentManager!=0) delete f_currentManager; 95 delete f_currentManager; << 96 106 97 G4PersistencyManager* pm = nullptr; << 107 G4PersistencyManager* pm = 0; 98 108 99 if(systemName == "ROOT") << 109 if (systemName=="None") 100 { 110 { 101 G4cout << " G4PersistencyCenter: \"ROOT\" << 111 G4cout<<" G4PersistencyCenter: Default is selected."<< G4endl; 102 << G4endl; << 112 pm = new G4PersistencyManager(this, "Default"); >> 113 } >> 114 else if (systemName=="ROOT") >> 115 { >> 116 G4cout<<" G4PersistencyCenter: \"ROOT\" Persistency Package is selected." >> 117 <<G4endl; 103 // G4UImanager *man=G4UImanager::GetUIpoin 118 // G4UImanager *man=G4UImanager::GetUIpointer(); 104 // std::string libs="Cint:Core:Tree:Rint:M 119 // std::string libs="Cint:Core:Tree:Rint:Matrix:Physics:fadsROOT"; 105 // st = man->ApplyCommand("/load "+libs); 120 // st = man->ApplyCommand("/load "+libs); 106 if(st == 0) << 121 if ( st == 0 ) { 107 { << 108 pm = GetPersistencyManager("ROOT"); 122 pm = GetPersistencyManager("ROOT"); 109 } 123 } 110 } 124 } 111 else if(systemName == "ODBMS") << 125 else if (systemName=="ODBMS") 112 { 126 { 113 G4cout << " G4PersistencyCenter: \"ODBMS\" << 127 G4cout<<" G4PersistencyCenter: \"ODBMS\" package is selected."<<G4endl; 114 // G4UImanager *man=G4UImanager::GetUIpoin 128 // G4UImanager *man=G4UImanager::GetUIpointer(); 115 // std::string libs="fadsODBMS"; 129 // std::string libs="fadsODBMS"; 116 // st = man->ApplyCommand("/load "+libs); 130 // st = man->ApplyCommand("/load "+libs); 117 if(st == 0) << 131 if ( st == 0 ) { 118 { << 119 pm = GetPersistencyManager("ODBMS"); 132 pm = GetPersistencyManager("ODBMS"); 120 } 133 } 121 } 134 } 122 else << 135 if ( st == 0 ) { 123 { << 124 G4cout << " G4PersistencyCenter: Default i << 125 pm = new G4PersistencyManager(this, "Defau << 126 } << 127 << 128 if(st == 0) << 129 { << 130 f_currentManager = pm->Create(); 136 f_currentManager = pm->Create(); 131 if(f_currentManager != nullptr) << 137 if (f_currentManager!=0) f_currentManager->SetVerboseLevel(m_verbose); 132 f_currentManager->SetVerboseLevel(m_verb << 133 f_currentSystemName = systemName; 138 f_currentSystemName = systemName; 134 } 139 } 135 } 140 } 136 141 137 // ------------------------------------------- << 142 // Implementation of SetHepMCObjyReaderFile 138 void G4PersistencyCenter::SetHepMCObjyReaderFi << 143 void G4PersistencyCenter::SetHepMCObjyReaderFile(std::string file) 139 { 144 { 140 if(SetReadFile("HepMC", file)) << 145 if ( SetReadFile("HepMC", file) ) { 141 { << 142 SetRetrieveMode("HepMC", true); 146 SetRetrieveMode("HepMC", true); 143 } 147 } 144 } 148 } 145 149 146 // ------------------------------------------- << 150 // Implementation of CurrentHepMCObjyReaderFile 147 G4String G4PersistencyCenter::CurrentHepMCObjy << 151 std::string G4PersistencyCenter::CurrentHepMCObjyReaderFile() 148 { 152 { 149 if(CurrentRetrieveMode("HepMC")) << 153 if ( CurrentRetrieveMode("HepMC") ) { 150 { << 151 return CurrentReadFile("HepMC"); 154 return CurrentReadFile("HepMC"); 152 } << 155 } else { 153 else << 154 { << 155 return ""; 156 return ""; 156 } 157 } 157 } 158 } 158 159 159 // ------------------------------------------- << 160 // Implementation of SetStoreMode 160 void G4PersistencyCenter::SetStoreMode(const G << 161 void G4PersistencyCenter::SetStoreMode(std::string objName, StoreMode mode) 161 { 162 { 162 if((*(f_writeFileName.find(objName))).second << 163 if ( (*(f_writeFileName.find(objName))).second != "" ) { 163 { << 164 f_writeFileMode[objName] = mode; 164 f_writeFileMode[objName] = mode; 165 } << 165 } else { 166 else << 166 G4cerr << "!! unknown object type " << objName << " for output." 167 { << 167 << G4endl; 168 G4cerr << "!! unknown object type " << obj << 169 } 168 } 170 } 169 } 171 170 172 // ------------------------------------------- << 171 // Implementation of SetRetrieveMode 173 void G4PersistencyCenter::SetRetrieveMode(cons << 172 void G4PersistencyCenter::SetRetrieveMode(std::string objName, G4bool mode) 174 { 173 { 175 if((*(f_readFileName.find(objName))).second << 174 if ( (*(f_readFileName.find(objName))).second != "" ) { 176 { << 177 f_readFileMode[objName] = mode; 175 f_readFileMode[objName] = mode; 178 } << 176 } else { 179 else << 177 G4cerr << "!! unknown object type " << objName << " for input." 180 { << 178 << G4endl; 181 G4cerr << "!! unknown object type " << obj << 182 } 179 } 183 } 180 } 184 181 185 // ------------------------------------------- << 182 // Implementation of CurrentStoreMode 186 StoreMode G4PersistencyCenter::CurrentStoreMod << 183 StoreMode G4PersistencyCenter::CurrentStoreMode(std::string objName) 187 { 184 { 188 if((*(f_writeFileName.find(objName))).second << 185 189 { << 186 >> 187 if ( (*(f_writeFileName.find(objName))).second != "" ) { 190 return f_writeFileMode[objName]; 188 return f_writeFileMode[objName]; 191 } << 189 } else { 192 else << 193 { << 194 return kOff; 190 return kOff; 195 } 191 } 196 } 192 } 197 193 198 // ------------------------------------------- << 194 // Implementation of CurrentRetrieveMode 199 G4bool G4PersistencyCenter::CurrentRetrieveMod << 195 G4bool G4PersistencyCenter::CurrentRetrieveMode(std::string objName) 200 { 196 { 201 if((*(f_readFileName.find(objName))).second << 197 if ( (*(f_readFileName.find(objName))).second != "" ) { 202 { << 203 return f_readFileMode[objName]; 198 return f_readFileMode[objName]; 204 } << 199 } else { 205 else << 206 { << 207 return false; 200 return false; 208 } 201 } 209 } 202 } 210 203 211 // ------------------------------------------- << 204 // Implementation of SetWriteFile 212 G4bool G4PersistencyCenter::SetWriteFile(const << 205 G4bool G4PersistencyCenter::SetWriteFile(std::string objName, std::string writeFileName) 213 const << 214 { 206 { 215 if((*(f_writeFileName.find(objName))).second << 207 if ( (*(f_writeFileName.find(objName))).second != "" ) { 216 { << 217 f_writeFileName[objName] = writeFileName; 208 f_writeFileName[objName] = writeFileName; 218 } << 209 } else { 219 else << 210 G4cerr << "!! unknown object type " << objName << " for output." 220 { << 211 << G4endl; 221 G4cerr << "!! unknown object type " << obj << 222 return false; 212 return false; 223 } 213 } 224 return true; 214 return true; 225 } 215 } 226 216 227 // ------------------------------------------- << 217 // Implementation of SetReadFile 228 G4bool G4PersistencyCenter::SetReadFile(const << 218 G4bool G4PersistencyCenter::SetReadFile(std::string objName, std::string readFileName) 229 const << 230 { 219 { 231 #ifndef WIN32 220 #ifndef WIN32 232 if(f_ut.FileExists(readFileName)) << 221 if ( f_ut.FileExists(readFileName) ) 233 { 222 { 234 f_readFileName[objName] = readFileName; 223 f_readFileName[objName] = readFileName; 235 } 224 } 236 else 225 else 237 { 226 { 238 G4cerr << "!! File \"" << objName << "\" d << 227 G4cerr << "!! File \"" << objName << "\" does not exist." >> 228 << G4endl; 239 return false; 229 return false; 240 } 230 } 241 #endif 231 #endif 242 return true; 232 return true; 243 } 233 } 244 234 245 // ------------------------------------------- << 235 // Implementation of CurrentWriteFile 246 G4String G4PersistencyCenter::CurrentWriteFile << 236 std::string G4PersistencyCenter::CurrentWriteFile(std::string objName) 247 { 237 { 248 if((*(f_writeFileName.find(objName))).second << 238 if ( (*(f_writeFileName.find(objName))).second != "" ) { 249 { << 250 return f_writeFileName[objName]; 239 return f_writeFileName[objName]; 251 } << 240 } else { 252 else << 253 { << 254 return "?????"; 241 return "?????"; 255 } 242 } 256 } 243 } 257 244 258 // ------------------------------------------- << 245 // Implementation of CurrentReadFile 259 G4String G4PersistencyCenter::CurrentReadFile( << 246 std::string G4PersistencyCenter::CurrentReadFile(std::string objName) 260 { 247 { 261 if((*(f_readFileName.find(objName))).second << 248 if ( (*(f_readFileName.find(objName))).second != "" ) { 262 { << 263 return f_readFileName[objName]; 249 return f_readFileName[objName]; 264 } << 250 } else { 265 else << 266 { << 267 return "?????"; 251 return "?????"; 268 } 252 } 269 } 253 } 270 254 271 // ------------------------------------------- << 255 // Implementation of CurrentObject 272 G4String G4PersistencyCenter::CurrentObject(co << 256 std::string G4PersistencyCenter::CurrentObject(std::string file) 273 { 257 { 274 for(auto itr = f_readFileName.cbegin(); itr << 258 FileMap::iterator itr; 275 { << 259 for ( itr = f_readFileName.begin(); itr != f_readFileName.end(); itr++ ) { 276 if(file == (*itr).second) << 260 if ( file == (*itr).second ) return (*itr).first; 277 return (*itr).first; << 278 } 261 } 279 for(auto itr = f_writeFileName.cbegin(); itr << 262 for ( itr = f_writeFileName.begin(); itr != f_writeFileName.end(); itr++ ) { 280 { << 263 if ( file == (*itr).second ) return (*itr).first; 281 if(file == (*itr).second) << 282 return (*itr).first; << 283 } 264 } 284 return "?????"; 265 return "?????"; 285 } 266 } 286 267 287 // ------------------------------------------- << 268 // Implementation of AddHCIOmanager 288 void G4PersistencyCenter::AddHCIOmanager(const << 269 void G4PersistencyCenter::AddHCIOmanager(std::string detName, std::string colName) 289 const << 290 { 270 { 291 G4HCIOcatalog* ioc = G4HCIOcatalog::GetHCIOc 271 G4HCIOcatalog* ioc = G4HCIOcatalog::GetHCIOcatalog(); 292 272 293 G4VHCIOentry* ioe = ioc->GetEntry(detName); 273 G4VHCIOentry* ioe = ioc->GetEntry(detName); 294 if(ioe != nullptr) << 274 if ( ioe != 0 ) { 295 { << 296 ioe->CreateHCIOmanager(detName, colName); 275 ioe->CreateHCIOmanager(detName, colName); 297 } << 276 } else { 298 else << 299 { << 300 G4cerr << "Error! -- HCIO assignment faile 277 G4cerr << "Error! -- HCIO assignment failed for detector " << detName 301 << ", collection " << colName << G4 << 278 << ", collection " << colName << G4endl; 302 } 279 } 303 } 280 } 304 281 305 // ------------------------------------------- << 282 // Implementation of CurrentHCIOmanager 306 G4String G4PersistencyCenter::CurrentHCIOmanag << 283 std::string G4PersistencyCenter::CurrentHCIOmanager() 307 { 284 { 308 G4HCIOcatalog* ioc = G4HCIOcatalog::GetHCIOc 285 G4HCIOcatalog* ioc = G4HCIOcatalog::GetHCIOcatalog(); 309 return ioc->CurrentHCIOmanager(); 286 return ioc->CurrentHCIOmanager(); 310 } 287 } 311 288 312 // ------------------------------------------- << 289 // Implementation of AddDCIOmanager 313 void G4PersistencyCenter::AddDCIOmanager(const << 290 void G4PersistencyCenter::AddDCIOmanager(std::string detName) 314 { 291 { 315 G4DCIOcatalog* ioc = G4DCIOcatalog::GetDCIOc 292 G4DCIOcatalog* ioc = G4DCIOcatalog::GetDCIOcatalog(); 316 293 317 G4String colName = ""; << 294 std::string colName = ""; 318 G4VDCIOentry* ioe = ioc->GetEntry(detName); 295 G4VDCIOentry* ioe = ioc->GetEntry(detName); 319 if(ioe != nullptr) << 296 if ( ioe != 0 ) { 320 { << 321 ioe->CreateDCIOmanager(detName, colName); 297 ioe->CreateDCIOmanager(detName, colName); 322 } << 298 } else { 323 else << 324 { << 325 G4cerr << "Error! -- DCIO assignment faile 299 G4cerr << "Error! -- DCIO assignment failed for detector " << detName 326 << ", collection " << colName << G4 << 300 << ", collection " << colName << G4endl; 327 } 301 } 328 } 302 } 329 303 330 // ------------------------------------------- << 304 // Implementation of CurrentDCIOmanager 331 G4String G4PersistencyCenter::CurrentDCIOmanag << 305 std::string G4PersistencyCenter::CurrentDCIOmanager() 332 { 306 { 333 G4DCIOcatalog* ioc = G4DCIOcatalog::GetDCIOc 307 G4DCIOcatalog* ioc = G4DCIOcatalog::GetDCIOcatalog(); 334 return ioc->CurrentDCIOmanager(); 308 return ioc->CurrentDCIOmanager(); 335 } 309 } 336 310 337 // ------------------------------------------- << 311 // Implementation of PrintAll 338 void G4PersistencyCenter::PrintAll() 312 void G4PersistencyCenter::PrintAll() 339 { 313 { 340 G4cout << "Persistency Package: " << Current 314 G4cout << "Persistency Package: " << CurrentSystem() << G4endl; 341 G4cout << G4endl; 315 G4cout << G4endl; 342 316 343 G4String name, file; << 317 ObjMap::iterator itr; 344 StoreMode mode; << 318 std::string name; >> 319 std::string file; >> 320 StoreMode mode; 345 321 346 G4cout << "Output object types and file name 322 G4cout << "Output object types and file names:" << G4endl; 347 for(auto itr = f_wrObj.cbegin(); itr != f_wr << 323 for ( itr = f_wrObj.begin(); itr != f_wrObj.end(); itr++ ) { 348 { << 349 name = (*itr).second; 324 name = (*itr).second; 350 // disabled HepMC and MCTruth for now 325 // disabled HepMC and MCTruth for now 351 if(name != "HepMC" && name != "MCTruth") << 326 if ( name != "HepMC" && name != "MCTruth" ) { 352 { << 353 G4cout << " Object: " << PadString(name 327 G4cout << " Object: " << PadString(name, 9); 354 mode = CurrentStoreMode(name); 328 mode = CurrentStoreMode(name); 355 if(mode == kOn) << 329 if ( mode == kOn ) { 356 { << 357 G4cout << " <on> "; 330 G4cout << " <on> "; 358 } << 331 } else if ( mode == kOff ) { 359 else if(mode == kOff) << 360 { << 361 G4cout << " <off> "; 332 G4cout << " <off> "; 362 } << 333 } else if ( mode == kRecycle ) { 363 else if(mode == kRecycle) << 364 { << 365 G4cout << "<recycle>"; 334 G4cout << "<recycle>"; 366 } 335 } 367 file = CurrentWriteFile(name); 336 file = CurrentWriteFile(name); 368 if(file == "") << 337 if ( file == "" ) file = " <N/A>"; 369 file = " <N/A>"; << 370 G4cout << " File: " << file << G4endl; 338 G4cout << " File: " << file << G4endl; 371 } 339 } 372 } 340 } 373 G4cout << G4endl; 341 G4cout << G4endl; 374 342 375 G4cout << "Input object types and file names 343 G4cout << "Input object types and file names:" << G4endl; 376 for(auto itr = f_rdObj.cbegin(); itr != f_rd << 344 for ( itr = f_rdObj.begin(); itr != f_rdObj.end(); itr++ ) { 377 { << 378 name = (*itr).second; 345 name = (*itr).second; 379 // disabled HepMC and MCTruth for now 346 // disabled HepMC and MCTruth for now 380 if(name != "HepMC" && name != "MCTruth") << 347 if ( name != "HepMC" && name != "MCTruth" ) { 381 { << 382 G4cout << " Object: " << PadString(name 348 G4cout << " Object: " << PadString(name, 9); 383 if(CurrentRetrieveMode(name)) << 349 if ( CurrentRetrieveMode(name) ) { 384 { << 385 G4cout << " <on> "; 350 G4cout << " <on> "; 386 } << 351 } else { 387 else << 388 { << 389 G4cout << " <off> "; 352 G4cout << " <off> "; 390 } 353 } 391 file = CurrentReadFile(name); 354 file = CurrentReadFile(name); 392 if(file == "") << 355 if ( file == "" ) file = " <N/A>"; 393 file = " <N/A>"; << 394 G4cout << " File: " << CurrentReadFile(n 356 G4cout << " File: " << CurrentReadFile(name) << G4endl; 395 } 357 } 396 } 358 } 397 G4cout << G4endl; 359 G4cout << G4endl; 398 360 399 G4HCIOcatalog* hioc = G4HCIOcatalog::GetHCIO 361 G4HCIOcatalog* hioc = G4HCIOcatalog::GetHCIOcatalog(); 400 if(hioc != nullptr) << 362 if ( hioc != 0 ) { 401 { << 402 G4cout << "Hit IO Managers:" << G4endl; 363 G4cout << "Hit IO Managers:" << G4endl; 403 hioc->PrintEntries(); 364 hioc->PrintEntries(); 404 hioc->PrintHCIOmanager(); 365 hioc->PrintHCIOmanager(); 405 G4cout << G4endl; 366 G4cout << G4endl; 406 } << 367 } else { 407 else << 408 { << 409 G4cout << "Hit IO Manager catalog is not r 368 G4cout << "Hit IO Manager catalog is not registered." << G4endl; 410 } 369 } 411 370 412 G4DCIOcatalog* dioc = G4DCIOcatalog::GetDCIO 371 G4DCIOcatalog* dioc = G4DCIOcatalog::GetDCIOcatalog(); 413 if(dioc != nullptr) << 372 if ( dioc != 0 ) { 414 { << 415 G4cout << "Digit IO Managers:" << G4endl; 373 G4cout << "Digit IO Managers:" << G4endl; 416 dioc->PrintEntries(); 374 dioc->PrintEntries(); 417 dioc->PrintDCIOmanager(); 375 dioc->PrintDCIOmanager(); 418 G4cout << G4endl; 376 G4cout << G4endl; 419 } << 377 } else { 420 else << 421 { << 422 G4cout << "Digit IO Manager catalog is not 378 G4cout << "Digit IO Manager catalog is not registered." << G4endl; 423 } 379 } 424 } 380 } 425 381 426 // ------------------------------------------- << 382 // Implementation of SetPersistencyManager 427 void G4PersistencyCenter::SetPersistencyManage 383 void G4PersistencyCenter::SetPersistencyManager(G4PersistencyManager* pm, 428 << 384 std::string name) 429 { 385 { 430 f_currentManager = pm; << 386 f_currentManager=pm; 431 f_currentSystemName = name; << 387 f_currentSystemName=name; 432 } 388 } 433 389 434 // ------------------------------------------- << 390 // Implementation of GetPersistencyManager 435 G4PersistencyManager* << 391 G4PersistencyManager* G4PersistencyCenter::GetPersistencyManager(std::string nam) 436 G4PersistencyCenter::GetPersistencyManager(con << 437 { 392 { 438 if(f_theCatalog.find(nam) != f_theCatalog.ce << 393 if (f_theCatalog.find(nam)!=f_theCatalog.end()) 439 return f_theCatalog[nam]; 394 return f_theCatalog[nam]; 440 return nullptr; << 395 return 0; 441 } 396 } 442 397 443 // ------------------------------------------- << 398 // Implementation of RegisterPersistencyManager 444 void G4PersistencyCenter::RegisterPersistencyM 399 void G4PersistencyCenter::RegisterPersistencyManager(G4PersistencyManager* pm) 445 { 400 { 446 f_theCatalog[pm->GetName()] = pm; << 401 f_theCatalog[pm->GetName()]=pm; 447 } 402 } 448 403 449 // ------------------------------------------- << 404 // Implementation of DeletePersistencyManager 450 void G4PersistencyCenter::DeletePersistencyMan 405 void G4PersistencyCenter::DeletePersistencyManager() 451 { 406 { 452 if(f_currentManager != nullptr) << 407 if (f_currentManager!=0) delete f_currentManager; 453 delete f_currentManager; << 408 f_currentManager=0; 454 f_currentManager = nullptr; << 455 } 409 } 456 410 457 // ------------------------------------------- << 411 // Implementation of SetVerboseLevel 458 void G4PersistencyCenter::SetVerboseLevel(G4in << 412 void G4PersistencyCenter::SetVerboseLevel(int v) 459 { 413 { 460 m_verbose = v; 414 m_verbose = v; 461 if(f_currentManager != nullptr) << 415 if ( f_currentManager != 0 ) f_currentManager->SetVerboseLevel(m_verbose); 462 f_currentManager->SetVerboseLevel(m_verbos << 463 } 416 } 464 417 465 // ------------------------------------------- << 418 // Implementation of PadString 466 G4String G4PersistencyCenter::PadString(const << 419 std::string G4PersistencyCenter::PadString(std::string name, unsigned int width) 467 unsign << 468 { 420 { 469 if(name.length() > width) << 421 if ( name.length() > width ) { 470 { << 422 return name.substr(0,width-1) + "#"; 471 return name.substr(0, width - 1) + "#"; << 423 } else { 472 } << 424 std::string wname = name; 473 else << 425 for ( unsigned int i=0; i < width-name.length(); i++) wname = wname + " "; 474 { << 475 G4String wname = name; << 476 for(unsigned int i = 0; i < width - name.l << 477 wname = wname + " "; << 478 return wname; 426 return wname; 479 } 427 } 480 } 428 } >> 429 >> 430 // End of G4PersistencyCenter.cc >> 431 481 432