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 apps/SchemaEditor/SchemaMethodImplementationEditor.cpp).
5
6#include <QMessageBox>
10#include "ui_SchemaMethodImplementationEditor.h"
11
12using namespace dunedaq::oks;
13
15
17 OksClass * Class, OksMethod * Method, OksMethodImplementation * Implementation, QWidget * parent )
18 : QWidget ( parent ),
20 m_class ( Class ),
21 m_method ( Method ),
22 m_implementation ( Implementation ),
23 UsedNew ( false )
24{
25 QWidget::setAttribute(Qt::WA_DeleteOnClose);
26 ui->setupUi ( this );
29}
30
32 OksClass * Class,
33 OksMethod * Method,
34 QWidget * parent )
35 : QWidget ( parent ),
37 m_class ( Class ),
38 m_method ( Method ),
39 m_implementation ( nullptr ),
40 UsedNew ( true )
41{
42 QWidget::setAttribute(Qt::WA_DeleteOnClose);
43 ui->setupUi ( this );
46}
47
49{
50 connect ( ui->SaveButton, SIGNAL ( clicked() ), this, SLOT ( ProxySlot() ) );
51 connect ( &KernelWrapper::GetInstance(), SIGNAL ( ClassUpdated ( QString ) ), this,
52 SLOT ( ClassUpdated ( QString ) ) );
53}
54
56{
57 if(!UsedNew && class_name.toStdString() == m_class->get_name()) {
58 if(m_method->find_implementation(m_implementation->get_language()) != nullptr) {
59 FillInfo();
60 } else {
61 QWidget::close();
62 }
63 }
64}
65
67{
68 ui->MethodImplementationLanguage->setText (
69 QString::fromStdString ( m_implementation->get_language() ) );
70 ui->MethodImplementationPrototype->setText (
71 QString::fromStdString ( m_implementation->get_prototype() ) );
72 ui->MethodImplementationDescription->setPlainText (
73 QString::fromStdString ( m_implementation->get_body() ) );
74
75 std::string name = m_class->get_name() + m_method->get_name()
76 + m_implementation->get_language();
77 setObjectName ( QString::fromStdString(name) );
78}
79
81{
82 std::string title = "Method Implementation for " + m_class->get_name() + "::" + m_method->get_name();
83 setWindowTitle (QString::fromStdString(title));
84
85 if ( UsedNew ) {
86 std::string name = m_class->get_name() + m_method->get_name();
87 setObjectName ( QString::fromStdString(name) );
88 }
89 else {
90 FillInfo();
91 }
92}
93
95{
96 bool changed = false;
97 std::string MethodLanguage = ui->MethodImplementationLanguage->text().toStdString();
98 std::string MethodPrototype = ui->MethodImplementationPrototype->text().toStdString();
99
100 std::string MethodDescription = ui->MethodImplementationDescription->toPlainText()
101 .toStdString();
102
103 if ( MethodLanguage != m_implementation->get_language() )
104 {
106 m_method,
108 MethodLanguage );
109 changed = true;
110 }
111
112 if ( MethodPrototype != m_implementation->get_prototype() )
113 {
115 m_method,
117 MethodPrototype );
118 changed = true;
119 }
120
121 if ( MethodDescription != m_implementation->get_body() )
122 {
124 m_method,
126 MethodDescription );
127 changed = true;
128 }
129
130 if ( changed )
131 {
132 emit RebuildModel();
133 }
134
135 close();
136}
137
139{
140 if ( ui->MethodImplementationLanguage->text().isEmpty()
141 && ui->MethodImplementationLanguage->text().isEmpty()
142 && ui->MethodImplementationDescription->toPlainText().isEmpty() ) {
143 // Close empty dialogue box
144 close();
145 return;
146 }
147
148 if ( ui->MethodImplementationLanguage->text().isEmpty() )
149 {
150 QMessageBox::warning (
151 0, "Schema editor",
152 QString ( "Please Provide a Language for the method implementation !" ) );
153 return;
154 }
155
156 if ( ui->MethodImplementationPrototype->text().isEmpty() )
157 {
158 QMessageBox::warning (
159 0, "Schema editor",
160 QString ( "Please Provide a prototype for the method implementation !" ) );
161 return;
162 }
163
164 std::string MethodLanguage = ui->MethodImplementationLanguage->text().toStdString();
165 std::string MethodPrototype = ui->MethodImplementationPrototype->text().toStdString();
166 std::string MethodDescription = ui->MethodImplementationDescription->toPlainText()
167 .toStdString();
168
170 m_method,
171 MethodLanguage,
172 MethodPrototype,
173 MethodDescription );
174 emit RebuildModel();
175 close();
176}
177
179{
180 if ( UsedNew )
181 {
183 }
184 else
185 {
186 ParseToSave();
187 }
188}
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:205
OKS method implementation class.
Definition method.hpp:40
OKS method class.
Definition method.hpp:158