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5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 // G4PersistencyCenter
 27 //
 28 // Class Description:
 29 //
 30 // Class to handle loading of the G4PersistencyManager.
 31 
 32 // Author: Youhei Morita, 10.08.2001
 33 // --------------------------------------------------------------------
 34 #ifndef G4PERSISTENCYCENTER_HH
 35 #define G4PERSISTENCYCENTER_HH 1
 36 
 37 #include <vector>
 38 #include <map>
 39 
 40 #include "G4Types.hh"
 41 #include "G4HCIOcatalog.hh"
 42 #include "G4DCIOcatalog.hh"
 43 
 44 #ifndef WIN32
 45 #  include "G4FileUtilities.hh"
 46 #endif
 47 
 48 // Forward Declarations
 49 class G4PersistencyManager;
 50 class G4PersistencyCenterMessenger;
 51 
 52 using PMap = std::map<G4String, G4PersistencyManager*, std::less<G4String>>;
 53 using ObjMap = std::map<G4int, G4String, std::less<G4int>>;
 54 using FileMap = std::map<G4String, G4String, std::less<G4String>>;
 55 
 56 enum StoreMode
 57 {
 58   kOn,
 59   kOff,
 60   kRecycle
 61 };
 62 
 63 using StoreMap = std::map<G4String, StoreMode, std::less<G4String>>;
 64 using BoolMap = std::map<G4String, G4bool, std::less<G4String>>;
 65 
 66 class G4PersistencyCenter
 67 {
 68   public:
 69 
 70     static G4PersistencyCenter* GetPersistencyCenter();
 71       // Returns the pointer of singleton G4PersistencyCenter
 72 
 73     void SelectSystem(const G4String& systemName);
 74       // Select the persistency package
 75 
 76     const G4String& CurrentSystem() { return f_currentSystemName; }
 77       // Returns the current persistent package name
 78 
 79     void SetHepMCObjyReaderFile(const G4String& file);
 80       // Sets the name of HepMCObjyReader file name. To be called by generator
 81 
 82     G4String CurrentHepMCObjyReaderFile();
 83       // Sets the name of HepMCObjyReader file name. To be called by generator
 84 
 85     void SetStoreMode(const G4String& objName, StoreMode mode);
 86       // Sets the object store mode.  Modes are kOn, kOff or kRecycle
 87 
 88     void SetRetrieveMode(const G4String& objName, G4bool mode);
 89       // Sets the object retrieve mode.  Modes are true or false
 90 
 91     StoreMode CurrentStoreMode(const G4String& objName);
 92       // Returns the current object store mode
 93 
 94     G4bool CurrentRetrieveMode(const G4String& objName);
 95       // Returns the current object store mode
 96 
 97     G4bool SetWriteFile(const G4String& objName, const G4String& writeFileName);
 98       // Sets the output filename
 99 
100     G4bool SetReadFile(const G4String& objName, const G4String& readFileName);
101       // Sets the input filename
102 
103     G4String CurrentWriteFile(const G4String& objName);
104       // Returns the current output filename
105 
106     G4String CurrentReadFile(const G4String& objName);
107       // Returns the current input filename
108 
109     G4String CurrentObject(const G4String& file);
110       // Returns the current object type
111 
112     void AddHCIOmanager(const G4String& detName, const G4String& colName);
113       // Adds a hits colleciton I/O manager to the catalog
114 
115     G4String CurrentHCIOmanager();
116       // Returns a list of registered hits colleciton I/O managers
117 
118     void AddDCIOmanager(const G4String& detName);
119       // Adds a digits colleciton I/O manager to the catalog
120 
121     G4String CurrentDCIOmanager();
122       // Returns a list of registered digits collection I/O managers
123 
124     void PrintAll();
125       // Prints the current G4PersistencyCenter settings
126 
127     G4PersistencyManager* CurrentPersistencyManager()
128     {
129       return f_currentManager;
130     }
131       // Returns the pointer of the current G4PersistencyManager
132 
133     void SetPersistencyManager(G4PersistencyManager* pm, const G4String& name);
134       // Returns the pointer of the current G4PersistencyManager
135 
136     G4PersistencyManager* GetPersistencyManager(const G4String& nam);
137       // Returns the pointer of the current G4PersistencyManager with name
138 
139     void RegisterPersistencyManager(G4PersistencyManager* pm);
140       // Registers the persistency manager to the runtime catalog
141 
142     void DeletePersistencyManager();
143       // Deletes the current G4PersistencyManager
144 
145     void SetVerboseLevel(G4int v);
146       // Sets verbose level
147 
148     G4int VerboseLevel() { return m_verbose; }
149       // Returns verbose level
150 
151   private:
152 
153     G4PersistencyCenter();
154       // Constructor
155 
156     ~G4PersistencyCenter();
157       // Destructor
158 
159     G4String PadString(const G4String& name, unsigned int width);
160       // Truncates or pad a string up to the width
161 
162   private:
163 
164     G4PersistencyCenterMessenger* f_theMessenger = nullptr;
165     static G4ThreadLocal G4PersistencyCenter* f_thePointer;
166     G4PersistencyManager* f_currentManager = nullptr;
167     G4String f_currentSystemName;
168     PMap f_theCatalog;
169     ObjMap f_wrObj;
170     ObjMap f_rdObj;
171     FileMap f_writeFileName;
172     FileMap f_readFileName;
173     StoreMap f_writeFileMode;
174     BoolMap f_readFileMode;
175     G4int m_verbose = 0;
176 #ifndef WIN32
177     G4FileUtilities f_ut;
178 #endif
179 };
180 
181 #endif
182