LCOV - code coverage report
Current view: top level - oksdalgen/apps - class_info.hpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 26 0
Test Date: 2026-10-11 15:05:20 Functions: 0.0 % 8 0

            Line data    Source code
       1              : //
       2              : // DUNE DAQ modification notice:
       3              : // This file has been modified from the original ATLAS genconfig source for the DUNE DAQ project.
       4              : // Fork baseline commit: genconfig-03-10-00 (2021-04-26).
       5              : // Renamed since fork: yes (from src/class_info.h to apps/class_info.hpp).
       6              : //
       7              : 
       8              : #ifndef __OKSDALGEN_CLASS_INFO__
       9              : #define __OKSDALGEN_CLASS_INFO__
      10              : 
      11              : #include "oks/class.hpp"
      12              : 
      13              : #include <map>
      14              : #include <ostream>
      15              : #include <set>
      16              : #include <string>
      17              : 
      18              : namespace dunedaq {
      19              : namespace oksdalgen {
      20              : 
      21              : class ClassInfo
      22              : {
      23              : 
      24              : public:
      25              :   struct SortByName
      26              :   {
      27            0 :     bool operator()(const oks::OksClass* c1, const oks::OksClass* c2) const { return c1->get_name() < c2->get_name(); }
      28              :   };
      29              : 
      30              :   typedef std::map<const oks::OksClass*, ClassInfo, SortByName> Map;
      31              : 
      32            0 :   ClassInfo() {};
      33              : 
      34            0 :   ClassInfo(const std::string& cpp_ns_name, const std::string& dir_prefix)
      35            0 :     : p_namespace(cpp_ns_name)
      36            0 :     , p_include_prefix(dir_prefix) {};
      37              : 
      38            0 :   const std::string& get_namespace() const { return p_namespace; }
      39            0 :   const std::string& get_include_prefix() const { return p_include_prefix; }
      40              : 
      41              : private:
      42              :   std::string p_namespace;
      43              :   std::string p_include_prefix;
      44              : };
      45              : 
      46              : struct NameSpaceInfo
      47              : {
      48              :   std::set<std::string> m_classes;
      49              :   std::map<std::string, NameSpaceInfo> m_nested;
      50              : 
      51            0 :   bool empty() const { return (m_classes.empty() && m_nested.empty()); }
      52              : 
      53            0 :   void add(const std::string& ns_name, const std::string& class_name)
      54              :   {
      55            0 :     if (!ns_name.empty()) {
      56            0 :       std::string::size_type idx = ns_name.find_first_of(':');
      57            0 :       NameSpaceInfo& ns = m_nested[ns_name.substr(0, idx)];
      58            0 :       if (idx != std::string::npos)
      59            0 :         ns.add(ns_name.substr(ns_name.find_first_not_of(':', idx)), class_name);
      60              :       else
      61            0 :         ns.add("", class_name);
      62              :     } else
      63            0 :       m_classes.insert(class_name);
      64            0 :   }
      65              : 
      66            0 :   void print(std::ostream& s, int level) const
      67              :   {
      68            0 :     std::string dx(level * 2, ' ');
      69              : 
      70            0 :     for (const auto& x : m_nested) {
      71            0 :       s << dx << "namespace " << x.first << " {\n";
      72            0 :       x.second.print(s, level + 1);
      73            0 :       s << dx << "}\n";
      74              :     }
      75              : 
      76            0 :     for (const auto& x : m_classes)
      77            0 :       s << dx << "class " << x << ";\n";
      78            0 :   }
      79              : };
      80              : 
      81              : } // namespace oksdalgen
      82              : } // namespace dunedaq
      83              : #endif
        

Generated by: LCOV version 2.0-1