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 apps/SchemaEditor/SchemaMethodImplementationEditor.cpp).
5
6
#include <QMessageBox>
8
#include "
dbe/SchemaMethodImplementationEditor.hpp
"
9
#include "
dbe/SchemaKernelWrapper.hpp
"
10
#include "ui_SchemaMethodImplementationEditor.h"
11
12
using namespace
dunedaq::oks
;
13
14
dbse::SchemaMethodImplementationEditor::~SchemaMethodImplementationEditor
() =
default
;
15
16
dbse::SchemaMethodImplementationEditor::SchemaMethodImplementationEditor
(
17
OksClass
* Class,
OksMethod
* Method,
OksMethodImplementation
* Implementation, QWidget * parent )
18
: QWidget ( parent ),
19
ui
( new
Ui
::
SchemaMethodImplementationEditor
),
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
);
27
InitialSettings
();
28
SetController
();
29
}
30
31
dbse::SchemaMethodImplementationEditor::SchemaMethodImplementationEditor
(
32
OksClass
* Class,
33
OksMethod
* Method,
34
QWidget * parent )
35
: QWidget ( parent ),
36
ui
( new
Ui
::
SchemaMethodImplementationEditor
),
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
);
44
InitialSettings
();
45
SetController
();
46
}
47
48
void
dbse::SchemaMethodImplementationEditor::SetController
()
49
{
50
connect (
ui
->SaveButton, SIGNAL ( clicked() ),
this
, SLOT (
ProxySlot
() ) );
51
connect ( &
KernelWrapper::GetInstance
(), SIGNAL (
ClassUpdated
( QString ) ),
this
,
52
SLOT (
ClassUpdated
( QString ) ) );
53
}
54
55
void
dbse::SchemaMethodImplementationEditor::ClassUpdated
( QString class_name )
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
66
void
dbse::SchemaMethodImplementationEditor::FillInfo
()
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
80
void
dbse::SchemaMethodImplementationEditor::InitialSettings
()
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
94
void
dbse::SchemaMethodImplementationEditor::ParseToSave
()
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
{
105
KernelWrapper::GetInstance
().
PushSetMethodImplementationLanguage
(
m_class
,
106
m_method
,
107
m_implementation
,
108
MethodLanguage );
109
changed =
true
;
110
}
111
112
if
( MethodPrototype !=
m_implementation
->get_prototype() )
113
{
114
KernelWrapper::GetInstance
().
PushSetMethodImplementationPrototype
(
m_class
,
115
m_method
,
116
m_implementation
,
117
MethodPrototype );
118
changed =
true
;
119
}
120
121
if
( MethodDescription !=
m_implementation
->get_body() )
122
{
123
KernelWrapper::GetInstance
().
PushSetMethodImplementationBody
(
m_class
,
124
m_method
,
125
m_implementation
,
126
MethodDescription );
127
changed =
true
;
128
}
129
130
if
( changed )
131
{
132
emit
RebuildModel
();
133
}
134
135
close();
136
}
137
138
void
dbse::SchemaMethodImplementationEditor::ParseToCreate
()
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
169
KernelWrapper::GetInstance
().
PushAddMethodImplementationComand
(
m_class
,
170
m_method
,
171
MethodLanguage,
172
MethodPrototype,
173
MethodDescription );
174
emit
RebuildModel
();
175
close();
176
}
177
178
void
dbse::SchemaMethodImplementationEditor::ProxySlot
()
179
{
180
if
(
UsedNew
)
181
{
182
ParseToCreate
();
183
}
184
else
185
{
186
ParseToSave
();
187
}
188
}
SchemaKernelWrapper.hpp
SchemaMethodImplementationEditor.hpp
dbse::KernelWrapper::GetInstance
static KernelWrapper & GetInstance()
Definition
SchemaKernelWrapper.cpp:18
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:574
dbse::KernelWrapper::PushSetMethodImplementationPrototype
void PushSetMethodImplementationPrototype(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, std::string Prototype)
Definition
SchemaKernelWrapper.cpp:590
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:620
dbse::KernelWrapper::PushSetMethodImplementationBody
void PushSetMethodImplementationBody(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, std::string Body)
Definition
SchemaKernelWrapper.cpp:604
dbse::SchemaMethodImplementationEditor::ui
std::unique_ptr< dbse::Ui::SchemaMethodImplementationEditor > ui
Definition
SchemaMethodImplementationEditor.hpp:44
dbse::SchemaMethodImplementationEditor::ParseToCreate
void ParseToCreate()
Definition
SchemaMethodImplementationEditor.cpp:138
dbse::SchemaMethodImplementationEditor::ParseToSave
void ParseToSave()
Definition
SchemaMethodImplementationEditor.cpp:94
dbse::SchemaMethodImplementationEditor::FillInfo
void FillInfo()
Definition
SchemaMethodImplementationEditor.cpp:66
dbse::SchemaMethodImplementationEditor::ProxySlot
void ProxySlot()
Definition
SchemaMethodImplementationEditor.cpp:178
dbse::SchemaMethodImplementationEditor::m_method
dunedaq::oks::OksMethod * m_method
Definition
SchemaMethodImplementationEditor.hpp:46
dbse::SchemaMethodImplementationEditor::InitialSettings
void InitialSettings()
Definition
SchemaMethodImplementationEditor.cpp:80
dbse::SchemaMethodImplementationEditor::ClassUpdated
void ClassUpdated(QString ClassName)
Definition
SchemaMethodImplementationEditor.cpp:55
dbse::SchemaMethodImplementationEditor::SchemaMethodImplementationEditor
SchemaMethodImplementationEditor(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, QWidget *parent=nullptr)
Definition
SchemaMethodImplementationEditor.cpp:16
dbse::SchemaMethodImplementationEditor::SetController
void SetController()
Definition
SchemaMethodImplementationEditor.cpp:48
dbse::SchemaMethodImplementationEditor::RebuildModel
void RebuildModel()
dbse::SchemaMethodImplementationEditor::m_implementation
dunedaq::oks::OksMethodImplementation * m_implementation
Definition
SchemaMethodImplementationEditor.hpp:47
dbse::SchemaMethodImplementationEditor::UsedNew
bool UsedNew
Definition
SchemaMethodImplementationEditor.hpp:48
dbse::SchemaMethodImplementationEditor::~SchemaMethodImplementationEditor
~SchemaMethodImplementationEditor()
dbse::SchemaMethodImplementationEditor::m_class
dunedaq::oks::OksClass * m_class
Definition
SchemaMethodImplementationEditor.hpp:45
dunedaq::oks::OksClass
The OKS class.
Definition
class.hpp:205
dunedaq::oks::OksMethodImplementation
OKS method implementation class.
Definition
method.hpp:40
dunedaq::oks::OksMethod
OKS method class.
Definition
method.hpp:158
Ui
Definition
SchemaSettings.hpp:10
dunedaq::oks
Definition
OksConfiguration.hpp:24
Generated on
for DUNE-DAQ by
1.17.0