UtilApp.h

Go to the documentation of this file.
00001 //===========================================================================//
00002 // This file is part of the Decomp Solver Framework.                         //
00003 //                                                                           //
00004 // Decomp is distributed under the Common Public License as part of the      //
00005 // COIN-OR repository (http://www.coin-or.org).                              //
00006 //                                                                           //
00007 // Author: Matthew Galati, SAS Institute Inc. (matthew.galati@sas.com)       //
00008 //                                                                           //
00009 // Copyright (C) 2002-2007, Lehigh University, Matthew Galati, and Ted Ralphs//
00010 // All Rights Reserved.                                                      //
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   //float       RunTime();      // in seconds and fractions
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     float       GetSetting(const char* name,
00058                            float defaultValue,
00059                            const char* section = NULL) const;
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   //void        add_to_environ(const char* env_var);
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     //void        LoadParmFile(std::string& fname);
00108     void        ScanCmdLineArgs(int& argc, char* argv[]);
00109 protected:
00110 //  -----   process variables
00111     std::string m_machine;
00112     std::string m_program;
00113     std::string m_fullPathname;
00114     int         m_pid;
00115   //UtilTimer    m_runTime;
00116 
00117 //  -----   parm file variables
00118     typedef std::map<std::string,std::string,less<std::string> > PARM_MAP;
00119 //    PARM_MAP    m_parms;
00120 
00121     static UtilApp* m_theApp;
00122 };
00123 
00124 
00125 #endif

Generated on 5 Apr 2015 for Dip-All by  doxygen 1.6.1