00001 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh"
00002 #include "artdaq-core/Utilities/ExceptionHandler.hh"
00003
00004 #include "cetlib/BasicPluginFactory.h"
00005 #include "fhiclcpp/ParameterSet.h"
00006
00007 #include <sstream>
00008
00009 namespace artdaq
00010 {
00011 std::unique_ptr<artdaq::CommanderInterface>
00012 MakeCommanderPlugin(const fhicl::ParameterSet& commander_pset,
00013 artdaq::Commandable& commandable)
00014 {
00015 static cet::BasicPluginFactory bpf("commander", "make");
00016
00017 try
00018 {
00019 auto commander =
00020 bpf.makePlugin<std::unique_ptr<CommanderInterface>,
00021 const fhicl::ParameterSet&,
00022 artdaq::Commandable&>(
00023 commander_pset.get<std::string>("commanderPluginType"),
00024 commander_pset,
00025 commandable);
00026
00027 return commander;
00028 }
00029 catch (...)
00030 {
00031 std::stringstream errmsg;
00032 errmsg
00033 << "Unable to create commander plugin using the FHiCL parameters \""
00034 << commander_pset.to_string()
00035 << "\"";
00036 ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
00037 }
00038
00039 return nullptr;
00040 }
00041 }