Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-09-16 00:05:35

0001 #ifndef FWCore_Framework_interface_resolveMaker_h
0002 #define FWCore_Framework_interface_resolveMaker_h
0003 
0004 #include "FWCore/Framework/interface/ModuleTypeResolverBase.h"
0005 #include "FWCore/Utilities/interface/Exception.h"
0006 
0007 #include <memory>
0008 #include <string>
0009 
0010 namespace edm::detail {
0011   void annotateResolverMakerExceptionAndRethrow(cms::Exception& except,
0012                                                 std::string const& modtype,
0013                                                 ModuleTypeResolverBase const* resolver);
0014 
0015   template <typename TFactory>
0016   auto resolveMaker(std::string const& moduleType, ModuleTypeResolverBase const* resolver) {
0017     if (resolver) {
0018       auto index = resolver->kInitialIndex;
0019       auto newType = moduleType;
0020       do {
0021         auto [ttype, tindex] = resolver->resolveType(std::move(newType), index);
0022         newType = std::move(ttype);
0023         index = tindex;
0024         auto m = TFactory::get()->tryToCreate(newType);
0025         if (m) {
0026           return m;
0027         }
0028       } while (index != resolver->kLastIndex);
0029       try {
0030         //failed to find a plugin
0031         return TFactory::get()->create(moduleType);
0032       } catch (cms::Exception& iExcept) {
0033         detail::annotateResolverMakerExceptionAndRethrow(iExcept, moduleType, resolver);
0034       }
0035     }
0036     return TFactory::get()->create(moduleType);
0037   }
0038 }  // namespace edm::detail
0039 
0040 #endif