Dip  0.92.4
UtilApp.h
Go to the documentation of this file.
1 //===========================================================================//
2 // This file is part of the Decomp Solver Framework. //
3 // //
4 // Decomp is distributed under the Common Public License as part of the //
5 // COIN-OR repository (http://www.coin-or.org). //
6 // //
7 // Author: Matthew Galati, SAS Institute Inc. (matthew.galati@sas.com) //
8 // //
9 // Copyright (C) 2002-2007, Lehigh University, Matthew Galati, and Ted Ralphs//
10 // All Rights Reserved. //
11 //===========================================================================//
12 
13 #ifndef UTIL_APP_INCLUDED
14 #define UTIL_APP_INCLUDED
15 
16 #include <string>
17 #include <map>
18 
19 #include "UtilParameters.h"
20 
21 class UtilApp
22 {
23 public:
24  UtilApp(int& argc, char* argv[]);
26  : m_parms(),
27  m_machine(""),
28  m_program(""),
29  m_fullPathname(""),
30  m_pid(0){};
31  ~UtilApp();
32 
33  static UtilApp& TheApp() {return *m_theApp;}
34 
35  const std::string& Machine();
36  const std::string& Program() const;
37  const std::string& FullPathname() const;
38  int Pid();
39  //float RunTime(); // in seconds and fractions
40 
41  bool GetSetting(const char* name,
42  bool defaultValue=true,
43  const char* section = NULL) const;
44  std::string GetSetting(const char* name,
45  const char* defaultValue,
46  const char* section = NULL) const;
47  short GetSetting(const char* name,
48  short defaultValue,
49  const char* section = NULL) const;
50  int GetSetting(const char* name,
51  int defaultValue,
52  const char* section = NULL) const;
53  long GetSetting(const char* name,
54  long defaultValue,
55  const char* section = NULL) const;
56 /*
57  float GetSetting(const char* name,
58  float defaultValue,
59  const char* section = NULL) const;
60 */
61  double GetSetting(const char* name,
62  double defaultValue,
63  const char* section = NULL) const;
64 
65  bool GetSetting(const char* name,
66  bool defaultValue,
67  const std::string& section) const
68  {return GetSetting(name,defaultValue,section.c_str());}
69 
70  std::string GetSetting(const char* name,
71  const char* defaultValue,
72  const std::string& section) const
73  {return GetSetting(name,defaultValue,section.c_str());}
74  short GetSetting(const char* name,
75  short defaultValue,
76  const std::string& section) const
77  {return GetSetting(name,defaultValue,section.c_str());}
78  int GetSetting(const char* name,
79  int defaultValue,
80  const std::string& section) const
81  {return GetSetting(name,defaultValue,section.c_str());}
82  long GetSetting(const char* name,
83  long defaultValue,
84  const std::string& section) const
85  {return GetSetting(name,defaultValue,section.c_str());}
86  double GetSetting(const char* name,
87  double defaultValue,
88  const std::string& section) const
89  {return GetSetting(name,defaultValue,section.c_str());}
90 
92 
93  public:
94  void LoadParmFile(std::string& fname);
95 
96 protected:
97  //void add_to_environ(const char* env_var);
98 private:
99  UtilApp& operator=(const UtilApp& rhs);
100  bool operator==(const UtilApp& rhs) const;
101  bool operator<(const UtilApp& rhs) const;
102 #if 0
103  std::string QualifiedName(const std::string& name,
104  const std::string& section) const;
105  std::string QualifiedName(const char* name, const char* section) const;
106 #endif
107  //void LoadParmFile(std::string& fname);
108  void ScanCmdLineArgs(int& argc, char* argv[]);
109 protected:
110 // ----- process variables
111  std::string m_machine;
112  std::string m_program;
113  std::string m_fullPathname;
114  int m_pid;
115  //UtilTimer m_runTime;
116 
117 // ----- parm file variables
118  typedef std::map<std::string,std::string,less<std::string> > PARM_MAP;
119 // PARM_MAP m_parms;
120 
121  static UtilApp* m_theApp;
122 };
123 
124 
125 #endif
static UtilApp & TheApp()
Definition: UtilApp.h:33
int GetSetting(const char *name, int defaultValue, const std::string &section) const
Definition: UtilApp.h:78
static UtilApp * m_theApp
Definition: UtilApp.h:121
std::string m_machine
Definition: UtilApp.h:111
bool GetSetting(const char *name, bool defaultValue, const std::string &section) const
Definition: UtilApp.h:65
std::string GetSetting(const char *name, const char *defaultValue, const std::string &section) const
Definition: UtilApp.h:70
UtilParameters m_parms
Definition: UtilApp.h:91
std::string m_fullPathname
Definition: UtilApp.h:113
bool GetSetting(const char *name, bool defaultValue=true, const char *section=NULL) const
int m_pid
Definition: UtilApp.h:114
long GetSetting(const char *name, long defaultValue, const std::string &section) const
Definition: UtilApp.h:82
int Pid()
bool operator==(const UtilApp &rhs) const
bool operator<(const UtilApp &rhs) const
const std::string & FullPathname() const
UtilApp()
Definition: UtilApp.h:25
std::map< std::string, std::string, less< std::string > > PARM_MAP
Definition: UtilApp.h:118
const std::string & Machine()
double GetSetting(const char *name, double defaultValue, const std::string &section) const
Definition: UtilApp.h:86
void ScanCmdLineArgs(int &argc, char *argv[])
short GetSetting(const char *name, short defaultValue, const std::string &section) const
Definition: UtilApp.h:74
const std::string & Program() const
void LoadParmFile(std::string &fname)
UtilApp & operator=(const UtilApp &rhs)
std::string m_program
Definition: UtilApp.h:112