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  ParameterSetDescriptionFiller(const ParameterSetDescriptionFiller&) = delete; // stop default
37  const ParameterSetDescriptionFiller& operator=(const ParameterSetDescriptionFiller&) = delete; // stop default
38 
39  void fill(ConfigurationDescriptions& descriptions) const override {
40  T::fillDescriptions(descriptions);
41  T::prevalidate(descriptions);
42  }
43 
44  const std::string& baseType() const override { return T::baseType(); }
45 
46  const std::string& extendedBaseType() const override {
47  const T* type = nullptr;
49  }
50  };
51 
52  // We need a special version of this class for Services because there is
53  // no common base class for all Service classes. This means we cannot define
54  // the baseType and fillDescriptions functions for all Service classes without
55  // great difficulty.
56 
57  // First, some template metaprogramming to determining if the class T has
58  // a fillDescriptions function.
59 
60  namespace fillDetails {
61 
62  using no_tag = std::false_type; // type indicating FALSE
63  using yes_tag = std::true_type; // type indicating TRUE
64 
65  template <typename T, void (*)(ConfigurationDescriptions&)>
67  template <typename T>
69  template <typename T>
71 
72  template <typename T>
74  static constexpr bool value = std::is_same<decltype(has_fillDescriptions_helper<T>(nullptr)), yes_tag>::value;
75  };
76 
77  template <typename T>
79  void operator()(ConfigurationDescriptions& descriptions) { T::fillDescriptions(descriptions); }
80  };
81 
82  template <typename T>
83  struct DoFillAsUnknown {
84  void operator()(ConfigurationDescriptions& descriptions) {
86  desc.setUnknown();
87  descriptions.addDefault(desc);
88  }
89  };
90 
91  template <typename T, void (*)(ConfigurationDescriptions&)>
93  template <typename T>
95  template <typename T>
97 
98  template <typename T>
100  static constexpr bool value = std::is_same<decltype(has_prevalidate_helper<T>(nullptr)), yes_tag>::value;
101  };
102 
103  template <typename T>
104  struct DoPrevalidate {
105  void operator()(ConfigurationDescriptions& descriptions) { T::prevalidate(descriptions); }
106  };
107 
108  template <typename T>
109  struct DoNothing {
110  void operator()(ConfigurationDescriptions& descriptions) {}
111  };
112 
113  } // namespace fillDetails
114 
115  // Not needed at the moment
116  //void prevalidateService(ConfigurationDescriptions &);
117 
118  template <typename T>
120  public:
122 
123  // If T has a fillDescriptions function then just call that, otherwise
124  // put in an "unknown description" as a default.
125  void fill(ConfigurationDescriptions& descriptions) const override {
129  fill_descriptions;
130  fill_descriptions(descriptions);
131  //we don't have a need for prevalidation of services at the moment, so this is a placeholder
132  // Probably the best package to declare this in would be FWCore/ServiceRegistry
133  //prevalidateService(descriptions);
134  }
135 
136  const std::string& baseType() const override { return kBaseForService; }
137 
138  const std::string& extendedBaseType() const override { return kEmpty; }
139 
140  private:
141  void prevalidate(ConfigurationDescriptions& descriptions);
144  };
145 
146  template <typename T>
148  public:
150  DescriptionFillerForESSources(const DescriptionFillerForESSources&) = delete; // stop default
151  const DescriptionFillerForESSources& operator=(const DescriptionFillerForESSources&) = delete; // stop default
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 
174  template <typename T>
176  public:
178  DescriptionFillerForESProducers(const DescriptionFillerForESProducers&) = delete; // stop default
179  const DescriptionFillerForESProducers& operator=(const DescriptionFillerForESProducers&) = delete; // stop default
180 
181  // If T has a fillDescriptions function then just call that, otherwise
182  // put in an "unknown description" as a default.
183  void fill(ConfigurationDescriptions& descriptions) const override {
187  fill_descriptions;
188  fill_descriptions(descriptions);
189 
193  prevalidate;
194  prevalidate(descriptions);
195  }
196 
197  const std::string& baseType() const override { return kBaseForESProducer; }
198 
199  const std::string& extendedBaseType() const override { return kEmpty; }
200  };
201 } // namespace edm
202 #endif
edm::ParameterSetDescriptionFillerBase::kBaseForService
static const std::string kBaseForService
Definition: ParameterSetDescriptionFillerBase.h:83
ConfigurationDescriptions.h
ParameterSetDescriptionFillerBase.h
edm::fillDetails::yes_tag
std::true_type yes_tag
Definition: ParameterSetDescriptionFiller.h:63
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:109
edm::ParameterSetDescriptionFillerBase
Definition: ParameterSetDescriptionFillerBase.h:64
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescriptionFillerBase::kBaseForESSource
static const std::string kBaseForESSource
Definition: ParameterSetDescriptionFillerBase.h:84
edm::ParameterSetDescriptionFiller::fill
void fill(ConfigurationDescriptions &descriptions) const override
Definition: ParameterSetDescriptionFiller.h:39
edm::fillDetails::DoFillAsUnknown
Definition: ParameterSetDescriptionFiller.h:83
edm::fillDetails::has_prevalidate_function
Definition: ParameterSetDescriptionFiller.h:99
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:78
edm::fillDetails::no_tag
std::false_type no_tag
Definition: ParameterSetDescriptionFiller.h:62
edm::DescriptionFillerForServices::prevalidate
void prevalidate(ConfigurationDescriptions &descriptions)
edm::ParameterSetDescriptionFiller::extendedBaseType
const std::string & extendedBaseType() const override
Definition: ParameterSetDescriptionFiller.h:46
edm::DescriptionFillerForServices::DescriptionFillerForServices
DescriptionFillerForServices()
Definition: ParameterSetDescriptionFiller.h:121
edm::DescriptionFillerForESProducers::extendedBaseType
const std::string & extendedBaseType() const override
Definition: ParameterSetDescriptionFiller.h:199
edm::DescriptionFillerForESSources::fill
void fill(ConfigurationDescriptions &descriptions) const override
Definition: ParameterSetDescriptionFiller.h:155
edm::DescriptionFillerForESProducers
Definition: ParameterSetDescriptionFiller.h:175
edm::DescriptionFillerForESProducers::operator=
const DescriptionFillerForESProducers & operator=(const DescriptionFillerForESProducers &)=delete
edm::fillDetails::fillDescriptions_function
Definition: ParameterSetDescriptionFiller.h:66
edm::ParameterSetDescriptionFiller::baseType
const std::string & baseType() const override
Definition: ParameterSetDescriptionFiller.h:44
edm::DescriptionFillerForServices::fill
void fill(ConfigurationDescriptions &descriptions) const override
Definition: ParameterSetDescriptionFiller.h:125
edm::DescriptionFillerForESSources::DescriptionFillerForESSources
DescriptionFillerForESSources()
Definition: ParameterSetDescriptionFiller.h:149
edm::fillDetails::DoFillAsUnknown::operator()
void operator()(ConfigurationDescriptions &descriptions)
Definition: ParameterSetDescriptionFiller.h:84
edm::DescriptionFillerForServices::extendedBaseType
const std::string & extendedBaseType() const override
Definition: ParameterSetDescriptionFiller.h:138
edm::DescriptionFillerForESSources
Definition: ParameterSetDescriptionFiller.h:147
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::ParameterSetDescriptionFillerBase::kEmpty
static const std::string kEmpty
Definition: ParameterSetDescriptionFillerBase.h:82
edm::DescriptionFillerForServices::baseType
const std::string & baseType() const override
Definition: ParameterSetDescriptionFiller.h:136
ParameterSetDescription.h
edm::DescriptionFillerForServices
Definition: ParameterSetDescriptionFiller.h:119
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:79
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
edm::fillDetails::DoPrevalidate::operator()
void operator()(ConfigurationDescriptions &descriptions)
Definition: ParameterSetDescriptionFiller.h:105
value
Definition: value.py:1
edm::DescriptionFillerForESProducers::fill
void fill(ConfigurationDescriptions &descriptions) const override
Definition: ParameterSetDescriptionFiller.h:183
edm::fillDetails::has_fillDescriptions_function
Definition: ParameterSetDescriptionFiller.h:73
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::DescriptionFillerForESProducers::DescriptionFillerForESProducers
DescriptionFillerForESProducers()
Definition: ParameterSetDescriptionFiller.h:177
edm::fillDetails::DoNothing::operator()
void operator()(ConfigurationDescriptions &descriptions)
Definition: ParameterSetDescriptionFiller.h:110
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:197
edm::fillDetails::DoPrevalidate
Definition: ParameterSetDescriptionFiller.h:104
edm::DescriptionFillerForServices::operator=
const DescriptionFillerForServices & operator=(const DescriptionFillerForServices &)
dummy
Definition: DummySelector.h:38
edm::fillDetails::prevalidate_function
Definition: ParameterSetDescriptionFiller.h:92
edm::ParameterSetDescriptionFillerBase::kBaseForESProducer
static const std::string kBaseForESProducer
Definition: ParameterSetDescriptionFillerBase.h:85
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(...)