CMS 3D CMS Logo

ParameterWildcardBase.cc
Go to the documentation of this file.
1 
3 
6 
7 #include <iomanip>
8 #include <ostream>
9 #include <sstream>
10 
11 namespace edm {
12 
14 
16  bool isTracked,
18  : type_(iType), isTracked_(isTracked), criteria_(criteria) {}
19 
21  std::string sPattern(pattern);
22  throwIfInvalidPattern(sPattern);
23  }
24 
26  if (pattern != std::string("*")) {
28  << "Currently, the only supported wildcard in ParameterSetDescriptions\n"
29  << "is the single character \"*\". The configuration contains a wildcard\n"
30  << "with pattern \"" << pattern << "\" and type \"" << parameterTypeEnumToString(type()) << "\"\n"
31  << "At some future date, globbing or regular expression support may be added\n"
32  << "if there are any requests for it from users.\n";
33  }
34  }
35 
36  void ParameterWildcardBase::validateMatchingNames(std::vector<std::string> const& matchingNames,
37  std::set<std::string>& validatedLabels,
38  bool optional) const {
39  validatedLabels.insert(matchingNames.begin(), matchingNames.end());
41  return;
42  if (criteria_ == RequireAtLeastOne && matchingNames.empty() && !optional) {
44  << "Parameter wildcard of type \"" << parameterTypeEnumToString(type()) << "\" requires "
45  << "at least one match\n"
46  << "and there are no parameters in the configuration matching\n"
47  << "that type.\n";
48  } else if (criteria_ == RequireExactlyOne) {
49  if ((matchingNames.empty() && !optional) || matchingNames.size() > 1U) {
51  << "Parameter wildcard of type \"" << parameterTypeEnumToString(type()) << "\" requires\n"
52  << "exactly one match and there are " << matchingNames.size() << " matching parameters\n"
53  << "in the configuration.\n";
54  }
55  }
56  }
57 
58  void ParameterWildcardBase::checkAndGetLabelsAndTypes_(std::set<std::string>& /*usedLabels*/,
59  std::set<ParameterTypes>& /*parameterTypes*/,
60  std::set<ParameterTypes>& wildcardTypes) const {
61  wildcardTypes.insert(type());
62  }
63 
64  void ParameterWildcardBase::print_(std::ostream& os, bool optional, bool /*writeToCfi*/, DocFormatHelper& dfh) const {
65  if (dfh.pass() == 0) {
66  dfh.setAtLeast1(11U);
67  if (isTracked()) {
69  } else {
71  }
72  dfh.setAtLeast3(8U);
73  } else {
74  if (dfh.brief()) {
75  dfh.indent(os);
76  std::ios::fmtflags oldFlags = os.flags();
77  os << std::left << std::setw(dfh.column1()) << "wildcard: *"
78  << " ";
79 
80  if (isTracked()) {
81  os << std::setw(dfh.column2()) << parameterTypeEnumToString(type());
82  } else {
83  std::stringstream ss;
84  ss << "untracked " << parameterTypeEnumToString(type());
85  os << ss.str();
86  }
87 
88  os << " ";
89  os << std::setw(dfh.column3());
90  if (optional)
91  os << "optional";
92  else
93  os << "";
94 
95  if (criteria() == RequireZeroOrMore) {
96  os << " (require zero or more)";
97  } else if (criteria() == RequireAtLeastOne) {
98  os << " (require at least one)";
99  } else if (criteria() == RequireExactlyOne) {
100  os << " (require exactly one)";
101  }
102  os << "\n";
103  if (hasNestedContent()) {
104  dfh.indent(os);
105  os << " (see Section " << dfh.section() << "." << dfh.counter() << ")\n";
106  }
107  os.flags(oldFlags);
108  } else {
109  // not brief
110 
111  dfh.indent(os);
112  os << "labels must match this wildcard pattern: *\n";
113 
114  dfh.indent2(os);
115  os << "type: ";
116  if (isTracked()) {
118  } else {
119  os << "untracked " << parameterTypeEnumToString(type());
120  }
121 
122  if (optional)
123  os << " optional";
124  os << "\n";
125 
126  dfh.indent2(os);
127  os << "criteria: ";
128  if (criteria() == RequireZeroOrMore)
129  os << "require zero or more";
130  else if (criteria() == RequireAtLeastOne)
131  os << "require at least one";
132  else if (criteria() == RequireExactlyOne)
133  os << "require exactly one";
134  os << "\n";
135 
136  if (hasNestedContent()) {
137  dfh.indent2(os);
138  os << "(see Section " << dfh.section() << "." << dfh.counter() << ")\n";
139  }
140 
141  if (!comment().empty()) {
143  }
144  os << "\n";
145  }
146  }
147  }
148 
150  std::ostream&, bool /*optional*/, bool& /*startWithComma*/, int /*indentation*/, bool& /*wroteSomething*/) const {
151  // Until we implement default labels and values there is nothing
152  // to do here.
153  }
154 
156 
158 } // namespace edm
edm::ParameterWildcardBase::throwIfInvalidPattern
void throwIfInvalidPattern(char const *pattern) const
Definition: ParameterWildcardBase.cc:20
edm::ParameterWildcardBase::partiallyExists_
bool partiallyExists_(ParameterSet const &pset) const override
Definition: ParameterWildcardBase.cc:155
edm::ParameterDescriptionNode::exists
bool exists(ParameterSet const &pset) const
Definition: ParameterDescriptionNode.h:134
edm::ParameterTypes
ParameterTypes
Definition: ParameterDescriptionNode.h:33
edm::ParameterWildcardBase::howManyXORSubNodesExist_
int howManyXORSubNodesExist_(ParameterSet const &pset) const override
Definition: ParameterWildcardBase.cc:157
edm::ParameterWildcardBase::print_
void print_(std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh) const override
Definition: ParameterWildcardBase.cc:64
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::DocFormatHelper::setAtLeast2
void setAtLeast2(size_t width)
Definition: DocFormatHelper.h:57
Types.optional
optional
Definition: Types.py:199
edm::DocFormatHelper::setAtLeast3
void setAtLeast3(size_t width)
Definition: DocFormatHelper.h:61
edm::DocFormatHelper::column2
size_t column2() const
Definition: DocFormatHelper.h:50
edm::parameterTypeEnumToString
std::string parameterTypeEnumToString(ParameterTypes iType)
Definition: ParameterDescriptionNode.cc:64
EDMException.h
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::DocFormatHelper
Definition: DocFormatHelper.h:15
edm::RequireAtLeastOne
Definition: ParameterWildcardBase.h:17
edm::WildcardValidationCriteria
WildcardValidationCriteria
Definition: ParameterWildcardBase.h:17
edm::ParameterWildcardBase::isTracked
bool isTracked() const
Definition: ParameterWildcardBase.h:24
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::RequireExactlyOne
Definition: ParameterWildcardBase.h:17
edm::DocFormatHelper::startColumn2
int startColumn2() const
Definition: DocFormatHelper.h:37
edm::ParameterSet
Definition: ParameterSet.h:47
edm::DocFormatHelper::brief
bool brief() const
Definition: DocFormatHelper.h:34
edm::DocFormatHelper::wrapAndPrintText
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
Definition: DocFormatHelper.cc:97
edm::DocFormatHelper::setAtLeast1
void setAtLeast1(size_t width)
Definition: DocFormatHelper.h:53
edm::ParameterDescriptionNode::hasNestedContent
bool hasNestedContent() const
Definition: ParameterDescriptionNode.h:123
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
edm::DocFormatHelper::indent
void indent(std::ostream &os) const
Definition: DocFormatHelper.cc:133
edm::DocFormatHelper::commentWidth
size_t commentWidth() const
Definition: DocFormatHelper.cc:123
edm::ParameterWildcardBase::validateMatchingNames
void validateMatchingNames(std::vector< std::string > const &matchingNames, std::set< std::string > &validatedLabels, bool optional) const
Definition: ParameterWildcardBase.cc:36
edm::ParameterWildcardBase::checkAndGetLabelsAndTypes_
void checkAndGetLabelsAndTypes_(std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const override
Definition: ParameterWildcardBase.cc:58
edm::DocFormatHelper::indent2
void indent2(std::ostream &os) const
Definition: DocFormatHelper.cc:139
edm::DocFormatHelper::counter
int counter() const
Definition: DocFormatHelper.h:66
DocFormatHelper.h
edm::DocFormatHelper::pass
int pass() const
Definition: DocFormatHelper.h:46
ParameterWildcardBase.h
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
Exception
Definition: hltDiff.cc:246
edm::ParameterWildcardBase::ParameterWildcardBase
ParameterWildcardBase(ParameterTypes iType, bool isTracked, WildcardValidationCriteria criteria)
Definition: ParameterWildcardBase.cc:15
edm::DocFormatHelper::column1
size_t column1() const
Definition: DocFormatHelper.h:49
edm::ParameterDescriptionNode::comment
std::string const & comment() const
Definition: ParameterDescriptionNode.h:92
edm::ParameterWildcardBase::criteria
WildcardValidationCriteria criteria() const
Definition: ParameterWildcardBase.h:25
edm::DocFormatHelper::section
std::string const & section() const
Definition: DocFormatHelper.h:43
edm::ParameterWildcardBase::criteria_
WildcardValidationCriteria criteria_
Definition: ParameterWildcardBase.h:53
edm::DocFormatHelper::column3
size_t column3() const
Definition: DocFormatHelper.h:51
edm::ParameterWildcardBase::~ParameterWildcardBase
~ParameterWildcardBase() override
Definition: ParameterWildcardBase.cc:13
edm::RequireZeroOrMore
Definition: ParameterWildcardBase.h:17
edm::errors::Configuration
Definition: EDMException.h:36
edm::ParameterWildcardBase::type
ParameterTypes type() const
Definition: ParameterWildcardBase.h:23
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
edm::ParameterWildcardBase::writeCfi_
void writeCfi_(std::ostream &os, bool optional, bool &startWithComma, int indentation, bool &wroteSomething) const override
Definition: ParameterWildcardBase.cc:149