|
||||
File indexing completed on 2024-10-07 04:59:29
0001 // -*- C++ -*- 0002 #ifndef Framework_ESProductResolverFactoryProducer_h 0003 #define Framework_ESProductResolverFactoryProducer_h 0004 // 0005 // Package: Framework 0006 // Class : ESProductResolverFactoryProducer 0007 // 0008 /**\class edm::ESProductResolverFactoryProducer 0009 0010 Description: An EventSetup algorithmic Provider that manages Factories of Resolvers 0011 0012 Usage: 0013 This class is used when the algorithms in the EventSetup that are to be run on demand are encapsulated 0014 in edm::eventsetup::ProductResolvers's. This 'design pattern' is more flexible than having the algorithm embedded 0015 directly in the Provider (see ESProducer for such an implemenation). 0016 0017 Users inherit from this class and then call the 'registerFactory' method in their class' constructor 0018 in order to get their Resolvers registered. For most users, the already available templated Factory classes 0019 should suffice and therefore they should not need to create their own Factories. 0020 0021 Example: register one Factory that creates a resolver that takes no arguments 0022 \code 0023 class FooResolver : public edm::eventsetup::ESProductResolver { ... }; 0024 class FooProd : public edm::ESProductResolverFactoryProducer { ... }; 0025 0026 FooProd::FooProd(const edm::ParameterSet&) { 0027 typedef edm::eventsetup::ESProductResolverFactoryTemplate<FooResolver> > TYPE; 0028 registerFactory(std::make_unique<TYPE>(); 0029 }; 0030 0031 \endcode 0032 0033 Example: register one Factory that creates a resolver that takes one argument 0034 \code 0035 class BarResolver : public edm::eventsetup::ESProductResolver { ... 0036 BarResolver(const edm::ParameterSet&) ; 0037 ... }; 0038 class BarProd : public edm::ESProductResolverFactoryProducer { ... }; 0039 0040 BarProd::BarProd(const edm::ParameterSet& iPS) { 0041 typedef edm::eventsetup::ESProductResolverArgumentFactoryTemplate<BarResolver, edm::ParmeterSet> TYPE; 0042 registerFactory(std::make_unique<TYPE>(iPS); 0043 }; 0044 0045 \endcode 0046 0047 */ 0048 // 0049 // Author: Chris Jones 0050 // Created: Thu Apr 7 17:14:58 CDT 2005 0051 // 0052 0053 // system include files 0054 #include <map> 0055 #include <memory> 0056 #include <string> 0057 0058 // user include files 0059 0060 // forward declarations 0061 #include "FWCore/Framework/interface/ESProductResolverProvider.h" 0062 #include "FWCore/Utilities/interface/propagate_const.h" 0063 0064 namespace edm { 0065 namespace eventsetup { 0066 class ESProductResolverFactoryBase; 0067 0068 struct FactoryInfo { 0069 FactoryInfo() : key_(), factory_() {} 0070 FactoryInfo(const DataKey& iKey, std::shared_ptr<ESProductResolverFactoryBase> iFactory) 0071 : key_(iKey), factory_(iFactory) {} 0072 DataKey key_; 0073 edm::propagate_const<std::shared_ptr<ESProductResolverFactoryBase>> factory_; 0074 }; 0075 } // namespace eventsetup 0076 0077 class ESProductResolverFactoryProducer : public eventsetup::ESProductResolverProvider { 0078 public: 0079 ESProductResolverFactoryProducer(); 0080 0081 ESProductResolverFactoryProducer(const ESProductResolverFactoryProducer&) = delete; 0082 const ESProductResolverFactoryProducer& operator=(const ESProductResolverFactoryProducer&) = delete; 0083 0084 ~ESProductResolverFactoryProducer() noexcept(false) override; 0085 0086 protected: 0087 using EventSetupRecordKey = eventsetup::EventSetupRecordKey; 0088 0089 KeyedResolversVector registerResolvers(const EventSetupRecordKey&, unsigned int iovIndex) override; 0090 0091 /** \param iFactory unique_ptr holding a new instance of a Factory 0092 \param iLabel extra string label used to get data (optional) 0093 Producer takes ownership of the Factory and uses it create the appropriate 0094 Resolver which is then registered with the EventSetup. If used, this method should 0095 be called in inheriting class' constructor. 0096 */ 0097 template <class TFactory> 0098 void registerFactory(std::unique_ptr<TFactory> iFactory, const std::string& iLabel = std::string()) { 0099 std::unique_ptr<eventsetup::ESProductResolverFactoryBase> temp(iFactory.release()); 0100 registerFactoryWithKey(EventSetupRecordKey::makeKey<typename TFactory::RecordType>(), std::move(temp), iLabel); 0101 } 0102 0103 virtual void registerFactoryWithKey(const EventSetupRecordKey& iRecord, 0104 std::unique_ptr<eventsetup::ESProductResolverFactoryBase> iFactory, 0105 const std::string& iLabel = std::string()); 0106 0107 private: 0108 // ---------- member data -------------------------------- 0109 std::multimap<EventSetupRecordKey, eventsetup::FactoryInfo> record2Factories_; 0110 }; 0111 0112 } // namespace edm 0113 0114 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.2.1 LXR engine. The LXR team |