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

            Line data    Source code
       1              : 
       2              : #include "ConfigObjectFactory.hpp"
       3              : #include "confmodel/Service.hpp"
       4              : #include "oks/file.hpp"
       5              : 
       6              : #include <fmt/core.h> // Replace with std::format when we switch to a newer compiler?
       7              : 
       8              : namespace dunedaq {
       9              : namespace appmodel {
      10              : 
      11            0 : ConfigObjectFactory::ConfigObjectFactory(const SmartDaqApplication* parent) :
      12            0 :     m_config(&parent->configuration()),
      13            0 :     m_dbfile(parent->config_object().contained_in()),
      14            0 :     m_app_uid(parent->UID()) {
      15              : 
      16              :     //FIXME: remove this hacky hack
      17            0 :     oks::OksFile::set_nolock_mode(true);
      18            0 : }
      19              : 
      20            0 : ConfigObjectFactory::~ConfigObjectFactory() {
      21              :     //FIXME: remove this hacky hack
      22            0 :     oks::OksFile::set_nolock_mode(false);
      23            0 : }
      24              : 
      25              : conffwk::ConfigObject
      26            0 : ConfigObjectFactory::create(const std::string& class_name,
      27              :                                      const std::string& id) const {
      28            0 :     conffwk::ConfigObject cfg_obj;
      29            0 :     m_config->create(m_dbfile, class_name, id, cfg_obj);
      30            0 :     return cfg_obj;
      31            0 : }
      32              : 
      33              : //---
      34              : conffwk::ConfigObject
      35            0 : ConfigObjectFactory::create_queue_obj(const QueueDescriptor* qdesc, std::string uid) const {
      36              : 
      37            0 :     std::string queue_uid(qdesc->get_uid_base() + uid);
      38            0 :     auto queue_obj = create("Queue", queue_uid);
      39            0 :     queue_obj.set_by_val<std::string>("data_type", qdesc->get_data_type());
      40            0 :     queue_obj.set_by_val<std::string>("queue_type", qdesc->get_queue_type());
      41            0 :     queue_obj.set_by_val<uint32_t>("capacity", qdesc->get_capacity());
      42              : 
      43            0 :     return queue_obj;
      44            0 : }
      45              : 
      46              : //---
      47              : conffwk::ConfigObject
      48            0 : ConfigObjectFactory::create_queue_sid_obj(const QueueDescriptor* qdesc, uint32_t src_id) const {
      49            0 :     std::string queue_uid(fmt::format("{}{}", qdesc->get_uid_base(), src_id));
      50            0 :     auto queue_obj = create("QueueWithSourceId", queue_uid);
      51              : 
      52            0 :     queue_obj.set_by_val<std::string>("data_type", qdesc->get_data_type());
      53            0 :     queue_obj.set_by_val<std::string>("queue_type", qdesc->get_queue_type());
      54            0 :     queue_obj.set_by_val<uint32_t>("capacity", qdesc->get_capacity());
      55            0 :     queue_obj.set_by_val<uint32_t>("source_id", src_id);
      56              : 
      57            0 :     return queue_obj;
      58            0 : }
      59              : 
      60              : //---
      61              : conffwk::ConfigObject
      62            0 : ConfigObjectFactory::create_queue_sid_obj(const QueueDescriptor* qdesc,
      63              :                                      const confmodel::DetectorStream* stream) const {
      64            0 : return create_queue_sid_obj(qdesc, stream->get_source_id());
      65              : }
      66              : 
      67              : //---
      68              : conffwk::ConfigObject
      69            0 : ConfigObjectFactory::create_callback_sid_obj(const DataMoveCallbackDescriptor* cdesc, uint32_t src_id) const
      70              : {
      71            0 :   std::string rdc_uid(fmt::format("{}{}", cdesc->get_uid_base(), src_id));
      72            0 :   auto rdc_obj = create("DataMoveCallbackConf", rdc_uid);
      73              : 
      74            0 :   rdc_obj.set_by_val<std::string>("data_type", cdesc->get_data_type());
      75            0 :   rdc_obj.set_by_val<uint32_t>("source_id", src_id);
      76              : 
      77            0 :   return rdc_obj;
      78            0 : }
      79              : //---
      80              : 
      81              : /**
      82              : * \brief Helper function that gets a network connection config
      83              : *
      84              : * \param uid  Unique ID name of the config object
      85              : * \param ndesc Network connection descriptor object
      86              : *
      87              : * \ret OKS configuration object for the network connection
      88              : */
      89              : conffwk::ConfigObject
      90            0 : ConfigObjectFactory::create_net_obj(const NetworkConnectionDescriptor* ndesc,
      91              :          std::string app_uid) const {
      92              : 
      93            0 :     auto svc_obj = ndesc->get_associated_service()->config_object();
      94            0 :     std::string net_id = ndesc->get_uid_base() + app_uid;
      95            0 :     auto net_obj = create("NetworkConnection", net_id);
      96              : 
      97            0 :     net_obj.set_by_val<std::string>("data_type", ndesc->get_data_type());
      98            0 :     net_obj.set_by_val<std::string>("connection_type", ndesc->get_connection_type());
      99            0 :     net_obj.set_by_val<uint32_t>("capacity", ndesc->get_capacity());
     100            0 :     net_obj.set_obj("associated_service", &svc_obj);
     101              : 
     102            0 :     return net_obj;
     103            0 : }
     104              : 
     105              : conffwk::ConfigObject
     106            0 : ConfigObjectFactory::create_net_obj(const NetworkConnectionDescriptor* ndesc) const {
     107            0 :     return create_net_obj(ndesc, this->m_app_uid);
     108              : }
     109              : 
     110              : } // namespace appmodel
     111              : } // namespace dunedaq
        

Generated by: LCOV version 2.0-1