LCOV - code coverage report
Current view: top level - dbe/src/internal - config_ui_info.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 169 0
Test Date: 2026-10-11 15:05:20 Functions: 0.0 % 10 0

            Line data    Source code
       1              : // DUNE DAQ modification notice:
       2              : // This file has been modified from the original ATLAS dbe source for the DUNE DAQ project.
       3              : // Fork baseline commit: dbe-02-12-17 (2022-05-12).
       4              : // Renamed since fork: no.
       5              : 
       6              : /*
       7              :  * configuration.cpp
       8              :  *
       9              :  *  Created on: Mar 22, 2016
      10              :  *      Author: Leonidas Georgopoulos
      11              :  */
      12              : 
      13              : #include "dbe/config_ui_info.hpp"
      14              : #include "dbe/Conversion.hpp"
      15              : #include "dbe/GraphicalClass.hpp"
      16              : #include "dbe/config_api_info.hpp"
      17              : #include "dbe/messenger.hpp"
      18              : 
      19              : #include "dbe/config_api_get.hpp"
      20              : #include "dbe/config_api_graph.hpp"
      21              : 
      22              : #include <QStringList>
      23              : 
      24              : #include <map>
      25              : #include <vector>
      26              : 
      27              : using namespace dunedaq::conffwk;
      28              : 
      29            0 : dbe::ui::config::info::info(std::vector<std::string> const& full_file_name)
      30            0 :   : this_full_filenames(full_file_name)
      31              : {
      32            0 :   parse();
      33            0 : }
      34              : 
      35              : dbe::GraphicalClass
      36            0 : dbe::ui::config::info::graphical(std::string const& name) const
      37              : {
      38            0 :   std::map<std::string, GraphicalClass>::const_iterator it = this_graphical.find(name);
      39              : 
      40            0 :   if (it != this_graphical.end()) {
      41            0 :     return it->second;
      42              :   } else {
      43            0 :     return {};
      44              :   }
      45            0 : }
      46              : 
      47              : dbe::ViewConfiguration
      48            0 : dbe::ui::config::info::view(std::string const& name) const
      49              : {
      50            0 :   std::map<std::string, ViewConfiguration>::const_iterator it = this_views.find(name);
      51              : 
      52            0 :   if (it != this_views.end()) {
      53            0 :     return it->second;
      54              :   } else {
      55            0 :     return {};
      56              :   }
      57            0 : }
      58              : 
      59              : dbe::Window
      60            0 : dbe::ui::config::info::window(std::string const& name) const
      61              : {
      62            0 :   std::map<std::string, Window>::const_iterator it = this_windows.find(name);
      63              : 
      64            0 :   if (it != this_windows.end()) {
      65            0 :     return it->second;
      66              :   } else {
      67            0 :     return {};
      68              :   }
      69            0 : }
      70              : 
      71              : void
      72            0 : dbe::ui::config::info::parse()
      73              : {
      74            0 :   for (std::string const& fname : this_full_filenames) {
      75            0 :     std::string Implementation = "oksconflibs:" + fname;
      76              : 
      77            0 :     try {
      78            0 :       std::shared_ptr<Configuration> ConfigFile(new Configuration(Implementation));
      79            0 :       std::vector<ConfigObject> objects;
      80              : 
      81            0 :       ConfigFile->get("Class", objects);
      82              : 
      83            0 :       for (ConfigObject& aclass : objects) {
      84            0 :         parse_graphical(ConfigFile, aclass);
      85              :       }
      86              : 
      87            0 :       objects.clear();
      88            0 :       ConfigFile->get("Window", objects);
      89              : 
      90            0 :       for (ConfigObject& awindow : objects) {
      91            0 :         parse_window(ConfigFile, awindow);
      92              :       }
      93            0 :     } catch (dunedaq::conffwk::Exception const& ex) {
      94            0 :       ERROR("Configuration database load did not succeed", dbe::config::errors::parse(ex).c_str());
      95            0 :     }
      96            0 :   }
      97            0 : }
      98              : 
      99              : void
     100            0 : dbe::ui::config::info::parse_graphical(std::shared_ptr<Configuration> ConfigFile, ConfigObject& Object)
     101              : {
     102            0 :   GraphicalClass GraphicalClassObject;
     103              : 
     104            0 :   GraphicalClassObject.GraphicalUID = QString(Object.UID().c_str());
     105            0 :   dunedaq::conffwk::class_t cinfo = ConfigFile->get_class_info(Object.class_name(), false);
     106              : 
     107            0 :   std::vector<dunedaq::conffwk::attribute_t> const& attributes = cinfo.p_attributes;
     108            0 :   std::vector<dunedaq::conffwk::relationship_t> const& relations = cinfo.p_relationships;
     109              : 
     110            0 :   for (dunedaq::conffwk::attribute_t const& attr : attributes) {
     111            0 :     QStringList data = dbe::config::api::get::direct::attribute<QStringList>(Object, attr);
     112              : 
     113            0 :     if (attr.p_name == "Name") {
     114            0 :       GraphicalClassObject.DatabaseClassName = data.at(0);
     115            0 :     } else if (attr.p_name == "Generic Pixmap File") {
     116            0 :       GraphicalClassObject.GenericPixmapFile = data.at(0);
     117            0 :     } else if (attr.p_name == "Used Pixmap File") {
     118            0 :       GraphicalClassObject.UsedPixmapFile = data.at(0);
     119            0 :     } else if (attr.p_name == "Icon Bitmap File") {
     120            0 :       GraphicalClassObject.BitmapFile = data.at(0);
     121            0 :     } else if (attr.p_name == "Icon Mask Bitmap File") {
     122            0 :       GraphicalClassObject.BitmapMaskFile = data.at(0);
     123            0 :     } else if (attr.p_name == "Show All Attributes") {
     124            0 :       GraphicalClassObject.ShowAllAttributes = convert::to<bool>(data, attr.p_int_format);
     125            0 :     } else if (attr.p_name == "Attributes") {
     126            0 :       GraphicalClassObject.Attributes = data;
     127            0 :     } else if (attr.p_name == "Show All Relationships") {
     128            0 :       GraphicalClassObject.ShowAllRelationships = convert::to<bool>(data, attr.p_int_format);
     129            0 :     } else if (attr.p_name == "Relationships") {
     130            0 :       GraphicalClassObject.Relationships = data;
     131              : 
     132            0 :     } else if (attr.p_name == "Icon Title") {
     133            0 :       GraphicalClassObject.IconTitle = data.at(0);
     134              :     }
     135            0 :   }
     136              : 
     137            0 :   for (dunedaq::conffwk::relationship_t const& relation : relations) {
     138            0 :     QStringList data;
     139            0 :     std::vector<ConfigObject> neighboring{};
     140              : 
     141            0 :     if (dbe::config::api::info::relation::is_simple(relation)) {
     142            0 :       neighboring.push_back(dbe::config::api::graph::direct::linked<ConfigObject>(Object, relation));
     143              :     } else {
     144            0 :       std::vector<ConfigObject> objects =
     145            0 :         dbe::config::api::graph::direct::linked<std::vector<ConfigObject>>(Object, relation);
     146            0 :       neighboring.insert(std::end(neighboring), std::begin(objects), std::end(objects));
     147            0 :     }
     148              : 
     149            0 :     for (ConfigObject& RelObject : neighboring) {
     150            0 :       dunedaq::conffwk::class_t RelClassInfo = ConfigFile->get_class_info(RelObject.class_name(), false);
     151            0 :       std::vector<dunedaq::conffwk::attribute_t> AttributeRelList = RelClassInfo.p_attributes;
     152              : 
     153            0 :       if (RelObject.class_name() == "Dual Relationship") {
     154            0 :         DualRelationship DRel;
     155              : 
     156            0 :         for (dunedaq::conffwk::attribute_t& Attribute : AttributeRelList) {
     157            0 :           data = dbe::config::api::get::direct::attribute<QStringList>(RelObject, Attribute);
     158              : 
     159            0 :           if (Attribute.p_name == "Direct") {
     160            0 :             DRel.Direct = data.at(0);
     161            0 :           } else if (Attribute.p_name == "Reverse") {
     162            0 :             DRel.Reverse = data.at(0);
     163              :           }
     164              :         }
     165              : 
     166            0 :         GraphicalClassObject.DualRelationships.push_back(DRel);
     167            0 :       } else if (RelObject.class_name() == "Init Attribute Value") {
     168            0 :         InitAttributeFromEnv IRel;
     169              : 
     170            0 :         for (dunedaq::conffwk::attribute_t& Attribute : AttributeRelList) {
     171            0 :           data = dbe::config::api::get::direct::attribute<QStringList>(RelObject, Attribute);
     172              : 
     173            0 :           if (Attribute.p_name == "Attribute Name") {
     174            0 :             IRel.AttributeName = data.at(0);
     175            0 :           } else if (Attribute.p_name == "Environment Variables") {
     176            0 :             IRel.EnvNames = data;
     177              :           }
     178              :         }
     179              : 
     180            0 :         GraphicalClassObject.NeedToInitialize.push_back(IRel);
     181            0 :       }
     182            0 :     }
     183            0 :   }
     184              : 
     185            0 :   this_graphical.emplace(GraphicalClassObject.GraphicalUID.toStdString(), GraphicalClassObject);
     186            0 : }
     187              : 
     188              : void
     189            0 : dbe::ui::config::info::parse_window(std::shared_ptr<Configuration> database, ConfigObject& object)
     190              : {
     191            0 :   Window WindowObject;
     192            0 :   dunedaq::conffwk::class_t ClassInfo = database->get_class_info(object.class_name(), false);
     193            0 :   std::vector<dunedaq::conffwk::attribute_t> const& attributes = ClassInfo.p_attributes;
     194            0 :   std::vector<dunedaq::conffwk::relationship_t> const& relations = ClassInfo.p_relationships;
     195              : 
     196            0 :   for (dunedaq::conffwk::attribute_t const& attribute : attributes) {
     197            0 :     if (attribute.p_name == "Title") {
     198            0 :       WindowObject.Title = dbe::config::api::get::direct::attribute<QStringList>(object, attribute).at(0);
     199              :     }
     200              :   }
     201              : 
     202            0 :   for (dunedaq::conffwk::relationship_t const& relation : relations) {
     203            0 :     std::vector<ConfigObject> linkedobjects;
     204              : 
     205            0 :     if (dbe::config::api::info::relation::is_simple(relation)) {
     206            0 :       linkedobjects.push_back(dbe::config::api::graph::direct::linked<ConfigObject>(object, relation));
     207              :     } else {
     208            0 :       std::vector<ConfigObject> voisins =
     209            0 :         dbe::config::api::graph::direct::linked<std::vector<ConfigObject>>(object, relation);
     210              : 
     211            0 :       if (not voisins.empty()) {
     212            0 :         linkedobjects.insert(std::end(linkedobjects), std::begin(voisins), std::end(voisins));
     213              :       }
     214            0 :     }
     215              : 
     216            0 :     for (ConfigObject& neighbor : linkedobjects) {
     217            0 :       dunedaq::conffwk::class_t classinfo = database->get_class_info(neighbor.class_name(), false);
     218            0 :       std::vector<dunedaq::conffwk::attribute_t> const& AttributeRelList = classinfo.p_attributes;
     219            0 :       std::vector<dunedaq::conffwk::relationship_t> const& RelationshipRelList = classinfo.p_relationships;
     220              : 
     221            0 :       if (neighbor.class_name() != "Window Separator") {
     222            0 :         for (dunedaq::conffwk::attribute_t const& Attribute : AttributeRelList) {
     223            0 :           if (Attribute.p_name == "Shown with children") {
     224            0 :             QStringList neighbor_names{ dbe::config::api::get::direct::attribute<QStringList>(neighbor, Attribute) };
     225              : 
     226            0 :             if (neighbor_names.at(0) != "none") {
     227            0 :               WindowObject.ShowChildren = true;
     228              :             } else {
     229            0 :               WindowObject.ShowChildren = false;
     230              :             }
     231            0 :           }
     232              :         }
     233              : 
     234            0 :         for (dunedaq::conffwk::relationship_t const& RelationshipRel : RelationshipRelList) {
     235            0 :           QStringList RelDataList;
     236            0 :           std::vector<ConfigObject> neighboring_nodes;
     237              : 
     238            0 :           if (dbe::config::api::info::relation::is_simple(RelationshipRel)) {
     239            0 :             neighboring_nodes.push_back(
     240            0 :               dbe::config::api::graph::direct::linked<ConfigObject>(neighbor, RelationshipRel));
     241              :           } else {
     242              : 
     243            0 :             std::vector<ConfigObject> neighbors =
     244            0 :               dbe::config::api::graph::direct::linked<std::vector<ConfigObject>>(neighbor, RelationshipRel);
     245              : 
     246            0 :             neighboring_nodes.insert(std::end(neighboring_nodes), std::begin(neighbors), std::end(neighbors));
     247            0 :           }
     248              : 
     249            0 :           for (ConfigObject& RelDataObject : neighboring_nodes) {
     250            0 :             RelDataList.push_back(QString(RelDataObject.UID().c_str()));
     251              :           }
     252              : 
     253            0 :           WindowObject.GraphicalClassesList.push_back(RelDataList.at(0));
     254            0 :         }
     255              :       }
     256            0 :     }
     257            0 :   }
     258              : 
     259            0 :   this_windows.emplace(WindowObject.Title.toStdString(), WindowObject);
     260            0 : }
     261              : 
     262              : std::vector<dbe::Window>
     263            0 : dbe::ui::config::info::windows() const
     264              : {
     265            0 :   std::vector<dbe::Window> windows;
     266              : 
     267            0 :   for (auto const& x : this_windows) {
     268            0 :     windows.push_back(x.second);
     269              :   }
     270              : 
     271            0 :   return windows;
     272            0 : }
     273              : 
     274              : std::vector<dbe::ViewConfiguration>
     275            0 : dbe::ui::config::info::views() const
     276              : {
     277            0 :   std::vector<dbe::ViewConfiguration> views;
     278              : 
     279            0 :   for (auto const& x : this_views) {
     280            0 :     views.push_back(x.second);
     281              :   }
     282              : 
     283            0 :   return views;
     284            0 : }
     285              : 
     286              : std::vector<dbe::GraphicalClass>
     287            0 : dbe::ui::config::info::graphicals() const
     288              : {
     289            0 :   std::vector<dbe::GraphicalClass> the_graphicals;
     290              : 
     291            0 :   for (auto const& x : this_graphical) {
     292            0 :     the_graphicals.push_back(x.second);
     293              :   }
     294              : 
     295            0 :   return the_graphicals;
     296            0 : }
        

Generated by: LCOV version 2.0-1