10 using namespace optutl;
12 const int VariableMapCont::kDefaultInteger = 0;
13 const double VariableMapCont::kDefaultDouble = 0.;
14 const std::string VariableMapCont::kDefaultString =
"";
15 const bool VariableMapCont::kDefaultBool =
false;
20 VariableMapCont::VariableMapCont() {}
25 if (m_integerMap.end() != m_integerMap.find(key))
27 if (m_doubleMap.end() != m_doubleMap.find(key))
29 if (m_stringMap.end() != m_stringMap.find(key))
31 if (m_boolMap.end() != m_boolMap.find(key))
33 if (m_integerVecMap.end() != m_integerVecMap.find(key))
34 return kIntegerVector;
35 if (m_doubleVecMap.end() != m_doubleVecMap.find(key))
37 if (m_stringVecMap.end() != m_stringVecMap.find(key))
43 void VariableMapCont::lowercaseString(
string &
arg) {
45 std::for_each(arg.begin(), arg.end(), VariableMapCont::toLower);
51 char VariableMapCont::toLower(
char &ch) {
59 if (m_variableModifiedMap.end() != m_variableModifiedMap.find(key)) {
60 cerr <<
"VariableMapCont::addVariable() Error: Key '" << key <<
"' has already been defined. Aborting." << endl;
63 m_variableModifiedMap[
key] =
false;
67 void VariableMapCont::addOption(
string key, OptionType
type,
const string &
description) {
68 _checkKey(key, description);
69 if (kInteger == type) {
70 m_integerMap[
key] = kDefaultInteger;
73 if (kDouble == type) {
74 m_doubleMap[
key] = kDefaultDouble;
77 if (kString == type) {
78 m_stringMap[
key] = kDefaultString;
82 m_boolMap[
key] = kDefaultBool;
85 if (kIntegerVector == type) {
86 m_integerVecMap[
key] = kEmptyIVec;
89 if (kDoubleVector == type) {
90 m_doubleVecMap[
key] = kEmptyDVec;
93 if (kStringVector == type) {
94 m_stringVecMap[
key] = kEmptySVec;
99 void VariableMapCont::addOption(
string key, OptionType type,
const string &description,
int defaultValue) {
100 _checkKey(key, description);
101 if (kInteger != type) {
102 cerr <<
"VariableMapCont::addOption() Error: Key '" << key <<
"' is not defined as an integer but has an integer "
103 <<
"default value. Aborting." << endl;
106 m_integerMap[
key] = defaultValue;
109 void VariableMapCont::addOption(
string key, OptionType type,
const string &description,
double defaultValue) {
110 _checkKey(key, description);
111 if (kDouble != type) {
112 cerr <<
"VariableMapCont::addOption() Error: Key '" << key <<
"' is not defined as an double but has an double "
113 <<
"default value. Aborting." << endl;
116 m_doubleMap[
key] = defaultValue;
119 void VariableMapCont::addOption(
string key, OptionType type,
const string &description,
const string &defaultValue) {
120 _checkKey(key, description);
121 if (kString != type) {
122 cerr <<
"VariableMapCont::addOption() Error: Key '" << key <<
"' is not defined as an string but has an string "
123 <<
"default value. Aborting." << endl;
126 m_stringMap[
key] = defaultValue;
129 void VariableMapCont::addOption(
string key, OptionType type,
const string &description,
const char *defaultValue) {
130 addOption(key, type, description, (
string)defaultValue);
133 void VariableMapCont::addOption(
string key, OptionType type,
const string &description,
bool defaultValue) {
134 _checkKey(key, description);
136 cerr <<
"VariableMapCont::addOption() Error: Key '" << key <<
"' is not defined as an bool but has an bool "
137 <<
"default value. Aborting." << endl;
140 m_boolMap[
key] = defaultValue;
144 lowercaseString(key);
146 if (m_integerMap.end() == iter) {
147 cerr <<
"VariableMapCont::integerValue() Error: key '" << key <<
"' not found. Aborting." << endl;
154 lowercaseString(key);
156 if (m_doubleMap.end() == iter) {
157 cerr <<
"VariableMapCont::doubleValue() Error: key '" << key <<
"' not found. Aborting." << endl;
164 lowercaseString(key);
166 if (m_stringMap.end() == iter) {
167 cerr <<
"VariableMapCont::stringValue() Error: key '" << key <<
"' not found. Aborting." << endl;
174 lowercaseString(key);
176 if (m_boolMap.end() == iter) {
177 cerr <<
"VariableMapCont::boolValue() Error: key '" << key <<
"' not found. Aborting." << endl;
184 lowercaseString(key);
186 if (m_integerVecMap.end() == iter) {
187 cerr <<
"VariableMapCont::integerVector() Error: key '" << key <<
"' not found. Aborting." << endl;
194 lowercaseString(key);
196 if (m_doubleVecMap.end() == iter) {
197 cerr <<
"VariableMapCont::doubleVector() Error: key '" << key <<
"' not found. Aborting." << endl;
204 lowercaseString(key);
206 if (m_stringVecMap.end() == iter) {
207 cerr <<
"VariableMapCont::stringVector() Error: key '" << key <<
"' not found. Aborting." << endl;
213 bool VariableMapCont::_valueHasBeenModified(
const string &key) {
215 if (m_variableModifiedMap.end() == iter) {
217 cerr <<
"VariableMapCont::valueHasBeenModfied () Error: '" << key <<
"' is not a valid key." << endl;
SSMap::iterator SSMapIter
SBMap::iterator SBMapIter
std::ostream & operator<<(std::ostream &out, const std::tuple< Types...> &value)
SIMap::iterator SIMapIter
SBMap::const_iterator SBMapConstIter
SIVecMap::iterator SIVecMapIter
std::vector< double > DVec
std::vector< std::string > SVec
tuple key
prepare the HTCondor submission files and eventually submit them
SSVecMap::iterator SSVecMapIter
SDVecMap::iterator SDVecMapIter
SDMap::iterator SDMapIter