File indexing completed on 2025-01-18 09:58:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
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
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
0072
0073 void SelectSystem(const G4String& systemName);
0074
0075
0076 const G4String& CurrentSystem() { return f_currentSystemName; }
0077
0078
0079 void SetHepMCObjyReaderFile(const G4String& file);
0080
0081
0082 G4String CurrentHepMCObjyReaderFile();
0083
0084
0085 void SetStoreMode(const G4String& objName, StoreMode mode);
0086
0087
0088 void SetRetrieveMode(const G4String& objName, G4bool mode);
0089
0090
0091 StoreMode CurrentStoreMode(const G4String& objName);
0092
0093
0094 G4bool CurrentRetrieveMode(const G4String& objName);
0095
0096
0097 G4bool SetWriteFile(const G4String& objName, const G4String& writeFileName);
0098
0099
0100 G4bool SetReadFile(const G4String& objName, const G4String& readFileName);
0101
0102
0103 G4String CurrentWriteFile(const G4String& objName);
0104
0105
0106 G4String CurrentReadFile(const G4String& objName);
0107
0108
0109 G4String CurrentObject(const G4String& file);
0110
0111
0112 void AddHCIOmanager(const G4String& detName, const G4String& colName);
0113
0114
0115 G4String CurrentHCIOmanager();
0116
0117
0118 void AddDCIOmanager(const G4String& detName);
0119
0120
0121 G4String CurrentDCIOmanager();
0122
0123
0124 void PrintAll();
0125
0126
0127 G4PersistencyManager* CurrentPersistencyManager()
0128 {
0129 return f_currentManager;
0130 }
0131
0132
0133 void SetPersistencyManager(G4PersistencyManager* pm, const G4String& name);
0134
0135
0136 G4PersistencyManager* GetPersistencyManager(const G4String& nam);
0137
0138
0139 void RegisterPersistencyManager(G4PersistencyManager* pm);
0140
0141
0142 void DeletePersistencyManager();
0143
0144
0145 void SetVerboseLevel(G4int v);
0146
0147
0148 G4int VerboseLevel() { return m_verbose; }
0149
0150
0151 private:
0152
0153 G4PersistencyCenter();
0154
0155
0156 ~G4PersistencyCenter();
0157
0158
0159 G4String PadString(const G4String& name, unsigned int width);
0160
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