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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
// -*- C++ -*-
//
// Package:    __subsys__/__pkgname__
// Class:      __class__
//
/**\class __class__

 Description: [one line class summary]

 Implementation:
     [Notes on implementation]
*/
//
// Original Author:  __author__
//         Created:  __date__
//
//

// PLEASE DELETE COMMENTS THAT THE SKELETON METHOD (mkesprod)
// GENERATES THAT ARE NOT USEFUL FOR LONG TERM CODE MAINTENANCE
// AND UNDERSTANDING. (For example, please delete this comment)

// system include files
#include <memory>

// user include files
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESProducer.h"

#include "FWCore/Framework/interface/ESHandle.h"

#python_begin
    if  len(__datatypes__) > 1:
        print('#include "FWCore/Framework/interface/ESProducts.h"')
#python_end

// Need to add #include statements for definitions of
// the data type and record type here

//
// class declaration
//

class __class__ : public edm::ESProducer {
public:
  __class__(const edm::ParameterSet&);
  ~__class__() override;

#python_begin
    if  len(__datatypes__) > 1:
        datatypes = []
        for dtype in __datatypes__:
            datatypes.append("std::unique_ptr<%s>" % dtype)
        print("  using ReturnType = edm::ESProducts<%s>;" % ', '.join(datatypes))
    elif len(__datatypes__) == 1:
        print("  using ReturnType = std::unique_ptr<%s>;" % __datatypes__[0])
#python_end

  ReturnType produce(const __record__&);

private:
  // ----------member data ---------------------------
};

//
// constants, enums and typedefs
//

//
// static data member definitions
//

//
// constructors and destructor
//
__class__::__class__(const edm::ParameterSet& iConfig) {
  //the following line is needed to tell the framework what
  // data is being produced
  setWhatProduced(this);

  //now do what ever other initialization is needed
}

__class__::~__class__() {
  // do anything here that needs to be done at destruction time
  // (e.g. close files, deallocate resources etc.)
}

//
// member functions
//

// ------------ method called to produce the data  ------------
__class__::ReturnType __class__::produce(const __record__& iRecord) {
  // You can add arguments to the make_unique function call
  // and they will be forwarded to the constructor of the
  // data object. Also you can call functions that modify
  // the data object after creating it. Often, before this
  // you will retrieve data from the EventSetup through the
  // record.
#python_begin
    if  len(__datatypes__) > 1:
        out1 = []
        out2 = []
        i = 1
        for dtype in __datatypes__:
            out1.append("  auto p%s = std::make_unique<%s>();" % (i, dtype))
            out2.append("std::move(p%s)" % i)
            i = i + 1
        output  = '\n'.join(out1)
        output += "\n  return edm::es::products(%s);" % ', '.join(out2)
        print(output)
    elif len(__datatypes__) == 1:
        print("  auto product = std::make_unique<%s>();" % __datatypes__[0])
        print("  return product;")
#python_end
}

//define this as a plug-in
DEFINE_FWK_EVENTSETUP_MODULE(__class__);