Line data Source code
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/SchemaKernelWrapper.cpp to apps/SchemaEditor/SchemaKernelWrapper.cpp).
5 :
6 : /// Including QT
7 : #include <QMessageBox>
8 : /// Including Schema
9 : #include "dbe/SchemaKernelWrapper.hpp"
10 : /// Include oks
11 : #include "oks/class.hpp"
12 : #include "oks/file.hpp"
13 : #include "oks/kernel.hpp"
14 :
15 : using namespace dunedaq;
16 : using namespace dunedaq::oks;
17 :
18 : dbse::KernelWrapper&
19 0 : dbse::KernelWrapper::GetInstance()
20 : {
21 0 : static KernelWrapper KernelManager;
22 0 : return KernelManager;
23 : }
24 :
25 : OksKernel*
26 0 : dbse::KernelWrapper::GetKernel()
27 : {
28 0 : return Kernel;
29 : }
30 :
31 : void
32 0 : dbse::KernelWrapper::SetActiveSchema(const std::string& ActiveSchema)
33 : {
34 0 : OksFile* File = Kernel->find_schema_file(ActiveSchema);
35 :
36 0 : if (File && IsFileWritable(ActiveSchema)) {
37 0 : Kernel->set_active_schema(File);
38 0 : emit active_updated();
39 : }
40 0 : }
41 :
42 : void
43 0 : dbse::KernelWrapper::GetClassList(std::vector<OksClass*>& ClassList) const
44 : {
45 0 : for (OksClass::Map::const_iterator i = Kernel->classes().begin(); i != Kernel->classes().end(); ++i) {
46 0 : ClassList.push_back(i->second);
47 : }
48 0 : }
49 :
50 : void
51 0 : dbse::KernelWrapper::GetClassListString(QStringList& ClassListString) const
52 : {
53 0 : std::vector<OksClass*> ClassList;
54 :
55 0 : for (OksClass::Map::const_iterator i = Kernel->classes().begin(); i != Kernel->classes().end(); ++i) {
56 0 : ClassList.push_back(i->second);
57 : }
58 :
59 0 : for (OksClass* ClassInfo : ClassList) {
60 0 : ClassListString.append(QString::fromStdString(ClassInfo->get_name()));
61 : }
62 0 : }
63 :
64 : std::string
65 0 : dbse::KernelWrapper::GetActiveSchema() const
66 : {
67 0 : auto file = Kernel->get_active_schema();
68 0 : if (file) {
69 0 : return file->get_full_file_name();
70 : } else {
71 0 : return "";
72 : }
73 : }
74 :
75 : // void dbse::KernelWrapper::AddInclude( std::string IncludeFile ) const
76 : // {
77 : // auto ActiveSchema = Kernel->get_active_schema();
78 : // ActiveSchema->add_include_file( IncludeFile );
79 : // Kernel->load_schema( IncludeFile, ActiveSchema );
80 : // }
81 : void
82 0 : dbse::KernelWrapper::AddInclude(std::string schemaFile, std::string IncludeFile) const
83 : {
84 0 : auto ParentSchema = Kernel->find_schema_file(schemaFile);
85 0 : if (ParentSchema != nullptr) {
86 0 : ParentSchema->add_include_file(IncludeFile);
87 0 : Kernel->load_schema(IncludeFile, ParentSchema);
88 : }
89 0 : }
90 :
91 : void
92 0 : dbse::KernelWrapper::RemoveInclude(std::string schemaFile, std::string IncludeFile) const
93 : {
94 0 : auto ParentSchema = Kernel->find_schema_file(schemaFile);
95 0 : if (ParentSchema != nullptr) {
96 0 : ParentSchema->remove_include_file(IncludeFile);
97 : }
98 0 : }
99 :
100 : void
101 0 : dbse::KernelWrapper::GetSchemaFiles(std::vector<std::string>& SchemaFiles)
102 : {
103 0 : for (OksFile::Map::const_iterator i = Kernel->schema_files().begin(); i != Kernel->schema_files().end(); ++i) {
104 0 : SchemaFiles.push_back(*(i->first));
105 : }
106 0 : }
107 :
108 : void
109 0 : dbse::KernelWrapper::GetSchemaFiles(std::vector<OksFile*>& SchemaFiles)
110 : {
111 0 : for (auto [name, file] : Kernel->schema_files()) {
112 0 : SchemaFiles.push_back(file);
113 : }
114 0 : }
115 :
116 : std::vector<OksClass*>
117 0 : dbse::KernelWrapper::get_schema_classes(std::string& filename)
118 : {
119 0 : auto file = Kernel->find_schema_file(filename);
120 0 : std::vector<OksClass*> list;
121 0 : auto klist = Kernel->create_list_of_schema_classes(file);
122 0 : if (klist != nullptr) {
123 0 : for (auto cls : *klist) {
124 0 : list.push_back(cls /*->get_name()*/);
125 : }
126 0 : delete klist;
127 : }
128 0 : return list;
129 0 : }
130 :
131 : void
132 0 : dbse::KernelWrapper::GetIncludedList(const std::string& filename, std::set<std::string>& included_files)
133 : {
134 0 : Kernel->get_includes(filename, included_files);
135 0 : }
136 : void
137 0 : dbse::KernelWrapper::get_all_includes(const std::string& filename, std::set<std::string>& included_files)
138 : {
139 0 : auto parentschema = Kernel->find_schema_file(filename);
140 0 : if (parentschema != nullptr) {
141 0 : std::set<OksFile*> includes;
142 0 : parentschema->get_all_include_files(Kernel, includes);
143 0 : for (auto file : includes) {
144 0 : included_files.insert(file->get_full_file_name());
145 : }
146 0 : }
147 0 : }
148 :
149 : void
150 0 : dbse::KernelWrapper::get_direct_includes(const std::string& filename, std::set<std::string>& included_files)
151 : {
152 0 : auto parentschema = Kernel->find_schema_file(filename);
153 0 : if (parentschema != nullptr) {
154 0 : for (auto file : parentschema->get_include_files()) {
155 0 : included_files.insert(file);
156 0 : }
157 : }
158 0 : }
159 :
160 : bool
161 0 : dbse::KernelWrapper::IsFileWritable(const std::string& FileName) const
162 : {
163 0 : OksFile* File = Kernel->find_schema_file(FileName);
164 :
165 0 : if (File) {
166 0 : return (!File->is_read_only());
167 : }
168 :
169 : return false;
170 : }
171 :
172 : bool
173 0 : dbse::KernelWrapper::is_file_modified(const std::string& FileName) const
174 : {
175 0 : OksFile* file = Kernel->find_schema_file(FileName);
176 0 : if (file != nullptr) {
177 0 : return file->is_updated();
178 : }
179 : return false;
180 : }
181 :
182 : OksClass*
183 0 : dbse::KernelWrapper::FindClass(std::string ClassName) const
184 : {
185 0 : return Kernel->find_class(ClassName);
186 : }
187 :
188 : OksFile*
189 0 : dbse::KernelWrapper::LoadSchema(const std::string& SchemaName) const
190 : {
191 0 : return Kernel->load_schema(SchemaName);
192 : }
193 :
194 : void
195 0 : dbse::KernelWrapper::SaveAllSchema() const
196 : {
197 0 : Kernel->save_all_schema();
198 0 : }
199 :
200 : std::string
201 0 : dbse::KernelWrapper::ModifiedSchemaFiles() const
202 : {
203 0 : std::string modified{ "" };
204 0 : for (auto [name, file] : Kernel->schema_files()) {
205 0 : if (file->is_updated()) {
206 0 : modified += file->get_full_file_name() + "\n\n";
207 : }
208 : }
209 0 : return modified;
210 0 : }
211 :
212 : std::vector<std::string>
213 0 : dbse::KernelWrapper::get_modified_schema_files() const
214 : {
215 0 : std::vector<std::string> modified;
216 0 : for (auto [name, file] : Kernel->schema_files()) {
217 0 : if (file->is_updated()) {
218 0 : modified.push_back(file->get_full_file_name());
219 : }
220 : }
221 0 : return modified;
222 0 : }
223 :
224 : std::string
225 0 : dbse::KernelWrapper::SaveModifiedSchema() const
226 : {
227 0 : std::string saved{ "" };
228 0 : for (auto [name, file] : Kernel->schema_files()) {
229 0 : if (file->is_updated()) {
230 0 : Kernel->save_schema(file);
231 0 : saved += file->get_full_file_name() + "\n\n";
232 : }
233 : }
234 0 : return saved;
235 0 : }
236 :
237 : void
238 0 : dbse::KernelWrapper::SaveSchema(const std::string& schema_file) const
239 : {
240 0 : OksFile* file = Kernel->find_schema_file(schema_file);
241 0 : Kernel->save_schema(file);
242 0 : }
243 :
244 : void
245 0 : dbse::KernelWrapper::CloseAllSchema() const
246 : {
247 0 : Kernel->close_all_schema();
248 0 : }
249 :
250 : void
251 0 : dbse::KernelWrapper::CreateNewSchema(const std::string& SchemaName) const
252 : {
253 0 : Kernel->new_schema(SchemaName);
254 0 : }
255 :
256 : bool
257 0 : dbse::KernelWrapper::AnyClassReferenceThis(OksClass* SchemaClass)
258 : {
259 0 : std::vector<OksClass*> ClassList;
260 0 : GetClassList(ClassList);
261 :
262 0 : for (OksClass* ClassInfo : ClassList) {
263 0 : const std::list<OksRelationship*>* RelationshipList = ClassInfo->direct_relationships();
264 :
265 0 : if (RelationshipList != nullptr) {
266 0 : for (OksRelationship* RelationshipInfo : *RelationshipList) {
267 0 : if (RelationshipInfo->get_class_type()->get_name() == SchemaClass->get_name()) {
268 0 : return true;
269 : }
270 : }
271 : }
272 : }
273 :
274 0 : return false;
275 0 : }
276 :
277 : QString
278 0 : dbse::KernelWrapper::GetCardinalityStringRelationship(OksRelationship* SchemaRelationship) const
279 : {
280 0 : QString RelationshipLowCc(OksRelationship::card2str(SchemaRelationship->get_low_cardinality_constraint()));
281 0 : QString RelationshipHighCc(OksRelationship::card2str(SchemaRelationship->get_high_cardinality_constraint()));
282 :
283 0 : if (RelationshipLowCc == "zero") {
284 0 : RelationshipLowCc = "0";
285 0 : } else if (RelationshipLowCc == "one") {
286 0 : RelationshipLowCc = "1";
287 0 : } else if (RelationshipLowCc == "many") {
288 0 : RelationshipLowCc = "n";
289 : }
290 :
291 0 : if (RelationshipHighCc == "zero") {
292 0 : RelationshipHighCc = "0";
293 0 : } else if (RelationshipHighCc == "one") {
294 0 : RelationshipHighCc = "1";
295 0 : } else if (RelationshipHighCc == "many") {
296 0 : RelationshipHighCc = "n";
297 : }
298 :
299 0 : return QString(RelationshipLowCc + ':' + RelationshipHighCc);
300 0 : }
301 :
302 : bool
303 0 : dbse::KernelWrapper::IsActive() const
304 : {
305 0 : OksFile* ActiveSchemaFile = Kernel->get_active_schema();
306 0 : return (ActiveSchemaFile != nullptr);
307 : }
308 :
309 : void
310 0 : dbse::KernelWrapper::SetInheritanceMode(bool Mode)
311 : {
312 0 : InheritanceMode = Mode;
313 0 : }
314 :
315 : bool
316 0 : dbse::KernelWrapper::GetInheritanceMode() const
317 : {
318 0 : return InheritanceMode;
319 : }
320 :
321 : QUndoStack*
322 0 : dbse::KernelWrapper::GetUndoStack()
323 : {
324 0 : return CommandStack;
325 : }
326 :
327 : void
328 0 : dbse::KernelWrapper::PushSetAbstractClassCommand(OksClass* Class, bool Value)
329 : {
330 0 : try {
331 0 : CommandStack->push(new SetAbstractClassCommand(Class, Value));
332 0 : } catch (oks::exception& Ex) {
333 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
334 0 : }
335 0 : }
336 :
337 : void
338 0 : dbse::KernelWrapper::PushSetDescriptionClassCommand(OksClass* Class, std::string Description)
339 : {
340 0 : try {
341 0 : CommandStack->push(new SetDescriptionClassCommand(Class, Description));
342 0 : } catch (oks::exception& Ex) {
343 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
344 0 : }
345 0 : }
346 :
347 : void
348 0 : dbse::KernelWrapper::PushAddSuperClassCommand(OksClass* Class, std::string SuperClass)
349 : {
350 0 : try {
351 0 : CommandStack->push(new AddSuperClassCommand(Class, SuperClass));
352 0 : } catch (oks::exception& Ex) {
353 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
354 0 : }
355 0 : }
356 :
357 : void
358 0 : dbse::KernelWrapper::PushRemoveSuperClassCommand(OksClass* Class, std::string SuperClass)
359 : {
360 0 : try {
361 0 : CommandStack->push(new RemoveSuperClassCommand(Class, SuperClass));
362 0 : } catch (oks::exception& Ex) {
363 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
364 0 : }
365 0 : }
366 :
367 : void
368 0 : dbse::KernelWrapper::PushCreateClassCommand(std::string ClassName, std::string ClassDescription, bool Abstract)
369 : {
370 0 : try {
371 0 : CommandStack->push(new CreateClassCommand(ClassName, ClassDescription, Abstract));
372 0 : } catch (...) {
373 0 : QMessageBox::warning(0, "Schema editor", QString("Error"));
374 0 : }
375 0 : }
376 :
377 : void
378 0 : dbse::KernelWrapper::PushRemoveClassCommand(OksClass* Class,
379 : std::string ClassName,
380 : std::string ClassDescription,
381 : bool Abstract)
382 : {
383 0 : try {
384 0 : CommandStack->push(new RemoveClassCommand(Class, ClassName, ClassDescription, Abstract));
385 0 : } catch (oks::exception& Ex) {
386 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
387 0 : }
388 0 : }
389 :
390 : void
391 0 : dbse::KernelWrapper::PushSetNameRelationshipCommand(OksClass* Class, OksRelationship* Relationship, std::string Name)
392 : {
393 0 : try {
394 0 : CommandStack->push(new SetNameRelationshipCommand(Class, Relationship, Name));
395 0 : } catch (oks::exception& Ex) {
396 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
397 0 : }
398 0 : }
399 :
400 : void
401 0 : dbse::KernelWrapper::PushSetClassTypeRelationshipCommand(OksClass* Class,
402 : OksRelationship* Relationship,
403 : std::string ClassType)
404 : {
405 0 : try {
406 0 : CommandStack->push(new SetClassTypeRelationshipCommand(Class, Relationship, ClassType));
407 0 : } catch (oks::exception& Ex) {
408 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
409 0 : }
410 0 : }
411 :
412 : void
413 0 : dbse::KernelWrapper::PushSetDescriptionRelationshipCommand(OksClass* Class,
414 : OksRelationship* Relationship,
415 : std::string Description)
416 : {
417 0 : try {
418 0 : CommandStack->push(new SetDescriptionRelationshipCommand(Class, Relationship, Description));
419 0 : } catch (oks::exception& Ex) {
420 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
421 0 : }
422 0 : }
423 :
424 : void
425 0 : dbse::KernelWrapper::PushSetLowCcRelationshipCommand(OksClass* Class,
426 : OksRelationship* Relationship,
427 : OksRelationship::CardinalityConstraint NewCardinality)
428 : {
429 0 : try {
430 0 : CommandStack->push(new SetLowCcRelationshipCommand(Class, Relationship, NewCardinality));
431 0 : } catch (oks::exception& Ex) {
432 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
433 0 : }
434 0 : }
435 :
436 : void
437 0 : dbse::KernelWrapper::PushSetHighCcRelationshipCommand(OksClass* Class,
438 : OksRelationship* Relationship,
439 : OksRelationship::CardinalityConstraint NewCardinality)
440 : {
441 0 : try {
442 0 : CommandStack->push(new SetHighCcRelationshipCommand(Class, Relationship, NewCardinality));
443 0 : } catch (oks::exception& Ex) {
444 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
445 0 : }
446 0 : }
447 :
448 : void
449 0 : dbse::KernelWrapper::PushSetIsCompositeRelationshipCommand(OksClass* Class, OksRelationship* Relationship, bool Value)
450 : {
451 0 : try {
452 0 : CommandStack->push(new SetIsCompositeRelationshipCommand(Class, Relationship, Value));
453 0 : } catch (oks::exception& Ex) {
454 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
455 0 : }
456 0 : }
457 :
458 : void
459 0 : dbse::KernelWrapper::PushSetIsDependentRelationshipCommand(OksClass* Class, OksRelationship* Relationship, bool Value)
460 : {
461 0 : try {
462 0 : CommandStack->push(new SetIsDependentRelationshipCommand(Class, Relationship, Value));
463 0 : } catch (oks::exception& Ex) {
464 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
465 0 : }
466 0 : }
467 :
468 : void
469 0 : dbse::KernelWrapper::PushSetIsExclusiveRelationshipCommand(OksClass* Class, OksRelationship* Relationship, bool Value)
470 : {
471 0 : try {
472 0 : CommandStack->push(new SetIsExclusiveRelationshipCommand(Class, Relationship, Value));
473 0 : } catch (oks::exception& Ex) {
474 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
475 0 : }
476 0 : }
477 :
478 : void
479 0 : dbse::KernelWrapper::PushAddRelationship(OksClass* Class,
480 : std::string Name,
481 : std::string Description,
482 : std::string Type,
483 : bool Composite,
484 : bool Exclusive,
485 : bool Dependent,
486 : OksRelationship::CardinalityConstraint LowCc,
487 : OksRelationship::CardinalityConstraint HighCc)
488 : {
489 0 : try {
490 0 : CommandStack->push(
491 0 : new AddRelationship(Class, Name, Description, Type, Composite, Exclusive, Dependent, LowCc, HighCc));
492 0 : } catch (oks::exception& Ex) {
493 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
494 0 : }
495 0 : }
496 :
497 : void
498 0 : dbse::KernelWrapper::PushRemoveRelationship(OksClass* Class,
499 : OksRelationship* Relationship,
500 : std::string Name,
501 : std::string Description,
502 : std::string Type,
503 : bool Composite,
504 : bool Exclusive,
505 : bool Dependent,
506 : OksRelationship::CardinalityConstraint LowCc,
507 : OksRelationship::CardinalityConstraint HighCc)
508 : {
509 0 : try {
510 0 : CommandStack->push(new RemoveRelationship(
511 0 : Class, Relationship, Name, Description, Type, Composite, Exclusive, Dependent, LowCc, HighCc));
512 0 : } catch (oks::exception& Ex) {
513 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
514 0 : }
515 0 : }
516 :
517 : void
518 0 : dbse::KernelWrapper::PushSetMethodImplementationLanguage(OksClass* Class,
519 : OksMethod* Method,
520 : OksMethodImplementation* Implementation,
521 : std::string Language)
522 : {
523 0 : try {
524 0 : CommandStack->push(new SetMethodImplementationLanguage(Class, Method, Implementation, Language));
525 0 : } catch (oks::exception& Ex) {
526 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
527 0 : }
528 0 : }
529 :
530 : void
531 0 : dbse::KernelWrapper::PushSetMethodImplementationPrototype(OksClass* Class,
532 : OksMethod* Method,
533 : OksMethodImplementation* Implementation,
534 : std::string Prototype)
535 : {
536 0 : try {
537 0 : CommandStack->push(new SetMethodImplementationPrototype(Class, Method, Implementation, Prototype));
538 0 : } catch (oks::exception& Ex) {
539 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
540 0 : }
541 0 : }
542 :
543 : void
544 0 : dbse::KernelWrapper::PushSetMethodImplementationBody(OksClass* Class,
545 : OksMethod* Method,
546 : OksMethodImplementation* Implementation,
547 : std::string Body)
548 : {
549 0 : try {
550 0 : CommandStack->push(new SetMethodImplementationBody(Class, Method, Implementation, Body));
551 0 : } catch (oks::exception& Ex) {
552 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
553 0 : }
554 0 : }
555 :
556 : void
557 0 : dbse::KernelWrapper::PushAddMethodImplementationComand(OksClass* Class,
558 : OksMethod* Method,
559 : std::string Language,
560 : std::string Prototype,
561 : std::string Body)
562 : {
563 0 : try {
564 0 : CommandStack->push(new AddMethodImplementationComand(Class, Method, Language, Prototype, Body));
565 0 : } catch (oks::exception& Ex) {
566 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
567 0 : }
568 0 : }
569 :
570 : void
571 0 : dbse::KernelWrapper::PushRemoveMethodImplementationComand(OksClass* Class,
572 : OksMethod* Method,
573 : std::string Language,
574 : std::string Prototype,
575 : std::string Body)
576 : {
577 0 : try {
578 0 : CommandStack->push(new RemoveMethodImplementationComand(Class, Method, Language, Prototype, Body));
579 0 : } catch (oks::exception& Ex) {
580 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
581 0 : }
582 0 : }
583 :
584 : void
585 0 : dbse::KernelWrapper::PushSetNameMethodCommand(OksClass* Class, OksMethod* Method, std::string name)
586 : {
587 0 : try {
588 0 : CommandStack->push(new SetNameMethodCommand(Class, Method, name));
589 0 : } catch (oks::exception& Ex) {
590 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
591 0 : }
592 0 : }
593 :
594 : void
595 0 : dbse::KernelWrapper::PushSetDescriptionMethodCommand(OksClass* Class, OksMethod* Method, std::string description)
596 : {
597 0 : try {
598 0 : CommandStack->push(new SetDescriptionMethodCommand(Class, Method, description));
599 0 : } catch (oks::exception& Ex) {
600 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
601 0 : }
602 0 : }
603 :
604 : void
605 0 : dbse::KernelWrapper::PushAddMethodCommand(OksClass* Class, std::string name, std::string description)
606 : {
607 0 : try {
608 0 : CommandStack->push(new AddMethodCommand(Class, name, description));
609 0 : } catch (oks::exception& Ex) {
610 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
611 0 : }
612 0 : }
613 :
614 : void
615 0 : dbse::KernelWrapper::PushRemoveMethodCommand(OksClass* Class,
616 : OksMethod* Method,
617 : std::string name,
618 : std::string description)
619 : {
620 0 : try {
621 0 : CommandStack->push(new RemoveMethodCommand(Class, Method, name, description));
622 0 : } catch (oks::exception& Ex) {
623 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
624 0 : }
625 0 : }
626 :
627 : void
628 0 : dbse::KernelWrapper::PushSetAttributeNameCommand(OksClass* Class, OksAttribute* Attribute, std::string NewName)
629 : {
630 0 : try {
631 0 : CommandStack->push(new SetAttributeNameCommand(Class, Attribute, NewName));
632 0 : } catch (oks::exception& Ex) {
633 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
634 0 : }
635 0 : }
636 :
637 : void
638 0 : dbse::KernelWrapper::PushSetAttributeDescriptionCommand(OksClass* Class,
639 : OksAttribute* Attribute,
640 : std::string NewDescription)
641 : {
642 0 : try {
643 0 : CommandStack->push(new SetAttributeDescriptionCommand(Class, Attribute, NewDescription));
644 0 : } catch (oks::exception& Ex) {
645 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
646 0 : }
647 0 : }
648 :
649 : void
650 0 : dbse::KernelWrapper::PushSetAttributeTypeCommand(OksClass* Class, OksAttribute* Attribute, std::string NewType)
651 : {
652 0 : try {
653 0 : CommandStack->push(new SetAttributeTypeCommand(Class, Attribute, NewType));
654 0 : } catch (oks::exception& Ex) {
655 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
656 0 : }
657 0 : }
658 :
659 : void
660 0 : dbse::KernelWrapper::PushSetAttributeRangeCommand(OksClass* Class, OksAttribute* Attribute, std::string NewRange)
661 : {
662 0 : try {
663 0 : CommandStack->push(new SetAttributeRangeCommand(Class, Attribute, NewRange));
664 0 : } catch (oks::exception& Ex) {
665 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
666 0 : }
667 0 : }
668 :
669 : void
670 0 : dbse::KernelWrapper::PushSetAttributeFormatCommand(OksClass* Class,
671 : OksAttribute* Attribute,
672 : OksAttribute::Format NewFormat)
673 : {
674 0 : try {
675 0 : CommandStack->push(new SetAttributeFormatCommand(Class, Attribute, NewFormat));
676 0 : } catch (oks::exception& Ex) {
677 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
678 0 : }
679 0 : }
680 :
681 : void
682 0 : dbse::KernelWrapper::PushSetAttributeMultiCommand(OksClass* Class, OksAttribute* Attribute, bool NewIsMulti)
683 : {
684 0 : try {
685 0 : CommandStack->push(new SetAttributeMultiCommand(Class, Attribute, NewIsMulti));
686 0 : } catch (oks::exception& Ex) {
687 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
688 0 : }
689 0 : }
690 :
691 : void
692 0 : dbse::KernelWrapper::PushSetAttributeIsNullCommand(OksClass* Class, OksAttribute* Attribute, bool NewIsNull)
693 : {
694 0 : try {
695 0 : CommandStack->push(new SetAttributeIsNullCommand(Class, Attribute, NewIsNull));
696 0 : } catch (oks::exception& Ex) {
697 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
698 0 : }
699 0 : }
700 :
701 : void
702 0 : dbse::KernelWrapper::PushSetAttributeInitialValuesCommand(OksClass* Class,
703 : OksAttribute* Attribute,
704 : std::string NewValues)
705 : {
706 0 : try {
707 0 : CommandStack->push(new SetAttributeInitialValuesCommand(Class, Attribute, NewValues));
708 0 : } catch (oks::exception& Ex) {
709 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
710 0 : }
711 0 : }
712 :
713 : void
714 0 : dbse::KernelWrapper::PushAddAttributeCommand(OksClass* Class,
715 : std::string name,
716 : std::string type,
717 : bool is_mv,
718 : std::string range,
719 : std::string init_values,
720 : std::string description,
721 : bool is_null,
722 : OksAttribute::Format format)
723 : {
724 0 : try {
725 0 : CommandStack->push(
726 0 : new AddAttributeCommand(Class, name, type, is_mv, range, init_values, description, is_null, format));
727 0 : } catch (oks::exception& Ex) {
728 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
729 0 : }
730 0 : }
731 :
732 : void
733 0 : dbse::KernelWrapper::PushRemoveAttributeCommand(OksClass* Class,
734 : OksAttribute* Attribute,
735 : std::string name,
736 : std::string type,
737 : bool is_mv,
738 : std::string range,
739 : std::string init_values,
740 : std::string description,
741 : bool is_null,
742 : OksAttribute::Format format)
743 : {
744 0 : try {
745 0 : CommandStack->push(new RemoveAttributeCommand(
746 0 : Class, Attribute, name, type, is_mv, range, init_values, description, is_null, format));
747 0 : } catch (oks::exception& Ex) {
748 0 : QMessageBox::warning(0, "Schema editor", QString("Error : \n\n %1").arg(Ex.what()));
749 0 : }
750 0 : }
751 :
752 0 : dbse::KernelWrapper::KernelWrapper(QObject* parent)
753 : : QObject(parent)
754 0 : , Kernel(new OksKernel())
755 0 : , CommandStack(new QUndoStack())
756 0 : , InheritanceMode(false)
757 : {
758 0 : }
|