LCOV - code coverage report
Current view: top level - dbe/apps/SchemaEditor - SchemaMethodImplementationEditor.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 92 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: yes (from src/SchemaEditor/SchemaMethodImplementationEditor.cpp to
       5              : // apps/SchemaEditor/SchemaMethodImplementationEditor.cpp).
       6              : 
       7              : #include <QMessageBox>
       8              : /// Including Schema
       9              : #include "dbe/SchemaKernelWrapper.hpp"
      10              : #include "dbe/SchemaMethodImplementationEditor.hpp"
      11              : #include "ui_SchemaMethodImplementationEditor.h"
      12              : 
      13              : using namespace dunedaq::oks;
      14              : 
      15            0 : dbse::SchemaMethodImplementationEditor::~SchemaMethodImplementationEditor() = default;
      16              : 
      17            0 : dbse::SchemaMethodImplementationEditor::SchemaMethodImplementationEditor(OksClass* Class,
      18              :                                                                          OksMethod* Method,
      19              :                                                                          OksMethodImplementation* Implementation,
      20            0 :                                                                          QWidget* parent)
      21              :   : QWidget(parent)
      22            0 :   , ui(new Ui::SchemaMethodImplementationEditor)
      23            0 :   , m_class(Class)
      24            0 :   , m_method(Method)
      25            0 :   , m_implementation(Implementation)
      26            0 :   , UsedNew(false)
      27              : {
      28            0 :   QWidget::setAttribute(Qt::WA_DeleteOnClose);
      29            0 :   ui->setupUi(this);
      30            0 :   InitialSettings();
      31            0 :   SetController();
      32            0 : }
      33              : 
      34            0 : dbse::SchemaMethodImplementationEditor::SchemaMethodImplementationEditor(OksClass* Class,
      35              :                                                                          OksMethod* Method,
      36            0 :                                                                          QWidget* parent)
      37              :   : QWidget(parent)
      38            0 :   , ui(new Ui::SchemaMethodImplementationEditor)
      39            0 :   , m_class(Class)
      40            0 :   , m_method(Method)
      41            0 :   , m_implementation(nullptr)
      42            0 :   , UsedNew(true)
      43              : {
      44            0 :   QWidget::setAttribute(Qt::WA_DeleteOnClose);
      45            0 :   ui->setupUi(this);
      46            0 :   InitialSettings();
      47            0 :   SetController();
      48            0 : }
      49              : 
      50              : void
      51            0 : dbse::SchemaMethodImplementationEditor::SetController()
      52              : {
      53            0 :   connect(ui->SaveButton, SIGNAL(clicked()), this, SLOT(ProxySlot()));
      54            0 :   connect(&KernelWrapper::GetInstance(), SIGNAL(ClassUpdated(QString)), this, SLOT(ClassUpdated(QString)));
      55            0 : }
      56              : 
      57              : void
      58            0 : dbse::SchemaMethodImplementationEditor::ClassUpdated(QString class_name)
      59              : {
      60            0 :   if (!UsedNew && class_name.toStdString() == m_class->get_name()) {
      61            0 :     if (m_method->find_implementation(m_implementation->get_language()) != nullptr) {
      62            0 :       FillInfo();
      63              :     } else {
      64            0 :       QWidget::close();
      65              :     }
      66              :   }
      67            0 : }
      68              : 
      69              : void
      70            0 : dbse::SchemaMethodImplementationEditor::FillInfo()
      71              : {
      72            0 :   ui->MethodImplementationLanguage->setText(QString::fromStdString(m_implementation->get_language()));
      73            0 :   ui->MethodImplementationPrototype->setText(QString::fromStdString(m_implementation->get_prototype()));
      74            0 :   ui->MethodImplementationDescription->setPlainText(QString::fromStdString(m_implementation->get_body()));
      75              : 
      76            0 :   std::string name = m_class->get_name() + m_method->get_name() + m_implementation->get_language();
      77            0 :   setObjectName(QString::fromStdString(name));
      78            0 : }
      79              : 
      80              : void
      81            0 : dbse::SchemaMethodImplementationEditor::InitialSettings()
      82              : {
      83            0 :   std::string title = "Method Implementation for " + m_class->get_name() + "::" + m_method->get_name();
      84            0 :   setWindowTitle(QString::fromStdString(title));
      85              : 
      86            0 :   if (UsedNew) {
      87            0 :     std::string name = m_class->get_name() + m_method->get_name();
      88            0 :     setObjectName(QString::fromStdString(name));
      89            0 :   } else {
      90            0 :     FillInfo();
      91              :   }
      92            0 : }
      93              : 
      94              : void
      95            0 : dbse::SchemaMethodImplementationEditor::ParseToSave()
      96              : {
      97            0 :   bool changed = false;
      98            0 :   std::string MethodLanguage = ui->MethodImplementationLanguage->text().toStdString();
      99            0 :   std::string MethodPrototype = ui->MethodImplementationPrototype->text().toStdString();
     100              : 
     101            0 :   std::string MethodDescription = ui->MethodImplementationDescription->toPlainText().toStdString();
     102              : 
     103            0 :   if (MethodLanguage != m_implementation->get_language()) {
     104            0 :     KernelWrapper::GetInstance().PushSetMethodImplementationLanguage(
     105              :       m_class, m_method, m_implementation, MethodLanguage);
     106            0 :     changed = true;
     107              :   }
     108              : 
     109            0 :   if (MethodPrototype != m_implementation->get_prototype()) {
     110            0 :     KernelWrapper::GetInstance().PushSetMethodImplementationPrototype(
     111              :       m_class, m_method, m_implementation, MethodPrototype);
     112            0 :     changed = true;
     113              :   }
     114              : 
     115            0 :   if (MethodDescription != m_implementation->get_body()) {
     116            0 :     KernelWrapper::GetInstance().PushSetMethodImplementationBody(
     117              :       m_class, m_method, m_implementation, MethodDescription);
     118            0 :     changed = true;
     119              :   }
     120              : 
     121            0 :   if (changed) {
     122            0 :     emit RebuildModel();
     123              :   }
     124              : 
     125            0 :   close();
     126            0 : }
     127              : 
     128              : void
     129            0 : dbse::SchemaMethodImplementationEditor::ParseToCreate()
     130              : {
     131            0 :   if (ui->MethodImplementationLanguage->text().isEmpty() && ui->MethodImplementationLanguage->text().isEmpty() &&
     132            0 :       ui->MethodImplementationDescription->toPlainText().isEmpty()) {
     133              :     // Close empty dialogue box
     134            0 :     close();
     135            0 :     return;
     136              :   }
     137              : 
     138            0 :   if (ui->MethodImplementationLanguage->text().isEmpty()) {
     139            0 :     QMessageBox::warning(0, "Schema editor", QString("Please Provide a Language for the method implementation !"));
     140            0 :     return;
     141              :   }
     142              : 
     143            0 :   if (ui->MethodImplementationPrototype->text().isEmpty()) {
     144            0 :     QMessageBox::warning(0, "Schema editor", QString("Please Provide a prototype for the method implementation !"));
     145            0 :     return;
     146              :   }
     147              : 
     148            0 :   std::string MethodLanguage = ui->MethodImplementationLanguage->text().toStdString();
     149            0 :   std::string MethodPrototype = ui->MethodImplementationPrototype->text().toStdString();
     150            0 :   std::string MethodDescription = ui->MethodImplementationDescription->toPlainText().toStdString();
     151              : 
     152            0 :   KernelWrapper::GetInstance().PushAddMethodImplementationComand(
     153              :     m_class, m_method, MethodLanguage, MethodPrototype, MethodDescription);
     154            0 :   emit RebuildModel();
     155            0 :   close();
     156            0 : }
     157              : 
     158              : void
     159            0 : dbse::SchemaMethodImplementationEditor::ProxySlot()
     160              : {
     161            0 :   if (UsedNew) {
     162            0 :     ParseToCreate();
     163              :   } else {
     164            0 :     ParseToSave();
     165              :   }
     166            0 : }
        

Generated by: LCOV version 2.0-1