CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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>
27 #include <boost/mpl/if.hpp>
45 
46 namespace edm {
47  template< typename T>
49  {
50  public:
52 
53  virtual void fill(ConfigurationDescriptions & descriptions) const {
54  T::fillDescriptions(descriptions);
55  T::prevalidate(descriptions);
56  }
57 
58  virtual const std::string& baseType() const {
59  return T::baseType();
60  }
61 
62  virtual const std::string& extendedBaseType() const {
91 
92  return kEmpty;
93  }
94 
95  private:
98  };
99 
100  // We need a special version of this class for Services because there is
101  // no common base class for all Service classes. This means we cannot define
102  // the baseType and fillDescriptions functions for all Service classes without
103  // great difficulty.
104 
105  // First, some template metaprogramming to determining if the class T has
106  // a fillDescriptions function.
107 
108  namespace fillDetails {
109 
110  typedef char (& no_tag)[1]; // type indicating FALSE
111  typedef char (& yes_tag)[2]; // type indicating TRUE
112 
113  template <typename T, void (*)(ConfigurationDescriptions &)> struct fillDescriptions_function;
114  template <typename T> no_tag has_fillDescriptions_helper(...);
116 
117  template<typename T>
119  static bool const value =
120  sizeof(has_fillDescriptions_helper<T>(0)) == sizeof(yes_tag);
121  };
122 
123  template <typename T>
125  void operator()(ConfigurationDescriptions & descriptions) {
126  T::fillDescriptions(descriptions);
127  }
128  };
129 
130  template <typename T>
132  void operator()(ConfigurationDescriptions & descriptions) {
134  desc.setUnknown();
135  descriptions.addDefault(desc);
136  }
137  };
138 
139  template <typename T, void (*)(ConfigurationDescriptions &)> struct prevalidate_function;
140  template <typename T> no_tag has_prevalidate_helper(...);
142 
143  template<typename T>
145  static bool const value =
146  sizeof(has_prevalidate_helper<T>(0)) == sizeof(yes_tag);
147  };
148 
149  template <typename T>
150  struct DoPrevalidate {
151  void operator()(ConfigurationDescriptions & descriptions) {
152  T::prevalidate(descriptions);
153  }
154  };
155 
156  template <typename T>
157  struct DoNothing {
158  void operator()(ConfigurationDescriptions & descriptions) {
159  }
160  };
161 
162  }
163 
164  // Not needed at the moment
165  //void prevalidateService(ConfigurationDescriptions &);
166 
167  template< typename T>
169  {
170  public:
172 
173  // If T has a fillDescriptions function then just call that, otherwise
174  // put in an "unknown description" as a default.
175  virtual void fill(ConfigurationDescriptions & descriptions) const {
178  edm::fillDetails::DoFillAsUnknown<T> >::type fill_descriptions;
179  fill_descriptions(descriptions);
180  //we don't have a need for prevalidation of services at the moment, so this is a placeholder
181  // Probably the best package to declare this in would be FWCore/ServiceRegistry
182  //prevalidateService(descriptions);
183  }
184 
185  virtual const std::string& baseType() const {
186  return kBaseForService;
187  }
188 
189  virtual const std::string& extendedBaseType() const {
190  return kEmpty;
191  }
192 
193  private:
194  void prevalidate(ConfigurationDescriptions & descriptions);
197  };
198 
199  template<typename T>
201  {
202  public:
204 
205  // If T has a fillDescriptions function then just call that, otherwise
206  // put in an "unknown description" as a default.
207  virtual void fill(ConfigurationDescriptions & descriptions) const {
210  edm::fillDetails::DoFillAsUnknown<T> >::type fill_descriptions;
211  fill_descriptions(descriptions);
212 
216  prevalidate(descriptions);
217  }
218 
219  virtual const std::string& baseType() const {
220  return kBaseForESSource;
221  }
222 
223  virtual const std::string& extendedBaseType() const {
224  return kEmpty;
225  }
226 
227  private:
230  };
231 
232  template<typename T>
234  {
235  public:
237 
238  // If T has a fillDescriptions function then just call that, otherwise
239  // put in an "unknown description" as a default.
240  virtual void fill(ConfigurationDescriptions & descriptions) const {
243  edm::fillDetails::DoFillAsUnknown<T> >::type fill_descriptions;
244  fill_descriptions(descriptions);
245 
249  prevalidate(descriptions);
250  }
251 
252  virtual const std::string& baseType() const {
253  return kBaseForESProducer;
254  }
255 
256  virtual const std::string& extendedBaseType() const {
257  return kEmpty;
258  }
259 
260  private:
263  };
264 }
265 #endif
type
Definition: HCALResponse.h:21
virtual const std::string & baseType() const
void prevalidate(ConfigurationDescriptions &descriptions)
virtual void fill(ConfigurationDescriptions &descriptions) const
virtual const std::string & extendedBaseType() const
virtual const std::string & baseType() const
no_tag has_prevalidate_helper(...)
virtual const std::string & baseType() const
const ParameterSetDescriptionFiller & operator=(const ParameterSetDescriptionFiller &)
no_tag has_fillDescriptions_helper(...)
virtual const std::string & extendedBaseType() const
void addDefault(ParameterSetDescription const &psetDescription)
virtual const std::string & baseType() const
void operator()(ConfigurationDescriptions &descriptions)
const DescriptionFillerForESSources & operator=(const DescriptionFillerForESSources &)
virtual const std::string & extendedBaseType() const
const DescriptionFillerForESProducers & operator=(const DescriptionFillerForESProducers &)
virtual void fill(ConfigurationDescriptions &descriptions) const
virtual const std::string & extendedBaseType() const
void operator()(ConfigurationDescriptions &descriptions)
virtual void fill(ConfigurationDescriptions &descriptions) const
virtual void fill(ConfigurationDescriptions &descriptions) const
const DescriptionFillerForServices & operator=(const DescriptionFillerForServices &)
void operator()(ConfigurationDescriptions &descriptions)
void operator()(ConfigurationDescriptions &descriptions)