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:
26  : ParameterWildcardBase(ParameterTypeToEnum::toEnum<T>(), isTracked, criteria) {
27  throwIfInvalidPattern(pattern);
28  }
29 
31  : ParameterWildcardBase(ParameterTypeToEnum::toEnum<T>(), isTracked, criteria) {
32  throwIfInvalidPattern(pattern);
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:
63  ParameterWildcard(char const* pattern, WildcardValidationCriteria criteria, bool isTracked);
64 
65  ParameterWildcard(std::string const& pattern,
67  bool isTracked,
68  ParameterSetDescription const& desc);
69  ParameterWildcard(char const* pattern,
71  bool isTracked,
72  ParameterSetDescription const& desc);
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:
96  ParameterWildcard(char const* pattern, WildcardValidationCriteria criteria, bool isTracked);
97 
98  ParameterWildcard(std::string const& pattern,
100  bool isTracked,
101  ParameterSetDescription const& desc);
102  ParameterWildcard(char const* pattern,
104  bool isTracked,
105  ParameterSetDescription const& desc);
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
virtual void printNestedContent_(std::ostream &, bool, DocFormatHelper &) const
ParameterWildcard(char const *pattern, WildcardValidationCriteria criteria, bool isTracked)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:169
bool exists_(ParameterSet const &pset) const override
value_ptr< ParameterSetDescription > psetDesc_
WildcardValidationCriteria criteria() const
ParameterDescriptionNode * clone() const override
void throwIfInvalidPattern(char const *pattern) const
value_ptr< ParameterSetDescription > psetDesc_
HLT enums.
ParameterWildcard(std::string const &pattern, WildcardValidationCriteria criteria, bool isTracked)
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
long double T