00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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
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
00058 class G4PersistencyCenterMessenger;
00059
00060
00061
00062
00063 class G4PersistencyCenter
00064 {
00065 public:
00066
00067 static G4PersistencyCenter* GetPersistencyCenter();
00068
00069
00070 void SelectSystem(std::string systemName);
00071
00072
00073 const std::string CurrentSystem() { return f_currentSystemName; }
00074
00075
00076 void SetHepMCObjyReaderFile(std::string file);
00077
00078
00079 std::string CurrentHepMCObjyReaderFile();
00080
00081
00082 void SetStoreMode(std::string objName, StoreMode mode);
00083
00084
00085 void SetRetrieveMode(std::string objName, G4bool mode);
00086
00087
00088 StoreMode CurrentStoreMode(std::string objName);
00089
00090
00091 G4bool CurrentRetrieveMode(std::string objName);
00092
00093
00094 G4bool SetWriteFile(std::string objName, std::string writeFileName);
00095
00096
00097 G4bool SetReadFile(std::string objName, std::string readFileName);
00098
00099
00100 std::string CurrentWriteFile(std::string objName);
00101
00102
00103 std::string CurrentReadFile(std::string objName);
00104
00105
00106 std::string CurrentObject(std::string file);
00107
00108
00109 void AddHCIOmanager(std::string detName, std::string colName);
00110
00111
00112 std::string CurrentHCIOmanager();
00113
00114
00115 void AddDCIOmanager(std::string detName);
00116
00117
00118 std::string CurrentDCIOmanager();
00119
00120
00121 void PrintAll();
00122
00123
00124 G4PersistencyManager* CurrentPersistencyManager() { return f_currentManager; }
00125
00126
00127 void SetPersistencyManager(G4PersistencyManager* pm, std::string name);
00128
00129
00130 G4PersistencyManager* GetPersistencyManager(std::string nam);
00131
00132
00133 void RegisterPersistencyManager(G4PersistencyManager* pm);
00134
00135
00136 void DeletePersistencyManager();
00137
00138
00139 void SetVerboseLevel(int v);
00140
00141
00142 int VerboseLevel() { return m_verbose; }
00143
00144
00145 public:
00146
00147 G4PersistencyCenter();
00148
00149
00150 ~G4PersistencyCenter();
00151
00152
00153 private:
00154
00155 std::string PadString(std::string name, unsigned int width);
00156
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 };
00175
00176 #endif
00177