LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
ModuleFactory.cc
Go to the documentation of this file.
2 
7 #include "cetlib/detail/wrapLibraryManagerException.h"
8 
10 art::detail::ModuleFactory::moduleType(std::string const& libspec)
11 {
12  ModuleTypeFunc_t* symbol = nullptr;
13  try {
14  lm_.getSymbolByLibspec(libspec, "moduleType", symbol);
15  }
16  catch (art::Exception& e) {
17  cet::detail::wrapLibraryManagerException(
18  e, "Module", libspec, getReleaseVersion());
19  }
20  if (symbol == nullptr) {
21  throw art::Exception(errors::Configuration, "BadPluginLibrary")
22  << "Module " << libspec << " with version " << getReleaseVersion()
23  << " has internal symbol definition problems: consult an expert.";
24  }
25  return symbol();
26 }
27 
28 std::unique_ptr<art::Worker>
30  ModuleDescription const& md)
31 {
32  auto const& libspec = p.pset_.get<std::string>("module_type");
33  WorkerMaker_t* symbol = nullptr;
34  try {
35  lm_.getSymbolByLibspec(libspec, "make_worker", symbol);
36  }
37  catch (art::Exception& e) {
38  cet::detail::wrapLibraryManagerException(
39  e, "Module", libspec, getReleaseVersion());
40  }
41  if (symbol == nullptr) {
42  throw art::Exception(errors::Configuration, "BadPluginLibrary: ")
43  << "Module " << libspec << " with version " << getReleaseVersion()
44  << " has internal symbol definition problems: consult an expert.";
45  }
46  return std::unique_ptr<Worker>(symbol(p, md));
47 } // makeWorker()
48 
49 // ======================================================================
ModuleType moduleType(std::string const &libspec)
Worker *(WorkerParams const &, ModuleDescription const &) WorkerMaker_t
Definition: ModuleMacros.h:36
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::string const & getReleaseVersion()
ModuleType( ModuleTypeFunc_t)
Definition: ModuleMacros.h:37
fhicl::ParameterSet const pset_
Definition: WorkerParams.h:25
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::unique_ptr< Worker > makeWorker(WorkerParams const &wp, ModuleDescription const &md)
Float_t e
Definition: plot.C:34
cet::LibraryManager lm_
Definition: ModuleFactory.h:39
ModuleType
Definition: ModuleType.h:22