CMS 3D CMS Logo

ParameterWildcardWithSpecifics.cc
Go to the documentation of this file.
2 
7 
8 #include <cassert>
9 #include <iomanip>
10 #include <ostream>
11 
12 namespace edm {
13 
15  std::string_view pattern,
17  bool isTracked,
19  std::map<std::string, ParameterSetDescription> exceptions)
20  : ParameterWildcardBase(k_PSet, isTracked, criteria), wildcardDesc_(desc), exceptions_(std::move(exceptions)) {
22  }
23 
25  return new ParameterWildcardWithSpecifics(*this);
26  }
27 
29  std::set<std::string>& validatedLabels,
30  bool optional) const {
31  std::vector<std::string> parameterNames = pset.getParameterNamesForType<ParameterSet>(isTracked());
32  validateMatchingNames(parameterNames, validatedLabels, optional);
33 
34  for (auto const& name : parameterNames) {
36  }
37  //inject exceptions if not already in the pset
38  for (auto const& v : exceptions_) {
39  if (std::find(parameterNames.begin(), parameterNames.end(), v.first) == parameterNames.end()) {
40  if (isTracked()) {
41  pset.addParameter<edm::ParameterSet>(v.first, edm::ParameterSet());
42  } else {
43  pset.addUntrackedParameter<edm::ParameterSet>(v.first, edm::ParameterSet());
44  }
45  validatedLabels.insert(v.first);
46  validateDescription(v.first, pset);
47  }
48  }
49  }
50 
52  ParameterSet* containedPSet = pset.getPSetForUpdate(parameterName);
53  auto itFound = exceptions_.find(parameterName);
54  if (itFound != exceptions_.end()) {
55  itFound->second.validate(*containedPSet);
56  } else {
57  wildcardDesc_.validate(*containedPSet);
58  }
59  }
60 
62 
64  bool /*optional*/,
65  DocFormatHelper& dfh) const {
66  int indentation = dfh.indentation();
67  if (dfh.parent() != DocFormatHelper::TOP) {
69  }
70 
72  os << "Section " << dfh.section() << "." << dfh.counter() << " description of PSet matching wildcard:";
73  os << "\n";
74  if (!dfh.brief())
75  os << "\n";
76 
77  std::stringstream ss;
78  ss << dfh.section() << "." << dfh.counter();
79  std::string newSection = ss.str();
80 
81  DocFormatHelper new_dfh(dfh);
82  new_dfh.setSection(newSection);
85 
86  wildcardDesc_.print(os, new_dfh);
87  //NOTE: need to extend to also include the specific cases.
88  }
89 
91  if (criteria() == RequireZeroOrMore)
92  return true;
93 
94  std::vector<std::string> parameterNames = pset.getParameterNamesForType<ParameterSet>(isTracked());
95 
96  if (criteria() == RequireAtLeastOne)
97  return !parameterNames.empty();
98  return parameterNames.size() == 1U;
99  }
100 
101 } // namespace edm
WildcardValidationCriteria
void printNestedContent_(std::ostream &os, bool optional, DocFormatHelper &dfh) const override
bool exists_(ParameterSet const &pset) const override
void print(std::ostream &os, DocFormatHelper &dfh) const
void throwIfInvalidPattern(char const *pattern) const
int exceptions(int argc, char *argv[])
Definition: exceptions.h:34
void insert(bool ok_to_replace, char const *, Entry const &)
void validateDescription(std::string const &parameterName, ParameterSet &pset) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
ParameterDescriptionNode * clone() const override
std::map< std::string, ParameterSetDescription > exceptions_
bool empty() const
Definition: ParameterSet.h:202
ParameterWildcardWithSpecifics(std::string_view, WildcardValidationCriteria criteria, bool isTracked, ParameterSetDescription const &desc, std::map< std::string, ParameterSetDescription > exceptions)
static int offsetSectionContent()
optional
Definition: Types.py:245
void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const override
void validateMatchingNames(std::vector< std::string > const &matchingNames, std::set< std::string > &validatedLabels, bool optional) const
std::string const & section() const
static void printSpaces(std::ostream &os, int n)
WildcardValidationCriteria criteria() const
void validate(ParameterSet &pset) const
HLT enums.
void setSection(std::string const &value)
def move(src, dest)
Definition: eostools.py:511
void setParent(DescriptionParent value)
DescriptionParent parent() const
void setIndentation(int value)