Go to the documentation of this file.00001 #ifndef FWCore_ParameterSet_ParameterSetDescriptionFiller_h
00002 #define FWCore_ParameterSet_ParameterSetDescriptionFiller_h
00003
00004
00005
00006
00007
00020
00021
00022
00023
00024
00025 #include "FWCore/ParameterSet/interface/ParameterSetDescriptionFillerBase.h"
00026 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00027 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00028 #include "boost/mpl/if.hpp"
00029 #include <string>
00030
00031 namespace edm {
00032 template< typename T>
00033 class ParameterSetDescriptionFiller : public ParameterSetDescriptionFillerBase
00034 {
00035 public:
00036 ParameterSetDescriptionFiller() {}
00037
00038 virtual void fill(ConfigurationDescriptions & descriptions) const {
00039 T::fillDescriptions(descriptions);
00040 T::prevalidate(descriptions);
00041 }
00042
00043 virtual const std::string& baseType() const {
00044 return T::baseType();
00045 }
00046
00047 private:
00048 ParameterSetDescriptionFiller(const ParameterSetDescriptionFiller&);
00049 const ParameterSetDescriptionFiller& operator=(const ParameterSetDescriptionFiller&);
00050 };
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 namespace fillDetails {
00061
00062 typedef char (& no_tag)[1];
00063 typedef char (& yes_tag)[2];
00064
00065 template <typename T, void (*)(ConfigurationDescriptions &)> struct fillDescriptions_function;
00066 template <typename T> no_tag has_fillDescriptions_helper(...);
00067 template <typename T> yes_tag has_fillDescriptions_helper(fillDescriptions_function<T, &T::fillDescriptions> * dummy);
00068
00069 template<typename T>
00070 struct has_fillDescriptions_function {
00071 static bool const value =
00072 sizeof(has_fillDescriptions_helper<T>(0)) == sizeof(yes_tag);
00073 };
00074
00075 template <typename T>
00076 struct DoFillDescriptions {
00077 void operator()(ConfigurationDescriptions & descriptions) {
00078 T::fillDescriptions(descriptions);
00079 }
00080 };
00081
00082 template <typename T>
00083 struct DoFillAsUnknown {
00084 void operator()(ConfigurationDescriptions & descriptions) {
00085 ParameterSetDescription desc;
00086 desc.setUnknown();
00087 descriptions.addDefault(desc);
00088 }
00089 };
00090
00091 template <typename T, void (*)(ConfigurationDescriptions &)> struct prevalidate_function;
00092 template <typename T> no_tag has_prevalidate_helper(...);
00093 template <typename T> yes_tag has_prevalidate_helper(fillDescriptions_function<T, &T::prevalidate> * dummy);
00094
00095 template<typename T>
00096 struct has_prevalidate_function {
00097 static bool const value =
00098 sizeof(has_prevalidate_helper<T>(0)) == sizeof(yes_tag);
00099 };
00100
00101 template <typename T>
00102 struct DoPrevalidate {
00103 void operator()(ConfigurationDescriptions & descriptions) {
00104 T::prevalidate(descriptions);
00105 }
00106 };
00107
00108 template <typename T>
00109 struct DoNothing {
00110 void operator()(ConfigurationDescriptions & descriptions) {
00111 }
00112 };
00113
00114 }
00115
00116
00117
00118
00119 template< typename T>
00120 class DescriptionFillerForServices : public ParameterSetDescriptionFillerBase
00121 {
00122 public:
00123 DescriptionFillerForServices() {}
00124
00125
00126
00127 virtual void fill(ConfigurationDescriptions & descriptions) const {
00128 typename boost::mpl::if_c<edm::fillDetails::has_fillDescriptions_function<T>::value,
00129 edm::fillDetails::DoFillDescriptions<T>,
00130 edm::fillDetails::DoFillAsUnknown<T> >::type fill_descriptions;
00131 fill_descriptions(descriptions);
00132
00133
00134
00135 }
00136
00137 virtual const std::string& baseType() const {
00138 return kBaseForService;
00139 }
00140
00141 private:
00142 void prevalidate(ConfigurationDescriptions & descriptions);
00143 DescriptionFillerForServices(const DescriptionFillerForServices&);
00144 const DescriptionFillerForServices& operator=(const DescriptionFillerForServices&);
00145 };
00146
00147 template<typename T>
00148 class DescriptionFillerForESSources : public ParameterSetDescriptionFillerBase
00149 {
00150 public:
00151 DescriptionFillerForESSources() {}
00152
00153
00154
00155 virtual void fill(ConfigurationDescriptions & descriptions) const {
00156 typename boost::mpl::if_c<edm::fillDetails::has_fillDescriptions_function<T>::value,
00157 edm::fillDetails::DoFillDescriptions<T>,
00158 edm::fillDetails::DoFillAsUnknown<T> >::type fill_descriptions;
00159 fill_descriptions(descriptions);
00160
00161 typename boost::mpl::if_c<edm::fillDetails::has_prevalidate_function<T>::value,
00162 edm::fillDetails::DoPrevalidate<T>,
00163 edm::fillDetails::DoNothing<T> >::type prevalidate;
00164 prevalidate(descriptions);
00165 }
00166
00167 virtual const std::string& baseType() const {
00168 return kBaseForESSource;
00169 }
00170
00171 private:
00172 DescriptionFillerForESSources(const DescriptionFillerForESSources&);
00173 const DescriptionFillerForESSources& operator=(const DescriptionFillerForESSources&);
00174 };
00175
00176 template<typename T>
00177 class DescriptionFillerForESProducers : public ParameterSetDescriptionFillerBase
00178 {
00179 public:
00180 DescriptionFillerForESProducers() {}
00181
00182
00183
00184 virtual void fill(ConfigurationDescriptions & descriptions) const {
00185 typename boost::mpl::if_c<edm::fillDetails::has_fillDescriptions_function<T>::value,
00186 edm::fillDetails::DoFillDescriptions<T>,
00187 edm::fillDetails::DoFillAsUnknown<T> >::type fill_descriptions;
00188 fill_descriptions(descriptions);
00189
00190 typename boost::mpl::if_c<edm::fillDetails::has_prevalidate_function<T>::value,
00191 edm::fillDetails::DoPrevalidate<T>,
00192 edm::fillDetails::DoNothing<T> >::type prevalidate;
00193 prevalidate(descriptions);
00194 }
00195
00196 virtual const std::string& baseType() const {
00197 return kBaseForESProducer;
00198 }
00199
00200 private:
00201 DescriptionFillerForESProducers(const DescriptionFillerForESProducers&);
00202 const DescriptionFillerForESProducers& operator=(const DescriptionFillerForESProducers&);
00203 };
00204 }
00205 #endif