Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-12-05 03:11:54

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;
0049     ProductResolverIndex prefetchImp(std::size_t iIndex) const { return transformInfo_.get<kResolverIndex>(iIndex); }
0050     void transformImpAsync(WaitingTaskHolder iTask,
0051                            std::size_t iIndex,
0052                            edm::ActivityRegistry* iAct,
0053                            ProducerBase const& iBase,
0054                            edm::EventForTransformer&) const;
0055 
0056     void extendUpdateLookup(ProducerBase const&,
0057                             ModuleDescription const& iModuleDesc,
0058                             ProductResolverIndexHelper const& iHelper);
0059 
0060   private:
0061     enum InfoColumns { kResolverIndex, kType, kToken, kPreTransform, kTransform };
0062     SoATuple<ProductResolverIndex, TypeID, EDPutToken, PreTransformFunction, TransformFunction> transformInfo_;
0063   };
0064 }  // namespace edm
0065 
0066 #endif /* TransformerBase_h */