00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __GLG4param_hh__
00009 #define __GLG4param_hh__
00010
00011 #include "globals.hh"
00012 #include "map"
00013 #include "iostream"
00014 #include "local_g4compat.hh"
00015
00016 class GLG4param : public G4std::map<G4String,G4double>
00017 {
00018 private:
00019 GLG4param();
00020 static GLG4param * theGLG4param;
00021
00022 public:
00023 enum EOverride { kKeepExistingValue, kOverrideExistingValue };
00024 static inline GLG4param & GetDB();
00025 static inline GLG4param * GetDBPtr();
00026 void ReadFile(const char *filename, EOverride oflag= kKeepExistingValue);
00027 void ReadFile(G4std::istream &is, EOverride oflag= kKeepExistingValue);
00028 void WriteFile(G4std::ostream &os);
00029 inline G4double GetWithDefault(G4String name, G4double defaultValue);
00030 };
00031
00032
00033 GLG4param *
00034 GLG4param::GetDBPtr()
00035 {
00036
00037
00038 if (theGLG4param == NULL)
00039 theGLG4param= new GLG4param();
00040 return theGLG4param;
00041 }
00042
00043 GLG4param &
00044 GLG4param::GetDB()
00045 {
00046
00047
00048 if (theGLG4param == NULL)
00049 theGLG4param= new GLG4param();
00050 return *theGLG4param;
00051 }
00052
00053 G4double
00054 GLG4param::GetWithDefault(G4String name, G4double defaultValue) {
00055 if (count(name))
00056 return (*this)[name];
00057 else
00058 return (*this)[name]= defaultValue;
00059 }
00060
00061 #endif