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, void (*)(ConfigurationDescriptions&)>
79  template <typename T>
81  template <typename T>
83 
84  template <typename T>
86  static constexpr bool value = std::is_same<decltype(has_prevalidate_helper<T>(nullptr)), yes_tag>::value;
87  };
88 
89  template <typename T>
92  T::fillDescriptions(descriptions);
93  } else {
95  desc.setUnknown();
96  descriptions.addDefault(desc);
97  }
98  }
99 
100  template <typename T>
103  T::prevalidate(descriptions);
104  }
105  }
106 
107  } // namespace fillDetails
108 
109  // Not needed at the moment
110  //void prevalidateService(ConfigurationDescriptions &);
111 
112  template <typename T>
114  public:
116 
117  // If T has a fillDescriptions function then just call that, otherwise
118  // put in an "unknown description" as a default.
119  void fill(ConfigurationDescriptions& descriptions) const override {
120  fillDetails::fillIfExists<T>(descriptions);
121  //we don't have a need for prevalidation of services at the moment, so this is a placeholder
122  // Probably the best package to declare this in would be FWCore/ServiceRegistry
123  //prevalidateService(descriptions);
124  }
125 
126  const std::string& baseType() const override { return kBaseForService; }
127 
128  const std::string& extendedBaseType() const override { return kEmpty; }
129 
130  private:
131  void prevalidate(ConfigurationDescriptions& descriptions);
134  };
135 
136  template <typename T>
138  public:
140  DescriptionFillerForESSources(const DescriptionFillerForESSources&) = delete; // stop default
141  const DescriptionFillerForESSources& operator=(const DescriptionFillerForESSources&) = delete; // stop default
142 
143  // If T has a fillDescriptions function then just call that, otherwise
144  // put in an "unknown description" as a default.
145  void fill(ConfigurationDescriptions& descriptions) const override {
146  fillDetails::fillIfExists<T>(descriptions);
147  fillDetails::prevalidateIfExists<T>(descriptions);
148  }
149 
150  const std::string& baseType() const override { return kBaseForESSource; }
151 
152  const std::string& extendedBaseType() const override { return kEmpty; }
153  };
154 
155  template <typename T>
157  public:
159  DescriptionFillerForESProducers(const DescriptionFillerForESProducers&) = delete; // stop default
160  const DescriptionFillerForESProducers& operator=(const DescriptionFillerForESProducers&) = delete; // stop default
161 
162  // If T has a fillDescriptions function then just call that, otherwise
163  // put in an "unknown description" as a default.
164  void fill(ConfigurationDescriptions& descriptions) const override {
165  fillDetails::fillIfExists<T>(descriptions);
166  fillDetails::prevalidateIfExists<T>(descriptions);
167  }
168 
169  const std::string& baseType() const override { return kBaseForESProducer; }
170 
171  const std::string& extendedBaseType() const override { return kEmpty; }
172  };
173 
174  template <typename T>
176  public:
178  DescriptionFillerForEDLoopers(const DescriptionFillerForEDLoopers&) = delete; // stop default
179  const DescriptionFillerForEDLoopers& operator=(const DescriptionFillerForEDLoopers&) = 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 {
184  fillDetails::fillIfExists<T>(descriptions);
185  fillDetails::prevalidateIfExists<T>(descriptions);
186  }
187 
188  const std::string& baseType() const override { return kBaseForEDLooper; }
189 
190  const std::string& extendedBaseType() const override { return kEmpty; }
191  };
192 } // namespace edm
193 #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
Definition: value.py:1
const std::string & baseType() const override
const std::string & extendedBaseType() const override
void fillIfExists(ConfigurationDescriptions &descriptions)
void fill(ConfigurationDescriptions &descriptions) const override
const DescriptionFillerForESSources & operator=(const DescriptionFillerForESSources &)=delete
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const ParameterSetDescriptionFiller & operator=(const ParameterSetDescriptionFiller &)=delete
HLT enums.
void fill(ConfigurationDescriptions &descriptions) const override
void prevalidateIfExists(ConfigurationDescriptions &descriptions)
virtual const std::string & extendedBaseType() const =0
const std::string & baseType() const override
const DescriptionFillerForServices & operator=(const DescriptionFillerForServices &)
void fill(ConfigurationDescriptions &descriptions) const override
long double T
const std::string & extendedBaseType() const override
const std::string & baseType() const override