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 12 of file VariableMapCont.h.

Member Typedef Documentation

◆ DVec

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

Definition at line 20 of file VariableMapCont.h.

◆ DVecConstIter

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

Definition at line 42 of file VariableMapCont.h.

◆ DVecIter

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

Definition at line 31 of file VariableMapCont.h.

◆ IVec

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

Definition at line 19 of file VariableMapCont.h.

◆ IVecConstIter

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

Definition at line 41 of file VariableMapCont.h.

◆ IVecIter

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

Definition at line 30 of file VariableMapCont.h.

◆ SBMap

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

Definition at line 24 of file VariableMapCont.h.

◆ SBMapConstIter

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

Definition at line 46 of file VariableMapCont.h.

◆ SBMapIter

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

Definition at line 35 of file VariableMapCont.h.

◆ SDMap

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

Definition at line 23 of file VariableMapCont.h.

◆ SDMapConstIter

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

Definition at line 45 of file VariableMapCont.h.

◆ SDMapIter

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

Definition at line 34 of file VariableMapCont.h.

◆ SDVecMap

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

Definition at line 27 of file VariableMapCont.h.

◆ SDVecMapConstIter

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

Definition at line 49 of file VariableMapCont.h.

◆ SDVecMapIter

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

Definition at line 38 of file VariableMapCont.h.

◆ SIMap

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

Definition at line 22 of file VariableMapCont.h.

◆ SIMapConstIter

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

Definition at line 44 of file VariableMapCont.h.

◆ SIMapIter

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

Definition at line 33 of file VariableMapCont.h.

◆ SIVecMap

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

Definition at line 26 of file VariableMapCont.h.

◆ SIVecMapConstIter

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

Definition at line 48 of file VariableMapCont.h.

◆ SIVecMapIter

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

Definition at line 37 of file VariableMapCont.h.

◆ SSMap

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

Definition at line 25 of file VariableMapCont.h.

◆ SSMapConstIter

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

Definition at line 47 of file VariableMapCont.h.

◆ SSMapIter

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

Definition at line 36 of file VariableMapCont.h.

◆ SSVecMap

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

Definition at line 28 of file VariableMapCont.h.

◆ SSVecMapConstIter

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

Definition at line 50 of file VariableMapCont.h.

◆ SSVecMapIter

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

Definition at line 39 of file VariableMapCont.h.

◆ SVec

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

Definition at line 21 of file VariableMapCont.h.

◆ SVecConstIter

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

Definition at line 43 of file VariableMapCont.h.

◆ SVecIter

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

Definition at line 32 of file VariableMapCont.h.

Member Enumeration Documentation

◆ OptionType

Constructor & Destructor Documentation

◆ VariableMapCont()

VariableMapCont::VariableMapCont ( )

Definition at line 20 of file VariableMapCont.cc.

20 {}

Member Function Documentation

◆ _checkKey()

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

Definition at line 56 of file VariableMapCont.cc.

References cms::cuda::assert(), DMR_cfg::cerr, makeListRunsInFiles::description, and submitPVResolutionJobs::key.

56  {
57  // Let's make sure we don't already have this key
59  if (m_variableModifiedMap.end() != m_variableModifiedMap.find(key)) {
60  cerr << "VariableMapCont::addVariable() Error: Key '" << key << "' has already been defined. Aborting." << endl;
61  assert(0);
62  } // found a duplicate
63  m_variableModifiedMap[key] = false;
65 }
assert(be >=bs)
key
prepare the HTCondor submission files and eventually submit them
static void lowercaseString(std::string &arg)

◆ _valueHasBeenModified()

bool VariableMapCont::_valueHasBeenModified ( const std::string &  key)
protected

Definition at line 213 of file VariableMapCont.cc.

References DMR_cfg::cerr, and submitPVResolutionJobs::key.

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

213  {
215  if (m_variableModifiedMap.end() == iter) {
216  // Not found. Not a valid option
217  cerr << "VariableMapCont::valueHasBeenModfied () Error: '" << key << "' is not a valid key." << endl;
218  return false;
219  }
220  return iter->second;
221 }
SBMap::const_iterator SBMapConstIter
key
prepare the HTCondor submission files and eventually submit them

◆ addOption() [1/6]

void optutl::VariableMapCont::addOption ( std::string  key,
OptionType  type,
const std::string &  description = "" 
)

◆ addOption() [2/6]

void optutl::VariableMapCont::addOption ( std::string  key,
OptionType  type,
const std::string &  description,
int  defaultValue 
)

◆ addOption() [3/6]

void optutl::VariableMapCont::addOption ( std::string  key,
OptionType  type,
const std::string &  description,
double  defaultValue 
)

◆ addOption() [4/6]

void optutl::VariableMapCont::addOption ( std::string  key,
OptionType  type,
const std::string &  description,
const std::string &  defaultValue 
)

◆ addOption() [5/6]

void optutl::VariableMapCont::addOption ( std::string  key,
OptionType  type,
const std::string &  description,
const char *  defaultValue 
)

◆ addOption() [6/6]

void optutl::VariableMapCont::addOption ( std::string  key,
OptionType  type,
const std::string &  description,
bool  defaultValue 
)

◆ addVariable() [1/6]

void optutl::VariableMapCont::addVariable ( std::string  key,
OptionType  type 
)
inline

Definition at line 111 of file VariableMapCont.h.

References addOption(), and submitPVResolutionJobs::key.

111 { addOption(key, type, ""); }
key
prepare the HTCondor submission files and eventually submit them
void addOption(std::string key, OptionType type, const std::string &description="")

◆ addVariable() [2/6]

void optutl::VariableMapCont::addVariable ( std::string  key,
OptionType  type,
int  defaultValue 
)
inline

Definition at line 112 of file VariableMapCont.h.

References addOption(), hltPixelClustersMultiplicity_cfi::defaultValue, and submitPVResolutionJobs::key.

112 { addOption(key, type, "", defaultValue); }
key
prepare the HTCondor submission files and eventually submit them
void addOption(std::string key, OptionType type, const std::string &description="")

◆ addVariable() [3/6]

void optutl::VariableMapCont::addVariable ( std::string  key,
OptionType  type,
double  defaultValue 
)
inline

Definition at line 113 of file VariableMapCont.h.

References addOption(), hltPixelClustersMultiplicity_cfi::defaultValue, and submitPVResolutionJobs::key.

113 { addOption(key, type, "", defaultValue); }
key
prepare the HTCondor submission files and eventually submit them
void addOption(std::string key, OptionType type, const std::string &description="")

◆ addVariable() [4/6]

void optutl::VariableMapCont::addVariable ( std::string  key,
OptionType  type,
const std::string &  defaultValue 
)
inline

Definition at line 114 of file VariableMapCont.h.

References addOption(), hltPixelClustersMultiplicity_cfi::defaultValue, and submitPVResolutionJobs::key.

114  {
116  }
key
prepare the HTCondor submission files and eventually submit them
void addOption(std::string key, OptionType type, const std::string &description="")

◆ addVariable() [5/6]

void optutl::VariableMapCont::addVariable ( std::string  key,
OptionType  type,
const char *  defaultValue 
)
inline

Definition at line 117 of file VariableMapCont.h.

References addOption(), hltPixelClustersMultiplicity_cfi::defaultValue, and submitPVResolutionJobs::key.

117  {
119  }
key
prepare the HTCondor submission files and eventually submit them
void addOption(std::string key, OptionType type, const std::string &description="")

◆ addVariable() [6/6]

void optutl::VariableMapCont::addVariable ( std::string  key,
OptionType  type,
bool  defaultValue 
)
inline

Definition at line 120 of file VariableMapCont.h.

References addOption(), hltPixelClustersMultiplicity_cfi::defaultValue, and submitPVResolutionJobs::key.

120 { addOption(key, type, "", defaultValue); }
key
prepare the HTCondor submission files and eventually submit them
void addOption(std::string key, OptionType type, const std::string &description="")

◆ boolValue()

bool & VariableMapCont::boolValue ( std::string  key)

Definition at line 173 of file VariableMapCont.cc.

References cms::cuda::assert(), DMR_cfg::cerr, and submitPVResolutionJobs::key.

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

173  {
175  SBMapIter iter = m_boolMap.find(key);
176  if (m_boolMap.end() == iter) {
177  cerr << "VariableMapCont::boolValue() Error: key '" << key << "' not found. Aborting." << endl;
178  assert(0);
179  }
180  return iter->second;
181 }
SBMap::iterator SBMapIter
assert(be >=bs)
key
prepare the HTCondor submission files and eventually submit them
static void lowercaseString(std::string &arg)

◆ doubleValue()

double & VariableMapCont::doubleValue ( std::string  key)

Definition at line 153 of file VariableMapCont.cc.

References cms::cuda::assert(), DMR_cfg::cerr, and submitPVResolutionJobs::key.

153  {
155  SDMapIter iter = m_doubleMap.find(key);
156  if (m_doubleMap.end() == iter) {
157  cerr << "VariableMapCont::doubleValue() Error: key '" << key << "' not found. Aborting." << endl;
158  assert(0);
159  }
160  return iter->second;
161 }
assert(be >=bs)
key
prepare the HTCondor submission files and eventually submit them
static void lowercaseString(std::string &arg)
SDMap::iterator SDMapIter

◆ doubleVector()

VariableMapCont::DVec & VariableMapCont::doubleVector ( std::string  key)

Definition at line 193 of file VariableMapCont.cc.

References cms::cuda::assert(), DMR_cfg::cerr, and submitPVResolutionJobs::key.

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

193  {
195  SDVecMapIter iter = m_doubleVecMap.find(key);
196  if (m_doubleVecMap.end() == iter) {
197  cerr << "VariableMapCont::doubleVector() Error: key '" << key << "' not found. Aborting." << endl;
198  assert(0);
199  }
200  return iter->second;
201 }
assert(be >=bs)
key
prepare the HTCondor submission files and eventually submit them
static void lowercaseString(std::string &arg)
SDVecMap::iterator SDVecMapIter

◆ hasOption()

OptionType optutl::VariableMapCont::hasOption ( std::string  key)
inline

Definition at line 100 of file VariableMapCont.h.

References hasVariable(), and submitPVResolutionJobs::key.

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

100 { return hasVariable(key); }
key
prepare the HTCondor submission files and eventually submit them
OptionType hasVariable(std::string key)

◆ hasVariable()

VariableMapCont::OptionType VariableMapCont::hasVariable ( std::string  key)

Definition at line 22 of file VariableMapCont.cc.

References submitPVResolutionJobs::key.

Referenced by hasOption().

22  {
24  // Look through our maps to see if we've got it
25  if (m_integerMap.end() != m_integerMap.find(key))
26  return kInteger;
27  if (m_doubleMap.end() != m_doubleMap.find(key))
28  return kDouble;
29  if (m_stringMap.end() != m_stringMap.find(key))
30  return kString;
31  if (m_boolMap.end() != m_boolMap.find(key))
32  return kBool;
33  if (m_integerVecMap.end() != m_integerVecMap.find(key))
34  return kIntegerVector;
35  if (m_doubleVecMap.end() != m_doubleVecMap.find(key))
36  return kDoubleVector;
37  if (m_stringVecMap.end() != m_stringVecMap.find(key))
38  return kStringVector;
39  // if we're here, the answer's no.
40  return kNone;
41 }
key
prepare the HTCondor submission files and eventually submit them
static void lowercaseString(std::string &arg)

◆ help()

void optutl::VariableMapCont::help ( )

◆ integerValue()

int & VariableMapCont::integerValue ( std::string  key)

Definition at line 143 of file VariableMapCont.cc.

References cms::cuda::assert(), DMR_cfg::cerr, and submitPVResolutionJobs::key.

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

143  {
145  SIMapIter iter = m_integerMap.find(key);
146  if (m_integerMap.end() == iter) {
147  cerr << "VariableMapCont::integerValue() Error: key '" << key << "' not found. Aborting." << endl;
148  assert(0);
149  }
150  return iter->second;
151 }
SIMap::iterator SIMapIter
assert(be >=bs)
key
prepare the HTCondor submission files and eventually submit them
static void lowercaseString(std::string &arg)

◆ integerVector()

VariableMapCont::IVec & VariableMapCont::integerVector ( std::string  key)

Definition at line 183 of file VariableMapCont.cc.

References cms::cuda::assert(), DMR_cfg::cerr, and submitPVResolutionJobs::key.

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

183  {
185  SIVecMapIter iter = m_integerVecMap.find(key);
186  if (m_integerVecMap.end() == iter) {
187  cerr << "VariableMapCont::integerVector() Error: key '" << key << "' not found. Aborting." << endl;
188  assert(0);
189  }
190  return iter->second;
191 }
SIVecMap::iterator SIVecMapIter
assert(be >=bs)
key
prepare the HTCondor submission files and eventually submit them
static void lowercaseString(std::string &arg)

◆ lowercaseString()

void VariableMapCont::lowercaseString ( std::string &  arg)
static

Definition at line 43 of file VariableMapCont.cc.

Referenced by optutl::CommandLineParser::_runVariableCommandFromString(), optutl::CommandLineParser::_setVariableFromString(), 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:31
static char toLower(char &ch)

◆ stringValue()

string & VariableMapCont::stringValue ( std::string  key)

Definition at line 163 of file VariableMapCont.cc.

References cms::cuda::assert(), DMR_cfg::cerr, and submitPVResolutionJobs::key.

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

163  {
165  SSMapIter iter = m_stringMap.find(key);
166  if (m_stringMap.end() == iter) {
167  cerr << "VariableMapCont::stringValue() Error: key '" << key << "' not found. Aborting." << endl;
168  assert(0);
169  }
170  return iter->second;
171 }
SSMap::iterator SSMapIter
assert(be >=bs)
key
prepare the HTCondor submission files and eventually submit them
static void lowercaseString(std::string &arg)

◆ stringVector()

VariableMapCont::SVec & VariableMapCont::stringVector ( std::string  key)

Definition at line 203 of file VariableMapCont.cc.

References cms::cuda::assert(), DMR_cfg::cerr, and submitPVResolutionJobs::key.

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

203  {
205  SSVecMapIter iter = m_stringVecMap.find(key);
206  if (m_stringVecMap.end() == iter) {
207  cerr << "VariableMapCont::stringVector() Error: key '" << key << "' not found. Aborting." << endl;
208  assert(0);
209  }
210  return iter->second;
211 }
assert(be >=bs)
key
prepare the HTCondor submission files and eventually submit them
static void lowercaseString(std::string &arg)
SSVecMap::iterator SSVecMapIter

◆ toLower()

char VariableMapCont::toLower ( char &  ch)
static

Definition at line 51 of file VariableMapCont.cc.

51  {
52  ch = tolower(ch);
53  return ch;
54 }

Friends And Related Function Documentation

◆ operator<<

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

Member Data Documentation

◆ kDefaultBool

const bool VariableMapCont::kDefaultBool = false
static

Definition at line 56 of file VariableMapCont.h.

◆ kDefaultDouble

const double VariableMapCont::kDefaultDouble = 0.
static

Definition at line 54 of file VariableMapCont.h.

◆ kDefaultInteger

const int VariableMapCont::kDefaultInteger = 0
static

Definition at line 53 of file VariableMapCont.h.

◆ kDefaultString

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

Definition at line 55 of file VariableMapCont.h.

◆ kEmptyDVec

const VariableMapCont::DVec VariableMapCont::kEmptyDVec
static

Definition at line 58 of file VariableMapCont.h.

◆ kEmptyIVec

const VariableMapCont::IVec VariableMapCont::kEmptyIVec
static

Definition at line 57 of file VariableMapCont.h.

◆ kEmptySVec

const VariableMapCont::SVec VariableMapCont::kEmptySVec
static

Definition at line 59 of file VariableMapCont.h.

◆ m_boolMap

SBMap optutl::VariableMapCont::m_boolMap
protected

◆ m_doubleMap

SDMap optutl::VariableMapCont::m_doubleMap
protected

◆ m_doubleVecMap

SDVecMap optutl::VariableMapCont::m_doubleVecMap
protected

◆ m_integerMap

SIMap optutl::VariableMapCont::m_integerMap
protected

◆ m_integerVecMap

SIVecMap optutl::VariableMapCont::m_integerVecMap
protected

◆ m_stringMap

SSMap optutl::VariableMapCont::m_stringMap
protected

◆ m_stringVecMap

SSVecMap optutl::VariableMapCont::m_stringVecMap
protected

◆ m_variableDescriptionMap

SSMap optutl::VariableMapCont::m_variableDescriptionMap
protected

Definition at line 160 of file VariableMapCont.h.

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

◆ m_variableModifiedMap

SBMap optutl::VariableMapCont::m_variableModifiedMap
protected