artdaq  v3_07_02
MakeTransferPlugin.cc
1 #include "artdaq/TransferPlugins/MakeTransferPlugin.hh"
2 #include "artdaq-core/Utilities/ExceptionHandler.hh"
3 
4 #include "cetlib/BasicPluginFactory.h"
5 #include "fhiclcpp/ParameterSet.h"
6 
7 #include <sstream>
8 
9 namespace artdaq {
10 std::unique_ptr<artdaq::TransferInterface>
11 MakeTransferPlugin(const fhicl::ParameterSet& pset,
12  std::string plugin_label,
14 {
15  static cet::BasicPluginFactory bpf("transfer", "make");
16 
17  fhicl::ParameterSet transfer_pset;
18 
19  try
20  {
21  transfer_pset = pset.get<fhicl::ParameterSet>(plugin_label);
22  }
23  catch (...)
24  {
25  std::stringstream errmsg;
26  errmsg
27  << "Error in artdaq::MakeTransferPlugin: Unable to find the transfer plugin parameters in the FHiCL code \"" << transfer_pset.to_string()
28  << "\"; FHiCL table with label \"" << plugin_label
29  << "\" may not exist, or if it does, one or more parameters may be missing.";
30  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
31  }
32 
33  try
34  {
35  auto transfer =
36  bpf.makePlugin<std::unique_ptr<TransferInterface>,
37  const fhicl::ParameterSet&,
39  transfer_pset.get<std::string>("transferPluginType"),
40  transfer_pset,
41  std::move(role));
42 
43  return transfer;
44  }
45  catch (...)
46  {
47  std::stringstream errmsg;
48  errmsg
49  << "Unable to create transfer plugin using the FHiCL parameters \""
50  << transfer_pset.to_string()
51  << "\"";
52  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
53  }
54 
55  return nullptr;
56 }
57 } // namespace artdaq
std::unique_ptr< artdaq::TransferInterface > MakeTransferPlugin(const fhicl::ParameterSet &pset, std::string plugin_label, TransferInterface::Role role)
Load a TransferInterface plugin.
Role
Used to determine if a TransferInterface is a Sender or Receiver.