CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
12 
14 {
15  public:
17  // Public Constants //
19 
20  // typedefs
21  typedef std::vector< int > IVec;
22  typedef std::vector< double > DVec;
23  typedef std::vector< std::string > SVec;
24  typedef std::map< std::string, int > SIMap;
25  typedef std::map< std::string, double > SDMap;
26  typedef std::map< std::string, bool > SBMap;
27  typedef std::map< std::string, std::string > SSMap;
28  typedef std::map< std::string, IVec > SIVecMap;
29  typedef std::map< std::string, DVec > SDVecMap;
30  typedef std::map< std::string, SVec > SSVecMap;
31  // Iterators
32  typedef IVec::iterator IVecIter;
33  typedef DVec::iterator DVecIter;
34  typedef SVec::iterator SVecIter;
35  typedef SIMap::iterator SIMapIter;
36  typedef SDMap::iterator SDMapIter;
37  typedef SBMap::iterator SBMapIter;
38  typedef SSMap::iterator SSMapIter;
39  typedef SIVecMap::iterator SIVecMapIter;
40  typedef SDVecMap::iterator SDVecMapIter;
41  typedef SSVecMap::iterator SSVecMapIter;
42  // constant iterators
43  typedef IVec::const_iterator IVecConstIter;
44  typedef DVec::const_iterator DVecConstIter;
45  typedef SVec::const_iterator SVecConstIter;
46  typedef SIMap::const_iterator SIMapConstIter;
47  typedef SDMap::const_iterator SDMapConstIter;
48  typedef SBMap::const_iterator SBMapConstIter;
49  typedef SSMap::const_iterator SSMapConstIter;
50  typedef SIVecMap::const_iterator SIVecMapConstIter;
51  typedef SDVecMap::const_iterator SDVecMapConstIter;
52  typedef SSVecMap::const_iterator SSVecMapConstIter;
53 
54 
55  // constants
56  static const int kDefaultInteger;
57  static const double kDefaultDouble;
59  static const bool kDefaultBool;
60  static const IVec kEmptyIVec;
61  static const DVec kEmptyDVec;
62  static const SVec kEmptySVec;
63 
65  {
66  kNone = 0,
75  };
76 
78  // friends //
80  // tells particle data how to print itself out
81  friend std::ostream& operator<< (std::ostream& o_stream,
82  const VariableMapCont &rhs);
83 
85  // _ //
86  // |\/| |_ //
87  // | |EMBER | UNCTIONS //
88  // //
90 
92  // Constructors and Destructor //
95 
97  // Regular Member Functions //
99 
100  // prints out '--help' screen, then exits.
101  void help();
102 
103  // returns OptionType (or kNone (0)) of a given option.
106  { return hasVariable (key); }
107 
108 
109  // Add variable to option maps. 'key' is passed in by copy
110  // because it is modified in place.
112  const std::string &description = "");
114  const std::string &description,
115  int defaultValue);
117  const std::string &description,
118  double defaultValue);
120  const std::string &description,
121  const std::string &defaultValue);
123  const std::string &description,
124  const char *defaultValue);
126  const std::string &description,
127  bool defaultValue);
128  // addVariable works just like addOption, but has no description.
130  { addOption (key, type, ""); }
131  void addVariable (std::string key, OptionType type, int defaultValue)
132  { addOption (key, type, "", defaultValue); }
133  void addVariable (std::string key, OptionType type, double defaultValue)
134  { addOption (key, type, "", defaultValue); }
136  const std::string &defaultValue)
137  { addOption (key, type, "", defaultValue); }
139  const char *defaultValue)
140  { addOption (key, type, "", defaultValue); }
141  void addVariable (std::string key, OptionType type, bool defaultValue)
142  { addOption (key, type, "", defaultValue); }
143 
144 
145  // some of the guts of above
146  void _checkKey (std::string &key, const std::string &description = "");
147 
149  double &doubleValue (std::string key);
151  bool &boolValue (std::string key);
155 
157  // Static Member Functions //
159 
160  // converts a string to lower case characters
161  static void lowercaseString(std::string &arg);
162 
163  // converts a single character to lower case
164  static char toLower (char &ch);
165 
166 
167  protected:
168 
169  // returns true if a variable has been modified from the command
170  // line.
171  bool _valueHasBeenModified (const std::string &key);
172 
174  // Private Member Data //
176 
186 
187 };
188 
189 }
190 #endif // VariableMapCont_H
std::map< std::string, double > SDMap
void _checkKey(std::string &key, const std::string &description="")
type
Definition: HCALResponse.h:21
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::vector< double > DVec
SIMap::iterator SIMapIter
std::string & stringValue(std::string key)
std::vector< std::string > SVec
SBMap::const_iterator SBMapConstIter
friend std::ostream & operator<<(std::ostream &o_stream, const VariableMapCont &rhs)
SIVecMap::iterator SIVecMapIter
SSVecMap::const_iterator SSVecMapConstIter
double & doubleValue(std::string key)
A arg
Definition: Factorize.h:36
static const SVec kEmptySVec
std::vector< int > IVec
int & integerValue(std::string key)
SSMap::const_iterator SSMapConstIter
static char toLower(char &ch)
DVec::const_iterator DVecConstIter
void addVariable(std::string key, OptionType type, bool defaultValue)
SIVecMap::const_iterator SIVecMapConstIter
DVec & doubleVector(std::string key)
static const double kDefaultDouble
void addVariable(std::string key, OptionType type, const std::string &defaultValue)
static void lowercaseString(std::string &arg)
static const bool kDefaultBool
SSVecMap::iterator SSVecMapIter
void addVariable(std::string key, OptionType type)
SDVecMap::iterator SDVecMapIter
std::map< std::string, int > SIMap
std::map< std::string, IVec > SIVecMap
void addVariable(std::string key, OptionType type, double defaultValue)
tuple description
Definition: idDealer.py:66
static const DVec kEmptyDVec
bool _valueHasBeenModified(const std::string &key)
static const IVec kEmptyIVec
IVec & integerVector(std::string key)
static const int kDefaultInteger
std::map< std::string, SVec > SSVecMap
SVec & stringVector(std::string key)
std::map< std::string, std::string > SSMap
std::map< std::string, DVec > SDVecMap
list key
Definition: combine.py:13
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)
SDMap::iterator SDMapIter
SDVecMap::const_iterator SDVecMapConstIter
std::map< std::string, bool > SBMap
SVec::const_iterator SVecConstIter
OptionType hasOption(std::string key)