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.
105  void addOption(std::string key, OptionType type, const std::string &description, int defaultValue);
106  void addOption(std::string key, OptionType type, const std::string &description, double defaultValue);
107  void addOption(std::string key, OptionType type, const std::string &description, const std::string &defaultValue);
108  void addOption(std::string key, OptionType type, const std::string &description, const char *defaultValue);
109  void addOption(std::string key, OptionType type, const std::string &description, bool defaultValue);
110  // addVariable works just like addOption, but has no description.
112  void addVariable(std::string key, OptionType type, int defaultValue) { addOption(key, type, "", defaultValue); }
113  void addVariable(std::string key, OptionType type, double defaultValue) { addOption(key, type, "", defaultValue); }
114  void addVariable(std::string key, OptionType type, const std::string &defaultValue) {
115  addOption(key, type, "", defaultValue);
116  }
117  void addVariable(std::string key, OptionType type, const char *defaultValue) {
118  addOption(key, type, "", defaultValue);
119  }
120  void addVariable(std::string key, OptionType type, bool defaultValue) { addOption(key, type, "", defaultValue); }
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
optutl::VariableMapCont::SBMapIter
SBMap::iterator SBMapIter
Definition: VariableMapCont.h:35
optutl::VariableMapCont::kDefaultBool
static const bool kDefaultBool
Definition: VariableMapCont.h:56
optutl::VariableMapCont::addVariable
void addVariable(std::string key, OptionType type, int defaultValue)
Definition: VariableMapCont.h:112
optutl::VariableMapCont::addVariable
void addVariable(std::string key, OptionType type, bool defaultValue)
Definition: VariableMapCont.h:120
optutl::VariableMapCont::stringValue
std::string & stringValue(std::string key)
Definition: VariableMapCont.cc:163
optutl::VariableMapCont::SIMapIter
SIMap::iterator SIMapIter
Definition: VariableMapCont.h:33
optutl::VariableMapCont::kStringVector
Definition: VariableMapCont.h:69
optutl::VariableMapCont::hasOption
OptionType hasOption(std::string key)
Definition: VariableMapCont.h:100
optutl::VariableMapCont::addVariable
void addVariable(std::string key, OptionType type, double defaultValue)
Definition: VariableMapCont.h:113
optutl::VariableMapCont::DVec
std::vector< double > DVec
Definition: VariableMapCont.h:20
optutl::VariableMapCont::help
void help()
optutl::VariableMapCont::SVecConstIter
SVec::const_iterator SVecConstIter
Definition: VariableMapCont.h:43
optutl::VariableMapCont::SBMap
std::map< std::string, bool > SBMap
Definition: VariableMapCont.h:24
edmLumisInFiles.description
description
Definition: edmLumisInFiles.py:11
optutl::VariableMapCont::SSVecMap
std::map< std::string, SVec > SSVecMap
Definition: VariableMapCont.h:28
optutl::VariableMapCont::m_stringVecMap
SSVecMap m_stringVecMap
Definition: VariableMapCont.h:158
optutl::VariableMapCont::_checkKey
void _checkKey(std::string &key, const std::string &description="")
Definition: VariableMapCont.cc:56
optutl::VariableMapCont::m_doubleMap
SDMap m_doubleMap
Definition: VariableMapCont.h:153
optutl::VariableMapCont::m_variableDescriptionMap
SSMap m_variableDescriptionMap
Definition: VariableMapCont.h:160
optutl::VariableMapCont::SDVecMap
std::map< std::string, DVec > SDVecMap
Definition: VariableMapCont.h:27
optutl::VariableMapCont::IVecIter
IVec::iterator IVecIter
Definition: VariableMapCont.h:30
optutl::VariableMapCont::SVecIter
SVec::iterator SVecIter
Definition: VariableMapCont.h:32
optutl::VariableMapCont::SDVecMapIter
SDVecMap::iterator SDVecMapIter
Definition: VariableMapCont.h:38
optutl::VariableMapCont::m_integerMap
SIMap m_integerMap
Definition: VariableMapCont.h:152
optutl::VariableMapCont::doubleValue
double & doubleValue(std::string key)
Definition: VariableMapCont.cc:153
optutl::VariableMapCont::kEmptySVec
static const SVec kEmptySVec
Definition: VariableMapCont.h:59
optutl::VariableMapCont::addOption
void addOption(std::string key, OptionType type, const std::string &description="")
optutl::VariableMapCont::hasVariable
OptionType hasVariable(std::string key)
Definition: VariableMapCont.cc:22
optutl::VariableMapCont::kDouble
Definition: VariableMapCont.h:64
optutl::VariableMapCont::kDefaultDouble
static const double kDefaultDouble
Definition: VariableMapCont.h:54
optutl::VariableMapCont::SDMapIter
SDMap::iterator SDMapIter
Definition: VariableMapCont.h:34
optutl::VariableMapCont::SIVecMap
std::map< std::string, IVec > SIVecMap
Definition: VariableMapCont.h:26
optutl::VariableMapCont::kString
Definition: VariableMapCont.h:65
optutl::VariableMapCont::kNone
Definition: VariableMapCont.h:62
optutl::VariableMapCont::m_variableModifiedMap
SBMap m_variableModifiedMap
Definition: VariableMapCont.h:159
optutl::VariableMapCont::VariableMapCont
VariableMapCont()
Definition: VariableMapCont.cc:20
optutl::VariableMapCont::kIntegerVector
Definition: VariableMapCont.h:67
optutl::VariableMapCont::addVariable
void addVariable(std::string key, OptionType type, const std::string &defaultValue)
Definition: VariableMapCont.h:114
optutl::VariableMapCont::kDefaultString
static const std::string kDefaultString
Definition: VariableMapCont.h:55
optutl::VariableMapCont::kDoubleVector
Definition: VariableMapCont.h:68
optutl::VariableMapCont::SIVecMapIter
SIVecMap::iterator SIVecMapIter
Definition: VariableMapCont.h:37
optutl::VariableMapCont::SSVecMapIter
SSVecMap::iterator SSVecMapIter
Definition: VariableMapCont.h:39
optutl::VariableMapCont::SSMapIter
SSMap::iterator SSMapIter
Definition: VariableMapCont.h:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
optutl::VariableMapCont::m_stringMap
SSMap m_stringMap
Definition: VariableMapCont.h:154
optutl::VariableMapCont::SDVecMapConstIter
SDVecMap::const_iterator SDVecMapConstIter
Definition: VariableMapCont.h:49
optutl::VariableMapCont::kEmptyIVec
static const IVec kEmptyIVec
Definition: VariableMapCont.h:57
optutl::VariableMapCont::_valueHasBeenModified
bool _valueHasBeenModified(const std::string &key)
Definition: VariableMapCont.cc:213
optutl::VariableMapCont::kDefaultInteger
static const int kDefaultInteger
Definition: VariableMapCont.h:53
optutl::VariableMapCont::kNumOptionTypes
Definition: VariableMapCont.h:70
optutl::VariableMapCont::SSMap
std::map< std::string, std::string > SSMap
Definition: VariableMapCont.h:25
optutl::VariableMapCont::SBMapConstIter
SBMap::const_iterator SBMapConstIter
Definition: VariableMapCont.h:46
optutl::VariableMapCont::kBool
Definition: VariableMapCont.h:66
optutl::VariableMapCont::kEmptyDVec
static const DVec kEmptyDVec
Definition: VariableMapCont.h:58
optutl::VariableMapCont::m_boolMap
SBMap m_boolMap
Definition: VariableMapCont.h:155
optutl::VariableMapCont::toLower
static char toLower(char &ch)
Definition: VariableMapCont.cc:51
optutl::VariableMapCont::SDMapConstIter
SDMap::const_iterator SDMapConstIter
Definition: VariableMapCont.h:45
optutl::VariableMapCont::DVecConstIter
DVec::const_iterator DVecConstIter
Definition: VariableMapCont.h:42
optutl::VariableMapCont::addVariable
void addVariable(std::string key, OptionType type, const char *defaultValue)
Definition: VariableMapCont.h:117
optutl::VariableMapCont::m_integerVecMap
SIVecMap m_integerVecMap
Definition: VariableMapCont.h:156
optutl::VariableMapCont::SIMapConstIter
SIMap::const_iterator SIMapConstIter
Definition: VariableMapCont.h:44
optutl::VariableMapCont::SSVecMapConstIter
SSVecMap::const_iterator SSVecMapConstIter
Definition: VariableMapCont.h:50
type
type
Definition: HCALResponse.h:21
optutl::VariableMapCont::OptionType
OptionType
Definition: VariableMapCont.h:61
optutl::VariableMapCont::m_doubleVecMap
SDVecMap m_doubleVecMap
Definition: VariableMapCont.h:157
optutl::VariableMapCont::integerVector
IVec & integerVector(std::string key)
Definition: VariableMapCont.cc:183
optutl::VariableMapCont::IVec
std::vector< int > IVec
Definition: VariableMapCont.h:19
optutl::VariableMapCont::kInteger
Definition: VariableMapCont.h:63
optutl::VariableMapCont::SVec
std::vector< std::string > SVec
Definition: VariableMapCont.h:21
optutl::VariableMapCont::doubleVector
DVec & doubleVector(std::string key)
Definition: VariableMapCont.cc:193
optutl::VariableMapCont::SIMap
std::map< std::string, int > SIMap
Definition: VariableMapCont.h:22
optutl::VariableMapCont::lowercaseString
static void lowercaseString(std::string &arg)
Definition: VariableMapCont.cc:43
optutl::VariableMapCont::IVecConstIter
IVec::const_iterator IVecConstIter
Definition: VariableMapCont.h:41
optutl::VariableMapCont::stringVector
SVec & stringVector(std::string key)
Definition: VariableMapCont.cc:203
optutl::VariableMapCont::addVariable
void addVariable(std::string key, OptionType type)
Definition: VariableMapCont.h:111
funct::arg
A arg
Definition: Factorize.h:36
optutl::VariableMapCont::integerValue
int & integerValue(std::string key)
Definition: VariableMapCont.cc:143
optutl::VariableMapCont::SSMapConstIter
SSMap::const_iterator SSMapConstIter
Definition: VariableMapCont.h:47
optutl::VariableMapCont::SIVecMapConstIter
SIVecMap::const_iterator SIVecMapConstIter
Definition: VariableMapCont.h:48
crabWrapper.key
key
Definition: crabWrapper.py:19
optutl::VariableMapCont::operator<<
friend std::ostream & operator<<(std::ostream &o_stream, const VariableMapCont &rhs)
optutl
Definition: CommandLineParser.h:8
optutl::VariableMapCont
Definition: VariableMapCont.h:12
optutl::VariableMapCont::SDMap
std::map< std::string, double > SDMap
Definition: VariableMapCont.h:23
optutl::VariableMapCont::DVecIter
DVec::iterator DVecIter
Definition: VariableMapCont.h:31
optutl::VariableMapCont::boolValue
bool & boolValue(std::string key)
Definition: VariableMapCont.cc:173