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 
25  public:
26 
28  ParameterWildcardBase(ParameterTypeToEnum::toEnum<T>(), isTracked, criteria) {
29  throwIfInvalidPattern(pattern);
30  }
31 
33  ParameterWildcardBase(ParameterTypeToEnum::toEnum<T>(), isTracked, criteria) {
34  throwIfInvalidPattern(pattern);
35  }
36 
37  ~ParameterWildcard() override { }
38 
39  ParameterDescriptionNode* clone() const override {
40  return new ParameterWildcard(*this);
41  }
42 
43  private:
44 
46  std::set<std::string> & validatedLabels,
47  bool optional) const override {
48 
49  std::vector<std::string> parameterNames = pset.getParameterNamesForType<T>(isTracked());
50  validateMatchingNames(parameterNames, validatedLabels, optional);
51 
52  }
53 
54  bool exists_(ParameterSet const& pset) const override {
55 
56  if (criteria() == RequireZeroOrMore) return true;
57 
58  std::vector<std::string> parameterNames = pset.getParameterNamesForType<T>(isTracked());
59 
60  if (criteria() == RequireAtLeastOne) return !parameterNames.empty();
61  return parameterNames.size() == 1U;
62  }
63 
64  // In the future may need to add a data member of type T to hold a default value
65  };
66 
67  template<>
69 
70  public:
71 
73  ParameterWildcard(char const* pattern, WildcardValidationCriteria criteria, bool isTracked);
74 
75  ParameterWildcard(std::string const& pattern, WildcardValidationCriteria criteria, bool isTracked,
76  ParameterSetDescription const& desc);
77  ParameterWildcard(char const* pattern, WildcardValidationCriteria criteria, bool isTracked,
78  ParameterSetDescription const& desc);
79 
80  ~ParameterWildcard() override;
81 
82  ParameterDescriptionNode* clone() const override;
83 
84  private:
85 
87  std::set<std::string> & validatedLabels,
88  bool optional) const override;
89 
90  bool hasNestedContent_() const override;
91 
92  void printNestedContent_(std::ostream & os,
93  bool optional,
94  DocFormatHelper & helper) const override;
95 
96  bool exists_(ParameterSet const& pset) const override;
97 
98  void validateDescription(std::string const& parameterName, ParameterSet & pset) const;
99 
101  };
102 
103  template<>
104  class ParameterWildcard<std::vector<ParameterSet> > : public ParameterWildcardBase {
105 
106  public:
107 
109  ParameterWildcard(char const* pattern, WildcardValidationCriteria criteria, bool isTracked);
110 
111  ParameterWildcard(std::string const& pattern, WildcardValidationCriteria criteria, bool isTracked,
112  ParameterSetDescription const& desc);
113  ParameterWildcard(char const* pattern, WildcardValidationCriteria criteria, bool isTracked,
114  ParameterSetDescription const& desc);
115 
116  ~ParameterWildcard() override;
117 
118  ParameterDescriptionNode* clone() const override;
119 
120  private:
121 
122  void validate_(ParameterSet & pset,
123  std::set<std::string> & validatedLabels,
124  bool optional) const override;
125 
126  bool hasNestedContent_() const override;
127 
128  void printNestedContent_(std::ostream & os,
129  bool optional,
130  DocFormatHelper & dfh) const override;
131 
132  bool exists_(ParameterSet const& pset) const override;
133 
134  void validatePSetVector(std::string const& parameterName, ParameterSet & pset) const;
135 
137  };
138 }
139 #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:194
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