CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ParameterWildcard.h
Go to the documentation of this file.
1 #ifndef FWCore_ParameterSet_ParameterWildcard_h
2 #define FWCore_ParameterSet_ParameterWildcard_h
3 
8 
9 #include <string>
10 #include <set>
11 #include <iosfwd>
12 #include <vector>
13 
14 namespace edm {
15 
16  class ParameterSet;
17  class VParameterSetEntry;
19  class DocFormatHelper;
20 
21  template<class T>
23 
24  public:
25 
27  ParameterWildcardBase(ParameterTypeToEnum::toEnum<T>(), isTracked, criteria) {
28  throwIfInvalidPattern(pattern);
29  }
30 
32  ParameterWildcardBase(ParameterTypeToEnum::toEnum<T>(), isTracked, criteria) {
33  throwIfInvalidPattern(pattern);
34  }
35 
36  virtual ~ParameterWildcard() { }
37 
38  virtual ParameterDescriptionNode* clone() const {
39  return new ParameterWildcard(*this);
40  }
41 
42  private:
43 
44  virtual void validate_(ParameterSet & pset,
45  std::set<std::string> & validatedLabels,
46  bool optional) const {
47 
48  std::vector<std::string> parameterNames = pset.getParameterNamesForType<T>(isTracked());
49  validateMatchingNames(parameterNames, validatedLabels, optional);
50 
51  }
52 
53  virtual bool exists_(ParameterSet const& pset) const {
54 
55  if (criteria() == RequireZeroOrMore) return true;
56 
57  std::vector<std::string> parameterNames = pset.getParameterNamesForType<T>(isTracked());
58 
59  if (criteria() == RequireAtLeastOne) return parameterNames.size() >= 1U;
60  return parameterNames.size() == 1U;
61  }
62 
63  // In the future may need to add a data member of type T to hold a default value
64  };
65 
66  template<>
68 
69  public:
70 
72  ParameterWildcard(char const* pattern, WildcardValidationCriteria criteria, bool isTracked);
73 
74  ParameterWildcard(std::string const& pattern, WildcardValidationCriteria criteria, bool isTracked,
75  ParameterSetDescription const& desc);
76  ParameterWildcard(char const* pattern, WildcardValidationCriteria criteria, bool isTracked,
77  ParameterSetDescription const& desc);
78 
79  virtual ~ParameterWildcard();
80 
81  virtual ParameterDescriptionNode* clone() const;
82 
83  private:
84 
85  virtual void validate_(ParameterSet & pset,
86  std::set<std::string> & validatedLabels,
87  bool optional) const;
88 
89  virtual bool hasNestedContent_();
90 
91  virtual void printNestedContent_(std::ostream & os,
92  bool optional,
93  DocFormatHelper & helper);
94 
95  virtual bool exists_(ParameterSet const& pset) const;
96 
97  void validateDescription(std::string const& parameterName, ParameterSet & pset) const;
98 
100  };
101 
102  template<>
103  class ParameterWildcard<std::vector<ParameterSet> > : public ParameterWildcardBase {
104 
105  public:
106 
108  ParameterWildcard(char const* pattern, WildcardValidationCriteria criteria, bool isTracked);
109 
110  ParameterWildcard(std::string const& pattern, WildcardValidationCriteria criteria, bool isTracked,
111  ParameterSetDescription const& desc);
112  ParameterWildcard(char const* pattern, WildcardValidationCriteria criteria, bool isTracked,
113  ParameterSetDescription const& desc);
114 
115  virtual ~ParameterWildcard();
116 
117  virtual ParameterDescriptionNode* clone() const;
118 
119  private:
120 
121  virtual void validate_(ParameterSet & pset,
122  std::set<std::string> & validatedLabels,
123  bool optional) const;
124 
125  virtual bool hasNestedContent_();
126 
127  virtual void printNestedContent_(std::ostream & os,
128  bool optional,
129  DocFormatHelper & dfh);
130 
131  virtual bool exists_(ParameterSet const& pset) const;
132 
133  void validatePSetVector(std::string const& parameterName, ParameterSet & pset) const;
134 
136  };
137 }
138 #endif
WildcardValidationCriteria
virtual bool exists_(ParameterSet const &pset) const
virtual void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const
virtual void printNestedContent_(std::ostream &, bool, DocFormatHelper &)
virtual ParameterDescriptionNode * clone() const
ParameterWildcard(char const *pattern, WildcardValidationCriteria criteria, bool isTracked)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:195
value_ptr< ParameterSetDescription > psetDesc_
WildcardValidationCriteria criteria() const
void throwIfInvalidPattern(char const *pattern) const
value_ptr< ParameterSetDescription > psetDesc_
ParameterWildcard(std::string const &pattern, WildcardValidationCriteria criteria, bool isTracked)
void validateMatchingNames(std::vector< std::string > const &matchingNames, std::set< std::string > &validatedLabels, bool optional) const
long double T