CMS 3D CMS Logo

ParameterWildcard.h
Go to the documentation of this file.
1 #ifndef FWCore_ParameterSet_ParameterWildcard_h
2 #define FWCore_ParameterSet_ParameterWildcard_h
3 
9 
10 #include <string>
11 #include <set>
12 #include <iosfwd>
13 #include <vector>
14 
15 namespace edm {
16 
17  class ParameterSet;
18  class VParameterSetEntry;
20  class DocFormatHelper;
21 
22  template <class T>
24  public:
28  }
29 
33  }
34 
35  ~ParameterWildcard() override {}
36 
37  ParameterDescriptionNode* clone() const override { return new ParameterWildcard(*this); }
38 
39  private:
40  void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const override {
41  std::vector<std::string> parameterNames = pset.getParameterNamesForType<T>(isTracked());
42  validateMatchingNames(parameterNames, validatedLabels, optional);
43  }
44 
45  bool exists_(ParameterSet const& pset) const override {
46  if (criteria() == RequireZeroOrMore)
47  return true;
48 
49  std::vector<std::string> parameterNames = pset.getParameterNamesForType<T>(isTracked());
50 
51  if (criteria() == RequireAtLeastOne)
52  return !parameterNames.empty();
53  return parameterNames.size() == 1U;
54  }
55 
56  // In the future may need to add a data member of type T to hold a default value
57  };
58 
59  template <>
61  public:
64 
67  bool isTracked,
69  ParameterWildcard(char const* pattern,
71  bool isTracked,
73 
74  ~ParameterWildcard() override;
75 
76  ParameterDescriptionNode* clone() const override;
77 
78  private:
79  void writeTemplate(std::ostream& os, int indentation, CfiOptions&) const override;
80  void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const override;
81 
82  bool hasNestedContent_() const override;
83 
84  void printNestedContent_(std::ostream& os, bool optional, DocFormatHelper& helper) const override;
85 
86  bool exists_(ParameterSet const& pset) const override;
87 
88  void validateDescription(std::string const& parameterName, ParameterSet& pset) const;
89 
91  };
92 
93  template <>
94  class ParameterWildcard<std::vector<ParameterSet> > : public ParameterWildcardBase {
95  public:
98 
101  bool isTracked,
103  ParameterWildcard(char const* pattern,
105  bool isTracked,
107 
108  ~ParameterWildcard() override;
109 
110  ParameterDescriptionNode* clone() const override;
111 
112  private:
113  void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const override;
114 
115  bool hasNestedContent_() const override;
116 
117  void printNestedContent_(std::ostream& os, bool optional, DocFormatHelper& dfh) const override;
118 
119  bool exists_(ParameterSet const& pset) const override;
120 
121  void validatePSetVector(std::string const& parameterName, ParameterSet& pset) const;
122 
124  };
125 } // namespace edm
126 #endif
WildcardValidationCriteria
Definition: helper.py:1
void throwIfInvalidPattern(char const *pattern) const
ParameterDescriptionNode * clone() const override
virtual void writeTemplate(std::ostream &os, int indentation, CfiOptions &) const
ParameterWildcard(char const *pattern, WildcardValidationCriteria criteria, bool isTracked)
optional
Definition: Types.py:245
value_ptr< ParameterSetDescription > psetDesc_
void validateMatchingNames(std::vector< std::string > const &matchingNames, std::set< std::string > &validatedLabels, bool optional) const
WildcardValidationCriteria criteria() const
value_ptr< ParameterSetDescription > psetDesc_
HLT enums.
ParameterWildcard(std::string const &pattern, WildcardValidationCriteria criteria, bool isTracked)
bool exists_(ParameterSet const &pset) const override
virtual void printNestedContent_(std::ostream &, bool, DocFormatHelper &) const
long double T
cfi::CfiOptions CfiOptions
void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const override