G4PersistencyCenter.hh

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: G4PersistencyCenter.hh
00027 //
00028 // History:
00029 //   '01.08.10  Youhei Morita  Initial creation (with "fadsclass3")
00030 
00031 #ifndef PERSISTENCY_CENTER_HH
00032 #define PERSISTENCY_CENTER_HH 1
00033 
00034 #include "G4Types.hh"
00035 #include <string>
00036 #include <vector>
00037 #include <map>
00038 #include "G4HCIOcatalog.hh"
00039 #include "G4DCIOcatalog.hh"
00040 
00041 #ifndef WIN32
00042   #include "G4FileUtilities.hh"
00043 #endif
00044 
00045 // Forward Declaration to avoid circular dependencies.
00046 class G4PersistencyManager;
00047 
00048 typedef std::map<std::string, G4PersistencyManager*,std::less<std::string> > PMap;
00049 typedef std::map<int, std::string, std::less<int> > ObjMap;
00050 typedef std::map<std::string, std::string, std::less<std::string> > FileMap;
00051 
00052 enum StoreMode { kOn, kOff, kRecycle };
00053 
00054 typedef std::map<std::string, StoreMode, std::less<std::string> > StoreMap;
00055 typedef std::map<std::string, G4bool, std::less<std::string> >     BoolMap;
00056 
00057 // Forward Declarations:
00058 class G4PersistencyCenterMessenger;
00059 
00060 // Class Description:
00061 //   Class to handle loading of the G4PersistencyManager.
00062 
00063 class G4PersistencyCenter
00064 {
00065     public: // With description
00066 
00067       static G4PersistencyCenter* GetPersistencyCenter();
00068       // returns the pointer of singleton G4PersistencyCenter
00069 
00070       void SelectSystem(std::string systemName);
00071       // Select the persistency package
00072 
00073       const std::string CurrentSystem() { return f_currentSystemName; }
00074       // returns the current persistent package name
00075 
00076       void SetHepMCObjyReaderFile(std::string file);
00077       // Sets the name of HepMCObjyReader file name.  To be called by generator.
00078 
00079       std::string CurrentHepMCObjyReaderFile();
00080       // Sets the name of HepMCObjyReader file name.  To be called by generator.
00081 
00082       void SetStoreMode(std::string objName, StoreMode mode);
00083       // Sets the object store mode.  Modes are kOn, kOff or kRecycle.
00084 
00085       void SetRetrieveMode(std::string objName, G4bool mode);
00086       // Sets the object retrieve mode.  Modes are true or false.
00087 
00088       StoreMode CurrentStoreMode(std::string objName);
00089       // returns the current object store mode.
00090 
00091       G4bool CurrentRetrieveMode(std::string objName);
00092       // returns the current object store mode.
00093 
00094       G4bool SetWriteFile(std::string objName, std::string writeFileName);
00095       // Sets the output filename.
00096 
00097       G4bool SetReadFile(std::string objName, std::string readFileName);
00098       // Sets the input filename.
00099 
00100       std::string CurrentWriteFile(std::string objName);
00101       // returns the current output filename.
00102 
00103       std::string CurrentReadFile(std::string objName);
00104       // returns the current input filename.
00105 
00106       std::string CurrentObject(std::string file);
00107       // returns the current object type
00108 
00109       void AddHCIOmanager(std::string detName, std::string colName);
00110       // add a hits colleciton I/O manager to the catalog
00111 
00112       std::string CurrentHCIOmanager();
00113       // Returns a list of registered hits colleciton I/O managers
00114 
00115       void AddDCIOmanager(std::string detName);
00116       // add a digits colleciton I/O manager to the catalog
00117 
00118       std::string CurrentDCIOmanager();
00119       // Returns a list of registered digits colleciton I/O managers
00120 
00121       void PrintAll();
00122       // prints the current G4PersistencyCenter settings.
00123 
00124       G4PersistencyManager* CurrentPersistencyManager() { return f_currentManager; }
00125       // returns the pointer of the currnet G4PersistencyManager.
00126 
00127       void SetPersistencyManager(G4PersistencyManager* pm, std::string name);
00128       // returns the pointer of the currnet G4PersistencyManager.
00129 
00130       G4PersistencyManager* GetPersistencyManager(std::string nam);
00131       // returns the pointer of the currnet G4PersistencyManager with name.
00132 
00133       void RegisterPersistencyManager(G4PersistencyManager* pm);
00134       // registers the persistency manager to the runtime catalog.
00135 
00136       void DeletePersistencyManager();
00137       // deletes the current G4PersistencyManager.
00138 
00139       void SetVerboseLevel(int v);
00140       // Set verbose level.
00141 
00142       int VerboseLevel() { return m_verbose; }
00143       // Return verbose level.
00144 
00145     public: // Without description
00146 
00147       G4PersistencyCenter();
00148       // Constructor
00149 
00150       ~G4PersistencyCenter();
00151       // Destructor
00152 
00153     private:
00154 
00155       std::string PadString(std::string name, unsigned int width);
00156       // truncate or pad a string up to the width.
00157 
00158     private:
00159       G4PersistencyCenterMessenger* f_theMessenger;
00160       static G4PersistencyCenter*   f_thePointer;
00161       G4PersistencyManager*         f_currentManager;
00162       std::string                   f_currentSystemName;
00163       PMap                          f_theCatalog;
00164       ObjMap                        f_wrObj;
00165       ObjMap                        f_rdObj;
00166       FileMap                       f_writeFileName;
00167       FileMap                       f_readFileName;
00168       StoreMap                      f_writeFileMode;
00169       BoolMap                       f_readFileMode;
00170       G4int                         m_verbose;
00171 #ifndef WIN32
00172       G4FileUtilities               f_ut;
00173 #endif
00174 }; // End of class G4PersistencyCenter
00175 
00176 #endif
00177 

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