ParameterAdapter

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
#ifndef UtilAlgos_ParameterAdapter_h
#define UtilAlgos_ParameterAdapter_h

#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

namespace reco {
  namespace modules {

    template <typename S>
    struct ParameterAdapter {
      static S make(const edm::ParameterSet& cfg) { return S(cfg); }
      static S make(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC) { return S(cfg, iC); }
      static S make(const edm::ParameterSet& cfg, edm::ConsumesCollector& iC) { return S(cfg, iC); }

      static void fillPSetDescription(edm::ParameterSetDescription& desc) { S::fillPSetDescription(desc); }
    };

    template <typename S>
    S make(const edm::ParameterSet& cfg) {
      return ParameterAdapter<S>::make(cfg);
    }
    template <typename S>
    S make(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC) {
      return ParameterAdapter<S>::make(cfg, iC);
    }
    template <typename S>
    S make(const edm::ParameterSet& cfg, edm::ConsumesCollector& iC) {
      return ParameterAdapter<S>::make(cfg, iC);
    }

    template <typename S>
    void fillPSetDescription(edm::ParameterSetDescription& desc) {
      ParameterAdapter<S>::fillPSetDescription(desc);
    }
  }  // namespace modules
}  // namespace reco

#define NOPARAMETER_ADAPTER(TYPE)                                                                      \
  namespace reco {                                                                                     \
    namespace modules {                                                                                \
      struct ParameterAdapter<TYPE> {                                                                  \
        static TYPE make(const edm::ParameterSet& cfg) { return TYPE(); }                              \
        static TYPE make(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC) { return TYPE(); } \
        static TYPE make(const edm::ParameterSet& cfg, edm::ConsumesCollector& iC) { return TYPE(); }  \
        static void fillPSetDescription(edm::ParameterSetDescription& desc) {}                         \
      };                                                                                               \
    }                                                                                                  \
  }

#endif