Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

GLG4param.hh

00001 // This file is part of the GenericLAND software library.
00002 // $Id: GLG4param.hh,v 1.1.1.1 2004/12/21 22:29:48 GLG4sim Exp $
00003 //
00004 // GLG4param.hh
00005 // defines a class for a "database" of numeric parameters
00006 // (a string/value hashtable that is initialized from a file)
00007 // Original by Glenn Horton-Smith, Jan 2001
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(); // singleton
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 // inline functions
00033 GLG4param *
00034 GLG4param::GetDBPtr()
00035 {
00036   // Get (and possibly create) the pointer to the singleton
00037   //----------------
00038   if (theGLG4param == NULL)
00039     theGLG4param= new GLG4param();
00040   return theGLG4param;
00041 }
00042 
00043 GLG4param &
00044 GLG4param::GetDB()
00045 {
00046   // Get (and possibly create) the pointer to the singleton
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

Generated on Fri Jul 6 13:31:46 2007 for GLG4sim by  doxygen 1.3.9.1