G4HCIOcatalog.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // File: G4HCIOcatalog.cc
00027 //
00028 // History:
00029 //   '01.09.12  Youhei Morita  Initial creation
00030 
00031 #include "G4HCIOcatalog.hh"
00032 
00033 // Addtional Include:
00034 #include "G4VHCIOentry.hh"
00035 
00036 G4HCIOcatalog* G4HCIOcatalog::f_thePointer = 0;
00037 
00038 // Implementation of Constructor #1
00039 G4HCIOcatalog::G4HCIOcatalog()
00040  : m_verbose(0)
00041 {}
00042 
00043 // Implementation of GetHCIOcatalog
00044 G4HCIOcatalog* G4HCIOcatalog::GetHCIOcatalog()
00045 {
00046   if ( f_thePointer == 0 ) f_thePointer = new G4HCIOcatalog;
00047   return f_thePointer;
00048 }
00049 
00050 // Implementation of RegisterEntry
00051 void G4HCIOcatalog::RegisterEntry(G4VHCIOentry* d)
00052 {
00053   if ( m_verbose > 0 ) {
00054     G4cout << "registering I/O manager entry \"" << d->GetName()
00055            << "\" " << d << "." << G4endl;
00056   }
00057   if ( theCatalog.find(d->GetName()) != theCatalog.end() ) {
00058     G4cout << "Redefining I/O Managers list " << d->GetName() << G4endl;
00059   } else {
00060     theCatalog[d->GetName()] = d;
00061   }
00062 }
00063 
00064 // Implementation of RegisterHCIOmanager
00065 void G4HCIOcatalog::RegisterHCIOmanager(G4VPHitsCollectionIO* d)
00066 {
00067   if ( m_verbose > 0 ) {
00068     G4cout << "registering I/O manager \"" << d->SDname()
00069            << "\" " << d << "." << G4endl;
00070   }
00071   if ( theStore.find(d->SDname()) != theStore.end() ) {
00072     G4cout << "Redefining I/O Manager " << d->SDname() << G4endl;
00073   } else {
00074     theStore[d->SDname()] = d;
00075   }
00076 }
00077 
00078 // Implementation of GetEntry
00079 G4VHCIOentry* G4HCIOcatalog::GetEntry(std::string name)
00080 {
00081   if ( theCatalog.find(name) == theCatalog.end() ) {
00082     G4cout << "Hit Collection I/O manager entry \"" << name
00083            << "\" not found!" << std::endl;
00084     return 0;
00085   } else {
00086     G4VHCIOentry* ds = theCatalog[name];
00087     return ds;
00088   }
00089 }
00090 
00091 // Implementation of GetHCIOmanager
00092 G4VPHitsCollectionIO* G4HCIOcatalog::GetHCIOmanager(std::string name)
00093 {
00094   if ( theStore.find(name) == theStore.end() ) {
00095     G4cout << "Hit Collection I/O manager \"" << name
00096            << "\" not found!" << G4endl;
00097     return 0;
00098   } else {
00099     G4VPHitsCollectionIO* ds = theStore[name];
00100     return ds;
00101   }
00102 }
00103 
00104 // Implementation of PrintEntries
00105 void G4HCIOcatalog::PrintEntries()
00106 {
00107   G4cout << "I/O manager entries: ";
00108   G4cout << theCatalog.size() << G4endl;
00109   HCIOmap::const_iterator it;
00110   for ( it=theCatalog.begin(); it != theCatalog.end(); it++ ) {
00111     G4cout << "  --- " << (*it).first << G4endl;
00112   }
00113 }
00114 
00115 // Implementation of CurrentHCIOmanager
00116 std::string G4HCIOcatalog::CurrentHCIOmanager()
00117 {
00118   std::string list = "";
00119   HCIOstore::const_iterator it;
00120   for ( it=theStore.begin(); it != theStore.end(); it++ ) {
00121     list += (*it).first + " ";
00122   }
00123   return list;
00124 }
00125 
00126 // Implementation of PrintHCIOmanager
00127 void G4HCIOcatalog::PrintHCIOmanager()
00128 {
00129   G4cout << "I/O managers: ";
00130   G4cout << theStore.size() << G4endl;
00131   HCIOstore::const_iterator it;
00132   for ( it=theStore.begin(); it != theStore.end(); it++ ) {
00133     G4cout << "  --- " << (*it).first
00134            << ", " << (*it).second << "." << G4endl;
00135   }
00136 }
00137 
00138 // Implementation of GetHCIOmanager
00139 G4VPHitsCollectionIO* G4HCIOcatalog::GetHCIOmanager(int n)
00140 {
00141   int i = 0;
00142   HCIOstore::const_iterator it;
00143   for ( it=theStore.begin(); it != theStore.end(); it++ ) {
00144     if (i++ == n) return (*it).second;
00145   }
00146   return 0;
00147 }
00148 
00149 // End of G4HCIOcatalog.cc
00150 

Generated on Mon May 27 17:48:27 2013 for Geant4 by  doxygen 1.4.7