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 
37  void fill(ConfigurationDescriptions& descriptions) const override {
38  T::fillDescriptions(descriptions);
39  T::prevalidate(descriptions);
40  }
41 
42  const std::string& baseType() const override { return T::baseType(); }
43 
44  const std::string& extendedBaseType() const override {
45  const T* type = nullptr;
47  }
48 
49  private:
50  ParameterSetDescriptionFiller(const ParameterSetDescriptionFiller&) = delete; // stop default
51  const ParameterSetDescriptionFiller& operator=(const ParameterSetDescriptionFiller&) = delete; // stop default
52  };
53 
54  // We need a special version of this class for Services because there is
55  // no common base class for all Service classes. This means we cannot define
56  // the baseType and fillDescriptions functions for all Service classes without
57  // great difficulty.
58 
59  // First, some template metaprogramming to determining if the class T has
60  // a fillDescriptions function.
61 
62  namespace fillDetails {
63 
64  using no_tag = std::false_type; // type indicating FALSE
65  using yes_tag = std::true_type; // type indicating TRUE
66 
67  template <typename T, void (*)(ConfigurationDescriptions&)>
69  template <typename T>
71  template <typename T>
73 
74  template <typename T>
76  static constexpr bool value = std::is_same<decltype(has_fillDescriptions_helper<T>(nullptr)), yes_tag>::value;
77  };
78 
79  template <typename T>
81  void operator()(ConfigurationDescriptions& descriptions) { T::fillDescriptions(descriptions); }
82  };
83 
84  template <typename T>
85  struct DoFillAsUnknown {
86  void operator()(ConfigurationDescriptions& descriptions) {
88  desc.setUnknown();
89  descriptions.addDefault(desc);
90  }
91  };
92 
93  template <typename T, void (*)(ConfigurationDescriptions&)>
95  template <typename T>
97  template <typename T>
99 
100  template <typename T>
102  static constexpr bool value = std::is_same<decltype(has_prevalidate_helper<T>(nullptr)), yes_tag>::value;
103  };
104 
105  template <typename T>
106  struct DoPrevalidate {
107  void operator()(ConfigurationDescriptions& descriptions) { T::prevalidate(descriptions); }
108  };
109 
110  template <typename T>
111  struct DoNothing {
112  void operator()(ConfigurationDescriptions& descriptions) {}
113  };
114 
115  } // namespace fillDetails
116 
117  // Not needed at the moment
118  //void prevalidateService(ConfigurationDescriptions &);
119 
120  template <typename T>
122  public:
124 
125  // If T has a fillDescriptions function then just call that, otherwise
126  // put in an "unknown description" as a default.
127  void fill(ConfigurationDescriptions& descriptions) const override {
131  fill_descriptions;
132  fill_descriptions(descriptions);
133  //we don't have a need for prevalidation of services at the moment, so this is a placeholder
134  // Probably the best package to declare this in would be FWCore/ServiceRegistry
135  //prevalidateService(descriptions);
136  }
137 
138  const std::string& baseType() const override { return kBaseForService; }
139 
140  const std::string& extendedBaseType() const override { return kEmpty; }
141 
142  private:
143  void prevalidate(ConfigurationDescriptions& descriptions);
146  };
147 
148  template <typename T>
150  public:
152 
153  // If T has a fillDescriptions function then just call that, otherwise
154  // put in an "unknown description" as a default.
155  void fill(ConfigurationDescriptions& descriptions) const override {
159  fill_descriptions;
160  fill_descriptions(descriptions);
161 
165  prevalidate;
166  prevalidate(descriptions);
167  }
168 
169  const std::string& baseType() const override { return kBaseForESSource; }
170 
171  const std::string& extendedBaseType() const override { return kEmpty; }
172 
173  private:
174  DescriptionFillerForESSources(const DescriptionFillerForESSources&) = delete; // stop default
175  const DescriptionFillerForESSources& operator=(const DescriptionFillerForESSources&) = delete; // stop default
176  };
177 
178  template <typename T>
180  public:
182 
183  // If T has a fillDescriptions function then just call that, otherwise
184  // put in an "unknown description" as a default.
185  void fill(ConfigurationDescriptions& descriptions) const override {
189  fill_descriptions;
190  fill_descriptions(descriptions);
191 
195  prevalidate;
196  prevalidate(descriptions);
197  }
198 
199  const std::string& baseType() const override { return kBaseForESProducer; }
200 
201  const std::string& extendedBaseType() const override { return kEmpty; }
202 
203  private:
204  DescriptionFillerForESProducers(const DescriptionFillerForESProducers&) = delete; // stop default
205  const DescriptionFillerForESProducers& operator=(const DescriptionFillerForESProducers&) = delete; // stop default
206  };
207 } // namespace edm
208 #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
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
#define constexpr
const std::string & baseType() const override