DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
apps
SchemaEditor
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>
9
#include "
dbe/SchemaKernelWrapper.hpp
"
10
#include "
dbe/SchemaMethodImplementationEditor.hpp
"
11
#include "ui_SchemaMethodImplementationEditor.h"
12
13
using namespace
dunedaq::oks
;
14
15
dbse::SchemaMethodImplementationEditor::~SchemaMethodImplementationEditor
() =
default
;
16
17
dbse::SchemaMethodImplementationEditor::SchemaMethodImplementationEditor
(
OksClass
* Class,
18
OksMethod
* Method,
19
OksMethodImplementation
* Implementation,
20
QWidget* parent)
21
: QWidget(parent)
22
,
ui
(new
Ui
::
SchemaMethodImplementationEditor
)
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
);
30
InitialSettings
();
31
SetController
();
32
}
33
34
dbse::SchemaMethodImplementationEditor::SchemaMethodImplementationEditor
(
OksClass
* Class,
35
OksMethod
* Method,
36
QWidget* parent)
37
: QWidget(parent)
38
,
ui
(new
Ui
::
SchemaMethodImplementationEditor
)
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
);
46
InitialSettings
();
47
SetController
();
48
}
49
50
void
51
dbse::SchemaMethodImplementationEditor::SetController
()
52
{
53
connect(
ui
->SaveButton, SIGNAL(clicked()),
this
, SLOT(
ProxySlot
()));
54
connect(&
KernelWrapper::GetInstance
(), SIGNAL(
ClassUpdated
(QString)),
this
, SLOT(
ClassUpdated
(QString)));
55
}
56
57
void
58
dbse::SchemaMethodImplementationEditor::ClassUpdated
(QString class_name)
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
69
void
70
dbse::SchemaMethodImplementationEditor::FillInfo
()
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
80
void
81
dbse::SchemaMethodImplementationEditor::InitialSettings
()
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
94
void
95
dbse::SchemaMethodImplementationEditor::ParseToSave
()
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()) {
104
KernelWrapper::GetInstance
().
PushSetMethodImplementationLanguage
(
105
m_class
,
m_method
,
m_implementation
, MethodLanguage);
106
changed =
true
;
107
}
108
109
if
(MethodPrototype !=
m_implementation
->get_prototype()) {
110
KernelWrapper::GetInstance
().
PushSetMethodImplementationPrototype
(
111
m_class
,
m_method
,
m_implementation
, MethodPrototype);
112
changed =
true
;
113
}
114
115
if
(MethodDescription !=
m_implementation
->get_body()) {
116
KernelWrapper::GetInstance
().
PushSetMethodImplementationBody
(
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
128
void
129
dbse::SchemaMethodImplementationEditor::ParseToCreate
()
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
152
KernelWrapper::GetInstance
().
PushAddMethodImplementationComand
(
153
m_class
,
m_method
, MethodLanguage, MethodPrototype, MethodDescription);
154
emit
RebuildModel
();
155
close();
156
}
157
158
void
159
dbse::SchemaMethodImplementationEditor::ProxySlot
()
160
{
161
if
(
UsedNew
) {
162
ParseToCreate
();
163
}
else
{
164
ParseToSave
();
165
}
166
}
SchemaKernelWrapper.hpp
SchemaMethodImplementationEditor.hpp
dbse::KernelWrapper::GetInstance
static KernelWrapper & GetInstance()
Definition
SchemaKernelWrapper.cpp:19
dbse::KernelWrapper::PushSetMethodImplementationLanguage
void PushSetMethodImplementationLanguage(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, std::string Language)
Method implementation commands.
Definition
SchemaKernelWrapper.cpp:518
dbse::KernelWrapper::PushSetMethodImplementationPrototype
void PushSetMethodImplementationPrototype(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, std::string Prototype)
Definition
SchemaKernelWrapper.cpp:531
dbse::KernelWrapper::PushAddMethodImplementationComand
void PushAddMethodImplementationComand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, std::string Language, std::string Prototype, std::string Body)
Definition
SchemaKernelWrapper.cpp:557
dbse::KernelWrapper::PushSetMethodImplementationBody
void PushSetMethodImplementationBody(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, std::string Body)
Definition
SchemaKernelWrapper.cpp:544
dbse::SchemaMethodImplementationEditor::ui
std::unique_ptr< dbse::Ui::SchemaMethodImplementationEditor > ui
Definition
SchemaMethodImplementationEditor.hpp:45
dbse::SchemaMethodImplementationEditor::ParseToCreate
void ParseToCreate()
Definition
SchemaMethodImplementationEditor.cpp:129
dbse::SchemaMethodImplementationEditor::ParseToSave
void ParseToSave()
Definition
SchemaMethodImplementationEditor.cpp:95
dbse::SchemaMethodImplementationEditor::FillInfo
void FillInfo()
Definition
SchemaMethodImplementationEditor.cpp:70
dbse::SchemaMethodImplementationEditor::ProxySlot
void ProxySlot()
Definition
SchemaMethodImplementationEditor.cpp:159
dbse::SchemaMethodImplementationEditor::m_method
dunedaq::oks::OksMethod * m_method
Definition
SchemaMethodImplementationEditor.hpp:47
dbse::SchemaMethodImplementationEditor::InitialSettings
void InitialSettings()
Definition
SchemaMethodImplementationEditor.cpp:81
dbse::SchemaMethodImplementationEditor::ClassUpdated
void ClassUpdated(QString ClassName)
Definition
SchemaMethodImplementationEditor.cpp:58
dbse::SchemaMethodImplementationEditor::SchemaMethodImplementationEditor
SchemaMethodImplementationEditor(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, QWidget *parent=nullptr)
Definition
SchemaMethodImplementationEditor.cpp:17
dbse::SchemaMethodImplementationEditor::SetController
void SetController()
Definition
SchemaMethodImplementationEditor.cpp:51
dbse::SchemaMethodImplementationEditor::RebuildModel
void RebuildModel()
dbse::SchemaMethodImplementationEditor::m_implementation
dunedaq::oks::OksMethodImplementation * m_implementation
Definition
SchemaMethodImplementationEditor.hpp:48
dbse::SchemaMethodImplementationEditor::UsedNew
bool UsedNew
Definition
SchemaMethodImplementationEditor.hpp:49
dbse::SchemaMethodImplementationEditor::~SchemaMethodImplementationEditor
~SchemaMethodImplementationEditor()
dbse::SchemaMethodImplementationEditor::m_class
dunedaq::oks::OksClass * m_class
Definition
SchemaMethodImplementationEditor.hpp:46
dunedaq::oks::OksClass
The OKS class.
Definition
class.hpp:223
dunedaq::oks::OksMethodImplementation
OKS method implementation class.
Definition
method.hpp:39
dunedaq::oks::OksMethod
OKS method class.
Definition
method.hpp:147
Ui
Definition
SchemaSettings.hpp:9
dunedaq::oks
Definition
SchemaCommand.hpp:17
Generated on
for DUNE-DAQ by
1.18.0