Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-11 03:34:13

0001 //
0002 //  TransformerBase.h
0003 //  CMSSW
0004 //
0005 //  Created by Chris Jones on 6/02/22.
0006 //
0007 
0008 #ifndef FWCore_Framework_TransformerBase_h
0009 #define FWCore_Framework_TransformerBase_h
0010 
0011 #include "FWCore/Utilities/interface/EDPutToken.h"
0012 #include "FWCore/Utilities/interface/SoATuple.h"
0013 #include "FWCore/Utilities/interface/TypeID.h"
0014 #include "FWCore/Utilities/interface/ProductResolverIndex.h"
0015 
0016 #include <string>
0017 #include <functional>
0018 #include <memory>
0019 #include <any>
0020 
0021 namespace edm {
0022   class ProducerBase;
0023   class TypeID;
0024   class WrapperBase;
0025   class EventForTransformer;
0026   class BranchDescription;
0027   class ProductResolverIndexHelper;
0028   class ModuleDescription;
0029   class WaitingTaskWithArenaHolder;
0030   class WaitingTaskHolder;
0031   class ActivityRegistry;
0032 
0033   class TransformerBase {
0034   public:
0035     TransformerBase() = default;
0036     virtual ~TransformerBase() noexcept(false) = default;
0037 
0038   protected:
0039     //The function takes the WrapperBase corresponding to the data product from the EDPutToken
0040     // and returns the WrapperBase associated to the id and instanceName
0041     using TransformFunction = std::function<std::unique_ptr<edm::WrapperBase>(std::any)>;
0042     using PreTransformFunction = std::function<std::any(edm::WrapperBase const&, edm::WaitingTaskWithArenaHolder)>;
0043 
0044     void registerTransformImp(ProducerBase&, EDPutToken, const TypeID& id, std::string instanceName, TransformFunction);
0045     void registerTransformAsyncImp(
0046         ProducerBase&, EDPutToken, const TypeID& id, std::string instanceName, PreTransformFunction, TransformFunction);
0047 
0048     std::size_t findMatchingIndex(ProducerBase const& iBase, edm::BranchDescription const&) const noexcept;
0049     ProductResolverIndex prefetchImp(std::size_t iIndex) const noexcept {
0050       return transformInfo_.get<kResolverIndex>(iIndex);
0051     }
0052     void transformImpAsync(WaitingTaskHolder iTask,
0053                            std::size_t iIndex,
0054                            edm::ActivityRegistry* iAct,
0055                            ProducerBase const& iBase,
0056                            edm::EventForTransformer&) const noexcept;
0057 
0058     void extendUpdateLookup(ProducerBase const&,
0059                             ModuleDescription const& iModuleDesc,
0060                             ProductResolverIndexHelper const& iHelper);
0061 
0062   private:
0063     enum InfoColumns { kResolverIndex, kType, kToken, kPreTransform, kTransform };
0064     SoATuple<ProductResolverIndex, TypeID, EDPutToken, PreTransformFunction, TransformFunction> transformInfo_;
0065   };
0066 }  // namespace edm
0067 
0068 #endif /* TransformerBase_h */