DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
SchemaMethodImplementationEditor.cpp
Go to the documentation of this file.
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>
11#include "ui_SchemaMethodImplementationEditor.h"
12
13using namespace dunedaq::oks;
14
16
18 OksMethod* Method,
19 OksMethodImplementation* Implementation,
20 QWidget* parent)
21 : QWidget(parent)
23 , m_class(Class)
24 , m_method(Method)
25 , m_implementation(Implementation)
26 , UsedNew(false)
27{
28 QWidget::setAttribute(Qt::WA_DeleteOnClose);
29 ui->setupUi(this);
32}
33
35 OksMethod* Method,
36 QWidget* parent)
37 : QWidget(parent)
39 , m_class(Class)
40 , m_method(Method)
41 , m_implementation(nullptr)
42 , UsedNew(true)
43{
44 QWidget::setAttribute(Qt::WA_DeleteOnClose);
45 ui->setupUi(this);
48}
49
50void
52{
53 connect(ui->SaveButton, SIGNAL(clicked()), this, SLOT(ProxySlot()));
54 connect(&KernelWrapper::GetInstance(), SIGNAL(ClassUpdated(QString)), this, SLOT(ClassUpdated(QString)));
55}
56
57void
59{
60 if (!UsedNew && class_name.toStdString() == m_class->get_name()) {
61 if (m_method->find_implementation(m_implementation->get_language()) != nullptr) {
62 FillInfo();
63 } else {
64 QWidget::close();
65 }
66 }
67}
68
69void
71{
72 ui->MethodImplementationLanguage->setText(QString::fromStdString(m_implementation->get_language()));
73 ui->MethodImplementationPrototype->setText(QString::fromStdString(m_implementation->get_prototype()));
74 ui->MethodImplementationDescription->setPlainText(QString::fromStdString(m_implementation->get_body()));
75
76 std::string name = m_class->get_name() + m_method->get_name() + m_implementation->get_language();
77 setObjectName(QString::fromStdString(name));
78}
79
80void
82{
83 std::string title = "Method Implementation for " + m_class->get_name() + "::" + m_method->get_name();
84 setWindowTitle(QString::fromStdString(title));
85
86 if (UsedNew) {
87 std::string name = m_class->get_name() + m_method->get_name();
88 setObjectName(QString::fromStdString(name));
89 } else {
90 FillInfo();
91 }
92}
93
94void
96{
97 bool changed = false;
98 std::string MethodLanguage = ui->MethodImplementationLanguage->text().toStdString();
99 std::string MethodPrototype = ui->MethodImplementationPrototype->text().toStdString();
100
101 std::string MethodDescription = ui->MethodImplementationDescription->toPlainText().toStdString();
102
103 if (MethodLanguage != m_implementation->get_language()) {
105 m_class, m_method, m_implementation, MethodLanguage);
106 changed = true;
107 }
108
109 if (MethodPrototype != m_implementation->get_prototype()) {
111 m_class, m_method, m_implementation, MethodPrototype);
112 changed = true;
113 }
114
115 if (MethodDescription != m_implementation->get_body()) {
117 m_class, m_method, m_implementation, MethodDescription);
118 changed = true;
119 }
120
121 if (changed) {
122 emit RebuildModel();
123 }
124
125 close();
126}
127
128void
130{
131 if (ui->MethodImplementationLanguage->text().isEmpty() && ui->MethodImplementationLanguage->text().isEmpty() &&
132 ui->MethodImplementationDescription->toPlainText().isEmpty()) {
133 // Close empty dialogue box
134 close();
135 return;
136 }
137
138 if (ui->MethodImplementationLanguage->text().isEmpty()) {
139 QMessageBox::warning(0, "Schema editor", QString("Please Provide a Language for the method implementation !"));
140 return;
141 }
142
143 if (ui->MethodImplementationPrototype->text().isEmpty()) {
144 QMessageBox::warning(0, "Schema editor", QString("Please Provide a prototype for the method implementation !"));
145 return;
146 }
147
148 std::string MethodLanguage = ui->MethodImplementationLanguage->text().toStdString();
149 std::string MethodPrototype = ui->MethodImplementationPrototype->text().toStdString();
150 std::string MethodDescription = ui->MethodImplementationDescription->toPlainText().toStdString();
151
153 m_class, m_method, MethodLanguage, MethodPrototype, MethodDescription);
154 emit RebuildModel();
155 close();
156}
157
158void
160{
161 if (UsedNew) {
163 } else {
164 ParseToSave();
165 }
166}
static KernelWrapper & GetInstance()
void PushSetMethodImplementationLanguage(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, std::string Language)
Method implementation commands.
void PushSetMethodImplementationPrototype(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, std::string Prototype)
void PushAddMethodImplementationComand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, std::string Language, std::string Prototype, std::string Body)
void PushSetMethodImplementationBody(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, std::string Body)
std::unique_ptr< dbse::Ui::SchemaMethodImplementationEditor > ui
SchemaMethodImplementationEditor(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, QWidget *parent=nullptr)
dunedaq::oks::OksMethodImplementation * m_implementation
The OKS class.
Definition class.hpp:223
OKS method implementation class.
Definition method.hpp:39
OKS method class.
Definition method.hpp:147