CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Defaults_Text.h
Go to the documentation of this file.
1 //
2 //
3 // File: hitfit/Defaults_Text.h
4 // Purpose: A lightweight implementation of the Defaults interface
5 // that uses simple text files.
6 // Created: Jul, 2000, sss.
7 //
8 // Create instances of these objects passing in the name of a file.
9 // Each line of the file should contain a parameter setting like
10 //
11 // NAME = VALUE
12 //
13 // Anything following a `;' or `#' is stried off; leading and trailing
14 // spaces on VALUE are also removed. Blank lines are ignored.
15 //
16 // You can also pass an argument list to the constructor. After the
17 // defaults file is read, the argument list will be scanned, to possibly
18 // override some of the parameter settings. An argument of the form
19 //
20 // --NAME=VALUE
21 //
22 // is equivalent to the parameter setting
23 //
24 // NAME=VALUE
25 //
26 // while
27 //
28 // --NAME
29 //
30 // is equivalent to
31 //
32 // NAME=1
33 //
34 // and
35 //
36 // --noNAME
37 //
38 // is equivalent to
39 //
40 // NAME=0
41 //
42 // CMSSW File : interface/Defaults_Text.h
43 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
44 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
45 //
46 
67 #ifndef HITFIT_DEFAULTS_TEXT_H
68 #define HITFIT_DEFAULTS_TEXT_H
69 
70 #include <string>
71 #include <iosfwd>
73 
74 namespace hitfit {
75 
76  class Defaults_Textrep;
77 
117  class Defaults_Text : public Defaults
118  //
119  // Purpose: A lightweight implementation of the Defaults interface
120  // that uses simple text files.
121  //
122  {
123  public:
124  // Constructor, destructor.
125 
132  Defaults_Text(std::string def_file);
133 
142  Defaults_Text(std::string def_file, int argc, char** argv);
143 
147  ~Defaults_Text() override;
148 
149  // Test to see if parameter NAME exists.
157  bool exists(std::string name) const override;
158 
159  // Get the value of NAME as an integer.
166  int get_int(std::string name) const override;
167 
168  // Get the value of NAME as a boolean.
175  bool get_bool(std::string name) const override;
176 
177  // Get the value of NAME as a float.
185  double get_float(std::string name) const override;
186 
187  // Get the value of NAME as a string.
194  std::string get_string(std::string name) const override;
195 
196  // Dump out all parameters.
205  friend std::ostream& operator<<(std::ostream& s, const Defaults_Text& def);
206 
207  private:
208  // The internal representation.
213  };
214 
215 } // namespace hitfit
216 
217 #endif // not HITFIT_DEFAULTS_TEXT_H
int def(FILE *, FILE *, int)
bool exists(std::string name) const override
Define an abstract interface for getting parameter settings.
std::string get_string(std::string name) const override
friend std::ostream & operator<<(std::ostream &s, const Defaults_Text &def)
A lightweight implementation of the Defaults interface that uses simple ASCII text files...
The internal representation for a Defaults_Text object.
int get_int(std::string name) const override
double get_float(std::string name) const override
Defaults_Text(std::string def_file)
Constructor, create a Default_Text object from an ASCII text file. Pass an empty string to skip readi...
bool get_bool(std::string name) const override
~Defaults_Text() override
Destructor.
tuple argc
Definition: dir2webdir.py:39
Defaults_Textrep * _rep
Define an interface for getting parameter settings.
Definition: Defaults.h:57