artdaq  v3_09_00
MakeCommanderPlugin.cc
1 #include "artdaq/ExternalComms/MakeCommanderPlugin.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::CommanderInterface>
11 MakeCommanderPlugin(const fhicl::ParameterSet& commander_pset,
12  artdaq::Commandable& commandable)
13 {
14  static cet::BasicPluginFactory bpf("commander", "make");
15 
16  try
17  {
18  auto commander =
19  bpf.makePlugin<std::unique_ptr<CommanderInterface>,
20  const fhicl::ParameterSet&,
22  commander_pset.get<std::string>("commanderPluginType"),
23  commander_pset,
24  commandable);
25 
26  return commander;
27  }
28  catch (...)
29  {
30  std::stringstream errmsg;
31  errmsg
32  << "Unable to create commander plugin using the FHiCL parameters \""
33  << commander_pset.to_string()
34  << "\"";
35  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
36  }
37 
38  return nullptr;
39 }
40 } // namespace artdaq
Commandable is the base class for all artdaq components which implement the artdaq state machine...
Definition: Commandable.hh:20
std::unique_ptr< artdaq::CommanderInterface > MakeCommanderPlugin(const fhicl::ParameterSet &commander_pset, artdaq::Commandable &commandable)
Load a CommanderInterface plugin.