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 
28 #include "boost/mpl/if.hpp"
29 #include <string>
30 
31 namespace edm {
32  template< typename T>
34  {
35  public:
37 
38  virtual void fill(ConfigurationDescriptions & descriptions) const {
39  T::fillDescriptions(descriptions);
40  T::prevalidate(descriptions);
41  }
42 
43  virtual const std::string& baseType() const {
44  return T::baseType();
45  }
46 
47  private:
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  typedef char (& no_tag)[1]; // type indicating FALSE
63  typedef char (& yes_tag)[2]; // type indicating TRUE
64 
65  template <typename T, void (*)(ConfigurationDescriptions &)> struct fillDescriptions_function;
66  template <typename T> no_tag has_fillDescriptions_helper(...);
68 
69  template<typename T>
71  static bool const value =
72  sizeof(has_fillDescriptions_helper<T>(0)) == sizeof(yes_tag);
73  };
74 
75  template <typename T>
77  void operator()(ConfigurationDescriptions & descriptions) {
78  T::fillDescriptions(descriptions);
79  }
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 &)> struct prevalidate_function;
92  template <typename T> no_tag has_prevalidate_helper(...);
94 
95  template<typename T>
97  static bool const value =
98  sizeof(has_prevalidate_helper<T>(0)) == sizeof(yes_tag);
99  };
100 
101  template <typename T>
102  struct DoPrevalidate {
103  void operator()(ConfigurationDescriptions & descriptions) {
104  T::prevalidate(descriptions);
105  }
106  };
107 
108  template <typename T>
109  struct DoNothing {
110  void operator()(ConfigurationDescriptions & descriptions) {
111  }
112  };
113 
114  }
115 
116  // Not needed at the moment
117  //void prevalidateService(ConfigurationDescriptions &);
118 
119  template< typename T>
121  {
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  virtual void fill(ConfigurationDescriptions & descriptions) const {
130  edm::fillDetails::DoFillAsUnknown<T> >::type fill_descriptions;
131  fill_descriptions(descriptions);
132  //we don't have a need for prevalidation of services at the moment, so this is a placeholder
133  // Probably the best package to declare this in would be FWCore/ServiceRegistry
134  //prevalidateService(descriptions);
135  }
136 
137  virtual const std::string& baseType() const {
138  return kBaseForService;
139  }
140 
141  private:
142  void prevalidate(ConfigurationDescriptions & descriptions);
145  };
146 
147  template<typename T>
149  {
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  virtual void fill(ConfigurationDescriptions & descriptions) const {
158  edm::fillDetails::DoFillAsUnknown<T> >::type fill_descriptions;
159  fill_descriptions(descriptions);
160 
164  prevalidate(descriptions);
165  }
166 
167  virtual const std::string& baseType() const {
168  return kBaseForESSource;
169  }
170 
171  private:
174  };
175 
176  template<typename T>
178  {
179  public:
181 
182  // If T has a fillDescriptions function then just call that, otherwise
183  // put in an "unknown description" as a default.
184  virtual void fill(ConfigurationDescriptions & descriptions) const {
187  edm::fillDetails::DoFillAsUnknown<T> >::type fill_descriptions;
188  fill_descriptions(descriptions);
189 
193  prevalidate(descriptions);
194  }
195 
196  virtual const std::string& baseType() const {
197  return kBaseForESProducer;
198  }
199 
200  private:
203  };
204 }
205 #endif
type
Definition: HCALResponse.h:22
virtual const std::string & baseType() const
void prevalidate(ConfigurationDescriptions &descriptions)
virtual void fill(ConfigurationDescriptions &descriptions) 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(...)
void addDefault(ParameterSetDescription const &psetDescription)
virtual const std::string & baseType() const
void operator()(ConfigurationDescriptions &descriptions)
const DescriptionFillerForESSources & operator=(const DescriptionFillerForESSources &)
const DescriptionFillerForESProducers & operator=(const DescriptionFillerForESProducers &)
virtual void fill(ConfigurationDescriptions &descriptions) 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)