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>
27 #include <boost/mpl/if.hpp>
31 
32 namespace edm {
33  template< typename T>
35  {
36  public:
38 
39  virtual void fill(ConfigurationDescriptions & descriptions) const {
40  T::fillDescriptions(descriptions);
41  T::prevalidate(descriptions);
42  }
43 
44  virtual const std::string& baseType() const {
45  return T::baseType();
46  }
47 
48  virtual const std::string& extendedBaseType() const {
49  const T* type = nullptr;
51  }
52 
53  private:
56 
57  };
58 
59  // We need a special version of this class for Services because there is
60  // no common base class for all Service classes. This means we cannot define
61  // the baseType and fillDescriptions functions for all Service classes without
62  // great difficulty.
63 
64  // First, some template metaprogramming to determining if the class T has
65  // a fillDescriptions function.
66 
67  namespace fillDetails {
68 
69  typedef char (& no_tag)[1]; // type indicating FALSE
70  typedef char (& yes_tag)[2]; // type indicating TRUE
71 
72  template <typename T, void (*)(ConfigurationDescriptions &)> struct fillDescriptions_function;
73  template <typename T> no_tag has_fillDescriptions_helper(...);
75 
76  template<typename T>
78  static bool const value =
79  sizeof(has_fillDescriptions_helper<T>(0)) == sizeof(yes_tag);
80  };
81 
82  template <typename T>
84  void operator()(ConfigurationDescriptions & descriptions) {
85  T::fillDescriptions(descriptions);
86  }
87  };
88 
89  template <typename T>
90  struct DoFillAsUnknown {
91  void operator()(ConfigurationDescriptions & descriptions) {
93  desc.setUnknown();
94  descriptions.addDefault(desc);
95  }
96  };
97 
98  template <typename T, void (*)(ConfigurationDescriptions &)> struct prevalidate_function;
99  template <typename T> no_tag has_prevalidate_helper(...);
101 
102  template<typename T>
104  static bool const value =
105  sizeof(has_prevalidate_helper<T>(0)) == sizeof(yes_tag);
106  };
107 
108  template <typename T>
109  struct DoPrevalidate {
110  void operator()(ConfigurationDescriptions & descriptions) {
111  T::prevalidate(descriptions);
112  }
113  };
114 
115  template <typename T>
116  struct DoNothing {
117  void operator()(ConfigurationDescriptions & descriptions) {
118  }
119  };
120 
121  }
122 
123  // Not needed at the moment
124  //void prevalidateService(ConfigurationDescriptions &);
125 
126  template< typename T>
128  {
129  public:
131 
132  // If T has a fillDescriptions function then just call that, otherwise
133  // put in an "unknown description" as a default.
134  virtual void fill(ConfigurationDescriptions & descriptions) const {
137  edm::fillDetails::DoFillAsUnknown<T>> fill_descriptions;
138  fill_descriptions(descriptions);
139  //we don't have a need for prevalidation of services at the moment, so this is a placeholder
140  // Probably the best package to declare this in would be FWCore/ServiceRegistry
141  //prevalidateService(descriptions);
142  }
143 
144  virtual const std::string& baseType() const {
145  return kBaseForService;
146  }
147 
148  virtual const std::string& extendedBaseType() const {
149  return kEmpty;
150  }
151 
152  private:
153  void prevalidate(ConfigurationDescriptions & descriptions);
156  };
157 
158  template<typename T>
160  {
161  public:
163 
164  // If T has a fillDescriptions function then just call that, otherwise
165  // put in an "unknown description" as a default.
166  virtual void fill(ConfigurationDescriptions & descriptions) const {
169  edm::fillDetails::DoFillAsUnknown<T>> fill_descriptions;
170  fill_descriptions(descriptions);
171 
174  edm::fillDetails::DoNothing<T>> prevalidate;
175  prevalidate(descriptions);
176  }
177 
178  virtual const std::string& baseType() const {
179  return kBaseForESSource;
180  }
181 
182  virtual const std::string& extendedBaseType() const {
183  return kEmpty;
184  }
185 
186  private:
189  };
190 
191  template<typename T>
193  {
194  public:
196 
197  // If T has a fillDescriptions function then just call that, otherwise
198  // put in an "unknown description" as a default.
199  virtual void fill(ConfigurationDescriptions & descriptions) const {
202  edm::fillDetails::DoFillAsUnknown<T>> fill_descriptions;
203  fill_descriptions(descriptions);
204 
207  edm::fillDetails::DoNothing<T>> prevalidate;
208  prevalidate(descriptions);
209  }
210 
211  virtual const std::string& baseType() const {
212  return kBaseForESProducer;
213  }
214 
215  virtual const std::string& extendedBaseType() const {
216  return kEmpty;
217  }
218 
219  private:
222  };
223 }
224 #endif
type
Definition: HCALResponse.h:21
virtual const std::string & baseType() const
yes_tag has_fillDescriptions_helper(fillDescriptions_function< T,&T::fillDescriptions > *dummy)
yes_tag has_prevalidate_helper(fillDescriptions_function< T,&T::prevalidate > *dummy)
virtual void fill(ConfigurationDescriptions &descriptions) const
virtual const std::string & extendedBaseType() const
virtual const std::string & baseType() const
virtual const std::string & baseType() const
const ParameterSetDescriptionFiller & operator=(const ParameterSetDescriptionFiller &)
virtual const std::string & extendedBaseType() const
void addDefault(ParameterSetDescription const &psetDescription)
virtual const std::string & baseType() const
void operator()(ConfigurationDescriptions &descriptions)
Definition: value.py:1
virtual const std::string & extendedBaseType() const
virtual void fill(ConfigurationDescriptions &descriptions) const
virtual const std::string & extendedBaseType() const
void operator()(ConfigurationDescriptions &descriptions)
virtual const std::string & extendedBaseType() const =0
virtual void fill(ConfigurationDescriptions &descriptions) const
virtual void fill(ConfigurationDescriptions &descriptions) const
HLT enums.
void operator()(ConfigurationDescriptions &descriptions)
void operator()(ConfigurationDescriptions &descriptions)
long double T