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  {
35  public:
37 
38  void fill(ConfigurationDescriptions & descriptions) const override {
39  T::fillDescriptions(descriptions);
40  T::prevalidate(descriptions);
41  }
42 
43  const std::string& baseType() const override {
44  return T::baseType();
45  }
46 
47  const std::string& extendedBaseType() const override {
48  const T* type = nullptr;
50  }
51 
52  private:
53  ParameterSetDescriptionFiller(const ParameterSetDescriptionFiller&) = delete; // stop default
54  const ParameterSetDescriptionFiller& operator=(const ParameterSetDescriptionFiller&) = delete; // stop default
55 
56  };
57 
58  // We need a special version of this class for Services because there is
59  // no common base class for all Service classes. This means we cannot define
60  // the baseType and fillDescriptions functions for all Service classes without
61  // great difficulty.
62 
63  // First, some template metaprogramming to determining if the class T has
64  // a fillDescriptions function.
65 
66  namespace fillDetails {
67 
68  using no_tag = std::false_type; // type indicating FALSE
69  using yes_tag = std::true_type; // type indicating TRUE
70 
71  template <typename T, void (*)(ConfigurationDescriptions &)> struct fillDescriptions_function;
72  template <typename T> no_tag has_fillDescriptions_helper(...);
74 
75  template<typename T>
77  static constexpr bool value =
78  std::is_same<decltype(has_fillDescriptions_helper<T>(nullptr)),yes_tag>::value;
79  };
80 
81  template <typename T>
83  void operator()(ConfigurationDescriptions & descriptions) {
84  T::fillDescriptions(descriptions);
85  }
86  };
87 
88  template <typename T>
89  struct DoFillAsUnknown {
90  void operator()(ConfigurationDescriptions & descriptions) {
92  desc.setUnknown();
93  descriptions.addDefault(desc);
94  }
95  };
96 
97  template <typename T, void (*)(ConfigurationDescriptions &)> struct prevalidate_function;
98  template <typename T> no_tag has_prevalidate_helper(...);
100 
101  template<typename T>
103  static constexpr bool value =
104  std::is_same<decltype(has_prevalidate_helper<T>(nullptr)),yes_tag>::value;
105  };
106 
107  template <typename T>
108  struct DoPrevalidate {
109  void operator()(ConfigurationDescriptions & descriptions) {
110  T::prevalidate(descriptions);
111  }
112  };
113 
114  template <typename T>
115  struct DoNothing {
116  void operator()(ConfigurationDescriptions & descriptions) {
117  }
118  };
119 
120  }
121 
122  // Not needed at the moment
123  //void prevalidateService(ConfigurationDescriptions &);
124 
125  template< typename T>
127  {
128  public:
130 
131  // If T has a fillDescriptions function then just call that, otherwise
132  // put in an "unknown description" as a default.
133  void fill(ConfigurationDescriptions & descriptions) const override {
136  edm::fillDetails::DoFillAsUnknown<T>> fill_descriptions;
137  fill_descriptions(descriptions);
138  //we don't have a need for prevalidation of services at the moment, so this is a placeholder
139  // Probably the best package to declare this in would be FWCore/ServiceRegistry
140  //prevalidateService(descriptions);
141  }
142 
143  const std::string& baseType() const override {
144  return kBaseForService;
145  }
146 
147  const std::string& extendedBaseType() const override {
148  return kEmpty;
149  }
150 
151  private:
152  void prevalidate(ConfigurationDescriptions & descriptions);
155  };
156 
157  template<typename T>
159  {
160  public:
162 
163  // If T has a fillDescriptions function then just call that, otherwise
164  // put in an "unknown description" as a default.
165  void fill(ConfigurationDescriptions & descriptions) const override {
168  edm::fillDetails::DoFillAsUnknown<T>> fill_descriptions;
169  fill_descriptions(descriptions);
170 
173  edm::fillDetails::DoNothing<T>> prevalidate;
174  prevalidate(descriptions);
175  }
176 
177  const std::string& baseType() const override {
178  return kBaseForESSource;
179  }
180 
181  const std::string& extendedBaseType() const override {
182  return kEmpty;
183  }
184 
185  private:
186  DescriptionFillerForESSources(const DescriptionFillerForESSources&) = delete; // stop default
187  const DescriptionFillerForESSources& operator=(const DescriptionFillerForESSources&) = delete; // stop default
188  };
189 
190  template<typename T>
192  {
193  public:
195 
196  // If T has a fillDescriptions function then just call that, otherwise
197  // put in an "unknown description" as a default.
198  void fill(ConfigurationDescriptions & descriptions) const override {
201  edm::fillDetails::DoFillAsUnknown<T>> fill_descriptions;
202  fill_descriptions(descriptions);
203 
206  edm::fillDetails::DoNothing<T>> prevalidate;
207  prevalidate(descriptions);
208  }
209 
210  const std::string& baseType() const override {
211  return kBaseForESProducer;
212  }
213 
214  const std::string& extendedBaseType() const override {
215  return kEmpty;
216  }
217 
218  private:
219  DescriptionFillerForESProducers(const DescriptionFillerForESProducers&) = delete; // stop default
220  const DescriptionFillerForESProducers& operator=(const DescriptionFillerForESProducers&) = delete; // stop default
221  };
222 }
223 #endif
type
Definition: HCALResponse.h:21
const std::string & extendedBaseType() const override
yes_tag has_fillDescriptions_helper(fillDescriptions_function< T,&T::fillDescriptions > *dummy)
const std::string & extendedBaseType() const override
void fill(ConfigurationDescriptions &descriptions) const override
void fill(ConfigurationDescriptions &descriptions) const override
yes_tag has_prevalidate_helper(fillDescriptions_function< T,&T::prevalidate > *dummy)
const std::string & extendedBaseType() const override
const std::string & baseType() const override
#define constexpr
void addDefault(ParameterSetDescription const &psetDescription)
void fill(ConfigurationDescriptions &descriptions) 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 & baseType() const override
void operator()(ConfigurationDescriptions &descriptions)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual const std::string & extendedBaseType() const =0
const ParameterSetDescriptionFiller & operator=(const ParameterSetDescriptionFiller &)=delete
HLT enums.
void operator()(ConfigurationDescriptions &descriptions)
void operator()(ConfigurationDescriptions &descriptions)
const std::string & extendedBaseType() const override
long double T
const std::string & baseType() const override