test
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>
46 
47 namespace edm {
48  template< typename T>
50  {
51  public:
53 
54  virtual void fill(ConfigurationDescriptions & descriptions) const {
55  T::fillDescriptions(descriptions);
56  T::prevalidate(descriptions);
57  }
58 
59  virtual const std::string& baseType() const {
60  return T::baseType();
61  }
62 
63  virtual const std::string& extendedBaseType() const {
94 
95  return kEmpty;
96  }
97 
98  private:
101  };
102 
103  // We need a special version of this class for Services because there is
104  // no common base class for all Service classes. This means we cannot define
105  // the baseType and fillDescriptions functions for all Service classes without
106  // great difficulty.
107 
108  // First, some template metaprogramming to determining if the class T has
109  // a fillDescriptions function.
110 
111  namespace fillDetails {
112 
113  typedef char (& no_tag)[1]; // type indicating FALSE
114  typedef char (& yes_tag)[2]; // type indicating TRUE
115 
116  template <typename T, void (*)(ConfigurationDescriptions &)> struct fillDescriptions_function;
117  template <typename T> no_tag has_fillDescriptions_helper(...);
119 
120  template<typename T>
122  static bool const value =
123  sizeof(has_fillDescriptions_helper<T>(0)) == sizeof(yes_tag);
124  };
125 
126  template <typename T>
128  void operator()(ConfigurationDescriptions & descriptions) {
129  T::fillDescriptions(descriptions);
130  }
131  };
132 
133  template <typename T>
135  void operator()(ConfigurationDescriptions & descriptions) {
137  desc.setUnknown();
138  descriptions.addDefault(desc);
139  }
140  };
141 
142  template <typename T, void (*)(ConfigurationDescriptions &)> struct prevalidate_function;
143  template <typename T> no_tag has_prevalidate_helper(...);
145 
146  template<typename T>
148  static bool const value =
149  sizeof(has_prevalidate_helper<T>(0)) == sizeof(yes_tag);
150  };
151 
152  template <typename T>
153  struct DoPrevalidate {
154  void operator()(ConfigurationDescriptions & descriptions) {
155  T::prevalidate(descriptions);
156  }
157  };
158 
159  template <typename T>
160  struct DoNothing {
161  void operator()(ConfigurationDescriptions & descriptions) {
162  }
163  };
164 
165  }
166 
167  // Not needed at the moment
168  //void prevalidateService(ConfigurationDescriptions &);
169 
170  template< typename T>
172  {
173  public:
175 
176  // If T has a fillDescriptions function then just call that, otherwise
177  // put in an "unknown description" as a default.
178  virtual void fill(ConfigurationDescriptions & descriptions) const {
181  edm::fillDetails::DoFillAsUnknown<T> >::type fill_descriptions;
182  fill_descriptions(descriptions);
183  //we don't have a need for prevalidation of services at the moment, so this is a placeholder
184  // Probably the best package to declare this in would be FWCore/ServiceRegistry
185  //prevalidateService(descriptions);
186  }
187 
188  virtual const std::string& baseType() const {
189  return kBaseForService;
190  }
191 
192  virtual const std::string& extendedBaseType() const {
193  return kEmpty;
194  }
195 
196  private:
197  void prevalidate(ConfigurationDescriptions & descriptions);
200  };
201 
202  template<typename T>
204  {
205  public:
207 
208  // If T has a fillDescriptions function then just call that, otherwise
209  // put in an "unknown description" as a default.
210  virtual void fill(ConfigurationDescriptions & descriptions) const {
213  edm::fillDetails::DoFillAsUnknown<T> >::type fill_descriptions;
214  fill_descriptions(descriptions);
215 
219  prevalidate(descriptions);
220  }
221 
222  virtual const std::string& baseType() const {
223  return kBaseForESSource;
224  }
225 
226  virtual const std::string& extendedBaseType() const {
227  return kEmpty;
228  }
229 
230  private:
233  };
234 
235  template<typename T>
237  {
238  public:
240 
241  // If T has a fillDescriptions function then just call that, otherwise
242  // put in an "unknown description" as a default.
243  virtual void fill(ConfigurationDescriptions & descriptions) const {
246  edm::fillDetails::DoFillAsUnknown<T> >::type fill_descriptions;
247  fill_descriptions(descriptions);
248 
252  prevalidate(descriptions);
253  }
254 
255  virtual const std::string& baseType() const {
256  return kBaseForESProducer;
257  }
258 
259  virtual const std::string& extendedBaseType() const {
260  return kEmpty;
261  }
262 
263  private:
266  };
267 }
268 #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)