LCOV - code coverage report
Current view: top level - conffwk/test/apps - conffwk_check_inheritance.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 56 0
Test Date: 2026-10-11 15:05:20 Functions: 0.0 % 2 0

            Line data    Source code
       1              : #include "CLI/CLI.hpp"
       2              : #include <fmt/core.h>
       3              : #include <fmt/ranges.h>
       4              : 
       5              : #include "conffwk/Configuration.hpp"
       6              : #include "conffwk/DalFactory.hpp"
       7              : #include "conffwk/Schema.hpp"
       8              : 
       9              : std::deque<std::set<std::string>>
      10            0 : construct_class_domains(dunedaq::conffwk::Configuration& cfg_db)
      11              : {
      12              : 
      13            0 :   std::deque<std::set<std::string>> domains;
      14              : 
      15            0 :   std::deque<dunedaq::conffwk::class_t> progenitors;
      16            0 :   for (const auto& c : cfg_db.get_class_list()) {
      17            0 :     auto ci = cfg_db.get_class_info(c);
      18            0 :     if (ci.p_superclasses.empty())
      19            0 :       progenitors.push_back(ci);
      20              :     // fmt::print("   - {} {}\n", c, ci.p_superclasses.size(), ci.p_superclasses.size());
      21            0 :   }
      22              : 
      23            0 :   for (const auto& ci : progenitors) {
      24              :     // Make a candidate cluster based using the seed subclasses
      25            0 :     std::set<std::string> class_cluster;
      26            0 :     class_cluster.insert(ci.p_name);
      27            0 :     class_cluster.insert(ci.p_subclasses.begin(), ci.p_subclasses.end());
      28              : 
      29              :     // Look for overlaps with other domains
      30            0 :     std::deque<std::set<std::string>> overlapping;
      31            0 :     for (auto& dom : domains) {
      32            0 :       std::set<std::string> intersection;
      33            0 :       std::set_intersection(dom.begin(),
      34              :                             dom.end(),
      35              :                             class_cluster.begin(),
      36              :                             class_cluster.end(),
      37              :                             std::inserter(intersection, intersection.begin()));
      38              :       // non-zero intersection, overlap found
      39            0 :       if (intersection.size() > 0) {
      40            0 :         overlapping.push_back(dom);
      41              :       }
      42            0 :     }
      43              : 
      44              :     // If overlapping are found, merge all overlapping domains
      45            0 :     if (!overlapping.empty()) {
      46            0 :       for (auto& dom : overlapping) {
      47              :         // merge the existing cluster in class_cluster
      48            0 :         class_cluster.insert(dom.begin(), dom.end());
      49              :         // Remove the old cluster from the list
      50            0 :         auto it = std::find(domains.begin(), domains.end(), dom);
      51            0 :         if (it != domains.end()) {
      52            0 :           domains.erase(it);
      53              :         }
      54              :       }
      55              :     }
      56              : 
      57            0 :     domains.push_back(class_cluster);
      58            0 :   }
      59              : 
      60            0 :   return domains;
      61            0 : }
      62              : 
      63              : int
      64            0 : main(int argc, char const* argv[])
      65              : {
      66            0 :   using namespace dunedaq;
      67              : 
      68            0 :   CLI::App app{ "App description" };
      69              : 
      70            0 :   std::string file;
      71            0 :   app.add_option("-f,--file", file, "Schema file")->required()->check(CLI::ExistingFile);
      72              : 
      73            0 :   CLI11_PARSE(app, argc, argv);
      74              : 
      75            0 :   fmt::print("Configuration database file: {}\n", file);
      76              : 
      77            0 :   conffwk::Configuration db("oksconflibs:" + file);
      78              : 
      79            0 :   std::deque<std::set<std::string>> domains = construct_class_domains(db);
      80              : 
      81            0 :   std::map<std::string, uint> class_domain_map;
      82            0 :   conffwk::fmap<uint> class_domain_map_2;
      83              :   // Print the clustered domains
      84            0 :   fmt::print("Found {} inheritance domains\n", domains.size());
      85            0 :   for (size_t i(0); i < domains.size(); ++i) {
      86            0 :     const auto& dom = domains[i];
      87            0 :     fmt::print("   - {} : {}", i, fmt::join(dom, ","));
      88              :     // fmt::print("   - {} : {}", i, dom);
      89            0 :     for (const auto& class_name : dom) {
      90            0 :       class_domain_map[class_name] = i;
      91            0 :       class_domain_map_2[&conffwk::DalFactory::instance().get_known_class_name_ref(class_name)] = i;
      92              :     }
      93            0 :     fmt::print("\n");
      94              :   }
      95              : 
      96            0 :   for (const auto& [name, id] : class_domain_map) {
      97            0 :     fmt::print("- {} : {}\n", name, id);
      98              :   }
      99              : 
     100            0 :   fmt::print("-------------------\n");
     101            0 :   fmt::print("cdm2 {}\n", class_domain_map_2.size());
     102              : 
     103            0 :   for (const auto& [name, id] : class_domain_map_2) {
     104            0 :     fmt::print("+ {} : {}\n", *name, id);
     105              :   }
     106              : 
     107              :   /* code */
     108            0 :   return 0;
     109            0 : }
        

Generated by: LCOV version 2.0-1