CMS 3D CMS Logo

resolveMaker.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_interface_resolveMaker_h
2 #define FWCore_Framework_interface_resolveMaker_h
3 
6 
7 #include <memory>
8 #include <string>
9 
10 namespace edm::detail {
12  std::string const& modtype,
13  ModuleTypeResolverBase const* resolver);
14 
15  template <typename TFactory>
16  auto resolveMaker(std::string const& moduleType, ModuleTypeResolverBase const* resolver) {
17  if (resolver) {
18  auto index = resolver->kInitialIndex;
19  auto newType = moduleType;
20  do {
21  auto [ttype, tindex] = resolver->resolveType(std::move(newType), index);
22  newType = std::move(ttype);
23  index = tindex;
24  auto m = TFactory::get()->tryToCreate(newType);
25  if (m) {
26  return m;
27  }
28  } while (index != resolver->kLastIndex);
29  try {
30  //failed to find a plugin
31  return TFactory::get()->create(moduleType);
32  } catch (cms::Exception& iExcept) {
33  detail::annotateResolverMakerExceptionAndRethrow(iExcept, moduleType, resolver);
34  }
35  }
36  return TFactory::get()->create(moduleType);
37  }
38 } // namespace edm::detail
39 
40 #endif
static constexpr int kInitialIndex
void annotateResolverMakerExceptionAndRethrow(cms::Exception &except, std::string const &modtype, ModuleTypeResolverBase const *resolver)
Definition: resolverMaker.cc:4
auto resolveMaker(std::string const &moduleType, ModuleTypeResolverBase const *resolver)
Definition: resolveMaker.h:16
virtual std::pair< std::string, int > resolveType(std::string basename, int index) const =0
#define get
def move(src, dest)
Definition: eostools.py:511