Line data Source code
1 : /**
2 : * @file DAQModule.cpp DAQModule class implementation
3 : *
4 : * This is part of the DUNE DAQ Application Framework, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #include "appfwk/DAQModule.hpp"
10 : #include "logging/Logging.hpp"
11 :
12 : #include <string>
13 : #include <vector>
14 :
15 : namespace dunedaq::appfwk {
16 :
17 : void
18 57 : DAQModule::execute_command(const std::string& cmd_name, const CommandData_t& data)
19 : {
20 57 : auto cmd = m_commands.find(cmd_name);
21 57 : if (cmd != m_commands.end()) {
22 56 : std::invoke(cmd->second, data);
23 52 : return;
24 : }
25 1 : throw UnknownCommand(ERS_HERE, get_name(), cmd_name);
26 : }
27 :
28 : std::vector<std::string>
29 2 : DAQModule::get_commands() const
30 : {
31 2 : std::vector<std::string> cmds;
32 6 : for (const auto& [key, value] : m_commands)
33 4 : cmds.push_back(key);
34 2 : return cmds;
35 0 : }
36 :
37 : bool
38 97 : DAQModule::has_command(const std::string& cmd_name) const
39 : {
40 97 : return m_commands.find(cmd_name) != m_commands.end();
41 : }
42 :
43 : } // namespace dunedaq::appfwk
|