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