CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends
optutl::VariableMapCont Class Reference

#include <VariableMapCont.h>

Inheritance diagram for optutl::VariableMapCont:
optutl::CommandLineParser

Public Types

typedef std::vector< double > DVec
 
typedef DVec::const_iterator DVecConstIter
 
typedef DVec::iterator DVecIter
 
typedef std::vector< int > IVec
 
typedef IVec::const_iterator IVecConstIter
 
typedef IVec::iterator IVecIter
 
enum  OptionType {
  kNone = 0, kInteger, kDouble, kString,
  kBool, kIntegerVector, kDoubleVector, kStringVector,
  kNumOptionTypes
}
 
typedef std::map< std::string, bool > SBMap
 
typedef SBMap::const_iterator SBMapConstIter
 
typedef SBMap::iterator SBMapIter
 
typedef std::map< std::string, double > SDMap
 
typedef SDMap::const_iterator SDMapConstIter
 
typedef SDMap::iterator SDMapIter
 
typedef std::map< std::string, DVecSDVecMap
 
typedef SDVecMap::const_iterator SDVecMapConstIter
 
typedef SDVecMap::iterator SDVecMapIter
 
typedef std::map< std::string, int > SIMap
 
typedef SIMap::const_iterator SIMapConstIter
 
typedef SIMap::iterator SIMapIter
 
typedef std::map< std::string, IVecSIVecMap
 
typedef SIVecMap::const_iterator SIVecMapConstIter
 
typedef SIVecMap::iterator SIVecMapIter
 
typedef std::map< std::string, std::string > SSMap
 
typedef SSMap::const_iterator SSMapConstIter
 
typedef SSMap::iterator SSMapIter
 
typedef std::map< std::string, SVecSSVecMap
 
typedef SSVecMap::const_iterator SSVecMapConstIter
 
typedef SSVecMap::iterator SSVecMapIter
 
typedef std::vector< std::string > SVec
 
typedef SVec::const_iterator SVecConstIter
 
typedef SVec::iterator SVecIter
 

Public Member Functions

void _checkKey (std::string &key, const std::string &description="")
 
void addOption (std::string key, OptionType type, const std::string &description="")
 
void addOption (std::string key, OptionType type, const std::string &description, int defaultValue)
 
void addOption (std::string key, OptionType type, const std::string &description, double defaultValue)
 
void addOption (std::string key, OptionType type, const std::string &description, const std::string &defaultValue)
 
void addOption (std::string key, OptionType type, const std::string &description, const char *defaultValue)
 
void addOption (std::string key, OptionType type, const std::string &description, bool defaultValue)
 
void addVariable (std::string key, OptionType type)
 
void addVariable (std::string key, OptionType type, int defaultValue)
 
void addVariable (std::string key, OptionType type, double defaultValue)
 
void addVariable (std::string key, OptionType type, const std::string &defaultValue)
 
void addVariable (std::string key, OptionType type, const char *defaultValue)
 
void addVariable (std::string key, OptionType type, bool defaultValue)
 
bool & boolValue (std::string key)
 
double & doubleValue (std::string key)
 
DVecdoubleVector (std::string key)
 
OptionType hasOption (std::string key)
 
OptionType hasVariable (std::string key)
 
void help ()
 
int & integerValue (std::string key)
 
IVecintegerVector (std::string key)
 
std::string & stringValue (std::string key)
 
SVecstringVector (std::string key)
 
 VariableMapCont ()
 

Static Public Member Functions

static void lowercaseString (std::string &arg)
 
static char toLower (char &ch)
 

Static Public Attributes

static const bool kDefaultBool = false
 
static const double kDefaultDouble = 0.
 
static const int kDefaultInteger = 0
 
static const std::string kDefaultString = ""
 
static const DVec kEmptyDVec
 
static const IVec kEmptyIVec
 
static const SVec kEmptySVec
 

Protected Member Functions

bool _valueHasBeenModified (const std::string &key)
 

Protected Attributes

SBMap m_boolMap
 
SDMap m_doubleMap
 
SDVecMap m_doubleVecMap
 
SIMap m_integerMap
 
SIVecMap m_integerVecMap
 
SSMap m_stringMap
 
SSVecMap m_stringVecMap
 
SSMap m_variableDescriptionMap
 
SBMap m_variableModifiedMap
 

Friends

std::ostream & operator<< (std::ostream &o_stream, const VariableMapCont &rhs)
 

Detailed Description

Definition at line 13 of file VariableMapCont.h.

Member Typedef Documentation

typedef std::vector< double > optutl::VariableMapCont::DVec

Definition at line 22 of file VariableMapCont.h.

typedef DVec::const_iterator optutl::VariableMapCont::DVecConstIter

Definition at line 44 of file VariableMapCont.h.

typedef DVec::iterator optutl::VariableMapCont::DVecIter

Definition at line 33 of file VariableMapCont.h.

typedef std::vector< int > optutl::VariableMapCont::IVec

Definition at line 21 of file VariableMapCont.h.

typedef IVec::const_iterator optutl::VariableMapCont::IVecConstIter

Definition at line 43 of file VariableMapCont.h.

typedef IVec::iterator optutl::VariableMapCont::IVecIter

Definition at line 32 of file VariableMapCont.h.

typedef std::map< std::string, bool > optutl::VariableMapCont::SBMap

Definition at line 26 of file VariableMapCont.h.

typedef SBMap::const_iterator optutl::VariableMapCont::SBMapConstIter

Definition at line 48 of file VariableMapCont.h.

typedef SBMap::iterator optutl::VariableMapCont::SBMapIter

Definition at line 37 of file VariableMapCont.h.

typedef std::map< std::string, double > optutl::VariableMapCont::SDMap

Definition at line 25 of file VariableMapCont.h.

typedef SDMap::const_iterator optutl::VariableMapCont::SDMapConstIter

Definition at line 47 of file VariableMapCont.h.

typedef SDMap::iterator optutl::VariableMapCont::SDMapIter

Definition at line 36 of file VariableMapCont.h.

typedef std::map< std::string, DVec > optutl::VariableMapCont::SDVecMap

Definition at line 29 of file VariableMapCont.h.

typedef SDVecMap::const_iterator optutl::VariableMapCont::SDVecMapConstIter

Definition at line 51 of file VariableMapCont.h.

typedef SDVecMap::iterator optutl::VariableMapCont::SDVecMapIter

Definition at line 40 of file VariableMapCont.h.

typedef std::map< std::string, int > optutl::VariableMapCont::SIMap

Definition at line 24 of file VariableMapCont.h.

typedef SIMap::const_iterator optutl::VariableMapCont::SIMapConstIter

Definition at line 46 of file VariableMapCont.h.

typedef SIMap::iterator optutl::VariableMapCont::SIMapIter

Definition at line 35 of file VariableMapCont.h.

typedef std::map< std::string, IVec > optutl::VariableMapCont::SIVecMap

Definition at line 28 of file VariableMapCont.h.

typedef SIVecMap::const_iterator optutl::VariableMapCont::SIVecMapConstIter

Definition at line 50 of file VariableMapCont.h.

typedef SIVecMap::iterator optutl::VariableMapCont::SIVecMapIter

Definition at line 39 of file VariableMapCont.h.

typedef std::map< std::string, std::string > optutl::VariableMapCont::SSMap

Definition at line 27 of file VariableMapCont.h.

typedef SSMap::const_iterator optutl::VariableMapCont::SSMapConstIter

Definition at line 49 of file VariableMapCont.h.

typedef SSMap::iterator optutl::VariableMapCont::SSMapIter

Definition at line 38 of file VariableMapCont.h.

typedef std::map< std::string, SVec > optutl::VariableMapCont::SSVecMap

Definition at line 30 of file VariableMapCont.h.

typedef SSVecMap::const_iterator optutl::VariableMapCont::SSVecMapConstIter

Definition at line 52 of file VariableMapCont.h.

typedef SSVecMap::iterator optutl::VariableMapCont::SSVecMapIter

Definition at line 41 of file VariableMapCont.h.

typedef std::vector< std::string > optutl::VariableMapCont::SVec

Definition at line 23 of file VariableMapCont.h.

typedef SVec::const_iterator optutl::VariableMapCont::SVecConstIter

Definition at line 45 of file VariableMapCont.h.

typedef SVec::iterator optutl::VariableMapCont::SVecIter

Definition at line 34 of file VariableMapCont.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

VariableMapCont::VariableMapCont ( )

Definition at line 21 of file VariableMapCont.cc.

22 {
23 }

Member Function Documentation

void VariableMapCont::_checkKey ( std::string &  key,
const std::string &  description = "" 
)

Definition at line 59 of file VariableMapCont.cc.

References MessageLogger_cfi::cerr, heppy_report::description, and crabWrapper::key.

Referenced by addVariable().

60 {
61  // Let's make sure we don't already have this key
63  if ( m_variableModifiedMap.end() != m_variableModifiedMap.find (key) )
64  {
65  cerr << "VariableMapCont::addVariable() Error: Key '" << key
66  << "' has already been defined. Aborting." << endl;
67  assert (0);
68  } // found a duplicate
69  m_variableModifiedMap[key] = false;
71 }
static void lowercaseString(std::string &arg)
bool VariableMapCont::_valueHasBeenModified ( const std::string &  key)
protected

Definition at line 284 of file VariableMapCont.cc.

References MessageLogger_cfi::cerr.

Referenced by optutl::CommandLineParser::_setVariableFromString(), and addVariable().

285 {
287  if (m_variableModifiedMap.end() == iter)
288  {
289  // Not found. Not a valid option
290  cerr << "VariableMapCont::valueHasBeenModfied () Error: '"
291  << key << "' is not a valid key." << endl;
292  return false;
293  }
294  return iter->second;
295 }
SBMap::const_iterator SBMapConstIter
void optutl::VariableMapCont::addOption ( std::string  key,
OptionType  type,
const std::string &  description = "" 
)
void optutl::VariableMapCont::addOption ( std::string  key,
OptionType  type,
const std::string &  description,
int  defaultValue 
)
void optutl::VariableMapCont::addOption ( std::string  key,
OptionType  type,
const std::string &  description,
double  defaultValue 
)
void optutl::VariableMapCont::addOption ( std::string  key,
OptionType  type,
const std::string &  description,
const std::string &  defaultValue 
)
void optutl::VariableMapCont::addOption ( std::string  key,
OptionType  type,
const std::string &  description,
const char *  defaultValue 
)
void optutl::VariableMapCont::addOption ( std::string  key,
OptionType  type,
const std::string &  description,
bool  defaultValue 
)
void optutl::VariableMapCont::addVariable ( std::string  key,
OptionType  type 
)
inline

Definition at line 129 of file VariableMapCont.h.

References addOption().

130  { addOption (key, type, ""); }
type
Definition: HCALResponse.h:21
void addOption(std::string key, OptionType type, const std::string &description="")
void optutl::VariableMapCont::addVariable ( std::string  key,
OptionType  type,
int  defaultValue 
)
inline

Definition at line 131 of file VariableMapCont.h.

References addOption().

132  { addOption (key, type, "", defaultValue); }
type
Definition: HCALResponse.h:21
void addOption(std::string key, OptionType type, const std::string &description="")
void optutl::VariableMapCont::addVariable ( std::string  key,
OptionType  type,
double  defaultValue 
)
inline

Definition at line 133 of file VariableMapCont.h.

References addOption().

134  { addOption (key, type, "", defaultValue); }
type
Definition: HCALResponse.h:21
void addOption(std::string key, OptionType type, const std::string &description="")
void optutl::VariableMapCont::addVariable ( std::string  key,
OptionType  type,
const std::string &  defaultValue 
)
inline

Definition at line 135 of file VariableMapCont.h.

References addOption().

137  { addOption (key, type, "", defaultValue); }
type
Definition: HCALResponse.h:21
void addOption(std::string key, OptionType type, const std::string &description="")
void optutl::VariableMapCont::addVariable ( std::string  key,
OptionType  type,
const char *  defaultValue 
)
inline

Definition at line 138 of file VariableMapCont.h.

References addOption().

140  { addOption (key, type, "", defaultValue); }
type
Definition: HCALResponse.h:21
void addOption(std::string key, OptionType type, const std::string &description="")
void optutl::VariableMapCont::addVariable ( std::string  key,
OptionType  type,
bool  defaultValue 
)
inline

Definition at line 141 of file VariableMapCont.h.

References _checkKey(), _valueHasBeenModified(), addOption(), boolValue(), doubleValue(), doubleVector(), integerValue(), integerVector(), lowercaseString(), AlCaHLTBitMon_QueryRunRegistry::string, stringValue(), stringVector(), and toLower().

142  { addOption (key, type, "", defaultValue); }
type
Definition: HCALResponse.h:21
void addOption(std::string key, OptionType type, const std::string &description="")
bool & VariableMapCont::boolValue ( std::string  key)

Definition at line 228 of file VariableMapCont.cc.

References MessageLogger_cfi::cerr.

Referenced by optutl::CommandLineParser::_finishDefaultOptions(), addVariable(), and fwlite::EventContainer::EventContainer().

229 {
231  SBMapIter iter = m_boolMap.find (key);
232  if (m_boolMap.end() == iter)
233  {
234  cerr << "VariableMapCont::boolValue() Error: key '"
235  << key << "' not found. Aborting." << endl;
236  assert (0);
237  }
238  return iter->second;
239 }
SBMap::iterator SBMapIter
static void lowercaseString(std::string &arg)
double & VariableMapCont::doubleValue ( std::string  key)

Definition at line 200 of file VariableMapCont.cc.

References MessageLogger_cfi::cerr.

Referenced by addVariable(), and main().

201 {
203  SDMapIter iter = m_doubleMap.find (key);
204  if (m_doubleMap.end() == iter)
205  {
206  cerr << "VariableMapCont::doubleValue() Error: key '"
207  << key << "' not found. Aborting." << endl;
208  assert (0);
209  }
210  return iter->second;
211 }
static void lowercaseString(std::string &arg)
SDMap::iterator SDMapIter
VariableMapCont::DVec & VariableMapCont::doubleVector ( std::string  key)

Definition at line 256 of file VariableMapCont.cc.

References MessageLogger_cfi::cerr.

Referenced by optutl::CommandLineParser::_runVariableCommandFromString(), and addVariable().

257 {
259  SDVecMapIter iter = m_doubleVecMap.find (key);
260  if (m_doubleVecMap.end() == iter)
261  {
262  cerr << "VariableMapCont::doubleVector() Error: key '"
263  << key << "' not found. Aborting." << endl;
264  assert (0);
265  }
266  return iter->second;
267 }
static void lowercaseString(std::string &arg)
SDVecMap::iterator SDVecMapIter
OptionType optutl::VariableMapCont::hasOption ( std::string  key)
inline
VariableMapCont::OptionType VariableMapCont::hasVariable ( std::string  key)

Definition at line 26 of file VariableMapCont.cc.

References WDecay::kNone.

Referenced by hasOption().

27 {
29  // Look through our maps to see if we've got it
30  if (m_integerMap.end() != m_integerMap.find (key)) return kInteger;
31  if (m_doubleMap.end() != m_doubleMap.find (key)) return kDouble;
32  if (m_stringMap.end() != m_stringMap.find (key)) return kString;
33  if (m_boolMap.end() != m_boolMap.find (key)) return kBool;
34  if (m_integerVecMap.end() != m_integerVecMap.find (key)) return kIntegerVector;
35  if (m_doubleVecMap.end() != m_doubleVecMap.find (key)) return kDoubleVector;
36  if (m_stringVecMap.end() != m_stringVecMap.find (key)) return kStringVector;
37  // if we're here, the answer's no.
38  return kNone;
39 }
static void lowercaseString(std::string &arg)
void optutl::VariableMapCont::help ( )
int & VariableMapCont::integerValue ( std::string  key)

Definition at line 186 of file VariableMapCont.cc.

References MessageLogger_cfi::cerr.

Referenced by optutl::CommandLineParser::_finishDefaultOptions(), addVariable(), bookHistograms(), calcSampleName(), fwlite::EventContainer::EventContainer(), and main().

187 {
189  SIMapIter iter = m_integerMap.find (key);
190  if (m_integerMap.end() == iter)
191  {
192  cerr << "VariableMapCont::integerValue() Error: key '"
193  << key << "' not found. Aborting." << endl;
194  assert (0);
195  }
196  return iter->second;
197 }
SIMap::iterator SIMapIter
static void lowercaseString(std::string &arg)
VariableMapCont::IVec & VariableMapCont::integerVector ( std::string  key)

Definition at line 242 of file VariableMapCont.cc.

References MessageLogger_cfi::cerr.

Referenced by optutl::CommandLineParser::_runVariableCommandFromString(), and addVariable().

243 {
245  SIVecMapIter iter = m_integerVecMap.find (key);
246  if (m_integerVecMap.end() == iter)
247  {
248  cerr << "VariableMapCont::integerVector() Error: key '"
249  << key << "' not found. Aborting." << endl;
250  assert (0);
251  }
252  return iter->second;
253 }
SIVecMap::iterator SIVecMapIter
static void lowercaseString(std::string &arg)
void VariableMapCont::lowercaseString ( std::string &  arg)
static

Definition at line 42 of file VariableMapCont.cc.

Referenced by optutl::CommandLineParser::_runVariableCommandFromString(), optutl::CommandLineParser::_setVariableFromString(), addVariable(), and optutl::CommandLineParser::parseArguments().

43 {
44  // assumes 'toLower(ch)' modifies ch
45  std::for_each (arg.begin(), arg.end(), VariableMapCont::toLower);
46  // // assumes 'toLower(ch)' returns the lower case char
47  // std::transform (arg.begin(), arg.end(), arg.begin(),
48  // VariableMapCont::toLower);
49 }
A arg
Definition: Factorize.h:36
static char toLower(char &ch)
string & VariableMapCont::stringValue ( std::string  key)

Definition at line 214 of file VariableMapCont.cc.

References MessageLogger_cfi::cerr.

Referenced by optutl::CommandLineParser::_finishDefaultOptions(), addVariable(), bookHistograms(), calcSampleName(), fwlite::EventContainer::EventContainer(), and main().

215 {
217  SSMapIter iter = m_stringMap.find (key);
218  if (m_stringMap.end() == iter)
219  {
220  cerr << "VariableMapCont::stringValue() Error: key '"
221  << key << "' not found. Aborting." << endl;
222  assert (0);
223  }
224  return iter->second;
225 }
SSMap::iterator SSMapIter
static void lowercaseString(std::string &arg)
VariableMapCont::SVec & VariableMapCont::stringVector ( std::string  key)

Definition at line 270 of file VariableMapCont.cc.

References MessageLogger_cfi::cerr.

Referenced by optutl::CommandLineParser::_finishDefaultOptions(), optutl::CommandLineParser::_runVariableCommandFromString(), addVariable(), fwlite::EventContainer::EventContainer(), main(), and fwlite::EventContainer::~EventContainer().

271 {
273  SSVecMapIter iter = m_stringVecMap.find (key);
274  if (m_stringVecMap.end() == iter)
275  {
276  cerr << "VariableMapCont::stringVector() Error: key '"
277  << key << "' not found. Aborting." << endl;
278  assert (0);
279  }
280  return iter->second;
281 }
static void lowercaseString(std::string &arg)
SSVecMap::iterator SSVecMapIter
char VariableMapCont::toLower ( char &  ch)
static

Definition at line 52 of file VariableMapCont.cc.

Referenced by addVariable().

53 {
54  ch = tolower (ch);
55  return ch;
56 }

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o_stream,
const VariableMapCont rhs 
)
friend

Member Data Documentation

const bool VariableMapCont::kDefaultBool = false
static

Definition at line 59 of file VariableMapCont.h.

const double VariableMapCont::kDefaultDouble = 0.
static

Definition at line 57 of file VariableMapCont.h.

const int VariableMapCont::kDefaultInteger = 0
static

Definition at line 56 of file VariableMapCont.h.

const std::string VariableMapCont::kDefaultString = ""
static

Definition at line 58 of file VariableMapCont.h.

const VariableMapCont::DVec VariableMapCont::kEmptyDVec
static

Definition at line 61 of file VariableMapCont.h.

const VariableMapCont::IVec VariableMapCont::kEmptyIVec
static

Definition at line 60 of file VariableMapCont.h.

const VariableMapCont::SVec VariableMapCont::kEmptySVec
static

Definition at line 62 of file VariableMapCont.h.

SBMap optutl::VariableMapCont::m_boolMap
protected
SDMap optutl::VariableMapCont::m_doubleMap
protected
SDVecMap optutl::VariableMapCont::m_doubleVecMap
protected
SIMap optutl::VariableMapCont::m_integerMap
protected
SIVecMap optutl::VariableMapCont::m_integerVecMap
protected
SSMap optutl::VariableMapCont::m_stringMap
protected
SSVecMap optutl::VariableMapCont::m_stringVecMap
protected
SSMap optutl::VariableMapCont::m_variableDescriptionMap
protected

Definition at line 185 of file VariableMapCont.h.

Referenced by optutl::CommandLineParser::printOptionValues().

SBMap optutl::VariableMapCont::m_variableModifiedMap
protected