00001 #include "artdaq/TransferPlugins/MakeTransferPlugin.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::TransferInterface> 00012 MakeTransferPlugin(const fhicl::ParameterSet& pset, 00013 std::string plugin_label, 00014 TransferInterface::Role role) 00015 { 00016 static cet::BasicPluginFactory bpf("transfer", "make"); 00017 00018 fhicl::ParameterSet transfer_pset; 00019 00020 try 00021 { 00022 transfer_pset = pset.get<fhicl::ParameterSet>(plugin_label); 00023 } 00024 catch (...) 00025 { 00026 std::stringstream errmsg; 00027 errmsg 00028 << "Error in artdaq::MakeTransferPlugin: Unable to find the transfer plugin parameters in the FHiCL code \"" << transfer_pset.to_string() 00029 << "\"; FHiCL table with label \"" << plugin_label 00030 << "\" may not exist, or if it does, one or more parameters may be missing."; 00031 ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str()); 00032 } 00033 00034 try 00035 { 00036 auto transfer = 00037 bpf.makePlugin<std::unique_ptr<TransferInterface>, 00038 const fhicl::ParameterSet&, 00039 TransferInterface::Role>( 00040 transfer_pset.get<std::string>("transferPluginType"), 00041 transfer_pset, 00042 std::move(role)); 00043 00044 return std::move(transfer); 00045 } 00046 catch (...) 00047 { 00048 std::stringstream errmsg; 00049 errmsg 00050 << "Unable to create transfer plugin using the FHiCL parameters \"" 00051 << transfer_pset.to_string() 00052 << "\""; 00053 ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str()); 00054 } 00055 00056 return nullptr; 00057 } 00058 }