Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-18 22:30:21

0001 #include "FWCore/Framework/interface/ProcessBlock.h"
0002 #include "FWCore/Framework/interface/ProcessBlockPrincipal.h"
0003 #include "FWCore/Framework/interface/ProductPutterBase.h"
0004 
0005 namespace edm {
0006 
0007   ProcessBlock::ProcessBlock(ProcessBlockPrincipal const& pbp,
0008                              ModuleDescription const& md,
0009                              ModuleCallingContext const* moduleCallingContext,
0010                              bool isAtEnd)
0011       : provRecorder_(pbp, md, isAtEnd), moduleCallingContext_(moduleCallingContext) {}
0012 
0013   void ProcessBlock::setProducer(ProducerBase const* iProducer) {
0014     provRecorder_.setProducer(iProducer);
0015     //set appropriate size
0016     putProducts_.resize(provRecorder_.putTokenIndexToProductResolverIndex().size());
0017   }
0018 
0019   ProcessBlock::CacheIdentifier_t ProcessBlock::cacheIdentifier() const {
0020     return processBlockPrincipal().cacheIdentifier();
0021   }
0022 
0023   std::string const& ProcessBlock::processName() const { return processBlockPrincipal().processName(); }
0024 
0025   ProcessBlockPrincipal const& ProcessBlock::processBlockPrincipal() const {
0026     return dynamic_cast<ProcessBlockPrincipal const&>(provRecorder_.principal());
0027   }
0028 
0029   void ProcessBlock::commit_(std::vector<edm::ProductResolverIndex> const& iShouldPut) {
0030     ProcessBlockPrincipal const& pbp = processBlockPrincipal();
0031     size_t nPut = 0;
0032     for (size_t i = 0; i < putProducts().size(); ++i) {
0033       auto& product = get_underlying_safe(putProducts()[i]);
0034       if (product) {
0035         pbp.put(provRecorder_.putTokenIndexToProductResolverIndex()[i], std::move(product));
0036         ++nPut;
0037       }
0038     }
0039 
0040     auto sz = iShouldPut.size();
0041     if (sz != 0 and sz != nPut) {
0042       //some were missed
0043       auto& principal = provRecorder_.principal();
0044       for (auto index : iShouldPut) {
0045         auto resolver = principal.getProductResolverByIndex(index);
0046         if (not resolver->productResolved() and isEndTransition(provRecorder_.transition()) ==
0047                                                     resolver->branchDescription().availableOnlyAtEndTransition()) {
0048           dynamic_cast<ProductPutterBase const*>(resolver)->putProduct(std::unique_ptr<WrapperBase>());
0049         }
0050       }
0051     }
0052 
0053     // the cleanup is all or none
0054     putProducts().clear();
0055   }
0056 
0057 }  // namespace edm