artdaq  v3_04_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 {
11  std::unique_ptr<artdaq::CommanderInterface>
12  MakeCommanderPlugin(const fhicl::ParameterSet& commander_pset,
13  artdaq::Commandable& commandable)
14  {
15  static cet::BasicPluginFactory bpf("commander", "make");
16 
17  try
18  {
19  auto commander =
20  bpf.makePlugin<std::unique_ptr<CommanderInterface>,
21  const fhicl::ParameterSet&,
23  commander_pset.get<std::string>("commanderPluginType"),
24  commander_pset,
25  commandable);
26 
27  return commander;
28  }
29  catch (...)
30  {
31  std::stringstream errmsg;
32  errmsg
33  << "Unable to create commander plugin using the FHiCL parameters \""
34  << commander_pset.to_string()
35  << "\"";
36  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
37  }
38 
39  return nullptr;
40  }
41 }
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.