26 OksFile * File = Kernel->find_schema_file ( ActiveSchema );
28 if ( File && IsFileWritable( ActiveSchema ))
30 Kernel->set_active_schema ( File );
31 emit active_updated();
37 for ( OksClass::Map::const_iterator i = Kernel->classes().begin();
38 i != Kernel->classes().end(); ++i )
40 ClassList.push_back ( i->second );
46 std::vector<OksClass *> ClassList;
48 for ( OksClass::Map::const_iterator i = Kernel->classes().begin();
49 i != Kernel->classes().end(); ++i )
51 ClassList.push_back ( i->second );
54 for (
OksClass * ClassInfo : ClassList )
56 ClassListString.append ( QString::fromStdString ( ClassInfo->get_name() ) );
62 auto file = Kernel->get_active_schema();
64 return file->get_full_file_name();
79 auto ParentSchema = Kernel->find_schema_file( schemaFile );
80 if ( ParentSchema !=
nullptr) {
81 ParentSchema->add_include_file( IncludeFile );
82 Kernel->load_schema( IncludeFile, ParentSchema );
88 auto ParentSchema = Kernel->find_schema_file( schemaFile );
89 if (ParentSchema !=
nullptr) {
90 ParentSchema->remove_include_file( IncludeFile );
96 for ( OksFile::Map::const_iterator i = Kernel->schema_files().begin();
97 i != Kernel->schema_files().end(); ++i )
99 SchemaFiles.push_back ( * ( i->first ) );
105 for (
auto [name, file]: Kernel->schema_files())
107 SchemaFiles.push_back ( file );
111std::vector<OksClass*>
114 auto file = Kernel->find_schema_file (
filename );
115 std::vector<OksClass*> list;
116 auto klist = Kernel->create_list_of_schema_classes(file);
117 if (klist !=
nullptr) {
118 for (
auto cls: *klist) {
127 std::set<std::string> & included_files )
129 Kernel->get_includes (
filename, included_files );
132 std::set<std::string> & included_files )
134 auto parentschema = Kernel->find_schema_file(
filename );
135 if ( parentschema !=
nullptr) {
136 std::set<OksFile*> includes;
137 parentschema->get_all_include_files(Kernel, includes);
138 for (
auto file : includes) {
139 included_files.insert(file->get_full_file_name());
145 std::set<std::string> & included_files )
147 auto parentschema = Kernel->find_schema_file(
filename );
148 if ( parentschema !=
nullptr) {
149 for (
auto file : parentschema->get_include_files()) {
150 included_files.insert(file);
157 OksFile * File = Kernel->find_schema_file ( FileName );
169 OksFile* file = Kernel->find_schema_file ( FileName );
170 if (file !=
nullptr) {
171 return file->is_updated();
178 return Kernel->find_class ( ClassName );
183 Kernel->load_schema ( SchemaName );
188 Kernel->save_all_schema();
193 std::string modified{
""};
194 for (
auto [name, file] : Kernel->schema_files()) {
195 if (file->is_updated()) {
196 modified += file->get_full_file_name() +
"\n\n";
204 std::vector<std::string> modified;
205 for (
auto [name, file] : Kernel->schema_files()) {
206 if (file->is_updated()) {
207 modified.push_back(file->get_full_file_name());
215 std::string saved{
""};
216 for (
auto [name, file] : Kernel->schema_files()) {
217 if (file->is_updated()) {
218 Kernel->save_schema(file);
219 saved += file->get_full_file_name() +
"\n\n";
227 OksFile * file = Kernel->find_schema_file ( schema_file );
228 Kernel->save_schema(file);
234 Kernel->close_all_schema();
239 Kernel->new_schema ( SchemaName );
244 std::vector<OksClass *> ClassList;
245 GetClassList ( ClassList );
247 for (
OksClass * ClassInfo : ClassList )
249 const std::list<OksRelationship *> * RelationshipList = ClassInfo->direct_relationships();
251 if ( RelationshipList !=
nullptr )
255 if ( RelationshipInfo->get_class_type()->get_name() == SchemaClass->
get_name() )
269 QString RelationshipLowCc (
271 QString RelationshipHighCc (
274 if ( RelationshipLowCc ==
"zero" )
276 RelationshipLowCc =
"0";
278 else if ( RelationshipLowCc ==
"one" )
280 RelationshipLowCc =
"1";
282 else if ( RelationshipLowCc ==
"many" )
284 RelationshipLowCc =
"n";
287 if ( RelationshipHighCc ==
"zero" )
289 RelationshipHighCc =
"0";
291 else if ( RelationshipHighCc ==
"one" )
293 RelationshipHighCc =
"1";
295 else if ( RelationshipHighCc ==
"many" )
297 RelationshipHighCc =
"n";
300 return QString ( RelationshipLowCc +
':' + RelationshipHighCc );
305 OksFile * ActiveSchemaFile = Kernel->get_active_schema();
306 return ( ActiveSchemaFile !=
nullptr );
311 InheritanceMode = Mode;
316 return InheritanceMode;
332 QMessageBox::warning ( 0,
"Schema editor",
333 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
338 std::string Description )
346 QMessageBox::warning ( 0,
"Schema editor",
347 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
352 std::string SuperClass )
360 QMessageBox::warning ( 0,
"Schema editor",
361 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
366 std::string SuperClass )
374 QMessageBox::warning ( 0,
"Schema editor",
375 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
380 std::string ClassDescription,
385 CommandStack->push (
new CreateClassCommand ( ClassName, ClassDescription, Abstract ) );
389 QMessageBox::warning ( 0,
"Schema editor", QString (
"Error" ) );
394 std::string ClassDescription,
bool Abstract )
403 QMessageBox::warning ( 0,
"Schema editor",
404 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
418 QMessageBox::warning ( 0,
"Schema editor",
419 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
425 std::string ClassType )
433 QMessageBox::warning ( 0,
"Schema editor",
434 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
441 std::string Description )
449 QMessageBox::warning ( 0,
"Schema editor",
450 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
463 QMessageBox::warning ( 0,
"Schema editor",
464 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
477 QMessageBox::warning ( 0,
"Schema editor",
478 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
492 QMessageBox::warning ( 0,
"Schema editor",
493 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
508 QMessageBox::warning ( 0,
"Schema editor",
509 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
524 QMessageBox::warning ( 0,
"Schema editor",
525 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
530 std::string Description, std::string Type,
531 bool Composite,
bool Exclusive,
bool Dependent,
538 new AddRelationship ( Class, Name, Description, Type, Composite, Exclusive, Dependent,
543 QMessageBox::warning ( 0,
"Schema editor",
544 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
550 std::string Name, std::string Description,
551 std::string Type,
bool Composite,
bool Exclusive,
560 Exclusive, Dependent, LowCc, HighCc ) );
564 QMessageBox::warning ( 0,
"Schema editor",
565 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
572 std::string Language )
580 QMessageBox::warning ( 0,
"Schema editor",
581 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
594 QMessageBox::warning ( 0,
"Schema editor",
595 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
610 QMessageBox::warning ( 0,
"Schema editor",
611 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
617 std::string Language,
618 std::string Prototype, std::string Body )
627 QMessageBox::warning ( 0,
"Schema editor",
628 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
634 std::string Language,
635 std::string Prototype,
645 QMessageBox::warning ( 0,
"Schema editor",
646 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
658 QMessageBox::warning ( 0,
"Schema editor",
659 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
664 std::string description )
672 QMessageBox::warning ( 0,
"Schema editor",
673 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
678 std::string description )
686 QMessageBox::warning ( 0,
"Schema editor",
687 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
692 std::string name, std::string description )
700 QMessageBox::warning ( 0,
"Schema editor",
701 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
707 std::string NewName )
715 QMessageBox::warning ( 0,
"Schema editor",
716 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
722 std::string NewDescription )
730 QMessageBox::warning ( 0,
"Schema editor",
731 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
737 std::string NewType )
745 QMessageBox::warning ( 0,
"Schema editor",
746 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
752 std::string NewRange )
760 QMessageBox::warning ( 0,
"Schema editor",
761 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
775 QMessageBox::warning ( 0,
"Schema editor",
776 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
790 QMessageBox::warning ( 0,
"Schema editor",
791 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
805 QMessageBox::warning ( 0,
"Schema editor",
806 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
812 std::string NewValues )
820 QMessageBox::warning ( 0,
"Schema editor",
821 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
827 bool is_mv, std::string
range,
828 std::string init_values, std::string description,
839 QMessageBox::warning ( 0,
"Schema editor",
840 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
846 std::string name, std::string type,
bool is_mv,
847 std::string
range, std::string init_values,
848 std::string description,
bool is_null,
855 description, is_null, format ) );
859 QMessageBox::warning ( 0,
"Schema editor",
860 QString (
"Error : \n\n %1" ).arg ( Ex.
what() ) );
865 : QObject ( parent ),
867 CommandStack ( new QUndoStack() ),
868 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)
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)
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 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.
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.