File indexing completed on 2025-02-26 04:25:18
0001 #include "DataFormats/TestObjects/interface/ThingWithDoNotSort.h"
0002 #include "DataFormats/TestObjects/interface/ThingWithPostInsert.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/global/EDProducer.h"
0005 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0008 #include "FWCore/Utilities/interface/EDPutToken.h"
0009
0010 namespace edmtest {
0011
0012 class PostInsertProducer : public edm::global::EDProducer<> {
0013 public:
0014 explicit PostInsertProducer(edm::ParameterSet const& ps);
0015
0016 void produce(edm::StreamID sid, edm::Event& event, edm::EventSetup const& es) const override;
0017
0018 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0019
0020 private:
0021 edm::EDPutTokenT<ThingWithPostInsert> putTokenPostInsert_;
0022 edm::EDPutTokenT<ThingWithDoNotSort> putTokenDoNotSort_;
0023 edm::EDPutTokenT<ThingWithPostInsert> emplaceTokenPostInsert_;
0024 edm::EDPutTokenT<ThingWithDoNotSort> emplaceTokenDoNotSort_;
0025 };
0026
0027 PostInsertProducer::PostInsertProducer(edm::ParameterSet const& iConfig)
0028 : putTokenPostInsert_{produces<ThingWithPostInsert>("put")},
0029 putTokenDoNotSort_{produces<ThingWithDoNotSort>("put")},
0030 emplaceTokenPostInsert_{produces<ThingWithPostInsert>("emplace")},
0031 emplaceTokenDoNotSort_{produces<ThingWithDoNotSort>("emplace")} {}
0032
0033
0034 void PostInsertProducer::produce(edm::StreamID sid, edm::Event& event, edm::EventSetup const& es) const {
0035 {
0036
0037 auto product = std::make_unique<ThingWithPostInsert>(42);
0038 assert(not product->valid());
0039 assert(product->value() == 42);
0040 auto handle = event.put(putTokenPostInsert_, std::move(product));
0041 assert(handle->valid());
0042 assert(handle->value() == 42);
0043 }
0044
0045 {
0046
0047
0048 auto product = std::make_unique<ThingWithDoNotSort>(42);
0049 assert(product->value() == 42);
0050 auto handle = event.put(putTokenDoNotSort_, std::move(product));
0051 assert(handle->value() == 42);
0052 }
0053
0054 {
0055
0056 ThingWithPostInsert product{42};
0057 assert(not product.valid());
0058 assert(product.value() == 42);
0059 auto handle = event.emplace(emplaceTokenPostInsert_, product);
0060 assert(handle->valid());
0061 assert(handle->value() == 42);
0062 }
0063
0064 {
0065
0066
0067 ThingWithDoNotSort product{42};
0068 assert(product.value() == 42);
0069 auto handle = event.emplace(emplaceTokenDoNotSort_, product);
0070 assert(handle->value() == 42);
0071 }
0072 }
0073
0074 void PostInsertProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0075 edm::ParameterSetDescription desc;
0076 descriptions.addWithDefaultLabel(desc);
0077 }
0078
0079 }
0080
0081 #include "FWCore/Framework/interface/MakerMacros.h"
0082 using edmtest::PostInsertProducer;
0083 DEFINE_FWK_MODULE(PostInsertProducer);