LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
make_tool.h
Go to the documentation of this file.
1 #ifndef art_Utilities_make_tool_h
2 #define art_Utilities_make_tool_h
3 
7 #include "cetlib/BasicPluginFactory.h"
8 #include "cetlib/detail/wrapLibraryManagerException.h"
11 
12 namespace art {
13 
14  template <typename T>
16 
17  template <typename T>
20  {
21  cet::BasicPluginFactory factory{Suffixes::tool(), "makeTool"};
22  std::string const libspec{pset.get<std::string>("tool_type")};
23  tool_return_type<T> result;
24  try {
25  result = detail::tool_type<T>::make_plugin(factory, libspec, pset);
26  }
27  catch (cet::exception const& e) {
28  throw Exception(errors::Configuration, "make_tool: ", e)
29  << "Exception caught while processing plugin spec: " << libspec << '\n';
30  }
31  return result;
32  }
33 
34  template <typename T>
37  std::string const& function_tool_type)
38  {
39  cet::BasicPluginFactory factory{
40  Suffixes::tool(), "toolFunction", "toolType"};
41  std::string const libspec{pset.get<std::string>("tool_type")};
42  tool_return_type<T> result;
43  try {
45  factory, libspec, pset, function_tool_type);
46  }
47  catch (cet::exception const& e) {
48  throw Exception(errors::Configuration, "make_tool: ", e)
49  << "Exception caught while processing plugin spec: " << libspec << '\n';
50  }
51  return result;
52  }
53 
54  template <typename T, typename TableConfig>
56  make_tool(TableConfig const& tc)
57  {
58  return make_tool<T>(tc.get_PSet());
59  }
60 
61  template <typename T, typename TableConfig>
63  make_tool(TableConfig const& tc, std::string const& function_tool_type)
64  {
65  return make_tool<T>(tc.get_PSet(), function_tool_type);
66  }
67 }
68 
69 #endif /* art_Utilities_make_tool_h */
70 
71 // Local variables:
72 // mode: c++
73 // End:
std::enable_if_t< std::is_class< T >::value, tool_return_type< T > > make_tool(fhicl::ParameterSet const &pset)
Definition: make_tool.h:19
T get(std::string const &key) const
Definition: ParameterSet.h:231
static std::string const & tool()
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string value(boost::any const &)
HLT enums.
Float_t e
Definition: plot.C:34
typename detail::tool_type< T >::return_type tool_return_type
Definition: make_tool.h:15
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33