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 if (!m_command_registration_allowed) {
19 throw CommandRegistrationFailedMessage(
20 ERS_HERE, get_name(), cmd_name, "Registering commands is not allowed at this time");
21 }
22 using namespace std::placeholders;
23
24 bool done =
25 m_commands.emplace(cmd_name, std::bind(f, dynamic_cast<Child*>(this), _1)).second; // NOLINT(modernize-avoid-bind)
26 if (!done) {
27 // Throw here
28 throw CommandRegistrationFailedMessage(
29 ERS_HERE, get_name(), cmd_name, "Emplacing command in command map failed, possible duplicate registration");
30 }
31}
32
39inline std::shared_ptr<DAQModule>
40make_module(std::string const& plugin_name, std::string const& instance_name)
41{
42 static cet::BasicPluginFactory bpf("duneDAQModule", "make");
43
44 std::shared_ptr<DAQModule> mod_ptr;
45 try {
46 mod_ptr = bpf.makePlugin<std::shared_ptr<DAQModule>>(plugin_name, instance_name);
47 } catch (const cet::exception& cexpt) {
48 throw DAQModuleCreationFailed(ERS_HERE, plugin_name, instance_name, cexpt);
49 }
50 return mod_ptr;
51}
52} // 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:40