LCOV - code coverage report
Current view: top level - appfwk/include/appfwk/detail - DAQModule.hxx (source / functions) Coverage Total Hit
Test: code.result Lines: 100.0 % 20 20
Test Date: 2025-12-21 13:07:08 Functions: 21.6 % 51 11

            Line data    Source code
       1              : /**
       2              :  * @file DAQModule.hxx DAQModule Inline Method Definitions
       3              :  *
       4              :  * N.B. register_command is defined here as it is a template method, and must be visible so that the compiler can
       5              :  * generate type-specific implementations as needed. make_module is a free function in the appfwk namespace, defined
       6              :  * here to reduce the clutter in DAQModule.hpp
       7              :  *
       8              :  * This is part of the DUNE DAQ Application Framework, copyright 2020.
       9              :  * Licensing/copyright details are in the COPYING file that you should have received with this code.
      10              :  */
      11              : 
      12              : namespace dunedaq::appfwk {
      13              : 
      14              : template<typename Child>
      15              : void
      16           95 : DAQModule::register_command(const std::string& cmd_name, void (Child::*f)(const CommandData_t&))
      17              : {
      18           95 :   if (!m_command_registration_allowed) {
      19            3 :     throw CommandRegistrationFailedMessage(
      20            2 :       ERS_HERE, get_name(), cmd_name, "Registering commands is not allowed at this time");
      21              :   }
      22              :   using namespace std::placeholders;
      23              : 
      24           94 :   bool done =
      25           94 :     m_commands.emplace(cmd_name, std::bind(f, dynamic_cast<Child*>(this), _1)).second; // NOLINT(modernize-avoid-bind)
      26           94 :   if (!done) {
      27              :     // Throw here
      28            3 :     throw CommandRegistrationFailedMessage(
      29            2 :       ERS_HERE, get_name(), cmd_name, "Emplacing command in command map failed, possible duplicate registration");
      30              :   }
      31           93 : }
      32              : 
      33              : /**
      34              :  * @brief Load a DAQModule plugin and return a shared_ptr to the contained DAQModule class
      35              :  * @param plugin_name Name of the plugin, e.g. DebugLoggingDAQModule
      36              :  * @param instance_name Name of the returned DAQModule instance, e.g. DebugLogger1
      37              :  * @return shared_ptr to created DAQModule instance
      38              :  */
      39              : inline std::shared_ptr<DAQModule>
      40           36 : make_module(std::string const& plugin_name, std::string const& instance_name)
      41              : {
      42           36 :   static cet::BasicPluginFactory bpf("duneDAQModule", "make");
      43              : 
      44           36 :   std::shared_ptr<DAQModule> mod_ptr;
      45           36 :   try {
      46           36 :     mod_ptr = bpf.makePlugin<std::shared_ptr<DAQModule>>(plugin_name, instance_name);
      47            1 :   } catch (const cet::exception& cexpt) {
      48            1 :     throw DAQModuleCreationFailed(ERS_HERE, plugin_name, instance_name, cexpt);
      49            1 :   }
      50           35 :   return mod_ptr;
      51            1 : }
      52              : } // namespace dunedaq::appfwk
        

Generated by: LCOV version 2.0-1