CMS 3D CMS Logo

ParameterSetDescriptionFiller.h
Go to the documentation of this file.
1 #ifndef FWCore_ParameterSet_ParameterSetDescriptionFiller_h
2 #define FWCore_ParameterSet_ParameterSetDescriptionFiller_h
3 // -*- C++ -*-
4 //
5 // Package: ParameterSet
6 // Class : ParameterSetDescriptionFiller
7 //
20 //
21 // Original Author: Chris Jones
22 // Created: Wed Aug 1 16:46:56 EDT 2007
23 //
24 
25 #include <type_traits>
26 #include <string>
30 
31 namespace edm {
32  template <typename T>
34  public:
36  ParameterSetDescriptionFiller(const ParameterSetDescriptionFiller&) = delete; // stop default
37  const ParameterSetDescriptionFiller& operator=(const ParameterSetDescriptionFiller&) = delete; // stop default
38 
39  void fill(ConfigurationDescriptions& descriptions) const override {
40  T::fillDescriptions(descriptions);
41  T::prevalidate(descriptions);
42  }
43 
44  const std::string& baseType() const override { return T::baseType(); }
45 
46  const std::string& extendedBaseType() const override {
47  const T* type = nullptr;
49  }
50  };
51 
52  // We need a special version of this class for Services because there is
53  // no common base class for all Service classes. This means we cannot define
54  // the baseType and fillDescriptions functions for all Service classes without
55  // great difficulty.
56 
57  // First, some template metaprogramming to determining if the class T has
58  // a fillDescriptions function.
59 
60  namespace fillDetails {
61 
62  using no_tag = std::false_type; // type indicating FALSE
63  using yes_tag = std::true_type; // type indicating TRUE
64 
65  template <typename T, void (*)(ConfigurationDescriptions&)>
67  template <typename T>
69  template <typename T>
71 
72  template <typename T>
74  static constexpr bool value = std::is_same<decltype(has_fillDescriptions_helper<T>(nullptr)), yes_tag>::value;
75  };
76 
77  template <typename T>
79  void operator()(ConfigurationDescriptions& descriptions) { T::fillDescriptions(descriptions); }
80  };
81 
82  template <typename T>
83  struct DoFillAsUnknown {
84  void operator()(ConfigurationDescriptions& descriptions) {
86  desc.setUnknown();
87  descriptions.addDefault(desc);
88  }
89  };
90 
91  template <typename T, void (*)(ConfigurationDescriptions&)>
93  template <typename T>
95  template <typename T>
97 
98  template <typename T>
100  static constexpr bool value = std::is_same<decltype(has_prevalidate_helper<T>(nullptr)), yes_tag>::value;
101  };
102 
103  template <typename T>
104  struct DoPrevalidate {
105  void operator()(ConfigurationDescriptions& descriptions) { T::prevalidate(descriptions); }
106  };
107 
108  template <typename T>
109  struct DoNothing {
110  void operator()(ConfigurationDescriptions& descriptions) {}
111  };
112 
113  } // namespace fillDetails
114 
115  // Not needed at the moment
116  //void prevalidateService(ConfigurationDescriptions &);
117 
118  template <typename T>
120  public:
122 
123  // If T has a fillDescriptions function then just call that, otherwise
124  // put in an "unknown description" as a default.
125  void fill(ConfigurationDescriptions& descriptions) const override {
129  fill_descriptions;
130  fill_descriptions(descriptions);
131  //we don't have a need for prevalidation of services at the moment, so this is a placeholder
132  // Probably the best package to declare this in would be FWCore/ServiceRegistry
133  //prevalidateService(descriptions);
134  }
135 
136  const std::string& baseType() const override { return kBaseForService; }
137 
138  const std::string& extendedBaseType() const override { return kEmpty; }
139 
140  private:
141  void prevalidate(ConfigurationDescriptions& descriptions);
144  };
145 
146  template <typename T>
148  public:
150  DescriptionFillerForESSources(const DescriptionFillerForESSources&) = delete; // stop default
151  const DescriptionFillerForESSources& operator=(const DescriptionFillerForESSources&) = delete; // stop default
152 
153  // If T has a fillDescriptions function then just call that, otherwise
154  // put in an "unknown description" as a default.
155  void fill(ConfigurationDescriptions& descriptions) const override {
159  fill_descriptions;
160  fill_descriptions(descriptions);
161 
165  prevalidate;
166  prevalidate(descriptions);
167  }
168 
169  const std::string& baseType() const override { return kBaseForESSource; }
170 
171  const std::string& extendedBaseType() const override { return kEmpty; }
172  };
173 
174  template <typename T>
176  public:
178  DescriptionFillerForESProducers(const DescriptionFillerForESProducers&) = delete; // stop default
179  const DescriptionFillerForESProducers& operator=(const DescriptionFillerForESProducers&) = delete; // stop default
180 
181  // If T has a fillDescriptions function then just call that, otherwise
182  // put in an "unknown description" as a default.
183  void fill(ConfigurationDescriptions& descriptions) const override {
187  fill_descriptions;
188  fill_descriptions(descriptions);
189 
193  prevalidate;
194  prevalidate(descriptions);
195  }
196 
197  const std::string& baseType() const override { return kBaseForESProducer; }
198 
199  const std::string& extendedBaseType() const override { return kEmpty; }
200  };
201 
202  template <typename T>
204  public:
206  DescriptionFillerForEDLoopers(const DescriptionFillerForEDLoopers&) = delete; // stop default
207  const DescriptionFillerForEDLoopers& operator=(const DescriptionFillerForEDLoopers&) = delete; // stop default
208 
209  // If T has a fillDescriptions function then just call that, otherwise
210  // put in an "unknown description" as a default.
211  void fill(ConfigurationDescriptions& descriptions) const override {
215  fill_descriptions;
216  fill_descriptions(descriptions);
217 
221  prevalidate;
222  prevalidate(descriptions);
223  }
224 
225  const std::string& baseType() const override { return kBaseForEDLooper; }
226 
227  const std::string& extendedBaseType() const override { return kEmpty; }
228  };
229 } // namespace edm
230 #endif
const std::string & extendedBaseType() const override
const std::string & extendedBaseType() const override
const std::string & baseType() const override
void prevalidate(ConfigurationDescriptions &descriptions)
void fill(ConfigurationDescriptions &descriptions) const override
no_tag has_prevalidate_helper(...)
const std::string & extendedBaseType() const override
no_tag has_fillDescriptions_helper(...)
const DescriptionFillerForEDLoopers & operator=(const DescriptionFillerForEDLoopers &)=delete
void addDefault(ParameterSetDescription const &psetDescription)
const DescriptionFillerForESProducers & operator=(const DescriptionFillerForESProducers &)=delete
const std::string & baseType() const override
void fill(ConfigurationDescriptions &descriptions) const override
void operator()(ConfigurationDescriptions &descriptions)
Definition: value.py:1
const std::string & baseType() const override
const std::string & extendedBaseType() const override
void fill(ConfigurationDescriptions &descriptions) const override
const DescriptionFillerForESSources & operator=(const DescriptionFillerForESSources &)=delete
void operator()(ConfigurationDescriptions &descriptions)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const ParameterSetDescriptionFiller & operator=(const ParameterSetDescriptionFiller &)=delete
HLT enums.
void fill(ConfigurationDescriptions &descriptions) const override
virtual const std::string & extendedBaseType() const =0
const std::string & baseType() const override
const DescriptionFillerForServices & operator=(const DescriptionFillerForServices &)
void operator()(ConfigurationDescriptions &descriptions)
void operator()(ConfigurationDescriptions &descriptions)
void fill(ConfigurationDescriptions &descriptions) const override
long double T
const std::string & extendedBaseType() const override
const std::string & baseType() const override