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

Generated by: LCOV version 2.0-1