artdaq  v3_01_00
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 {
11  std::unique_ptr<artdaq::TransferInterface>
12  MakeTransferPlugin(const fhicl::ParameterSet& pset,
13  std::string plugin_label,
15  {
16  static cet::BasicPluginFactory bpf("transfer", "make");
17 
18  fhicl::ParameterSet transfer_pset;
19 
20  try
21  {
22  transfer_pset = pset.get<fhicl::ParameterSet>(plugin_label);
23  }
24  catch (...)
25  {
26  std::stringstream errmsg;
27  errmsg
28  << "Error in artdaq::MakeTransferPlugin: Unable to find the transfer plugin parameters in the FHiCL code \"" << transfer_pset.to_string()
29  << "\"; FHiCL table with label \"" << plugin_label
30  << "\" may not exist, or if it does, one or more parameters may be missing.";
31  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
32  }
33 
34  try
35  {
36  auto transfer =
37  bpf.makePlugin<std::unique_ptr<TransferInterface>,
38  const fhicl::ParameterSet&,
40  transfer_pset.get<std::string>("transferPluginType"),
41  transfer_pset,
42  std::move(role));
43 
44  return transfer;
45  }
46  catch (...)
47  {
48  std::stringstream errmsg;
49  errmsg
50  << "Unable to create transfer plugin using the FHiCL parameters \""
51  << transfer_pset.to_string()
52  << "\"";
53  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
54  }
55 
56  return nullptr;
57  }
58 }
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.