35 Kernel->set_active_schema ( File );
42 for ( OksClass::Map::const_iterator i =
Kernel->classes().begin();
43 i !=
Kernel->classes().end(); ++i )
45 ClassList.push_back ( i->second );
51 std::vector<OksClass *> ClassList;
53 for ( OksClass::Map::const_iterator i =
Kernel->classes().begin();
54 i !=
Kernel->classes().end(); ++i )
56 ClassList.push_back ( i->second );
59 for (
OksClass * ClassInfo : ClassList )
61 ClassListString.append ( QString::fromStdString ( ClassInfo->get_name() ) );
67 auto file =
Kernel->get_active_schema();
69 return file->get_full_file_name();
84 auto ParentSchema =
Kernel->find_schema_file( schemaFile );
85 if ( ParentSchema !=
nullptr) {
86 ParentSchema->add_include_file( IncludeFile );
87 Kernel->load_schema( IncludeFile, ParentSchema );
93 auto ParentSchema =
Kernel->find_schema_file( schemaFile );
94 if (ParentSchema !=
nullptr) {
95 ParentSchema->remove_include_file( IncludeFile );
101 for ( OksFile::Map::const_iterator i =
Kernel->schema_files().begin();
102 i !=
Kernel->schema_files().end(); ++i )
104 SchemaFiles.push_back ( * ( i->first ) );
110 for (
auto [name, file]:
Kernel->schema_files())
112 SchemaFiles.push_back ( file );
116std::vector<OksClass*>
120 std::vector<OksClass*> list;
121 auto klist =
Kernel->create_list_of_schema_classes(file);
122 if (klist !=
nullptr) {
123 for (
auto cls: *klist) {
132 std::set<std::string> & included_files )
137 std::set<std::string> & included_files )
140 if ( parentschema !=
nullptr) {
141 std::set<OksFile*> includes;
142 parentschema->get_all_include_files(
Kernel, includes);
143 for (
auto file : includes) {
144 included_files.insert(file->get_full_file_name());
150 std::set<std::string> & included_files )
153 if ( parentschema !=
nullptr) {
154 for (
auto file : parentschema->get_include_files()) {
155 included_files.insert(file);
175 if (file !=
nullptr) {
176 return file->is_updated();
183 return Kernel->find_class ( ClassName );
188 return Kernel->load_schema ( SchemaName );
193 Kernel->save_all_schema();
198 std::string modified{
""};
199 for (
auto [name, file] :
Kernel->schema_files()) {
200 if (file->is_updated()) {
201 modified += file->get_full_file_name() +
"\n\n";
209 std::vector<std::string> modified;
210 for (
auto [name, file] :
Kernel->schema_files()) {
211 if (file->is_updated()) {
212 modified.push_back(file->get_full_file_name());
220 std::string saved{
""};
221 for (
auto [name, file] :
Kernel->schema_files()) {
222 if (file->is_updated()) {
223 Kernel->save_schema(file);
224 saved += file->get_full_file_name() +
"\n\n";
233 Kernel->save_schema(file);
239 Kernel->close_all_schema();
244 Kernel->new_schema ( SchemaName );
249 std::vector<OksClass *> ClassList;
252 for (
OksClass * ClassInfo : ClassList )
254 const std::list<OksRelationship *> * RelationshipList = ClassInfo->direct_relationships();
256 if ( RelationshipList !=
nullptr )
260 if ( RelationshipInfo->get_class_type()->get_name() == SchemaClass->
get_name() )
274 QString RelationshipLowCc (
276 QString RelationshipHighCc (
279 if ( RelationshipLowCc ==
"zero" )
281 RelationshipLowCc =
"0";
283 else if ( RelationshipLowCc ==
"one" )
285 RelationshipLowCc =
"1";
287 else if ( RelationshipLowCc ==
"many" )
289 RelationshipLowCc =
"n";
292 if ( RelationshipHighCc ==
"zero" )
294 RelationshipHighCc =
"0";
296 else if ( RelationshipHighCc ==
"one" )
298 RelationshipHighCc =
"1";
300 else if ( RelationshipHighCc ==
"many" )
302 RelationshipHighCc =
"n";
305 return QString ( RelationshipLowCc +
':' + RelationshipHighCc );
311 return ( ActiveSchemaFile !=
nullptr );
337 QMessageBox::warning ( 0,
"Schema editor",
338 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
343 std::string Description )
351 QMessageBox::warning ( 0,
"Schema editor",
352 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
357 std::string SuperClass )
365 QMessageBox::warning ( 0,
"Schema editor",
366 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
371 std::string SuperClass )
379 QMessageBox::warning ( 0,
"Schema editor",
380 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
385 std::string ClassDescription,
394 QMessageBox::warning ( 0,
"Schema editor", QString (
"Error" ) );
399 std::string ClassDescription,
bool Abstract )
408 QMessageBox::warning ( 0,
"Schema editor",
409 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
423 QMessageBox::warning ( 0,
"Schema editor",
424 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
430 std::string ClassType )
438 QMessageBox::warning ( 0,
"Schema editor",
439 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
446 std::string Description )
454 QMessageBox::warning ( 0,
"Schema editor",
455 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
468 QMessageBox::warning ( 0,
"Schema editor",
469 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
482 QMessageBox::warning ( 0,
"Schema editor",
483 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
497 QMessageBox::warning ( 0,
"Schema editor",
498 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
513 QMessageBox::warning ( 0,
"Schema editor",
514 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
529 QMessageBox::warning ( 0,
"Schema editor",
530 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
535 std::string Description, std::string Type,
536 bool Composite,
bool Exclusive,
bool Dependent,
543 new AddRelationship ( Class, Name, Description, Type, Composite, Exclusive, Dependent,
548 QMessageBox::warning ( 0,
"Schema editor",
549 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
555 std::string Name, std::string Description,
556 std::string Type,
bool Composite,
bool Exclusive,
565 Exclusive, Dependent, LowCc, HighCc ) );
569 QMessageBox::warning ( 0,
"Schema editor",
570 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
577 std::string Language )
585 QMessageBox::warning ( 0,
"Schema editor",
586 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
599 QMessageBox::warning ( 0,
"Schema editor",
600 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
615 QMessageBox::warning ( 0,
"Schema editor",
616 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
622 std::string Language,
623 std::string Prototype, std::string Body )
632 QMessageBox::warning ( 0,
"Schema editor",
633 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
639 std::string Language,
640 std::string Prototype,
650 QMessageBox::warning ( 0,
"Schema editor",
651 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
663 QMessageBox::warning ( 0,
"Schema editor",
664 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
669 std::string description )
677 QMessageBox::warning ( 0,
"Schema editor",
678 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
683 std::string description )
691 QMessageBox::warning ( 0,
"Schema editor",
692 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
697 std::string name, std::string description )
705 QMessageBox::warning ( 0,
"Schema editor",
706 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
712 std::string NewName )
720 QMessageBox::warning ( 0,
"Schema editor",
721 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
727 std::string NewDescription )
735 QMessageBox::warning ( 0,
"Schema editor",
736 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
742 std::string NewType )
750 QMessageBox::warning ( 0,
"Schema editor",
751 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
757 std::string NewRange )
765 QMessageBox::warning ( 0,
"Schema editor",
766 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
780 QMessageBox::warning ( 0,
"Schema editor",
781 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
795 QMessageBox::warning ( 0,
"Schema editor",
796 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
810 QMessageBox::warning ( 0,
"Schema editor",
811 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
817 std::string NewValues )
825 QMessageBox::warning ( 0,
"Schema editor",
826 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
832 bool is_mv, std::string
range,
833 std::string init_values, std::string description,
844 QMessageBox::warning ( 0,
"Schema editor",
845 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
851 std::string name, std::string type,
bool is_mv,
852 std::string
range, std::string init_values,
853 std::string description,
bool is_null,
860 description, is_null, format ) );
864 QMessageBox::warning ( 0,
"Schema editor",
865 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
870 : QObject ( parent ),
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::OksFile * LoadSchema(const std::string &SchemaName) const
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)
std::vector< std::string > get_modified_schema_files() const
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)
dunedaq::oks::OksKernel * Kernel
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 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 get_all_includes(const std::string &FileName, std::set< std::string > &IncludedFiles)
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.
QUndoStack * CommandStack
std::vector< dunedaq::oks::OksClass * > get_schema_classes(std::string &filename)
void PushSetMethodImplementationBody(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, dunedaq::oks::OksMethodImplementation *Implementation, std::string Body)
bool is_file_modified(const std::string &FileName) const
void GetSchemaFiles(std::vector< std::string > &SchemaFiles)
void get_direct_includes(const std::string &FileName, std::set< std::string > &IncludedFiles)
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.