CMS 3D CMS Logo

VariableMapCont.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 #if !defined(VariableMapCont_H)
4 #define VariableMapCont_H
5 
6 #include <map>
7 #include <vector>
8 #include <string>
9 
10 namespace optutl {
11 
13  public:
15  // Public Constants //
17 
18  // typedefs
19  typedef std::vector<int> IVec;
20  typedef std::vector<double> DVec;
21  typedef std::vector<std::string> SVec;
22  typedef std::map<std::string, int> SIMap;
23  typedef std::map<std::string, double> SDMap;
24  typedef std::map<std::string, bool> SBMap;
25  typedef std::map<std::string, std::string> SSMap;
26  typedef std::map<std::string, IVec> SIVecMap;
27  typedef std::map<std::string, DVec> SDVecMap;
28  typedef std::map<std::string, SVec> SSVecMap;
29  // Iterators
30  typedef IVec::iterator IVecIter;
31  typedef DVec::iterator DVecIter;
32  typedef SVec::iterator SVecIter;
33  typedef SIMap::iterator SIMapIter;
34  typedef SDMap::iterator SDMapIter;
35  typedef SBMap::iterator SBMapIter;
36  typedef SSMap::iterator SSMapIter;
37  typedef SIVecMap::iterator SIVecMapIter;
38  typedef SDVecMap::iterator SDVecMapIter;
39  typedef SSVecMap::iterator SSVecMapIter;
40  // constant iterators
41  typedef IVec::const_iterator IVecConstIter;
42  typedef DVec::const_iterator DVecConstIter;
43  typedef SVec::const_iterator SVecConstIter;
44  typedef SIMap::const_iterator SIMapConstIter;
45  typedef SDMap::const_iterator SDMapConstIter;
46  typedef SBMap::const_iterator SBMapConstIter;
47  typedef SSMap::const_iterator SSMapConstIter;
48  typedef SIVecMap::const_iterator SIVecMapConstIter;
49  typedef SDVecMap::const_iterator SDVecMapConstIter;
50  typedef SSVecMap::const_iterator SSVecMapConstIter;
51 
52  // constants
53  static const int kDefaultInteger;
54  static const double kDefaultDouble;
56  static const bool kDefaultBool;
57  static const IVec kEmptyIVec;
58  static const DVec kEmptyDVec;
59  static const SVec kEmptySVec;
60 
61  enum OptionType {
62  kNone = 0,
71  };
72 
74  // friends //
76  // tells particle data how to print itself out
77  friend std::ostream &operator<<(std::ostream &o_stream, const VariableMapCont &rhs);
78 
80  // _ //
81  // |\/| |_ //
82  // | |EMBER | UNCTIONS //
83  // //
85 
87  // Constructors and Destructor //
90 
92  // Regular Member Functions //
94 
95  // prints out '--help' screen, then exits.
96  void help();
97 
98  // returns OptionType (or kNone (0)) of a given option.
101 
102  // Add variable to option maps. 'key' is passed in by copy
103  // because it is modified in place.
110  // addVariable works just like addOption, but has no description.
116  }
119  }
121 
122  // some of the guts of above
123  void _checkKey(std::string &key, const std::string &description = "");
124 
126  double &doubleValue(std::string key);
128  bool &boolValue(std::string key);
132 
134  // Static Member Functions //
136 
137  // converts a string to lower case characters
138  static void lowercaseString(std::string &arg);
139 
140  // converts a single character to lower case
141  static char toLower(char &ch);
142 
143  protected:
144  // returns true if a variable has been modified from the command
145  // line.
147 
149  // Private Member Data //
151 
161  };
162 
163 } // namespace optutl
164 #endif // VariableMapCont_H
void _checkKey(std::string &key, const std::string &description="")
void addVariable(std::string key, OptionType type, const char *defaultValue)
SIMap::const_iterator SIMapConstIter
static const std::string kDefaultString
SDMap::const_iterator SDMapConstIter
SSMap::iterator SSMapIter
IVec::const_iterator IVecConstIter
SBMap::iterator SBMapIter
std::map< std::string, bool > SBMap
SIMap::iterator SIMapIter
std::string & stringValue(std::string key)
SBMap::const_iterator SBMapConstIter
friend std::ostream & operator<<(std::ostream &o_stream, const VariableMapCont &rhs)
std::map< std::string, double > SDMap
SIVecMap::iterator SIVecMapIter
std::vector< double > DVec
SSVecMap::const_iterator SSVecMapConstIter
std::map< std::string, std::string > SSMap
double & doubleValue(std::string key)
std::vector< std::string > SVec
A arg
Definition: Factorize.h:31
static const SVec kEmptySVec
int & integerValue(std::string key)
SSMap::const_iterator SSMapConstIter
std::map< std::string, DVec > SDVecMap
static char toLower(char &ch)
DVec::const_iterator DVecConstIter
void addVariable(std::string key, OptionType type, bool defaultValue)
SIVecMap::const_iterator SIVecMapConstIter
std::map< std::string, IVec > SIVecMap
DVec & doubleVector(std::string key)
static const double kDefaultDouble
void addVariable(std::string key, OptionType type, const std::string &defaultValue)
std::map< std::string, int > SIMap
static void lowercaseString(std::string &arg)
static const bool kDefaultBool
SSVecMap::iterator SSVecMapIter
void addVariable(std::string key, OptionType type)
SDVecMap::iterator SDVecMapIter
void addVariable(std::string key, OptionType type, double defaultValue)
static const DVec kEmptyDVec
bool _valueHasBeenModified(const std::string &key)
static const IVec kEmptyIVec
std::map< std::string, SVec > SSVecMap
IVec & integerVector(std::string key)
static const int kDefaultInteger
SVec & stringVector(std::string key)
void addVariable(std::string key, OptionType type, int defaultValue)
bool & boolValue(std::string key)
void addOption(std::string key, OptionType type, const std::string &description="")
OptionType hasVariable(std::string key)
std::vector< int > IVec
SDMap::iterator SDMapIter
SDVecMap::const_iterator SDVecMapConstIter
SVec::const_iterator SVecConstIter
OptionType hasOption(std::string key)