Dip  0.92.4
UtilParameters.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_PARAMETERS_INCLUDED
14 #define UTIL_PARAMETERS_INCLUDED
15 
16 //===========================================================================//
17 #include <map>
18 #include <string>
19 #include <fstream>
20 using namespace std;
21 
22 //===========================================================================//
23 struct UtilParamT {
24  string paramName;
25  bool isUsed; //is used in code (a call to getSetting)?
26 };
27 typedef struct UtilParamT UtilParam;
28 
29 //===========================================================================//
31 private:
32  UtilParameters(const UtilParameters& copy);
33  UtilParameters& operator=(const UtilParameters& rhs);
34 
35 private:
36  map<string, UtilParam> m_paramMap;
37 
38 public:
40  : m_paramMap() {}
41 
42  UtilParameters(int& argc,
43  char* argv[]) :
44  m_paramMap() {
45  ScanCmdLineArgs(argc, argv);
46  };
47 
49 
50  void ScanCmdLineArgs(int& argc,
51  char* argv[]);
52  void LoadParamFile(string& paramFileName);
53  void Add(string& section,
54  string& name,
55  string& value);
56  void Add(const char* section,
57  const char* name,
58  const char* value);
59  string GetSetting(const char* name,
60  const char* defaultValue,
61  const char* section = NULL);
62  int GetSetting(const char* name,
63  const int defaultValue,
64  const char* section = NULL);
65  bool GetSetting(const char* name,
66  const bool defaultValue,
67  const char* section = NULL);
68  long GetSetting(const char* name,
69  const long defaultValue,
70  const char* section = NULL);
71  double GetSetting(const char* name,
72  const double defaultValue,
73  const char* section = NULL);
74 
75 private:
76  UtilParam* FindEntry(const char* section,
77  const char* name);
78  string* Find(const char* section,
79  const char* name);
80 };
81 
82 #endif
UtilParameters(int &argc, char *argv[])
string paramName
map< string, UtilParam > m_paramMap