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
edm::ParameterSetDescriptionFillerBase::kBaseForService
static const std::string kBaseForService
Definition: ParameterSetDescriptionFillerBase.h:80
ConfigurationDescriptions.h
ParameterSetDescriptionFillerBase.h
edm::fillDetails::yes_tag
std::true_type yes_tag
Definition: ParameterSetDescriptionFiller.h:65
edm::ParameterSetDescriptionFiller::ParameterSetDescriptionFiller
ParameterSetDescriptionFiller()
Definition: ParameterSetDescriptionFiller.h:35
edm::ParameterSetDescriptionFillerBase::extendedBaseType
virtual const std::string & extendedBaseType() const =0
edm::DescriptionFillerForESSources::operator=
const DescriptionFillerForESSources & operator=(const DescriptionFillerForESSources &)=delete
edm::fillDetails::DoNothing
Definition: ParameterSetDescriptionFiller.h:111
edm::ParameterSetDescriptionFillerBase
Definition: ParameterSetDescriptionFillerBase.h:64
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescriptionFillerBase::kBaseForESSource
static const std::string kBaseForESSource
Definition: ParameterSetDescriptionFillerBase.h:81
edm::ParameterSetDescriptionFiller::fill
void fill(ConfigurationDescriptions &descriptions) const override
Definition: ParameterSetDescriptionFiller.h:37
edm::fillDetails::DoFillAsUnknown
Definition: ParameterSetDescriptionFiller.h:85
edm::fillDetails::has_prevalidate_function
Definition: ParameterSetDescriptionFiller.h:101
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::DescriptionFillerForESSources::extendedBaseType
const std::string & extendedBaseType() const override
Definition: ParameterSetDescriptionFiller.h:171
edm::ParameterSetDescriptionFiller::operator=
const ParameterSetDescriptionFiller & operator=(const ParameterSetDescriptionFiller &)=delete
edm::fillDetails::DoFillDescriptions
Definition: ParameterSetDescriptionFiller.h:80
edm::fillDetails::no_tag
std::false_type no_tag
Definition: ParameterSetDescriptionFiller.h:64
edm::DescriptionFillerForServices::prevalidate
void prevalidate(ConfigurationDescriptions &descriptions)
edm::ParameterSetDescriptionFiller::extendedBaseType
const std::string & extendedBaseType() const override
Definition: ParameterSetDescriptionFiller.h:44
edm::DescriptionFillerForServices::DescriptionFillerForServices
DescriptionFillerForServices()
Definition: ParameterSetDescriptionFiller.h:123
edm::DescriptionFillerForESProducers::extendedBaseType
const std::string & extendedBaseType() const override
Definition: ParameterSetDescriptionFiller.h:201
edm::DescriptionFillerForESSources::fill
void fill(ConfigurationDescriptions &descriptions) const override
Definition: ParameterSetDescriptionFiller.h:155
edm::DescriptionFillerForESProducers
Definition: ParameterSetDescriptionFiller.h:179
edm::DescriptionFillerForESProducers::operator=
const DescriptionFillerForESProducers & operator=(const DescriptionFillerForESProducers &)=delete
edm::fillDetails::fillDescriptions_function
Definition: ParameterSetDescriptionFiller.h:68
edm::ParameterSetDescriptionFiller::baseType
const std::string & baseType() const override
Definition: ParameterSetDescriptionFiller.h:42
edm::DescriptionFillerForServices::fill
void fill(ConfigurationDescriptions &descriptions) const override
Definition: ParameterSetDescriptionFiller.h:127
edm::DescriptionFillerForESSources::DescriptionFillerForESSources
DescriptionFillerForESSources()
Definition: ParameterSetDescriptionFiller.h:151
edm::fillDetails::DoFillAsUnknown::operator()
void operator()(ConfigurationDescriptions &descriptions)
Definition: ParameterSetDescriptionFiller.h:86
edm::DescriptionFillerForServices::extendedBaseType
const std::string & extendedBaseType() const override
Definition: ParameterSetDescriptionFiller.h:140
edm::DescriptionFillerForESSources
Definition: ParameterSetDescriptionFiller.h:149
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::ParameterSetDescriptionFillerBase::kEmpty
static const std::string kEmpty
Definition: ParameterSetDescriptionFillerBase.h:79
edm::DescriptionFillerForServices::baseType
const std::string & baseType() const override
Definition: ParameterSetDescriptionFiller.h:138
ParameterSetDescription.h
edm::DescriptionFillerForServices
Definition: ParameterSetDescriptionFiller.h:121
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSetDescriptionFiller
Definition: ParameterSetDescriptionFiller.h:33
edm::fillDetails::DoFillDescriptions::operator()
void operator()(ConfigurationDescriptions &descriptions)
Definition: ParameterSetDescriptionFiller.h:81
edm::fillDetails::DoPrevalidate::operator()
void operator()(ConfigurationDescriptions &descriptions)
Definition: ParameterSetDescriptionFiller.h:107
value
Definition: value.py:1
edm::ParameterSetDescription::setUnknown
void setUnknown()
Definition: ParameterSetDescription.cc:39
edm::DescriptionFillerForESProducers::fill
void fill(ConfigurationDescriptions &descriptions) const override
Definition: ParameterSetDescriptionFiller.h:185
edm::fillDetails::has_fillDescriptions_function
Definition: ParameterSetDescriptionFiller.h:75
type
type
Definition: HCALResponse.h:21
edm::DescriptionFillerForESProducers::DescriptionFillerForESProducers
DescriptionFillerForESProducers()
Definition: ParameterSetDescriptionFiller.h:181
edm::fillDetails::DoNothing::operator()
void operator()(ConfigurationDescriptions &descriptions)
Definition: ParameterSetDescriptionFiller.h:112
T
long double T
Definition: Basic3DVectorLD.h:48
relativeConstraints.value
value
Definition: relativeConstraints.py:53
edm::DescriptionFillerForESProducers::baseType
const std::string & baseType() const override
Definition: ParameterSetDescriptionFiller.h:199
edm::fillDetails::DoPrevalidate
Definition: ParameterSetDescriptionFiller.h:106
edm::DescriptionFillerForServices::operator=
const DescriptionFillerForServices & operator=(const DescriptionFillerForServices &)
dummy
Definition: DummySelector.h:38
edm::fillDetails::prevalidate_function
Definition: ParameterSetDescriptionFiller.h:94
edm::ParameterSetDescriptionFillerBase::kBaseForESProducer
static const std::string kBaseForESProducer
Definition: ParameterSetDescriptionFillerBase.h:82
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::DescriptionFillerForESSources::baseType
const std::string & baseType() const override
Definition: ParameterSetDescriptionFiller.h:169
edm::fillDetails::has_fillDescriptions_helper
no_tag has_fillDescriptions_helper(...)
edm::fillDetails::has_prevalidate_helper
no_tag has_prevalidate_helper(...)