00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef UTIL_APP_INCLUDED
00014 #define UTIL_APP_INCLUDED
00015
00016 #include <string>
00017 #include <map>
00018
00019 #include "UtilParameters.h"
00020
00021 class UtilApp
00022 {
00023 public:
00024 UtilApp(int& argc, char* argv[]);
00025 UtilApp()
00026 : m_parms(),
00027 m_machine(""),
00028 m_program(""),
00029 m_fullPathname(""),
00030 m_pid(0){};
00031 ~UtilApp();
00032
00033 static UtilApp& TheApp() {return *m_theApp;}
00034
00035 const std::string& Machine();
00036 const std::string& Program() const;
00037 const std::string& FullPathname() const;
00038 int Pid();
00039
00040
00041 bool GetSetting(const char* name,
00042 bool defaultValue=true,
00043 const char* section = NULL) const;
00044 std::string GetSetting(const char* name,
00045 const char* defaultValue,
00046 const char* section = NULL) const;
00047 short GetSetting(const char* name,
00048 short defaultValue,
00049 const char* section = NULL) const;
00050 int GetSetting(const char* name,
00051 int defaultValue,
00052 const char* section = NULL) const;
00053 long GetSetting(const char* name,
00054 long defaultValue,
00055 const char* section = NULL) const;
00056
00057
00058
00059
00060
00061 double GetSetting(const char* name,
00062 double defaultValue,
00063 const char* section = NULL) const;
00064
00065 bool GetSetting(const char* name,
00066 bool defaultValue,
00067 const std::string& section) const
00068 {return GetSetting(name,defaultValue,section.c_str());}
00069
00070 std::string GetSetting(const char* name,
00071 const char* defaultValue,
00072 const std::string& section) const
00073 {return GetSetting(name,defaultValue,section.c_str());}
00074 short GetSetting(const char* name,
00075 short defaultValue,
00076 const std::string& section) const
00077 {return GetSetting(name,defaultValue,section.c_str());}
00078 int GetSetting(const char* name,
00079 int defaultValue,
00080 const std::string& section) const
00081 {return GetSetting(name,defaultValue,section.c_str());}
00082 long GetSetting(const char* name,
00083 long defaultValue,
00084 const std::string& section) const
00085 {return GetSetting(name,defaultValue,section.c_str());}
00086 double GetSetting(const char* name,
00087 double defaultValue,
00088 const std::string& section) const
00089 {return GetSetting(name,defaultValue,section.c_str());}
00090
00091 UtilParameters m_parms;
00092
00093 public:
00094 void LoadParmFile(std::string& fname);
00095
00096 protected:
00097
00098 private:
00099 UtilApp& operator=(const UtilApp& rhs);
00100 bool operator==(const UtilApp& rhs) const;
00101 bool operator<(const UtilApp& rhs) const;
00102 #if 0
00103 std::string QualifiedName(const std::string& name,
00104 const std::string& section) const;
00105 std::string QualifiedName(const char* name, const char* section) const;
00106 #endif
00107
00108 void ScanCmdLineArgs(int& argc, char* argv[]);
00109 protected:
00110
00111 std::string m_machine;
00112 std::string m_program;
00113 std::string m_fullPathname;
00114 int m_pid;
00115
00116
00117
00118 typedef std::map<std::string,std::string,less<std::string> > PARM_MAP;
00119
00120
00121 static UtilApp* m_theApp;
00122 };
00123
00124
00125 #endif