25 OksFile * File = Kernel->find_schema_file ( ActiveSchema );
27 if ( File && IsFileWritable( ActiveSchema ))
29 Kernel->set_active_schema ( File );
35 for ( OksClass::Map::const_iterator i = Kernel->classes().begin();
36 i != Kernel->classes().end(); ++i )
38 ClassList.push_back ( i->second );
44 std::vector<OksClass *> ClassList;
46 for ( OksClass::Map::const_iterator i = Kernel->classes().begin();
47 i != Kernel->classes().end(); ++i )
49 ClassList.push_back ( i->second );
52 for (
OksClass * ClassInfo : ClassList )
54 ClassListString.append ( QString::fromStdString ( ClassInfo->get_name() ) );
60 auto file = Kernel->get_active_schema();
62 return file->get_full_file_name();
77 auto ParentSchema = Kernel->find_schema_file( schemaFile );
78 if ( ParentSchema !=
nullptr) {
79 ParentSchema->add_include_file( IncludeFile );
80 Kernel->load_schema( IncludeFile, ParentSchema );
86 auto ParentSchema = Kernel->find_schema_file( schemaFile );
87 if (ParentSchema !=
nullptr) {
88 std::cout <<
"Calling remove_include_file()\n";
89 ParentSchema->remove_include_file( IncludeFile );
90 std::cout <<
"Called remove_include_file()\n";
96 for ( OksFile::Map::const_iterator i = Kernel->schema_files().begin();
97 i != Kernel->schema_files().end(); ++i )
99 SchemaFiles.push_back ( * ( i->first ) );
104 std::set<std::string> & IncludedFiles )
106 Kernel->get_includes ( FileName, IncludedFiles );
111 OksFile * File = Kernel->find_schema_file ( FileName );
123 return Kernel->find_class ( ClassName );
128 Kernel->load_schema ( SchemaName );
133 Kernel->save_all_schema();
138 std::string modified{
""};
139 for (
auto [name, file] : Kernel->schema_files()) {
140 if (file->is_updated()) {
141 modified += file->get_full_file_name() +
"\n\n";
149 std::string saved{
""};
150 for (
auto [name, file] : Kernel->schema_files()) {
151 if (file->is_updated()) {
152 Kernel->save_schema(file);
153 saved += file->get_full_file_name() +
"\n\n";
161 OksFile * file = Kernel->find_schema_file ( schema_file );
162 Kernel->save_schema(file);
168 Kernel->close_all_schema();
173 Kernel->new_schema ( SchemaName );
178 std::vector<OksClass *> ClassList;
179 GetClassList ( ClassList );
181 for (
OksClass * ClassInfo : ClassList )
183 const std::list<OksRelationship *> * RelationshipList = ClassInfo->direct_relationships();
185 if ( RelationshipList !=
nullptr )
189 if ( RelationshipInfo->get_class_type()->get_name() == SchemaClass->
get_name() )
203 QString RelationshipLowCc (
205 QString RelationshipHighCc (
208 if ( RelationshipLowCc ==
"zero" )
210 RelationshipLowCc =
"0";
212 else if ( RelationshipLowCc ==
"one" )
214 RelationshipLowCc =
"1";
216 else if ( RelationshipLowCc ==
"many" )
218 RelationshipLowCc =
"n";
221 if ( RelationshipHighCc ==
"zero" )
223 RelationshipHighCc =
"0";
225 else if ( RelationshipHighCc ==
"one" )
227 RelationshipHighCc =
"1";
229 else if ( RelationshipHighCc ==
"many" )
231 RelationshipHighCc =
"n";
234 return QString ( RelationshipLowCc +
':' + RelationshipHighCc );
239 OksFile * ActiveSchemaFile = Kernel->get_active_schema();
240 return ( ActiveSchemaFile !=
nullptr );
245 InheritanceMode = Mode;
250 return InheritanceMode;
266 QMessageBox::warning ( 0,
"Schema editor",
267 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
272 std::string Description )
280 QMessageBox::warning ( 0,
"Schema editor",
281 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
286 std::string SuperClass )
294 QMessageBox::warning ( 0,
"Schema editor",
295 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
300 std::string SuperClass )
308 QMessageBox::warning ( 0,
"Schema editor",
309 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
314 std::string ClassDescription,
319 CommandStack->push (
new CreateClassCommand ( ClassName, ClassDescription, Abstract ) );
323 QMessageBox::warning ( 0,
"Schema editor", QString (
"Error" ) );
328 std::string ClassDescription,
bool Abstract )
337 QMessageBox::warning ( 0,
"Schema editor",
338 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
352 QMessageBox::warning ( 0,
"Schema editor",
353 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
359 std::string ClassType )
367 QMessageBox::warning ( 0,
"Schema editor",
368 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
375 std::string Description )
383 QMessageBox::warning ( 0,
"Schema editor",
384 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
397 QMessageBox::warning ( 0,
"Schema editor",
398 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
411 QMessageBox::warning ( 0,
"Schema editor",
412 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
426 QMessageBox::warning ( 0,
"Schema editor",
427 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
442 QMessageBox::warning ( 0,
"Schema editor",
443 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
458 QMessageBox::warning ( 0,
"Schema editor",
459 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
464 std::string Description, std::string Type,
465 bool Composite,
bool Exclusive,
bool Dependent,
472 new AddRelationship ( Class, Name, Description, Type, Composite, Exclusive, Dependent,
477 QMessageBox::warning ( 0,
"Schema editor",
478 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
484 std::string Name, std::string Description,
485 std::string Type,
bool Composite,
bool Exclusive,
494 Exclusive, Dependent, LowCc, HighCc ) );
498 QMessageBox::warning ( 0,
"Schema editor",
499 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
506 std::string Language )
514 QMessageBox::warning ( 0,
"Schema editor",
515 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
528 QMessageBox::warning ( 0,
"Schema editor",
529 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
544 QMessageBox::warning ( 0,
"Schema editor",
545 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
551 std::string Language,
552 std::string Prototype, std::string Body )
561 QMessageBox::warning ( 0,
"Schema editor",
562 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
568 std::string Language,
569 std::string Prototype,
579 QMessageBox::warning ( 0,
"Schema editor",
580 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
592 QMessageBox::warning ( 0,
"Schema editor",
593 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
598 std::string description )
606 QMessageBox::warning ( 0,
"Schema editor",
607 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
612 std::string description )
620 QMessageBox::warning ( 0,
"Schema editor",
621 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
626 std::string name, std::string description )
634 QMessageBox::warning ( 0,
"Schema editor",
635 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
641 std::string NewName )
649 QMessageBox::warning ( 0,
"Schema editor",
650 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
656 std::string NewDescription )
664 QMessageBox::warning ( 0,
"Schema editor",
665 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
671 std::string NewType )
679 QMessageBox::warning ( 0,
"Schema editor",
680 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
686 std::string NewRange )
694 QMessageBox::warning ( 0,
"Schema editor",
695 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
709 QMessageBox::warning ( 0,
"Schema editor",
710 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
724 QMessageBox::warning ( 0,
"Schema editor",
725 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
739 QMessageBox::warning ( 0,
"Schema editor",
740 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
746 std::string NewValues )
754 QMessageBox::warning ( 0,
"Schema editor",
755 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
761 bool is_mv, std::string
range,
762 std::string init_values, std::string description,
773 QMessageBox::warning ( 0,
"Schema editor",
774 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
780 std::string name, std::string type,
bool is_mv,
781 std::string
range, std::string init_values,
782 std::string description,
bool is_null,
789 description, is_null, format ) );
793 QMessageBox::warning ( 0,
"Schema editor",
794 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
799 : QObject ( parent ),
801 CommandStack ( new QUndoStack() ),
802 InheritanceMode ( false )
void PushSetIsCompositeRelationshipCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksRelationship *Relationship, bool Value)
void PushRemoveSuperClassCommand(dunedaq::oks::OksClass *Class, std::string SuperClass)
void PushSetAttributeDescriptionCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, std::string NewDescription)
void PushSetAttributeIsNullCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, bool NewIsNull)
std::string GetActiveSchema() const
void GetClassListString(QStringList &ClassListString) const
void GetIncludedList(const std::string &FileName, std::set< std::string > &IncludedFiles)
std::string SaveModifiedSchema() const
static KernelWrapper & GetInstance()
void PushSetAttributeRangeCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, std::string NewRange)
void GetClassList(std::vector< dunedaq::oks::OksClass * > &ClassList) const
QUndoStack * GetUndoStack()
Stack Functions.
dunedaq::oks::OksKernel * GetKernel()
QString GetCardinalityStringRelationship(dunedaq::oks::OksRelationship *SchemaRelationship) const
void PushSetMethodImplementationLanguage(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, std::string Language)
Method implementation commands.
void PushSetHighCcRelationshipCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksRelationship *Relationship, dunedaq::oks::OksRelationship::CardinalityConstraint NewCardinality)
void PushSetAttributeFormatCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, dunedaq::oks::OksAttribute::Format NewFormat)
void SetActiveSchema(const std::string &ActiveSchema)
void PushSetAbstractClassCommand(dunedaq::oks::OksClass *Class, bool Value)
dunedaq::oks::OksClass * FindClass(std::string ClassName) const
void PushSetIsDependentRelationshipCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksRelationship *Relationship, bool Value)
void RemoveInclude(std::string schemaFile, std::string IncludeFile) const
void SaveSchema(const std::string &file) const
void PushAddSuperClassCommand(dunedaq::oks::OksClass *Class, std::string SuperClass)
void PushSetMethodImplementationPrototype(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, std::string Prototype)
void PushRemoveAttributeCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, std::string name, std::string type, bool is_mv, std::string range, std::string init_values, std::string description, bool is_null, dunedaq::oks::OksAttribute::Format format=dunedaq::oks::OksAttribute::Format::Dec)
void CloseAllSchema() const
void PushAddRelationship(dunedaq::oks::OksClass *Class, std::string Name, std::string Description, std::string Type, bool Composite, bool Exclusive, bool Dependent, dunedaq::oks::OksRelationship::CardinalityConstraint LowCc, dunedaq::oks::OksRelationship::CardinalityConstraint HighCc)
void PushAddMethodImplementationComand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, std::string Language, std::string Prototype, std::string Body)
bool GetInheritanceMode() const
void PushSetIsExclusiveRelationshipCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksRelationship *Relationship, bool Value)
void PushSetDescriptionClassCommand(dunedaq::oks::OksClass *Class, std::string Description)
std::string ModifiedSchemaFiles() const
void PushSetAttributeMultiCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, bool NewIsMulti)
bool AnyClassReferenceThis(dunedaq::oks::OksClass *SchemaClass)
void PushSetAttributeInitialValuesCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, std::string NewValues)
void PushSetDescriptionMethodCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, std::string description)
KernelWrapper(QObject *parent=nullptr)
void SetInheritanceMode(bool Mode)
Editor Functions.
void PushSetClassTypeRelationshipCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksRelationship *Relationship, std::string ClassType)
void PushRemoveMethodImplementationComand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, std::string Language, std::string Prototype, std::string Body)
void CreateNewSchema(const std::string &SchemaName) const
void SaveAllSchema() const
void PushSetNameMethodCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, std::string name)
Method commands.
void LoadSchema(const std::string &SchemaName) const
void PushRemoveRelationship(dunedaq::oks::OksClass *Class, dunedaq::oks::OksRelationship *Relationship, std::string Name, std::string Description, std::string Type, bool Composite, bool Exclusive, bool Dependent, dunedaq::oks::OksRelationship::CardinalityConstraint LowCc, dunedaq::oks::OksRelationship::CardinalityConstraint HighCc)
void PushSetAttributeTypeCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, std::string NewType)
void PushAddAttributeCommand(dunedaq::oks::OksClass *Class, std::string name, std::string type, bool is_mv, std::string range, std::string init_values, std::string description, bool is_null, dunedaq::oks::OksAttribute::Format format=dunedaq::oks::OksAttribute::Format::Dec)
void PushRemoveClassCommand(dunedaq::oks::OksClass *Class, std::string ClassName, std::string ClassDescription, bool Abstract)
void PushSetLowCcRelationshipCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksRelationship *Relationship, dunedaq::oks::OksRelationship::CardinalityConstraint NewCardinality)
bool IsFileWritable(const std::string &FileName) const
void AddInclude(std::string schemaFile, std::string IncludeFile) const
void PushSetDescriptionRelationshipCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksRelationship *Relationship, std::string Description)
void PushAddMethodCommand(dunedaq::oks::OksClass *Class, std::string name, std::string description)
void PushRemoveMethodCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, std::string name, std::string description)
void PushCreateClassCommand(std::string ClassName, std::string ClassDescription, bool Abstract)
void PushSetNameRelationshipCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksRelationship *Relationship, std::string Name)
Relationship commands.
void PushSetAttributeNameCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, std::string NewName)
Attribute commands.
void PushSetMethodImplementationBody(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, std::string Body)
void GetSchemaFiles(std::vector< std::string > &SchemaFiles)
Methods implementation commands.
const std::string & get_name() const noexcept
Provides interface to the OKS XML schema and data files.
bool is_read_only() const
Return read-only status of OKS file.
Provides interface to the OKS kernel.
OKS method implementation class.
CardinalityConstraint get_high_cardinality_constraint() const noexcept
Get relationship high cardinality constraint.
static const char * card2str(CardinalityConstraint) noexcept
CardinalityConstraint get_low_cardinality_constraint() const noexcept
Get relationship low cardinality constraint.
virtual const char * what() const noexcept
DAC value out of range
Message.