Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:54

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4PersistencyCenter
0027 //
0028 // Class Description:
0029 //
0030 // Class to handle loading of the G4PersistencyManager.
0031 
0032 // Author: Youhei Morita, 10.08.2001
0033 // --------------------------------------------------------------------
0034 #ifndef G4PERSISTENCYCENTER_HH
0035 #define G4PERSISTENCYCENTER_HH 1
0036 
0037 #include "G4Types.hh"
0038 #include <string>
0039 #include <vector>
0040 #include <map>
0041 #include "G4HCIOcatalog.hh"
0042 #include "G4DCIOcatalog.hh"
0043 
0044 #ifndef WIN32
0045 #  include "G4FileUtilities.hh"
0046 #endif
0047 
0048 // Forward Declarations
0049 class G4PersistencyManager;
0050 class G4PersistencyCenterMessenger;
0051 
0052 using PMap = std::map<G4String, G4PersistencyManager*, std::less<G4String>>;
0053 using ObjMap = std::map<G4int, G4String, std::less<G4int>>;
0054 using FileMap = std::map<G4String, G4String, std::less<G4String>>;
0055 
0056 enum StoreMode
0057 {
0058   kOn,
0059   kOff,
0060   kRecycle
0061 };
0062 
0063 using StoreMap = std::map<G4String, StoreMode, std::less<G4String>>;
0064 using BoolMap = std::map<G4String, G4bool, std::less<G4String>>;
0065 
0066 class G4PersistencyCenter
0067 {
0068   public:
0069 
0070     static G4PersistencyCenter* GetPersistencyCenter();
0071       // Returns the pointer of singleton G4PersistencyCenter
0072 
0073     void SelectSystem(const G4String& systemName);
0074       // Select the persistency package
0075 
0076     const G4String& CurrentSystem() { return f_currentSystemName; }
0077       // Returns the current persistent package name
0078 
0079     void SetHepMCObjyReaderFile(const G4String& file);
0080       // Sets the name of HepMCObjyReader file name. To be called by generator
0081 
0082     G4String CurrentHepMCObjyReaderFile();
0083       // Sets the name of HepMCObjyReader file name. To be called by generator
0084 
0085     void SetStoreMode(const G4String& objName, StoreMode mode);
0086       // Sets the object store mode.  Modes are kOn, kOff or kRecycle
0087 
0088     void SetRetrieveMode(const G4String& objName, G4bool mode);
0089       // Sets the object retrieve mode.  Modes are true or false
0090 
0091     StoreMode CurrentStoreMode(const G4String& objName);
0092       // Returns the current object store mode
0093 
0094     G4bool CurrentRetrieveMode(const G4String& objName);
0095       // Returns the current object store mode
0096 
0097     G4bool SetWriteFile(const G4String& objName, const G4String& writeFileName);
0098       // Sets the output filename
0099 
0100     G4bool SetReadFile(const G4String& objName, const G4String& readFileName);
0101       // Sets the input filename
0102 
0103     G4String CurrentWriteFile(const G4String& objName);
0104       // Returns the current output filename
0105 
0106     G4String CurrentReadFile(const G4String& objName);
0107       // Returns the current input filename
0108 
0109     G4String CurrentObject(const G4String& file);
0110       // Returns the current object type
0111 
0112     void AddHCIOmanager(const G4String& detName, const G4String& colName);
0113       // Adds a hits colleciton I/O manager to the catalog
0114 
0115     G4String CurrentHCIOmanager();
0116       // Returns a list of registered hits colleciton I/O managers
0117 
0118     void AddDCIOmanager(const G4String& detName);
0119       // Adds a digits colleciton I/O manager to the catalog
0120 
0121     G4String CurrentDCIOmanager();
0122       // Returns a list of registered digits collection I/O managers
0123 
0124     void PrintAll();
0125       // Prints the current G4PersistencyCenter settings
0126 
0127     G4PersistencyManager* CurrentPersistencyManager()
0128     {
0129       return f_currentManager;
0130     }
0131       // Returns the pointer of the current G4PersistencyManager
0132 
0133     void SetPersistencyManager(G4PersistencyManager* pm, const G4String& name);
0134       // Returns the pointer of the current G4PersistencyManager
0135 
0136     G4PersistencyManager* GetPersistencyManager(const G4String& nam);
0137       // Returns the pointer of the current G4PersistencyManager with name
0138 
0139     void RegisterPersistencyManager(G4PersistencyManager* pm);
0140       // Registers the persistency manager to the runtime catalog
0141 
0142     void DeletePersistencyManager();
0143       // Deletes the current G4PersistencyManager
0144 
0145     void SetVerboseLevel(G4int v);
0146       // Sets verbose level
0147 
0148     G4int VerboseLevel() { return m_verbose; }
0149       // Returns verbose level
0150 
0151   private:
0152 
0153     G4PersistencyCenter();
0154       // Constructor
0155 
0156     ~G4PersistencyCenter();
0157       // Destructor
0158 
0159     G4String PadString(const G4String& name, unsigned int width);
0160       // Truncates or pad a string up to the width
0161 
0162   private:
0163 
0164     G4PersistencyCenterMessenger* f_theMessenger = nullptr;
0165     static G4ThreadLocal G4PersistencyCenter* f_thePointer;
0166     G4PersistencyManager* f_currentManager = nullptr;
0167     G4String f_currentSystemName;
0168     PMap f_theCatalog;
0169     ObjMap f_wrObj;
0170     ObjMap f_rdObj;
0171     FileMap f_writeFileName;
0172     FileMap f_readFileName;
0173     StoreMap f_writeFileMode;
0174     BoolMap f_readFileMode;
0175     G4int m_verbose = 0;
0176 #ifndef WIN32
0177     G4FileUtilities f_ut;
0178 #endif
0179 };
0180 
0181 #endif