CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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()) {
42  } else {
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 
71  printSpaces(os, indentation);
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
bool empty() const
Definition: ParameterSet.h:201
tuple optional
Definition: Types.py:198
void printNestedContent_(std::ostream &os, bool optional, DocFormatHelper &dfh) const override
bool exists_(ParameterSet const &pset) const override
void validate(ParameterSet &pset) const
void insert(bool ok_to_replace, char const *, Entry 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
DescriptionParent parent() const
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:179
int indentation() const
std::map< std::string, ParameterSetDescription > exceptions_
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:135
ParameterWildcardWithSpecifics(std::string_view, WildcardValidationCriteria criteria, bool isTracked, ParameterSetDescription const &desc, std::map< std::string, ParameterSetDescription > exceptions)
def move
Definition: eostools.py:511
void print(std::ostream &os, DocFormatHelper &dfh) const
static int offsetSectionContent()
void validateDescription(std::string const &parameterName, ParameterSet &pset) const
void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const override
static void printSpaces(std::ostream &os, int n)
WildcardValidationCriteria criteria() const
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:192
void throwIfInvalidPattern(char const *pattern) const
void validateMatchingNames(std::vector< std::string > const &matchingNames, std::set< std::string > &validatedLabels, bool optional) const
void setSection(std::string const &value)
void setParent(DescriptionParent value)
void setIndentation(int value)
ParameterSet * getPSetForUpdate(std::string const &name, bool &isTracked)
std::string const & section() const