DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
SchemaMethodImplementationEditor.cpp
Go to the documentation of this file.
1#include <QMessageBox>
5#include "ui_SchemaMethodImplementationEditor.h"
6
7using namespace dunedaq::oks;
8
10
12 OksClass * Class, OksMethod * Method, OksMethodImplementation * Implementation, QWidget * parent )
13 : QWidget ( parent ),
15 m_class ( Class ),
16 m_method ( Method ),
17 m_implementation ( Implementation ),
18 UsedNew ( false )
19{
20 QWidget::setAttribute(Qt::WA_DeleteOnClose);
21 ui->setupUi ( this );
24}
25
27 OksClass * Class,
28 OksMethod * Method,
29 QWidget * parent )
30 : QWidget ( parent ),
32 m_class ( Class ),
33 m_method ( Method ),
34 m_implementation ( nullptr ),
35 UsedNew ( true )
36{
37 QWidget::setAttribute(Qt::WA_DeleteOnClose);
38 ui->setupUi ( this );
41}
42
44{
45 connect ( ui->SaveButton, SIGNAL ( clicked() ), this, SLOT ( ProxySlot() ) );
46 connect ( &KernelWrapper::GetInstance(), SIGNAL ( ClassUpdated ( QString ) ), this,
47 SLOT ( ClassUpdated ( QString ) ) );
48}
49
51{
52 if(!UsedNew && class_name.toStdString() == m_class->get_name()) {
53 if(m_method->find_implementation(m_implementation->get_language()) != nullptr) {
54 FillInfo();
55 } else {
56 QWidget::close();
57 }
58 }
59}
60
62{
63 ui->MethodImplementationLanguage->setText (
64 QString::fromStdString ( m_implementation->get_language() ) );
65 ui->MethodImplementationPrototype->setText (
66 QString::fromStdString ( m_implementation->get_prototype() ) );
67 ui->MethodImplementationDescription->setPlainText (
68 QString::fromStdString ( m_implementation->get_body() ) );
69
70 std::string name = m_class->get_name() + m_method->get_name()
71 + m_implementation->get_language();
72 setObjectName ( QString::fromStdString(name) );
73}
74
76{
77 std::string title = "Method Implementation for " + m_method->get_name() ;
78 setWindowTitle (QString::fromStdString(title));
79 std::string name = m_method->get_name();
80 setObjectName ( QString::fromStdString(name) );
81
82 if ( !UsedNew ) {
83 FillInfo();
84 }
85}
86
88{
89 bool changed = false;
90 std::string MethodLanguage = ui->MethodImplementationLanguage->text().toStdString();
91 std::string MethodPrototype = ui->MethodImplementationPrototype->text().toStdString();
92 std::string MethodDescription = ui->MethodImplementationDescription->toPlainText()
93 .toStdString();
94
95 if ( MethodLanguage != m_implementation->get_language() )
96 {
98 m_method,
99 m_implementation,
100 MethodLanguage );
101 changed = true;
102 }
103
104 if ( MethodPrototype != m_implementation->get_prototype() )
105 {
107 m_method,
108 m_implementation,
109 MethodPrototype );
110 changed = true;
111 }
112
113 if ( MethodDescription != m_implementation->get_body() )
114 {
116 m_method,
117 m_implementation,
118 MethodDescription );
119 changed = true;
120 }
121
122 if ( changed )
123 {
124 emit RebuildModel();
125 }
126
127 close();
128}
129
131{
132 if ( ui->MethodImplementationLanguage->text().isEmpty()
133 && ui->MethodImplementationLanguage->text().isEmpty()
134 && ui->MethodImplementationDescription->toPlainText().isEmpty() ) {
135 // Close empty dialogue box
136 close();
137 return;
138 }
139
140 if ( ui->MethodImplementationLanguage->text().isEmpty() )
141 {
142 QMessageBox::warning (
143 0, "Schema editor",
144 QString ( "Please Provide a Language for the method implementation !" ) );
145 return;
146 }
147
148 if ( ui->MethodImplementationPrototype->text().isEmpty() )
149 {
150 QMessageBox::warning (
151 0, "Schema editor",
152 QString ( "Please Provide a prototype for the method implementation !" ) );
153 return;
154 }
155
156 std::string MethodLanguage = ui->MethodImplementationLanguage->text().toStdString();
157 std::string MethodPrototype = ui->MethodImplementationPrototype->text().toStdString();
158 std::string MethodDescription = ui->MethodImplementationDescription->toPlainText()
159 .toStdString();
160
162 m_method,
163 MethodLanguage,
164 MethodPrototype,
165 MethodDescription );
166 emit RebuildModel();
167 close();
168}
169
171{
172 if ( UsedNew )
173 {
174 ParseToCreate();
175 }
176 else
177 {
178 ParseToSave();
179 }
180}
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)
The OKS class.
Definition class.hpp:200
OKS method implementation class.
Definition method.hpp:35
OKS method class.
Definition method.hpp:153