LCOV - code coverage report
Current view: top level - appmodel/src - ConfigObjectFactory.hpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 14 0
Test Date: 2026-03-29 15:29:34 Functions: 0.0 % 24 0

            Line data    Source code
       1              : /**
       2              :  * @file ConfigObjectFactory.hpp
       3              :  *
       4              :  * Define a helper class for SmartDaqApplication module generators
       5              :  *
       6              :  * This is part of the DUNE DAQ Software Suite, copyright 2023.
       7              :  * Licensing/copyright details are in the COPYING file that you should have
       8              :  * received with this code.
       9              :  */
      10              : #ifndef APPMODEL_INCLUDE_OBJECTFACTORY_HPP_
      11              : #define APPMODEL_INCLUDE_OBJECTFACTORY_HPP_
      12              : 
      13              : #include "appmodel/appmodelIssues.hpp"
      14              : #include "appmodel/NetworkConnectionDescriptor.hpp"
      15              : #include "appmodel/QueueDescriptor.hpp"
      16              : #include "appmodel/DataMoveCallbackDescriptor.hpp"
      17              : #include "appmodel/SmartDaqApplication.hpp"
      18              : 
      19              : #include "conffwk/ConfigObject.hpp"
      20              : #include "conffwk/Configuration.hpp"
      21              : 
      22              : #include "confmodel/DaqModule.hpp"
      23              : #include "confmodel/DetectorStream.hpp"
      24              : 
      25              : #include <cstdint>
      26              : #include <string>
      27              : #include <vector>
      28              : 
      29              : namespace dunedaq::appmodel {
      30              : 
      31              : class ConfigObjectFactory
      32              : {
      33              : 
      34              :   conffwk::Configuration* m_config;
      35              :   std::string m_dbfile;
      36              :   std::string m_app_uid;
      37              : 
      38              : public:
      39              :   explicit ConfigObjectFactory(const SmartDaqApplication* );
      40              : 
      41              :   ~ConfigObjectFactory();
      42              : 
      43              :   [[nodiscard]] conffwk::ConfigObject
      44              :   create(const std::string& class_name, const std::string& id) const;
      45              : 
      46              :   //---
      47              :   [[nodiscard]] conffwk::ConfigObject
      48            0 :   create_queue_obj(const QueueDescriptor* qdesc, std::string uid = "") const;
      49              : 
      50              :   //---
      51              :   [[nodiscard]] conffwk::ConfigObject
      52              :   create_queue_sid_obj(const QueueDescriptor* qdesc, uint32_t src_id) const;
      53              : 
      54              :   //---
      55              :   [[nodiscard]] conffwk::ConfigObject
      56              :   create_queue_sid_obj(const QueueDescriptor* qdesc, const confmodel::DetectorStream* stream) const;
      57              : 
      58              :   //---
      59              :   [[nodiscard]] conffwk::ConfigObject create_callback_sid_obj(const DataMoveCallbackDescriptor* cdesc,
      60              :                                                               uint32_t src_id) const;
      61              : 
      62              :   /**
      63              :    * \brief Helper function that gets a network connection config
      64              :    *
      65              :    * \param uid  Unique ID name of the config object
      66              :    * \param ndesc Network connection descriptor object
      67              :    *
      68              :    * \ret OKS configuration object for the network connection
      69              :    */
      70              :   [[nodiscard]] conffwk::ConfigObject
      71              :   create_net_obj(const NetworkConnectionDescriptor* ndesc, std::string uid) const;
      72              : 
      73              :   [[nodiscard]] conffwk::ConfigObject
      74              :   create_net_obj(const NetworkConnectionDescriptor* ndesc) const;
      75              : 
      76              :   template<class T>
      77            0 :   const T* get_dal(std::string uid) const {
      78            0 :     return m_config->get<T>(uid);
      79              :   }
      80              : 
      81              :   template<class T>
      82            0 :   const T* get_dal(conffwk::ConfigObject& obj) const {
      83            0 :     return m_config->get<T>(obj);
      84              :   }
      85              : 
      86              :   void
      87            0 :   update_modules(const std::vector<const confmodel::DaqModule*>& modules) {
      88            0 :     auto app = m_config->get<SmartDaqApplication>(m_app_uid);
      89            0 :     if (!app->get_modules().empty()) {
      90            0 :       throw (BadConf(ERS_HERE,
      91            0 :                      "SmartDaqApplication contains DaqModules which would be overwritten by generated DaqModules"));
      92              :     }
      93            0 :     if (!modules.empty()) {
      94            0 :       const_cast<SmartDaqApplication*>(app)->set_modules(modules);
      95            0 :       m_config->update<SmartDaqApplication>({m_app_uid}, {}, {});
      96              :     }
      97            0 :   }
      98              : 
      99              : };
     100              : 
     101              : } // namespace dunedaq::appmodel
     102              : 
     103              : #endif // APPMODEL_INCLUDE_OBJECTFACTORY_HPP_
        

Generated by: LCOV version 2.0-1