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 validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const override;
80 
81  bool hasNestedContent_() const override;
82 
83  void printNestedContent_(std::ostream& os, bool optional, DocFormatHelper& helper) const override;
84 
85  bool exists_(ParameterSet const& pset) const override;
86 
87  void validateDescription(std::string const& parameterName, ParameterSet& pset) const;
88 
90  };
91 
92  template <>
93  class ParameterWildcard<std::vector<ParameterSet> > : public ParameterWildcardBase {
94  public:
97 
100  bool isTracked,
102  ParameterWildcard(char const* pattern,
104  bool isTracked,
106 
107  ~ParameterWildcard() override;
108 
109  ParameterDescriptionNode* clone() const override;
110 
111  private:
112  void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const override;
113 
114  bool hasNestedContent_() const override;
115 
116  void printNestedContent_(std::ostream& os, bool optional, DocFormatHelper& dfh) const override;
117 
118  bool exists_(ParameterSet const& pset) const override;
119 
120  void validatePSetVector(std::string const& parameterName, ParameterSet& pset) const;
121 
123  };
124 } // namespace edm
125 #endif
WildcardValidationCriteria
Definition: helper.py:1
void throwIfInvalidPattern(char const *pattern) const
ParameterDescriptionNode * clone() const override
ParameterWildcard(char const *pattern, WildcardValidationCriteria criteria, bool isTracked)
optional
Definition: Types.py:239
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
void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const override