DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DAQModule.hxx
Go to the documentation of this file.
1
12namespace dunedaq::appfwk {
13
14template<typename Child>
15void
16DAQModule::register_command(const std::string& cmd_name, void (Child::*f)(const data_t&))
17{
18 using namespace std::placeholders;
19
20 bool done =
21 m_commands.emplace(cmd_name, std::bind(f, dynamic_cast<Child*>(this), _1)).second; // NOLINT(modernize-avoid-bind)
22 if (!done) {
23 // Throw here
24 throw CommandRegistrationFailed(ERS_HERE, get_name(), cmd_name);
25 }
26}
27
34inline std::shared_ptr<DAQModule>
35make_module(std::string const& plugin_name, std::string const& instance_name)
36{
37 static cet::BasicPluginFactory bpf("duneDAQModule", "make");
38
39 std::shared_ptr<DAQModule> mod_ptr;
40 try {
41 mod_ptr = bpf.makePlugin<std::shared_ptr<DAQModule>>(plugin_name, instance_name);
42 } catch (const cet::exception& cexpt) {
43 throw DAQModuleCreationFailed(ERS_HERE, plugin_name, instance_name, cexpt);
44 }
45 return mod_ptr;
46}
47} // namespace dunedaq::appfwk
#define ERS_HERE
std::shared_ptr< DAQModule > make_module(std::string const &plugin_name, std::string const &instance_name)
Load a DAQModule plugin and return a shared_ptr to the contained DAQModule class.
Definition DAQModule.hxx:35