From a620f07468780778bd55dcffc30245def37ece69 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Thu, 6 Aug 2020 16:07:16 +0200 Subject: MoDeS3 unit propagation WIP --- .../.ApplicationConfigurationIdeModule.xtendbin | Bin 1701 -> 1700 bytes .../ide/.ApplicationConfigurationIdeSetup.xtendbin | Bin 2526 -> 2525 bytes .../.SolverSemanticHighlightCalculator.xtendbin | Bin 5334 -> 5333 bytes .../.SolverSemanticTextAttributeProvider.xtendbin | Bin 4902 -> 4902 bytes .../validation/.SolverLanguageValidator.xtendbin | Bin 1717 -> 1716 bytes ....SolverLanguageTokenDefInjectingParser.xtendbin | Bin 2742 -> 2741 bytes ...nguageSyntheticTokenSyntacticSequencer.xtendbin | Bin 2758 -> 2757 bytes Domains/ca.mcgill.rtgmrt.example.modes3/.classpath | 10 + Domains/ca.mcgill.rtgmrt.example.modes3/.gitignore | 1 + Domains/ca.mcgill.rtgmrt.example.modes3/.project | 40 + ...ry.patternlanguage.emf.EMFPatternLanguage.prefs | 27 + .../META-INF/MANIFEST.MF | 34 + .../build.properties | 11 + .../ecore-gen/modes3/Modes3Factory.java | 69 + .../ecore-gen/modes3/Modes3ModelRoot.java | 87 ++ .../ecore-gen/modes3/Modes3Package.java | 640 ++++++++ .../ecore-gen/modes3/Segment.java | 86 ++ .../ecore-gen/modes3/Train.java | 94 ++ .../ecore-gen/modes3/Turnout.java | 68 + .../ecore-gen/modes3/impl/Modes3FactoryImpl.java | 128 ++ .../ecore-gen/modes3/impl/Modes3ModelRootImpl.java | 296 ++++ .../ecore-gen/modes3/impl/Modes3PackageImpl.java | 363 +++++ .../ecore-gen/modes3/impl/SegmentImpl.java | 319 ++++ .../ecore-gen/modes3/impl/TrainImpl.java | 332 +++++ .../ecore-gen/modes3/impl/TurnoutImpl.java | 216 +++ .../modes3/util/Modes3AdapterFactory.java | 174 +++ .../ecore-gen/modes3/util/Modes3Switch.java | 174 +++ .../model/modes3.aird_deactivated | 1531 ++++++++++++++++++++ .../model/modes3.ecore | 32 + .../model/modes3.genmodel | 30 + .../output/solution.partialinterpretation | 1068 ++++++++++++++ .../output/solution1.gml | 1191 +++++++++++++++ .../output/solution1.partialinterpretation | 1037 +++++++++++++ .../output/solution1.png | Bin 0 -> 105065 bytes .../plugin.properties | 4 + Domains/ca.mcgill.rtgmrt.example.modes3/plugin.xml | 28 + .../src/modes3/queries/Modes3Queries.vql | 112 ++ .../src/modes3/run/Modes3ModelGenerator.xtend | 222 +++ .../run/Modes3UnitPropagationGenerator.xtend | 205 +++ .../vql-gen/modes3/queries/.gitignore | 26 + .../vql-gen/modes3/queries/Adjacent.java | 719 +++++++++ .../vql-gen/modes3/queries/ConnectedTo.java | 704 +++++++++ .../modes3/queries/ConnectedToNotSymmetric.java | 724 +++++++++ .../modes3/queries/ConnectedToReflexive.java | 563 +++++++ .../modes3/queries/ExtraInputOfTurnout.java | 730 ++++++++++ .../vql-gen/modes3/queries/Modes3Queries.java | 229 +++ .../modes3/queries/NoExtraInputOfTurnout.java | 560 +++++++ .../vql-gen/modes3/queries/Output.java | 724 +++++++++ .../vql-gen/modes3/queries/OutputReflexive.java | 559 +++++++ .../vql-gen/modes3/queries/Reachable.java | 719 +++++++++ .../queries/TooManyExtraInputsOfTurnout.java | 570 ++++++++ .../modes3/queries/TooManyInputsOfSegment.java | 601 ++++++++ .../vql-gen/modes3/queries/Turnout.java | 543 +++++++ .../queries/TurnoutConnectedToBothOutputs.java | 589 ++++++++ .../vql-gen/modes3/queries/TurnoutInSegments.java | 564 +++++++ .../vql-gen/modes3/queries/TurnoutOutput.java | 727 ++++++++++ .../modes3/queries/TurnoutOutputsAreSame.java | 572 ++++++++ .../vql-gen/modes3/queries/Unreachable.java | 714 +++++++++ .../modes3/run/.Modes3ModelGenerator.xtendbin | Bin 0 -> 14631 bytes .../run/.Modes3UnitPropagationGenerator.xtendbin | Bin 0 -> 9899 bytes .../xtend-gen/modes3/run/.gitignore | 2 + .../xtend-gen/modes3/run/Modes3ModelGenerator.java | 381 +++++ .../modes3/run/Modes3UnitPropagationGenerator.java | 585 ++++++++ .../ModelGenerationMethodProvider.xtend | 5 +- .../logic2viatra/patterns/PatternGenerator.xtend | 21 +- .../logic2viatra/patterns/PatternProvider.xtend | 56 +- .../patterns/RelationDeclarationIndexer.xtend | 158 +- .../viatrasolver/reasoner/ViatraReasoner.xtend | 1 + .../reasoner/ViatraReasonerConfiguration.xtend | 5 +- 69 files changed, 20874 insertions(+), 106 deletions(-) create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/.classpath create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/.gitignore create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/.project create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/.settings/org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguage.prefs create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/META-INF/MANIFEST.MF create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/build.properties create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Factory.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3ModelRoot.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Package.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Segment.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Train.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Turnout.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3FactoryImpl.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3ModelRootImpl.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3PackageImpl.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/SegmentImpl.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/TrainImpl.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/TurnoutImpl.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3AdapterFactory.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3Switch.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.aird_deactivated create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.ecore create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.genmodel create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/output/solution.partialinterpretation create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/output/solution1.gml create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/output/solution1.partialinterpretation create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/output/solution1.png create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/plugin.properties create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/plugin.xml create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3ModelGenerator.xtend create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3UnitPropagationGenerator.xtend create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/.gitignore create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Adjacent.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedTo.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedToNotSymmetric.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedToReflexive.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ExtraInputOfTurnout.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Modes3Queries.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/NoExtraInputOfTurnout.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Output.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/OutputReflexive.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Reachable.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyExtraInputsOfTurnout.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfSegment.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Turnout.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutConnectedToBothOutputs.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutInSegments.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutOutput.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutOutputsAreSame.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Unreachable.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3ModelGenerator.xtendbin create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3UnitPropagationGenerator.xtendbin create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.gitignore create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3UnitPropagationGenerator.java diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin index 2a740f24..1e457bb2 100644 Binary files a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin and b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin differ diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin index 6fd0f505..6ad24fc0 100644 Binary files a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin and b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin differ diff --git a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticHighlightCalculator.xtendbin b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticHighlightCalculator.xtendbin index 0b252347..18c9aee3 100644 Binary files a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticHighlightCalculator.xtendbin and b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticHighlightCalculator.xtendbin differ diff --git a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticTextAttributeProvider.xtendbin b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticTextAttributeProvider.xtendbin index 930ba6bf..0ebd4493 100644 Binary files a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticTextAttributeProvider.xtendbin and b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticTextAttributeProvider.xtendbin differ diff --git a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.SolverLanguageValidator.xtendbin b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.SolverLanguageValidator.xtendbin index 65fea578..bb484ba1 100644 Binary files a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.SolverLanguageValidator.xtendbin and b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.SolverLanguageValidator.xtendbin differ diff --git a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.SolverLanguageTokenDefInjectingParser.xtendbin b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.SolverLanguageTokenDefInjectingParser.xtendbin index 340908fe..61448536 100644 Binary files a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.SolverLanguageTokenDefInjectingParser.xtendbin and b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.SolverLanguageTokenDefInjectingParser.xtendbin differ diff --git a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.SolverLanguageSyntheticTokenSyntacticSequencer.xtendbin b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.SolverLanguageSyntheticTokenSyntacticSequencer.xtendbin index 21b52163..9af9309d 100644 Binary files a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.SolverLanguageSyntheticTokenSyntacticSequencer.xtendbin and b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.SolverLanguageSyntheticTokenSyntacticSequencer.xtendbin differ diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/.classpath b/Domains/ca.mcgill.rtgmrt.example.modes3/.classpath new file mode 100644 index 00000000..73ebde52 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/.gitignore b/Domains/ca.mcgill.rtgmrt.example.modes3/.gitignore new file mode 100644 index 00000000..ae3c1726 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/.project b/Domains/ca.mcgill.rtgmrt.example.modes3/.project new file mode 100644 index 00000000..5e0fbc45 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/.project @@ -0,0 +1,40 @@ + + + ca.mcgill.rtgmrt.example.modes3 + + + + + + org.eclipse.viatra.query.tooling.ui.projectbuilder + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + org.eclipse.xtext.ui.shared.xtextNature + org.eclipse.viatra.query.projectnature + + diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/.settings/org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguage.prefs b/Domains/ca.mcgill.rtgmrt.example.modes3/.settings/org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguage.prefs new file mode 100644 index 00000000..31cda49a --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/.settings/org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguage.prefs @@ -0,0 +1,27 @@ +BuilderConfiguration.is_project_specific=true +autobuilding=true +eclipse.preferences.version=1 +generateEclipseExtensions=true +generateGeneratedAnnotation=false +generateManifestEntries=true +generateMatchProcessors=false +generateMatchers=NESTED_CLASS +generateSuppressWarnings=true +generatedAnnotationComment= +includeDateInGenerated=false +outlet.DEFAULT_OUTPUT.cleanDirectory=false +outlet.DEFAULT_OUTPUT.cleanupDerived=true +outlet.DEFAULT_OUTPUT.createDirectory=true +outlet.DEFAULT_OUTPUT.derived=true +outlet.DEFAULT_OUTPUT.directory=./vql-gen +outlet.DEFAULT_OUTPUT.hideLocalSyntheticVariables=true +outlet.DEFAULT_OUTPUT.installDslAsPrimarySource=false +outlet.DEFAULT_OUTPUT.keepLocalHistory=true +outlet.DEFAULT_OUTPUT.override=true +outlet.DEFAULT_OUTPUT.sourceFolder.ecore-gen.directory= +outlet.DEFAULT_OUTPUT.sourceFolder.ecore-gen.ignore= +outlet.DEFAULT_OUTPUT.sourceFolder.src.directory= +outlet.DEFAULT_OUTPUT.sourceFolder.src.ignore= +outlet.DEFAULT_OUTPUT.userOutputPerSourceFolder= +targetJavaVersion=JAVA5 +useJavaCompilerCompliance=true diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/META-INF/MANIFEST.MF b/Domains/ca.mcgill.rtgmrt.example.modes3/META-INF/MANIFEST.MF new file mode 100644 index 00000000..53e4a39c --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/META-INF/MANIFEST.MF @@ -0,0 +1,34 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: ca.mcgill.rtgmrt.example.modes3;singleton:=true +Bundle-Version: 0.1.0.qualifier +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Export-Package: modes3, + modes3.impl, + modes3.queries, + modes3.util +Require-Bundle: org.eclipse.viatra.query.runtime, + org.eclipse.viatra.query.runtime.rete, + org.eclipse.viatra.query.runtime.localsearch, + org.eclipse.xtext.xbase.lib, + org.eclipse.emf.ecore;visibility:=reexport, + org.eclipse.core.runtime, + org.eclipse.xtend.lib;bundle-version="2.21.0", + org.eclipse.xtend.lib.macro;bundle-version="2.21.0", + hu.bme.mit.inf.dslreasoner.application;bundle-version="1.0.0", + hu.bme.mit.inf.dslreasoner.logic.model;bundle-version="1.0.0", + hu.bme.mit.inf.dslreasoner.logic2ecore;bundle-version="1.0.0", + hu.bme.mit.inf.dslreasoner.viatra2logic;bundle-version="1.0.0", + hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatraquery;bundle-version="1.0.0", + hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage;bundle-version="1.0.0", + hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner;bundle-version="1.0.0", + hu.bme.mit.inf.dslreasoner.ecore2logic;bundle-version="1.0.0", + org.eclipse.emf.ecore.xmi;bundle-version="2.16.0", + hu.bme.mit.inf.dslreasoner.visualisation;bundle-version="1.0.0", + org.eclipse.viatra.query.patternlanguage.emf;bundle-version="2.4.0" +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-ActivationPolicy: lazy +Import-Package: org.apache.log4j +Automatic-Module-Name: ca.mcgill.rtgmrt.example.modes3 diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/build.properties b/Domains/ca.mcgill.rtgmrt.example.modes3/build.properties new file mode 100644 index 00000000..a431f6b2 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/build.properties @@ -0,0 +1,11 @@ +bin.includes = .,\ + model/,\ + META-INF/,\ + plugin.xml,\ + plugin.properties +jars.compile.order = . +source.. = src/,\ + ecore-gen/,\ + vql-gen/,\ + xtend-gen/ +output.. = bin/ diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Factory.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Factory.java new file mode 100644 index 00000000..73188db1 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Factory.java @@ -0,0 +1,69 @@ +/** + */ +package modes3; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see modes3.Modes3Package + * @generated + */ +public interface Modes3Factory extends EFactory { + /** + * The singleton instance of the factory. + * + * + * @generated + */ + Modes3Factory eINSTANCE = modes3.impl.Modes3FactoryImpl.init(); + + /** + * Returns a new object of class 'Segment'. + * + * + * @return a new object of class 'Segment'. + * @generated + */ + Segment createSegment(); + + /** + * Returns a new object of class 'Model Root'. + * + * + * @return a new object of class 'Model Root'. + * @generated + */ + Modes3ModelRoot createModes3ModelRoot(); + + /** + * Returns a new object of class 'Turnout'. + * + * + * @return a new object of class 'Turnout'. + * @generated + */ + Turnout createTurnout(); + + /** + * Returns a new object of class 'Train'. + * + * + * @return a new object of class 'Train'. + * @generated + */ + Train createTrain(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + Modes3Package getModes3Package(); + +} //Modes3Factory diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3ModelRoot.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3ModelRoot.java new file mode 100644 index 00000000..4f925b7a --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3ModelRoot.java @@ -0,0 +1,87 @@ +/** + */ +package modes3; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Model Root'. + * + * + *

+ * The following features are supported: + *

+ * + * + * @see modes3.Modes3Package#getModes3ModelRoot() + * @model + * @generated + */ +public interface Modes3ModelRoot extends EObject { + /** + * Returns the value of the 'Id' attribute. + * + * + * @return the value of the 'Id' attribute. + * @see #setId(int) + * @see modes3.Modes3Package#getModes3ModelRoot_Id() + * @model + * @generated + */ + int getId(); + + /** + * Sets the value of the '{@link modes3.Modes3ModelRoot#getId Id}' attribute. + * + * + * @param value the new value of the 'Id' attribute. + * @see #getId() + * @generated + */ + void setId(int value); + + /** + * Returns the value of the 'Trains' containment reference list. + * The list contents are of type {@link modes3.Train}. + * + * + * @return the value of the 'Trains' containment reference list. + * @see modes3.Modes3Package#getModes3ModelRoot_Trains() + * @model containment="true" + * @generated + */ + EList getTrains(); + + /** + * Returns the value of the 'Segments' containment reference list. + * The list contents are of type {@link modes3.Segment}. + * + * + * @return the value of the 'Segments' containment reference list. + * @see modes3.Modes3Package#getModes3ModelRoot_Segments() + * @model containment="true" + * @generated + */ + EList getSegments(); + + /** + * Returns the value of the 'Turnouts' containment reference list. + * The list contents are of type {@link modes3.Turnout}. + * + * + * @return the value of the 'Turnouts' containment reference list. + * @see modes3.Modes3Package#getModes3ModelRoot_Turnouts() + * @model containment="true" + * @generated + */ + EList getTurnouts(); + +} // Modes3ModelRoot diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Package.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Package.java new file mode 100644 index 00000000..4760af9d --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Package.java @@ -0,0 +1,640 @@ +/** + */ +package modes3; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each operation of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see modes3.Modes3Factory + * @model kind="package" + * @generated + */ +public interface Modes3Package extends EPackage { + /** + * The package name. + * + * + * @generated + */ + String eNAME = "modes3"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://www.ece.mcgill.ca/wcet/modes3"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "modes3"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + Modes3Package eINSTANCE = modes3.impl.Modes3PackageImpl.init(); + + /** + * The meta object id for the '{@link modes3.impl.SegmentImpl Segment}' class. + * + * + * @see modes3.impl.SegmentImpl + * @see modes3.impl.Modes3PackageImpl#getSegment() + * @generated + */ + int SEGMENT = 0; + + /** + * The feature id for the 'Connected To' reference list. + * + * + * @generated + * @ordered + */ + int SEGMENT__CONNECTED_TO = 0; + + /** + * The feature id for the 'Occupied By' reference. + * + * + * @generated + * @ordered + */ + int SEGMENT__OCCUPIED_BY = 1; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int SEGMENT__ID = 2; + + /** + * The number of structural features of the 'Segment' class. + * + * + * @generated + * @ordered + */ + int SEGMENT_FEATURE_COUNT = 3; + + /** + * The number of operations of the 'Segment' class. + * + * + * @generated + * @ordered + */ + int SEGMENT_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link modes3.impl.Modes3ModelRootImpl Model Root}' class. + * + * + * @see modes3.impl.Modes3ModelRootImpl + * @see modes3.impl.Modes3PackageImpl#getModes3ModelRoot() + * @generated + */ + int MODES3_MODEL_ROOT = 1; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int MODES3_MODEL_ROOT__ID = 0; + + /** + * The feature id for the 'Trains' containment reference list. + * + * + * @generated + * @ordered + */ + int MODES3_MODEL_ROOT__TRAINS = 1; + + /** + * The feature id for the 'Segments' containment reference list. + * + * + * @generated + * @ordered + */ + int MODES3_MODEL_ROOT__SEGMENTS = 2; + + /** + * The feature id for the 'Turnouts' containment reference list. + * + * + * @generated + * @ordered + */ + int MODES3_MODEL_ROOT__TURNOUTS = 3; + + /** + * The number of structural features of the 'Model Root' class. + * + * + * @generated + * @ordered + */ + int MODES3_MODEL_ROOT_FEATURE_COUNT = 4; + + /** + * The number of operations of the 'Model Root' class. + * + * + * @generated + * @ordered + */ + int MODES3_MODEL_ROOT_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link modes3.impl.TurnoutImpl Turnout}' class. + * + * + * @see modes3.impl.TurnoutImpl + * @see modes3.impl.Modes3PackageImpl#getTurnout() + * @generated + */ + int TURNOUT = 2; + + /** + * The feature id for the 'Connected To' reference list. + * + * + * @generated + * @ordered + */ + int TURNOUT__CONNECTED_TO = SEGMENT__CONNECTED_TO; + + /** + * The feature id for the 'Occupied By' reference. + * + * + * @generated + * @ordered + */ + int TURNOUT__OCCUPIED_BY = SEGMENT__OCCUPIED_BY; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int TURNOUT__ID = SEGMENT__ID; + + /** + * The feature id for the 'Straight' reference. + * + * + * @generated + * @ordered + */ + int TURNOUT__STRAIGHT = SEGMENT_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Divergent' reference. + * + * + * @generated + * @ordered + */ + int TURNOUT__DIVERGENT = SEGMENT_FEATURE_COUNT + 1; + + /** + * The number of structural features of the 'Turnout' class. + * + * + * @generated + * @ordered + */ + int TURNOUT_FEATURE_COUNT = SEGMENT_FEATURE_COUNT + 2; + + /** + * The number of operations of the 'Turnout' class. + * + * + * @generated + * @ordered + */ + int TURNOUT_OPERATION_COUNT = SEGMENT_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link modes3.impl.TrainImpl Train}' class. + * + * + * @see modes3.impl.TrainImpl + * @see modes3.impl.Modes3PackageImpl#getTrain() + * @generated + */ + int TRAIN = 3; + + /** + * The feature id for the 'Location' reference. + * + * + * @generated + * @ordered + */ + int TRAIN__LOCATION = 0; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int TRAIN__ID = 1; + + /** + * The feature id for the 'Speed' attribute. + * + * + * @generated + * @ordered + */ + int TRAIN__SPEED = 2; + + /** + * The number of structural features of the 'Train' class. + * + * + * @generated + * @ordered + */ + int TRAIN_FEATURE_COUNT = 3; + + /** + * The number of operations of the 'Train' class. + * + * + * @generated + * @ordered + */ + int TRAIN_OPERATION_COUNT = 0; + + + /** + * Returns the meta object for class '{@link modes3.Segment Segment}'. + * + * + * @return the meta object for class 'Segment'. + * @see modes3.Segment + * @generated + */ + EClass getSegment(); + + /** + * Returns the meta object for the reference list '{@link modes3.Segment#getConnectedTo Connected To}'. + * + * + * @return the meta object for the reference list 'Connected To'. + * @see modes3.Segment#getConnectedTo() + * @see #getSegment() + * @generated + */ + EReference getSegment_ConnectedTo(); + + /** + * Returns the meta object for the reference '{@link modes3.Segment#getOccupiedBy Occupied By}'. + * + * + * @return the meta object for the reference 'Occupied By'. + * @see modes3.Segment#getOccupiedBy() + * @see #getSegment() + * @generated + */ + EReference getSegment_OccupiedBy(); + + /** + * Returns the meta object for the attribute '{@link modes3.Segment#getId Id}'. + * + * + * @return the meta object for the attribute 'Id'. + * @see modes3.Segment#getId() + * @see #getSegment() + * @generated + */ + EAttribute getSegment_Id(); + + /** + * Returns the meta object for class '{@link modes3.Modes3ModelRoot Model Root}'. + * + * + * @return the meta object for class 'Model Root'. + * @see modes3.Modes3ModelRoot + * @generated + */ + EClass getModes3ModelRoot(); + + /** + * Returns the meta object for the attribute '{@link modes3.Modes3ModelRoot#getId Id}'. + * + * + * @return the meta object for the attribute 'Id'. + * @see modes3.Modes3ModelRoot#getId() + * @see #getModes3ModelRoot() + * @generated + */ + EAttribute getModes3ModelRoot_Id(); + + /** + * Returns the meta object for the containment reference list '{@link modes3.Modes3ModelRoot#getTrains Trains}'. + * + * + * @return the meta object for the containment reference list 'Trains'. + * @see modes3.Modes3ModelRoot#getTrains() + * @see #getModes3ModelRoot() + * @generated + */ + EReference getModes3ModelRoot_Trains(); + + /** + * Returns the meta object for the containment reference list '{@link modes3.Modes3ModelRoot#getSegments Segments}'. + * + * + * @return the meta object for the containment reference list 'Segments'. + * @see modes3.Modes3ModelRoot#getSegments() + * @see #getModes3ModelRoot() + * @generated + */ + EReference getModes3ModelRoot_Segments(); + + /** + * Returns the meta object for the containment reference list '{@link modes3.Modes3ModelRoot#getTurnouts Turnouts}'. + * + * + * @return the meta object for the containment reference list 'Turnouts'. + * @see modes3.Modes3ModelRoot#getTurnouts() + * @see #getModes3ModelRoot() + * @generated + */ + EReference getModes3ModelRoot_Turnouts(); + + /** + * Returns the meta object for class '{@link modes3.Turnout Turnout}'. + * + * + * @return the meta object for class 'Turnout'. + * @see modes3.Turnout + * @generated + */ + EClass getTurnout(); + + /** + * Returns the meta object for the reference '{@link modes3.Turnout#getStraight Straight}'. + * + * + * @return the meta object for the reference 'Straight'. + * @see modes3.Turnout#getStraight() + * @see #getTurnout() + * @generated + */ + EReference getTurnout_Straight(); + + /** + * Returns the meta object for the reference '{@link modes3.Turnout#getDivergent Divergent}'. + * + * + * @return the meta object for the reference 'Divergent'. + * @see modes3.Turnout#getDivergent() + * @see #getTurnout() + * @generated + */ + EReference getTurnout_Divergent(); + + /** + * Returns the meta object for class '{@link modes3.Train Train}'. + * + * + * @return the meta object for class 'Train'. + * @see modes3.Train + * @generated + */ + EClass getTrain(); + + /** + * Returns the meta object for the reference '{@link modes3.Train#getLocation Location}'. + * + * + * @return the meta object for the reference 'Location'. + * @see modes3.Train#getLocation() + * @see #getTrain() + * @generated + */ + EReference getTrain_Location(); + + /** + * Returns the meta object for the attribute '{@link modes3.Train#getId Id}'. + * + * + * @return the meta object for the attribute 'Id'. + * @see modes3.Train#getId() + * @see #getTrain() + * @generated + */ + EAttribute getTrain_Id(); + + /** + * Returns the meta object for the attribute '{@link modes3.Train#getSpeed Speed}'. + * + * + * @return the meta object for the attribute 'Speed'. + * @see modes3.Train#getSpeed() + * @see #getTrain() + * @generated + */ + EAttribute getTrain_Speed(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + Modes3Factory getModes3Factory(); + + /** + * + * Defines literals for the meta objects that represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each operation of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link modes3.impl.SegmentImpl Segment}' class. + * + * + * @see modes3.impl.SegmentImpl + * @see modes3.impl.Modes3PackageImpl#getSegment() + * @generated + */ + EClass SEGMENT = eINSTANCE.getSegment(); + + /** + * The meta object literal for the 'Connected To' reference list feature. + * + * + * @generated + */ + EReference SEGMENT__CONNECTED_TO = eINSTANCE.getSegment_ConnectedTo(); + + /** + * The meta object literal for the 'Occupied By' reference feature. + * + * + * @generated + */ + EReference SEGMENT__OCCUPIED_BY = eINSTANCE.getSegment_OccupiedBy(); + + /** + * The meta object literal for the 'Id' attribute feature. + * + * + * @generated + */ + EAttribute SEGMENT__ID = eINSTANCE.getSegment_Id(); + + /** + * The meta object literal for the '{@link modes3.impl.Modes3ModelRootImpl Model Root}' class. + * + * + * @see modes3.impl.Modes3ModelRootImpl + * @see modes3.impl.Modes3PackageImpl#getModes3ModelRoot() + * @generated + */ + EClass MODES3_MODEL_ROOT = eINSTANCE.getModes3ModelRoot(); + + /** + * The meta object literal for the 'Id' attribute feature. + * + * + * @generated + */ + EAttribute MODES3_MODEL_ROOT__ID = eINSTANCE.getModes3ModelRoot_Id(); + + /** + * The meta object literal for the 'Trains' containment reference list feature. + * + * + * @generated + */ + EReference MODES3_MODEL_ROOT__TRAINS = eINSTANCE.getModes3ModelRoot_Trains(); + + /** + * The meta object literal for the 'Segments' containment reference list feature. + * + * + * @generated + */ + EReference MODES3_MODEL_ROOT__SEGMENTS = eINSTANCE.getModes3ModelRoot_Segments(); + + /** + * The meta object literal for the 'Turnouts' containment reference list feature. + * + * + * @generated + */ + EReference MODES3_MODEL_ROOT__TURNOUTS = eINSTANCE.getModes3ModelRoot_Turnouts(); + + /** + * The meta object literal for the '{@link modes3.impl.TurnoutImpl Turnout}' class. + * + * + * @see modes3.impl.TurnoutImpl + * @see modes3.impl.Modes3PackageImpl#getTurnout() + * @generated + */ + EClass TURNOUT = eINSTANCE.getTurnout(); + + /** + * The meta object literal for the 'Straight' reference feature. + * + * + * @generated + */ + EReference TURNOUT__STRAIGHT = eINSTANCE.getTurnout_Straight(); + + /** + * The meta object literal for the 'Divergent' reference feature. + * + * + * @generated + */ + EReference TURNOUT__DIVERGENT = eINSTANCE.getTurnout_Divergent(); + + /** + * The meta object literal for the '{@link modes3.impl.TrainImpl Train}' class. + * + * + * @see modes3.impl.TrainImpl + * @see modes3.impl.Modes3PackageImpl#getTrain() + * @generated + */ + EClass TRAIN = eINSTANCE.getTrain(); + + /** + * The meta object literal for the 'Location' reference feature. + * + * + * @generated + */ + EReference TRAIN__LOCATION = eINSTANCE.getTrain_Location(); + + /** + * The meta object literal for the 'Id' attribute feature. + * + * + * @generated + */ + EAttribute TRAIN__ID = eINSTANCE.getTrain_Id(); + + /** + * The meta object literal for the 'Speed' attribute feature. + * + * + * @generated + */ + EAttribute TRAIN__SPEED = eINSTANCE.getTrain_Speed(); + + } + +} //Modes3Package diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Segment.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Segment.java new file mode 100644 index 00000000..002f25a5 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Segment.java @@ -0,0 +1,86 @@ +/** + */ +package modes3; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Segment'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link modes3.Segment#getConnectedTo Connected To}
  • + *
  • {@link modes3.Segment#getOccupiedBy Occupied By}
  • + *
  • {@link modes3.Segment#getId Id}
  • + *
+ * + * @see modes3.Modes3Package#getSegment() + * @model + * @generated + */ +public interface Segment extends EObject { + /** + * Returns the value of the 'Connected To' reference list. + * The list contents are of type {@link modes3.Segment}. + * + * + * @return the value of the 'Connected To' reference list. + * @see modes3.Modes3Package#getSegment_ConnectedTo() + * @model upper="2" + * @generated + */ + EList getConnectedTo(); + + /** + * Returns the value of the 'Occupied By' reference. + * It is bidirectional and its opposite is '{@link modes3.Train#getLocation Location}'. + * + * + * @return the value of the 'Occupied By' reference. + * @see #setOccupiedBy(Train) + * @see modes3.Modes3Package#getSegment_OccupiedBy() + * @see modes3.Train#getLocation + * @model opposite="location" + * @generated + */ + Train getOccupiedBy(); + + /** + * Sets the value of the '{@link modes3.Segment#getOccupiedBy Occupied By}' reference. + * + * + * @param value the new value of the 'Occupied By' reference. + * @see #getOccupiedBy() + * @generated + */ + void setOccupiedBy(Train value); + + /** + * Returns the value of the 'Id' attribute. + * + * + * @return the value of the 'Id' attribute. + * @see #setId(int) + * @see modes3.Modes3Package#getSegment_Id() + * @model + * @generated + */ + int getId(); + + /** + * Sets the value of the '{@link modes3.Segment#getId Id}' attribute. + * + * + * @param value the new value of the 'Id' attribute. + * @see #getId() + * @generated + */ + void setId(int value); + +} // Segment diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Train.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Train.java new file mode 100644 index 00000000..1829586d --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Train.java @@ -0,0 +1,94 @@ +/** + */ +package modes3; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Train'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link modes3.Train#getLocation Location}
  • + *
  • {@link modes3.Train#getId Id}
  • + *
  • {@link modes3.Train#getSpeed Speed}
  • + *
+ * + * @see modes3.Modes3Package#getTrain() + * @model + * @generated + */ +public interface Train extends EObject { + /** + * Returns the value of the 'Location' reference. + * It is bidirectional and its opposite is '{@link modes3.Segment#getOccupiedBy Occupied By}'. + * + * + * @return the value of the 'Location' reference. + * @see #setLocation(Segment) + * @see modes3.Modes3Package#getTrain_Location() + * @see modes3.Segment#getOccupiedBy + * @model opposite="occupiedBy" required="true" + * @generated + */ + Segment getLocation(); + + /** + * Sets the value of the '{@link modes3.Train#getLocation Location}' reference. + * + * + * @param value the new value of the 'Location' reference. + * @see #getLocation() + * @generated + */ + void setLocation(Segment value); + + /** + * Returns the value of the 'Id' attribute. + * + * + * @return the value of the 'Id' attribute. + * @see #setId(int) + * @see modes3.Modes3Package#getTrain_Id() + * @model + * @generated + */ + int getId(); + + /** + * Sets the value of the '{@link modes3.Train#getId Id}' attribute. + * + * + * @param value the new value of the 'Id' attribute. + * @see #getId() + * @generated + */ + void setId(int value); + + /** + * Returns the value of the 'Speed' attribute. + * + * + * @return the value of the 'Speed' attribute. + * @see #setSpeed(double) + * @see modes3.Modes3Package#getTrain_Speed() + * @model + * @generated + */ + double getSpeed(); + + /** + * Sets the value of the '{@link modes3.Train#getSpeed Speed}' attribute. + * + * + * @param value the new value of the 'Speed' attribute. + * @see #getSpeed() + * @generated + */ + void setSpeed(double value); + +} // Train diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Turnout.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Turnout.java new file mode 100644 index 00000000..799f8d7b --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Turnout.java @@ -0,0 +1,68 @@ +/** + */ +package modes3; + + +/** + * + * A representation of the model object 'Turnout'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link modes3.Turnout#getStraight Straight}
  • + *
  • {@link modes3.Turnout#getDivergent Divergent}
  • + *
+ * + * @see modes3.Modes3Package#getTurnout() + * @model + * @generated + */ +public interface Turnout extends Segment { + /** + * Returns the value of the 'Straight' reference. + * + * + * @return the value of the 'Straight' reference. + * @see #setStraight(Segment) + * @see modes3.Modes3Package#getTurnout_Straight() + * @model required="true" + * @generated + */ + Segment getStraight(); + + /** + * Sets the value of the '{@link modes3.Turnout#getStraight Straight}' reference. + * + * + * @param value the new value of the 'Straight' reference. + * @see #getStraight() + * @generated + */ + void setStraight(Segment value); + + /** + * Returns the value of the 'Divergent' reference. + * + * + * @return the value of the 'Divergent' reference. + * @see #setDivergent(Segment) + * @see modes3.Modes3Package#getTurnout_Divergent() + * @model required="true" + * @generated + */ + Segment getDivergent(); + + /** + * Sets the value of the '{@link modes3.Turnout#getDivergent Divergent}' reference. + * + * + * @param value the new value of the 'Divergent' reference. + * @see #getDivergent() + * @generated + */ + void setDivergent(Segment value); + +} // Turnout diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3FactoryImpl.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3FactoryImpl.java new file mode 100644 index 00000000..6ec86cb6 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3FactoryImpl.java @@ -0,0 +1,128 @@ +/** + */ +package modes3.impl; + +import modes3.*; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class Modes3FactoryImpl extends EFactoryImpl implements Modes3Factory { + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static Modes3Factory init() { + try { + Modes3Factory theModes3Factory = (Modes3Factory)EPackage.Registry.INSTANCE.getEFactory(Modes3Package.eNS_URI); + if (theModes3Factory != null) { + return theModes3Factory; + } + } + catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new Modes3FactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public Modes3FactoryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case Modes3Package.SEGMENT: return createSegment(); + case Modes3Package.MODES3_MODEL_ROOT: return createModes3ModelRoot(); + case Modes3Package.TURNOUT: return createTurnout(); + case Modes3Package.TRAIN: return createTrain(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public Segment createSegment() { + SegmentImpl segment = new SegmentImpl(); + return segment; + } + + /** + * + * + * @generated + */ + public Modes3ModelRoot createModes3ModelRoot() { + Modes3ModelRootImpl modes3ModelRoot = new Modes3ModelRootImpl(); + return modes3ModelRoot; + } + + /** + * + * + * @generated + */ + public Turnout createTurnout() { + TurnoutImpl turnout = new TurnoutImpl(); + return turnout; + } + + /** + * + * + * @generated + */ + public Train createTrain() { + TrainImpl train = new TrainImpl(); + return train; + } + + /** + * + * + * @generated + */ + public Modes3Package getModes3Package() { + return (Modes3Package)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static Modes3Package getPackage() { + return Modes3Package.eINSTANCE; + } + +} //Modes3FactoryImpl diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3ModelRootImpl.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3ModelRootImpl.java new file mode 100644 index 00000000..d1ee25ff --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3ModelRootImpl.java @@ -0,0 +1,296 @@ +/** + */ +package modes3.impl; + +import java.util.Collection; + +import modes3.Modes3ModelRoot; +import modes3.Modes3Package; +import modes3.Segment; +import modes3.Train; +import modes3.Turnout; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Model Root'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link modes3.impl.Modes3ModelRootImpl#getId Id}
  • + *
  • {@link modes3.impl.Modes3ModelRootImpl#getTrains Trains}
  • + *
  • {@link modes3.impl.Modes3ModelRootImpl#getSegments Segments}
  • + *
  • {@link modes3.impl.Modes3ModelRootImpl#getTurnouts Turnouts}
  • + *
+ * + * @generated + */ +public class Modes3ModelRootImpl extends MinimalEObjectImpl.Container implements Modes3ModelRoot { + /** + * The default value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected static final int ID_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected int id = ID_EDEFAULT; + + /** + * The cached value of the '{@link #getTrains() Trains}' containment reference list. + * + * + * @see #getTrains() + * @generated + * @ordered + */ + protected EList trains; + + /** + * The cached value of the '{@link #getSegments() Segments}' containment reference list. + * + * + * @see #getSegments() + * @generated + * @ordered + */ + protected EList segments; + + /** + * The cached value of the '{@link #getTurnouts() Turnouts}' containment reference list. + * + * + * @see #getTurnouts() + * @generated + * @ordered + */ + protected EList turnouts; + + /** + * + * + * @generated + */ + protected Modes3ModelRootImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return Modes3Package.Literals.MODES3_MODEL_ROOT; + } + + /** + * + * + * @generated + */ + public int getId() { + return id; + } + + /** + * + * + * @generated + */ + public void setId(int newId) { + int oldId = id; + id = newId; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.MODES3_MODEL_ROOT__ID, oldId, id)); + } + + /** + * + * + * @generated + */ + public EList getTrains() { + if (trains == null) { + trains = new EObjectContainmentEList(Train.class, this, Modes3Package.MODES3_MODEL_ROOT__TRAINS); + } + return trains; + } + + /** + * + * + * @generated + */ + public EList getSegments() { + if (segments == null) { + segments = new EObjectContainmentEList(Segment.class, this, Modes3Package.MODES3_MODEL_ROOT__SEGMENTS); + } + return segments; + } + + /** + * + * + * @generated + */ + public EList getTurnouts() { + if (turnouts == null) { + turnouts = new EObjectContainmentEList(Turnout.class, this, Modes3Package.MODES3_MODEL_ROOT__TURNOUTS); + } + return turnouts; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case Modes3Package.MODES3_MODEL_ROOT__TRAINS: + return ((InternalEList)getTrains()).basicRemove(otherEnd, msgs); + case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: + return ((InternalEList)getSegments()).basicRemove(otherEnd, msgs); + case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: + return ((InternalEList)getTurnouts()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case Modes3Package.MODES3_MODEL_ROOT__ID: + return getId(); + case Modes3Package.MODES3_MODEL_ROOT__TRAINS: + return getTrains(); + case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: + return getSegments(); + case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: + return getTurnouts(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case Modes3Package.MODES3_MODEL_ROOT__ID: + setId((Integer)newValue); + return; + case Modes3Package.MODES3_MODEL_ROOT__TRAINS: + getTrains().clear(); + getTrains().addAll((Collection)newValue); + return; + case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: + getSegments().clear(); + getSegments().addAll((Collection)newValue); + return; + case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: + getTurnouts().clear(); + getTurnouts().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case Modes3Package.MODES3_MODEL_ROOT__ID: + setId(ID_EDEFAULT); + return; + case Modes3Package.MODES3_MODEL_ROOT__TRAINS: + getTrains().clear(); + return; + case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: + getSegments().clear(); + return; + case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: + getTurnouts().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case Modes3Package.MODES3_MODEL_ROOT__ID: + return id != ID_EDEFAULT; + case Modes3Package.MODES3_MODEL_ROOT__TRAINS: + return trains != null && !trains.isEmpty(); + case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: + return segments != null && !segments.isEmpty(); + case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: + return turnouts != null && !turnouts.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (id: "); + result.append(id); + result.append(')'); + return result.toString(); + } + +} //Modes3ModelRootImpl diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3PackageImpl.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3PackageImpl.java new file mode 100644 index 00000000..2b9e828c --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3PackageImpl.java @@ -0,0 +1,363 @@ +/** + */ +package modes3.impl; + +import modes3.Modes3Factory; +import modes3.Modes3ModelRoot; +import modes3.Modes3Package; +import modes3.Segment; +import modes3.Train; +import modes3.Turnout; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class Modes3PackageImpl extends EPackageImpl implements Modes3Package { + /** + * + * + * @generated + */ + private EClass segmentEClass = null; + + /** + * + * + * @generated + */ + private EClass modes3ModelRootEClass = null; + + /** + * + * + * @generated + */ + private EClass turnoutEClass = null; + + /** + * + * + * @generated + */ + private EClass trainEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see modes3.Modes3Package#eNS_URI + * @see #init() + * @generated + */ + private Modes3PackageImpl() { + super(eNS_URI, Modes3Factory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link Modes3Package#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static Modes3Package init() { + if (isInited) return (Modes3Package)EPackage.Registry.INSTANCE.getEPackage(Modes3Package.eNS_URI); + + // Obtain or create and register package + Object registeredModes3Package = EPackage.Registry.INSTANCE.get(eNS_URI); + Modes3PackageImpl theModes3Package = registeredModes3Package instanceof Modes3PackageImpl ? (Modes3PackageImpl)registeredModes3Package : new Modes3PackageImpl(); + + isInited = true; + + // Create package meta-data objects + theModes3Package.createPackageContents(); + + // Initialize created meta-data + theModes3Package.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theModes3Package.freeze(); + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(Modes3Package.eNS_URI, theModes3Package); + return theModes3Package; + } + + /** + * + * + * @generated + */ + public EClass getSegment() { + return segmentEClass; + } + + /** + * + * + * @generated + */ + public EReference getSegment_ConnectedTo() { + return (EReference)segmentEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EReference getSegment_OccupiedBy() { + return (EReference)segmentEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EAttribute getSegment_Id() { + return (EAttribute)segmentEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EClass getModes3ModelRoot() { + return modes3ModelRootEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getModes3ModelRoot_Id() { + return (EAttribute)modes3ModelRootEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EReference getModes3ModelRoot_Trains() { + return (EReference)modes3ModelRootEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EReference getModes3ModelRoot_Segments() { + return (EReference)modes3ModelRootEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EReference getModes3ModelRoot_Turnouts() { + return (EReference)modes3ModelRootEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + public EClass getTurnout() { + return turnoutEClass; + } + + /** + * + * + * @generated + */ + public EReference getTurnout_Straight() { + return (EReference)turnoutEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EReference getTurnout_Divergent() { + return (EReference)turnoutEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EClass getTrain() { + return trainEClass; + } + + /** + * + * + * @generated + */ + public EReference getTrain_Location() { + return (EReference)trainEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getTrain_Id() { + return (EAttribute)trainEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EAttribute getTrain_Speed() { + return (EAttribute)trainEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public Modes3Factory getModes3Factory() { + return (Modes3Factory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + segmentEClass = createEClass(SEGMENT); + createEReference(segmentEClass, SEGMENT__CONNECTED_TO); + createEReference(segmentEClass, SEGMENT__OCCUPIED_BY); + createEAttribute(segmentEClass, SEGMENT__ID); + + modes3ModelRootEClass = createEClass(MODES3_MODEL_ROOT); + createEAttribute(modes3ModelRootEClass, MODES3_MODEL_ROOT__ID); + createEReference(modes3ModelRootEClass, MODES3_MODEL_ROOT__TRAINS); + createEReference(modes3ModelRootEClass, MODES3_MODEL_ROOT__SEGMENTS); + createEReference(modes3ModelRootEClass, MODES3_MODEL_ROOT__TURNOUTS); + + turnoutEClass = createEClass(TURNOUT); + createEReference(turnoutEClass, TURNOUT__STRAIGHT); + createEReference(turnoutEClass, TURNOUT__DIVERGENT); + + trainEClass = createEClass(TRAIN); + createEReference(trainEClass, TRAIN__LOCATION); + createEAttribute(trainEClass, TRAIN__ID); + createEAttribute(trainEClass, TRAIN__SPEED); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + turnoutEClass.getESuperTypes().add(this.getSegment()); + + // Initialize classes, features, and operations; add parameters + initEClass(segmentEClass, Segment.class, "Segment", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getSegment_ConnectedTo(), this.getSegment(), null, "connectedTo", null, 0, 2, Segment.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getSegment_OccupiedBy(), this.getTrain(), this.getTrain_Location(), "occupiedBy", null, 0, 1, Segment.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getSegment_Id(), ecorePackage.getEInt(), "id", null, 0, 1, Segment.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(modes3ModelRootEClass, Modes3ModelRoot.class, "Modes3ModelRoot", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getModes3ModelRoot_Id(), ecorePackage.getEInt(), "id", null, 0, 1, Modes3ModelRoot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getModes3ModelRoot_Trains(), this.getTrain(), null, "trains", null, 0, -1, Modes3ModelRoot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getModes3ModelRoot_Segments(), this.getSegment(), null, "segments", null, 0, -1, Modes3ModelRoot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getModes3ModelRoot_Turnouts(), this.getTurnout(), null, "turnouts", null, 0, -1, Modes3ModelRoot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(turnoutEClass, Turnout.class, "Turnout", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getTurnout_Straight(), this.getSegment(), null, "straight", null, 1, 1, Turnout.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getTurnout_Divergent(), this.getSegment(), null, "divergent", null, 1, 1, Turnout.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(trainEClass, Train.class, "Train", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getTrain_Location(), this.getSegment(), this.getSegment_OccupiedBy(), "location", null, 1, 1, Train.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getTrain_Id(), ecorePackage.getEInt(), "id", null, 0, 1, Train.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getTrain_Speed(), ecorePackage.getEDouble(), "speed", null, 0, 1, Train.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} //Modes3PackageImpl diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/SegmentImpl.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/SegmentImpl.java new file mode 100644 index 00000000..905bcec1 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/SegmentImpl.java @@ -0,0 +1,319 @@ +/** + */ +package modes3.impl; + +import java.util.Collection; + +import modes3.Modes3Package; +import modes3.Segment; +import modes3.Train; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectResolvingEList; + +/** + * + * An implementation of the model object 'Segment'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link modes3.impl.SegmentImpl#getConnectedTo Connected To}
  • + *
  • {@link modes3.impl.SegmentImpl#getOccupiedBy Occupied By}
  • + *
  • {@link modes3.impl.SegmentImpl#getId Id}
  • + *
+ * + * @generated + */ +public class SegmentImpl extends MinimalEObjectImpl.Container implements Segment { + /** + * The cached value of the '{@link #getConnectedTo() Connected To}' reference list. + * + * + * @see #getConnectedTo() + * @generated + * @ordered + */ + protected EList connectedTo; + + /** + * The cached value of the '{@link #getOccupiedBy() Occupied By}' reference. + * + * + * @see #getOccupiedBy() + * @generated + * @ordered + */ + protected Train occupiedBy; + + /** + * The default value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected static final int ID_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected int id = ID_EDEFAULT; + + /** + * + * + * @generated + */ + protected SegmentImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return Modes3Package.Literals.SEGMENT; + } + + /** + * + * + * @generated + */ + public EList getConnectedTo() { + if (connectedTo == null) { + connectedTo = new EObjectResolvingEList(Segment.class, this, Modes3Package.SEGMENT__CONNECTED_TO); + } + return connectedTo; + } + + /** + * + * + * @generated + */ + public Train getOccupiedBy() { + if (occupiedBy != null && occupiedBy.eIsProxy()) { + InternalEObject oldOccupiedBy = (InternalEObject)occupiedBy; + occupiedBy = (Train)eResolveProxy(oldOccupiedBy); + if (occupiedBy != oldOccupiedBy) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, Modes3Package.SEGMENT__OCCUPIED_BY, oldOccupiedBy, occupiedBy)); + } + } + return occupiedBy; + } + + /** + * + * + * @generated + */ + public Train basicGetOccupiedBy() { + return occupiedBy; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetOccupiedBy(Train newOccupiedBy, NotificationChain msgs) { + Train oldOccupiedBy = occupiedBy; + occupiedBy = newOccupiedBy; + if (eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Modes3Package.SEGMENT__OCCUPIED_BY, oldOccupiedBy, newOccupiedBy); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setOccupiedBy(Train newOccupiedBy) { + if (newOccupiedBy != occupiedBy) { + NotificationChain msgs = null; + if (occupiedBy != null) + msgs = ((InternalEObject)occupiedBy).eInverseRemove(this, Modes3Package.TRAIN__LOCATION, Train.class, msgs); + if (newOccupiedBy != null) + msgs = ((InternalEObject)newOccupiedBy).eInverseAdd(this, Modes3Package.TRAIN__LOCATION, Train.class, msgs); + msgs = basicSetOccupiedBy(newOccupiedBy, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.SEGMENT__OCCUPIED_BY, newOccupiedBy, newOccupiedBy)); + } + + /** + * + * + * @generated + */ + public int getId() { + return id; + } + + /** + * + * + * @generated + */ + public void setId(int newId) { + int oldId = id; + id = newId; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.SEGMENT__ID, oldId, id)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case Modes3Package.SEGMENT__OCCUPIED_BY: + if (occupiedBy != null) + msgs = ((InternalEObject)occupiedBy).eInverseRemove(this, Modes3Package.TRAIN__LOCATION, Train.class, msgs); + return basicSetOccupiedBy((Train)otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case Modes3Package.SEGMENT__OCCUPIED_BY: + return basicSetOccupiedBy(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case Modes3Package.SEGMENT__CONNECTED_TO: + return getConnectedTo(); + case Modes3Package.SEGMENT__OCCUPIED_BY: + if (resolve) return getOccupiedBy(); + return basicGetOccupiedBy(); + case Modes3Package.SEGMENT__ID: + return getId(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case Modes3Package.SEGMENT__CONNECTED_TO: + getConnectedTo().clear(); + getConnectedTo().addAll((Collection)newValue); + return; + case Modes3Package.SEGMENT__OCCUPIED_BY: + setOccupiedBy((Train)newValue); + return; + case Modes3Package.SEGMENT__ID: + setId((Integer)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case Modes3Package.SEGMENT__CONNECTED_TO: + getConnectedTo().clear(); + return; + case Modes3Package.SEGMENT__OCCUPIED_BY: + setOccupiedBy((Train)null); + return; + case Modes3Package.SEGMENT__ID: + setId(ID_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case Modes3Package.SEGMENT__CONNECTED_TO: + return connectedTo != null && !connectedTo.isEmpty(); + case Modes3Package.SEGMENT__OCCUPIED_BY: + return occupiedBy != null; + case Modes3Package.SEGMENT__ID: + return id != ID_EDEFAULT; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (id: "); + result.append(id); + result.append(')'); + return result.toString(); + } + +} //SegmentImpl diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/TrainImpl.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/TrainImpl.java new file mode 100644 index 00000000..f096dca8 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/TrainImpl.java @@ -0,0 +1,332 @@ +/** + */ +package modes3.impl; + +import modes3.Modes3Package; +import modes3.Segment; +import modes3.Train; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +/** + * + * An implementation of the model object 'Train'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link modes3.impl.TrainImpl#getLocation Location}
  • + *
  • {@link modes3.impl.TrainImpl#getId Id}
  • + *
  • {@link modes3.impl.TrainImpl#getSpeed Speed}
  • + *
+ * + * @generated + */ +public class TrainImpl extends MinimalEObjectImpl.Container implements Train { + /** + * The cached value of the '{@link #getLocation() Location}' reference. + * + * + * @see #getLocation() + * @generated + * @ordered + */ + protected Segment location; + + /** + * The default value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected static final int ID_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected int id = ID_EDEFAULT; + + /** + * The default value of the '{@link #getSpeed() Speed}' attribute. + * + * + * @see #getSpeed() + * @generated + * @ordered + */ + protected static final double SPEED_EDEFAULT = 0.0; + + /** + * The cached value of the '{@link #getSpeed() Speed}' attribute. + * + * + * @see #getSpeed() + * @generated + * @ordered + */ + protected double speed = SPEED_EDEFAULT; + + /** + * + * + * @generated + */ + protected TrainImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return Modes3Package.Literals.TRAIN; + } + + /** + * + * + * @generated + */ + public Segment getLocation() { + if (location != null && location.eIsProxy()) { + InternalEObject oldLocation = (InternalEObject)location; + location = (Segment)eResolveProxy(oldLocation); + if (location != oldLocation) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, Modes3Package.TRAIN__LOCATION, oldLocation, location)); + } + } + return location; + } + + /** + * + * + * @generated + */ + public Segment basicGetLocation() { + return location; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetLocation(Segment newLocation, NotificationChain msgs) { + Segment oldLocation = location; + location = newLocation; + if (eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__LOCATION, oldLocation, newLocation); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setLocation(Segment newLocation) { + if (newLocation != location) { + NotificationChain msgs = null; + if (location != null) + msgs = ((InternalEObject)location).eInverseRemove(this, Modes3Package.SEGMENT__OCCUPIED_BY, Segment.class, msgs); + if (newLocation != null) + msgs = ((InternalEObject)newLocation).eInverseAdd(this, Modes3Package.SEGMENT__OCCUPIED_BY, Segment.class, msgs); + msgs = basicSetLocation(newLocation, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__LOCATION, newLocation, newLocation)); + } + + /** + * + * + * @generated + */ + public int getId() { + return id; + } + + /** + * + * + * @generated + */ + public void setId(int newId) { + int oldId = id; + id = newId; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__ID, oldId, id)); + } + + /** + * + * + * @generated + */ + public double getSpeed() { + return speed; + } + + /** + * + * + * @generated + */ + public void setSpeed(double newSpeed) { + double oldSpeed = speed; + speed = newSpeed; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__SPEED, oldSpeed, speed)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case Modes3Package.TRAIN__LOCATION: + if (location != null) + msgs = ((InternalEObject)location).eInverseRemove(this, Modes3Package.SEGMENT__OCCUPIED_BY, Segment.class, msgs); + return basicSetLocation((Segment)otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case Modes3Package.TRAIN__LOCATION: + return basicSetLocation(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case Modes3Package.TRAIN__LOCATION: + if (resolve) return getLocation(); + return basicGetLocation(); + case Modes3Package.TRAIN__ID: + return getId(); + case Modes3Package.TRAIN__SPEED: + return getSpeed(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case Modes3Package.TRAIN__LOCATION: + setLocation((Segment)newValue); + return; + case Modes3Package.TRAIN__ID: + setId((Integer)newValue); + return; + case Modes3Package.TRAIN__SPEED: + setSpeed((Double)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case Modes3Package.TRAIN__LOCATION: + setLocation((Segment)null); + return; + case Modes3Package.TRAIN__ID: + setId(ID_EDEFAULT); + return; + case Modes3Package.TRAIN__SPEED: + setSpeed(SPEED_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case Modes3Package.TRAIN__LOCATION: + return location != null; + case Modes3Package.TRAIN__ID: + return id != ID_EDEFAULT; + case Modes3Package.TRAIN__SPEED: + return speed != SPEED_EDEFAULT; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (id: "); + result.append(id); + result.append(", speed: "); + result.append(speed); + result.append(')'); + return result.toString(); + } + +} //TrainImpl diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/TurnoutImpl.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/TurnoutImpl.java new file mode 100644 index 00000000..d20a104e --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/TurnoutImpl.java @@ -0,0 +1,216 @@ +/** + */ +package modes3.impl; + +import modes3.Modes3Package; +import modes3.Segment; +import modes3.Turnout; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +/** + * + * An implementation of the model object 'Turnout'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link modes3.impl.TurnoutImpl#getStraight Straight}
  • + *
  • {@link modes3.impl.TurnoutImpl#getDivergent Divergent}
  • + *
+ * + * @generated + */ +public class TurnoutImpl extends SegmentImpl implements Turnout { + /** + * The cached value of the '{@link #getStraight() Straight}' reference. + * + * + * @see #getStraight() + * @generated + * @ordered + */ + protected Segment straight; + + /** + * The cached value of the '{@link #getDivergent() Divergent}' reference. + * + * + * @see #getDivergent() + * @generated + * @ordered + */ + protected Segment divergent; + + /** + * + * + * @generated + */ + protected TurnoutImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return Modes3Package.Literals.TURNOUT; + } + + /** + * + * + * @generated + */ + public Segment getStraight() { + if (straight != null && straight.eIsProxy()) { + InternalEObject oldStraight = (InternalEObject)straight; + straight = (Segment)eResolveProxy(oldStraight); + if (straight != oldStraight) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, Modes3Package.TURNOUT__STRAIGHT, oldStraight, straight)); + } + } + return straight; + } + + /** + * + * + * @generated + */ + public Segment basicGetStraight() { + return straight; + } + + /** + * + * + * @generated + */ + public void setStraight(Segment newStraight) { + Segment oldStraight = straight; + straight = newStraight; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TURNOUT__STRAIGHT, oldStraight, straight)); + } + + /** + * + * + * @generated + */ + public Segment getDivergent() { + if (divergent != null && divergent.eIsProxy()) { + InternalEObject oldDivergent = (InternalEObject)divergent; + divergent = (Segment)eResolveProxy(oldDivergent); + if (divergent != oldDivergent) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, Modes3Package.TURNOUT__DIVERGENT, oldDivergent, divergent)); + } + } + return divergent; + } + + /** + * + * + * @generated + */ + public Segment basicGetDivergent() { + return divergent; + } + + /** + * + * + * @generated + */ + public void setDivergent(Segment newDivergent) { + Segment oldDivergent = divergent; + divergent = newDivergent; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TURNOUT__DIVERGENT, oldDivergent, divergent)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case Modes3Package.TURNOUT__STRAIGHT: + if (resolve) return getStraight(); + return basicGetStraight(); + case Modes3Package.TURNOUT__DIVERGENT: + if (resolve) return getDivergent(); + return basicGetDivergent(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case Modes3Package.TURNOUT__STRAIGHT: + setStraight((Segment)newValue); + return; + case Modes3Package.TURNOUT__DIVERGENT: + setDivergent((Segment)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case Modes3Package.TURNOUT__STRAIGHT: + setStraight((Segment)null); + return; + case Modes3Package.TURNOUT__DIVERGENT: + setDivergent((Segment)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case Modes3Package.TURNOUT__STRAIGHT: + return straight != null; + case Modes3Package.TURNOUT__DIVERGENT: + return divergent != null; + } + return super.eIsSet(featureID); + } + +} //TurnoutImpl diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3AdapterFactory.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3AdapterFactory.java new file mode 100644 index 00000000..86568e9d --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3AdapterFactory.java @@ -0,0 +1,174 @@ +/** + */ +package modes3.util; + +import modes3.*; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see modes3.Modes3Package + * @generated + */ +public class Modes3AdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * + * + * @generated + */ + protected static Modes3Package modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public Modes3AdapterFactory() { + if (modelPackage == null) { + modelPackage = Modes3Package.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) { + if (object == modelPackage) { + return true; + } + if (object instanceof EObject) { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected Modes3Switch modelSwitch = + new Modes3Switch() { + @Override + public Adapter caseSegment(Segment object) { + return createSegmentAdapter(); + } + @Override + public Adapter caseModes3ModelRoot(Modes3ModelRoot object) { + return createModes3ModelRootAdapter(); + } + @Override + public Adapter caseTurnout(Turnout object) { + return createTurnoutAdapter(); + } + @Override + public Adapter caseTrain(Train object) { + return createTrainAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link modes3.Segment Segment}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see modes3.Segment + * @generated + */ + public Adapter createSegmentAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link modes3.Modes3ModelRoot Model Root}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see modes3.Modes3ModelRoot + * @generated + */ + public Adapter createModes3ModelRootAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link modes3.Turnout Turnout}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see modes3.Turnout + * @generated + */ + public Adapter createTurnoutAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link modes3.Train Train}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see modes3.Train + * @generated + */ + public Adapter createTrainAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //Modes3AdapterFactory diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3Switch.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3Switch.java new file mode 100644 index 00000000..5dab272b --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3Switch.java @@ -0,0 +1,174 @@ +/** + */ +package modes3.util; + +import modes3.*; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see modes3.Modes3Package + * @generated + */ +public class Modes3Switch extends Switch { + /** + * The cached model package + * + * + * @generated + */ + protected static Modes3Package modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public Modes3Switch() { + if (modelPackage == null) { + modelPackage = Modes3Package.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @param ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case Modes3Package.SEGMENT: { + Segment segment = (Segment)theEObject; + T result = caseSegment(segment); + if (result == null) result = defaultCase(theEObject); + return result; + } + case Modes3Package.MODES3_MODEL_ROOT: { + Modes3ModelRoot modes3ModelRoot = (Modes3ModelRoot)theEObject; + T result = caseModes3ModelRoot(modes3ModelRoot); + if (result == null) result = defaultCase(theEObject); + return result; + } + case Modes3Package.TURNOUT: { + Turnout turnout = (Turnout)theEObject; + T result = caseTurnout(turnout); + if (result == null) result = caseSegment(turnout); + if (result == null) result = defaultCase(theEObject); + return result; + } + case Modes3Package.TRAIN: { + Train train = (Train)theEObject; + T result = caseTrain(train); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Segment'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Segment'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseSegment(Segment object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Model Root'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Model Root'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseModes3ModelRoot(Modes3ModelRoot object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Turnout'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Turnout'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseTurnout(Turnout object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Train'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Train'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseTrain(Train object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //Modes3Switch diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.aird_deactivated b/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.aird_deactivated new file mode 100644 index 00000000..f5400732 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.aird_deactivated @@ -0,0 +1,1531 @@ + + + + http://www.eclipse.org/emf/2002/Ecore + modes3.ecore + modes3.genmodel + ../src/modes3/queries/Modes3Queries.vql + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch + java:/Objects/java.lang.Object + java:/Objects/jdk.internal.HotSpotIntrinsicCandidate + java:/Objects/java.lang.annotation.Target + java:/Objects/java.lang.annotation.ElementType + java:/Objects/java.lang.Enum + java:/Objects/java.lang.Comparable + java:/Primitives + java:/Objects/java.lang.CloneNotSupportedException + java:/Objects/java.lang.Exception + java:/Objects/java.lang.Throwable + java:/Objects/java.io.Serializable + java:/Objects/java.lang.Deprecated + java:/Objects/java.lang.annotation.Retention + java:/Objects/java.lang.annotation.RetentionPolicy + java:/Objects/java.lang.String + java:/Objects/java.lang.CharSequence + java:/Objects/java.util.stream.IntStream + java:/Objects/java.util.stream.BaseStream + java:/Objects/java.lang.AutoCloseable + java:/Objects/java.lang.Class + java:/Objects/java.lang.reflect.GenericDeclaration + java:/Objects/java.lang.reflect.AnnotatedElement + java:/Objects/java.lang.annotation.Annotation + java:/Objects/java.lang.InterruptedException + java:/Objects/java.lang.StackTraceElement + java:/Objects/java.lang.Module + java:/Objects/java.lang.WeakPairMap + java:/Objects/java.lang.ref.ReferenceQueue + java:/Objects/java.lang.ref.Reference + java:/Objects/java.lang.Thread + java:/Objects/java.lang.Runnable + java:/Objects/java.lang.FunctionalInterface + java:/Objects/java.lang.annotation.Documented + java:/Objects/java.io.ObjectInputStream + java:/Objects/java.io.InputStream + java:/Objects/java.io.Closeable + java:/Objects/java.io.IOException + java:/Objects/java.util.Comparator + java:/Objects/java.util.function.Function + java:/Objects/java.lang.ClassNotFoundException + java:/Objects/java.lang.ReflectiveOperationException + java:/Objects/java.lang.StringBuffer + java:/Objects/java.lang.AbstractStringBuilder + java:/Objects/java.lang.Appendable + java:/Objects/java.io.ObjectStreamException + java:/Objects/java.io.PrintStream + java:/Objects/java.io.FilterOutputStream + java:/Objects/java.io.OutputStream + java:/Objects/java.io.Flushable + java:/Objects/java.io.ObjectInput + java:/Objects/java.io.DataInput + java:/Objects/java.io.ObjectStreamConstants + java:/Objects/java.io.SerializablePermission + java:/Objects/java.security.BasicPermission + java:/Objects/java.security.Permission + java:/Objects/java.security.Guard + java:/Objects/java.lang.SecurityException + java:/Objects/java.lang.RuntimeException + java:/Objects/java.lang.StringBuilder + java:/Objects/java.io.ObjectOutputStream + java:/Objects/java.io.ObjectOutput + java:/Objects/java.io.DataOutput + java:/Objects/java.io.DataInputStream + java:/Objects/java.io.FilterInputStream + java:/Objects/java.util.concurrent.ConcurrentMap + java:/Objects/java.util.Map + java:/Objects/java.util.function.BiFunction + java:/Objects/java.io.PrintWriter + java:/Objects/java.io.Writer + java:/Objects/java.io.ObjectStreamClass + java:/Objects/java.io.InvalidClassException + java:/Objects/java.util.Set + java:/Objects/java.util.Collection + java:/Objects/java.lang.Iterable + java:/Objects/java.util.function.Consumer + java:/Objects/java.util.List + java:/Objects/java.util.Iterator + java:/Objects/java.lang.Boolean + java:/Objects/java.lang.StackFrameInfo + java:/Objects/java.lang.StackWalker + java:/Objects/java.lang.invoke.MethodType + java:/Objects/java.lang.ref.WeakReference + java:/Objects/java.lang.ThreadGroup + java:/Objects/java.lang.Void + java:/Objects/java.io.ObjectInputFilter + java:/Objects/java.lang.IllegalArgumentException + java:/Objects/java.io.UnsupportedEncodingException + java:/Objects/java.lang.reflect.Type + java:/Objects/java.lang.System + java:/Objects/java.util.function.Supplier + java:/Objects/java.lang.ClassLoader + java:/Objects/java.util.Deque + java:/Objects/java.util.Queue + java:/Objects/java.util.stream.Stream + java:/Objects/java.util.function.Predicate + java:/Objects/java.lang.module.ModuleDescriptor + java:/Objects/java.util.Optional + java:/Objects/java.io.ObjectInputValidation + java:/Objects/java.io.InvalidObjectException + java:/Objects/sun.reflect.annotation.AnnotationType + java:/Objects/java.lang.reflect.Method + java:/Objects/java.lang.reflect.Executable + java:/Objects/java.lang.reflect.AccessibleObject + java:/Objects/jdk.internal.reflect.CallerSensitive + java:/Objects/java.lang.ModuleLayer + java:/Objects/java.lang.module.Configuration + java:/Objects/java.lang.module.Resolver + java:/Objects/java.lang.module.ModuleFinder + java:/Objects/java.lang.module.ModuleReference + java:/Objects/java.net.URI + java:/Objects/java.net.URISyntaxException + java:/Objects/java.lang.ref.SoftReference + java:/Objects/jdk.internal.vm.annotation.ForceInline + java:/Objects/java.lang.module.ResolvedModule + java:/Objects/java.security.AccessControlContext + java:/Objects/java.security.ProtectionDomain + java:/Objects/sun.security.util.Debug + java:/Objects/java.math.BigInteger + java:/Objects/java.lang.Number + java:/Objects/java.io.StreamCorruptedException + java:/Objects/jdk.internal.misc.Unsafe + java:/Objects/java.lang.InstantiationException + java:/Objects/java.lang.reflect.Constructor + java:/Objects/jdk.internal.reflect.ConstructorAccessor + java:/Objects/java.lang.reflect.InvocationTargetException + java:/Objects/java.lang.reflect.Field + java:/Objects/java.lang.reflect.Member + java:/Objects/java.io.Externalizable + java:/Objects/java.io.NotActiveException + java:/Objects/java.lang.SecurityManager + java:/Objects/java.net.InetAddress + java:/Objects/java.net.UnknownHostException + java:/Objects/java.lang.reflect.AnnotatedType + java:/Objects/java.io.SerialCallbackContext + java:/Objects/java.security.PermissionCollection + java:/Objects/java.util.Enumeration + java:/Objects/java.util.stream.Collector + java:/Objects/java.util.function.BiConsumer + java:/Objects/java.util.concurrent.ConcurrentHashMap + java:/Objects/java.util.AbstractMap + java:/Objects/java.util.stream.DoubleStream + java:/Objects/java.lang.Double + java:/Objects/java.lang.NumberFormatException + java:/Objects/jdk.internal.reflect.ConstantPool + java:/Objects/sun.nio.ch.Interruptible + java:/Objects/java.util.stream.LongStream + java:/Objects/java.lang.Long + java:/Objects/java.lang.ThreadLocal + java:/Objects/java.util.concurrent.atomic.AtomicInteger + java:/Objects/java.util.function.IntBinaryOperator + java:/Objects/jdk.internal.vm.annotation.Contended + java:/Objects/java.security.DomainCombiner + java:/Objects/java.util.function.UnaryOperator + java:/Objects/java.security.AccessControlException + java:/Objects/java.lang.NoSuchMethodException + java:/Objects/java.lang.NoSuchFieldException + java:/Objects/sun.reflect.generics.factory.GenericsFactory + java:/Objects/java.lang.reflect.TypeVariable + java:/Objects/java.util.function.ToDoubleFunction + java:/Objects/jdk.internal.misc.JavaSecurityAccess + java:/Objects/java.security.PrivilegedAction + java:/Objects/java.util.function.ToIntFunction + java:/Objects/java.security.CodeSource + java:/Objects/java.net.URL + java:/Objects/java.net.URLStreamHandlerFactory + java:/Objects/java.net.URLStreamHandler + java:/Objects/java.net.URLConnection + java:/Objects/java.net.UnknownServiceException + java:/Objects/sun.reflect.generics.repository.ClassRepository + java:/Objects/sun.reflect.generics.repository.GenericDeclRepository + java:/Objects/sun.reflect.generics.repository.AbstractRepository + java:/Objects/sun.reflect.generics.visitor.Reifier + java:/Objects/sun.reflect.generics.visitor.TypeTreeVisitor + java:/Objects/sun.reflect.generics.tree.ArrayTypeSignature + java:/Objects/sun.reflect.generics.tree.FieldTypeSignature + java:/Objects/sun.reflect.generics.tree.BaseType + java:/Objects/sun.reflect.generics.tree.TypeSignature + java:/Objects/sun.reflect.generics.tree.ReturnType + java:/Objects/sun.reflect.generics.tree.TypeTree + java:/Objects/sun.reflect.generics.tree.Tree + java:/Objects/java.util.function.ToLongFunction + java:/Objects/java.security.Principal + java:/Objects/javax.security.auth.Subject + java:/Objects/javax.security.auth.AuthPermission + java:/Objects/java.security.cert.Certificate + java:/Objects/java.security.cert.CertificateEncodingException + java:/Objects/java.security.cert.CertificateException + java:/Objects/java.security.GeneralSecurityException + java:/Objects/java.nio.charset.Charset + java:/Objects/java.nio.charset.spi.CharsetProvider + java:/Objects/java.lang.SafeVarargs + java:/Objects/java.security.CodeSigner + java:/Objects/java.security.cert.CertPath + java:/Objects/java.util.function.BinaryOperator + java:/Objects/java.security.cert.CertificateFactory + java:/Objects/java.security.cert.CertificateFactorySpi + java:/Objects/java.security.cert.CRLException + java:/Objects/java.util.Locale + java:/Objects/java.lang.Cloneable + java:/Objects/java.util.function.IntFunction + java:/Objects/java.net.SocketPermission + java:/Objects/java.net.MalformedURLException + java:/Objects/java.lang.PublicMethods + java:/Objects/jdk.internal.reflect.ReflectionFactory + java:/Objects/java.lang.invoke.MethodHandle + java:/Objects/java.lang.invoke.LambdaForm + java:/Objects/sun.invoke.util.Wrapper + java:/Objects/java.lang.ClassCastException + java:/Objects/java.lang.Package + java:/Objects/java.lang.NamedPackage + java:/Objects/java.util.Spliterator + java:/Objects/java.util.function.DoubleConsumer + java:/Objects/java.net.Proxy + java:/Objects/java.net.SocketAddress + java:/Objects/java.lang.Integer + java:/Objects/java.net.spi.URLStreamHandlerProvider + java:/Objects/java.util.function.IntConsumer + java:/Objects/java.util.Hashtable + java:/Objects/java.util.Dictionary + java:/Objects/java.util.function.LongConsumer + java:/Objects/java.io.ObjectStreamField + java:/Objects/java.util.Random + java:/Objects/java.util.concurrent.atomic.AtomicLong + java:/Objects/java.util.function.LongBinaryOperator + java:/Objects/java.net.UrlDeserializedState + java:/Objects/java.util.function.LongUnaryOperator + java:/Objects/java.io.FileDescriptor + java:/Objects/jdk.internal.ref.PhantomCleanable + java:/Objects/java.lang.ref.PhantomReference + java:/Objects/java.io.DataOutputStream + java:/Objects/java.util.ListIterator + java:/Objects/java.io.SyncFailedException + java:/Objects/java.lang.IllegalAccessException + java:/Objects/java.lang.ClassValue + java:/Objects/java.util.WeakHashMap + java:/Objects/java.util.AbstractSet + java:/Objects/java.util.AbstractCollection + java:/Objects/jdk.internal.reflect.FieldAccessor + java:/Objects/sun.reflect.generics.repository.FieldRepository + java:/Objects/jdk.internal.reflect.MethodAccessor + java:/Objects/jdk.internal.reflect.LangReflectAccess + java:/Objects/java.util.function.DoublePredicate + java:/Objects/java.lang.ref.Cleaner + java:/Objects/java.util.concurrent.ThreadFactory + java:/Objects/java.io.OptionalDataException + java:/Objects/java.util.OptionalDouble + java:/Objects/java.util.function.DoubleSupplier + java:/Objects/jdk.internal.ref.CleanerImpl + java:/Objects/jdk.internal.ref.SoftCleanable + java:/Objects/sun.reflect.generics.repository.ConstructorRepository + java:/Objects/sun.reflect.generics.tree.MethodTypeSignature + java:/Objects/sun.reflect.generics.tree.Signature + java:/Objects/sun.reflect.generics.tree.FormalTypeParameter + java:/Objects/sun.reflect.generics.tree.TypeArgument + java:/Objects/sun.reflect.generics.tree.BooleanSignature + java:/Objects/sun.reflect.generics.tree.BottomSignature + java:/Objects/sun.reflect.generics.tree.ByteSignature + java:/Objects/sun.reflect.generics.tree.CharSignature + java:/Objects/sun.reflect.generics.tree.ClassTypeSignature + java:/Objects/sun.reflect.generics.tree.SimpleClassTypeSignature + java:/Objects/sun.reflect.generics.tree.DoubleSignature + java:/Objects/sun.reflect.generics.tree.FloatSignature + java:/Objects/sun.reflect.generics.tree.IntSignature + java:/Objects/sun.reflect.generics.tree.LongSignature + java:/Objects/sun.reflect.generics.tree.ShortSignature + java:/Objects/sun.reflect.generics.tree.TypeVariableSignature + java:/Objects/sun.reflect.generics.tree.VoidDescriptor + java:/Objects/sun.reflect.generics.tree.Wildcard + java:/Objects/sun.reflect.generics.visitor.Visitor + java:/Objects/sun.reflect.generics.tree.ClassSignature + java:/Objects/sun.reflect.generics.repository.MethodRepository + java:/Objects/jdk.internal.ref.WeakCleanable + java:/Objects/java.lang.invoke.BoundMethodHandle + java:/Objects/java.lang.invoke.ClassSpecializer + java:/Objects/jdk.internal.org.objectweb.asm.MethodVisitor + java:/Objects/jdk.internal.org.objectweb.asm.AnnotationVisitor + java:/Objects/java.lang.invoke.MemberName + java:/Objects/java.lang.invoke.ResolvedMethodName + java:/Objects/java.lang.invoke.MethodHandleImpl + java:/Objects/java.lang.invoke.DelegatingMethodHandle + java:/Objects/java.lang.reflect.Parameter + java:/Objects/java.lang.invoke.MethodTypeForm + java:/Objects/jdk.internal.vm.annotation.Stable + java:/Objects/java.util.function.IntUnaryOperator + java:/Objects/java.util.function.IntPredicate + java:/Objects/java.util.function.ObjIntConsumer + java:/Objects/java.util.OptionalInt + java:/Objects/java.util.function.IntSupplier + java:/Objects/java.util.PrimitiveIterator + java:/Objects/java.util.function.IntToDoubleFunction + java:/Objects/java.util.function.IntToLongFunction + java:/Objects/java.util.IntSummaryStatistics + java:/Objects/java.lang.TypeNotPresentException + java:/Objects/java.lang.UnsupportedOperationException + java:/Objects/java.io.FileNotFoundException + java:/Objects/java.util.function.ObjDoubleConsumer + java:/Objects/java.util.function.DoubleFunction + java:/Objects/java.util.function.DoubleUnaryOperator + java:/Objects/java.util.function.DoubleToIntFunction + java:/Objects/java.util.function.DoubleToLongFunction + java:/Objects/java.util.function.DoubleBinaryOperator + java:/Objects/java.util.DoubleSummaryStatistics + java:/Objects/java.lang.invoke.Invokers + java:/Objects/java.lang.invoke.VarHandle + java:/Objects/java.lang.invoke.VarForm + java:/Objects/java.lang.invoke.LambdaFormEditor + java:/Objects/java.lang.invoke.LambdaFormBuffer + java:/Objects/java.util.ArrayList + java:/Objects/java.util.AbstractList + java:/Objects/java.util.RandomAccess + java:/Objects/java.lang.IndexOutOfBoundsException + java:/Objects/java.util.function.LongPredicate + java:/Objects/java.util.function.ObjLongConsumer + java:/Objects/java.util.OptionalLong + java:/Objects/java.util.function.LongSupplier + java:/Objects/java.util.function.LongFunction + java:/Objects/java.util.function.LongToDoubleFunction + java:/Objects/java.util.function.LongToIntFunction + java:/Objects/java.util.LongSummaryStatistics + java:/Objects/java.util.concurrent.CountedCompleter + java:/Objects/java.util.concurrent.ForkJoinTask + java:/Objects/java.util.concurrent.Future + java:/Objects/java.util.concurrent.ExecutionException + java:/Objects/java.io.File + java:/Objects/java.security.SecureRandom + java:/Objects/java.util.regex.Pattern + java:/Objects/java.util.regex.Matcher + java:/Objects/java.util.regex.MatchResult + java:/Objects/java.util.function.ToDoubleBiFunction + java:/Objects/java.lang.invoke.CallSite + java:/Objects/java.lang.invoke.WrongMethodTypeException + java:/Objects/java.io.OutputStreamWriter + java:/Objects/java.nio.charset.CharsetEncoder + java:/Objects/java.nio.CharBuffer + java:/Objects/java.nio.Buffer + java:/Objects/java.util.function.ToIntBiFunction + java:/Objects/jdk.internal.vm.annotation.DontInline + java:/Objects/java.lang.ArrayIndexOutOfBoundsException + java:/Objects/java.lang.ClassFormatError + java:/Objects/java.lang.LinkageError + java:/Objects/java.lang.Error + java:/Objects/java.nio.ByteBuffer + java:/Objects/java.nio.DoubleBuffer + java:/Objects/java.nio.ByteOrder + java:/Objects/java.util.function.ToLongBiFunction + java:/Objects/java.lang.invoke.MethodHandleNatives + java:/Objects/java.lang.NoSuchMethodError + java:/Objects/java.lang.IncompatibleClassChangeError + java:/Objects/java.lang.AssertionStatusDirectives + java:/Objects/java.util.concurrent.atomic.AtomicReference + java:/Objects/java.util.concurrent.locks.ReentrantLock + java:/Objects/java.util.concurrent.locks.Lock + java:/Objects/java.util.concurrent.locks.Condition + java:/Objects/java.util.concurrent.TimeUnit + java:/Objects/java.time.Duration + java:/Objects/java.time.temporal.TemporalAmount + java:/Objects/java.time.temporal.Temporal + java:/Objects/java.time.temporal.TemporalAccessor + java:/Objects/java.time.temporal.TemporalField + java:/Objects/java.time.temporal.TemporalUnit + java:/Objects/java.util.concurrent.RunnableFuture + java:/Objects/jdk.internal.perf.PerfCounter + java:/Objects/java.nio.LongBuffer + java:/Objects/java.net.ContentHandler + java:/Objects/java.util.concurrent.Callable + java:/Objects/jdk.internal.misc.JavaLangInvokeAccess + java:/Objects/java.util.HashMap + java:/Objects/java.util.LinkedHashMap + java:/Objects/jdk.internal.perf.Perf + java:/Objects/java.util.concurrent.TimeoutException + java:/Objects/java.util.Vector + java:/Objects/java.nio.FloatBuffer + java:/Objects/java.net.FileNameMap + java:/Objects/java.util.concurrent.ForkJoinPool + java:/Objects/java.util.concurrent.AbstractExecutorService + java:/Objects/java.util.concurrent.ExecutorService + java:/Objects/java.util.concurrent.Executor + java:/Objects/java.time.temporal.ChronoUnit + java:/Objects/java.nio.IntBuffer + java:/Objects/java.net.ContentHandlerFactory + java:/Objects/java.math.BigDecimal + java:/Objects/java.math.MathContext + java:/Objects/java.math.RoundingMode + java:/Objects/java.nio.ShortBuffer + java:/Objects/sun.net.www.MessageHeader + java:/Objects/java.util.regex.PatternSyntaxException + java:/Objects/java.security.Timestamp + java:/Objects/java.util.Date + java:/Objects/java.time.Instant + java:/Objects/java.time.temporal.TemporalAdjuster + java:/Objects/java.lang.Readable + java:/Objects/java.util.regex.IntHashSet + java:/Objects/java.time.temporal.TemporalQuery + java:/Objects/jdk.internal.org.objectweb.asm.Attribute + java:/Objects/jdk.internal.org.objectweb.asm.ClassReader + java:/Objects/jdk.internal.org.objectweb.asm.ClassVisitor + java:/Objects/jdk.internal.org.objectweb.asm.FieldVisitor + java:/Objects/jdk.internal.org.objectweb.asm.TypePath + java:/Objects/java.time.temporal.ValueRange + java:/Objects/jdk.internal.org.objectweb.asm.Handle + java:/Objects/java.time.format.ResolverStyle + java:/Objects/jdk.internal.org.objectweb.asm.Label + java:/Objects/jdk.internal.org.objectweb.asm.MethodWriter + java:/Objects/jdk.internal.org.objectweb.asm.ClassWriter + java:/Objects/jdk.internal.org.objectweb.asm.Item + java:/Objects/sun.util.locale.InternalLocaleBuilder + java:/Objects/sun.util.locale.LocaleSyntaxException + java:/Objects/sun.util.calendar.BaseCalendar + java:/Objects/sun.util.calendar.AbstractCalendar + java:/Objects/sun.util.calendar.CalendarSystem + java:/Objects/sun.util.calendar.CalendarDate + java:/Objects/java.util.TimeZone + java:/Objects/java.time.ZoneId + java:/Objects/java.time.format.TextStyle + java:/Objects/jdk.internal.org.objectweb.asm.ByteVector + java:/Objects/sun.util.locale.LocaleObjectCache + java:/Objects/sun.util.locale.BaseLocale + java:/Objects/sun.util.locale.LocaleExtensions + java:/Objects/java.lang.Character + java:/Objects/jdk.internal.org.objectweb.asm.Context + java:/Objects/sun.util.locale.provider.LocaleServiceProviderPool + java:/Objects/java.util.spi.LocaleServiceProvider + java:/Objects/java.math.MutableBigInteger + java:/Objects/java.util.spi.LocaleNameProvider + java:/Objects/java.util.concurrent.ForkJoinWorkerThread + java:/Objects/java.util.ResourceBundle + java:/Objects/java.util.ServiceLoader + java:/Objects/jdk.internal.module.ServicesCatalog + java:/Objects/jdk.internal.loader.ClassLoaderValue + java:/Objects/jdk.internal.loader.AbstractClassLoaderValue + java:/Objects/java.lang.IllegalStateException + java:/Objects/java.util.Formatter + java:/Objects/java.util.Calendar + java:/Objects/java.text.DateFormatSymbols + java:/Objects/java.lang.RuntimePermission + java:/Objects/jdk.internal.org.objectweb.asm.ModuleVisitor + java:/Objects/sun.util.locale.provider.LocaleResources + java:/Objects/sun.util.locale.provider.ResourceBundleBasedAdapter + java:/Objects/sun.util.resources.LocaleData + java:/Objects/java.util.spi.ResourceBundleProvider + java:/Objects/jdk.internal.vm.annotation.ReservedStackAccess + java:/Objects/jdk.internal.org.objectweb.asm.AnnotationWriter + java:/Objects/jdk.internal.org.objectweb.asm.FieldWriter + java:/Objects/jdk.internal.org.objectweb.asm.ModuleWriter + java:/Objects/java.util.MissingResourceException + java:/Objects/java.io.BufferedWriter + java:/Objects/sun.util.locale.LanguageTag + java:/Objects/sun.util.locale.ParseStatus + java:/Objects/sun.util.locale.StringTokenIterator + java:/Objects/sun.util.locale.Extension + java:/Objects/java.util.SortedMap + java:/Objects/jdk.internal.org.objectweb.asm.Frame + java:/Objects/jdk.internal.org.objectweb.asm.Type + java:/Objects/sun.util.locale.provider.LocaleProviderAdapter + java:/Objects/sun.util.locale.provider.FallbackLocaleProviderAdapter + java:/Objects/sun.util.locale.provider.JRELocaleProviderAdapter + java:/Objects/java.text.spi.BreakIteratorProvider + java:/Objects/java.text.BreakIterator + java:/Objects/java.text.CharacterIterator + java:/Objects/sun.util.calendar.Era + java:/Objects/java.util.concurrent.locks.AbstractQueuedSynchronizer + java:/Objects/java.util.concurrent.locks.AbstractOwnableSynchronizer + java:/Objects/java.io.FilenameFilter + java:/Objects/jdk.internal.org.objectweb.asm.Handler + java:/Objects/sun.util.calendar.Gregorian + java:/Objects/java.time.ZoneOffset + java:/Objects/java.time.zone.ZoneRules + java:/Objects/java.time.zone.ZoneOffsetTransition + java:/Objects/java.time.LocalDateTime + java:/Objects/java.time.chrono.ChronoLocalDateTime + java:/Objects/java.time.chrono.ChronoZonedDateTime + java:/Objects/java.time.format.DateTimeFormatter + java:/Objects/java.text.Format + java:/Objects/java.text.AttributedCharacterIterator + java:/Objects/java.time.zone.ZoneOffsetTransitionRule + java:/Objects/java.time.Month + java:/Objects/jdk.internal.org.objectweb.asm.Edge + java:/Objects/java.time.DayOfWeek + java:/Objects/sun.invoke.empty.Empty + java:/Objects/java.time.LocalTime + java:/Objects/java.time.LocalDate + java:/Objects/java.time.chrono.ChronoLocalDate + java:/Objects/java.time.chrono.Chronology + java:/Objects/java.time.chrono.Era + java:/Objects/java.lang.InternalError + java:/Objects/java.lang.VirtualMachineError + java:/Objects/java.io.FileFilter + java:/Objects/java.lang.reflect.ParameterizedType + java:/Objects/java.time.OffsetTime + java:/Objects/java.time.OffsetDateTime + java:/Objects/java.time.ZonedDateTime + java:/Objects/java.time.Clock + java:/Objects/java.lang.reflect.WildcardType + java:/Objects/java.time.Period + java:/Objects/java.time.chrono.ChronoPeriod + java:/Objects/java.net.NetworkInterface + java:/Objects/java.net.SocketException + java:/Objects/java.util.spi.ResourceBundleControlProvider + java:/Objects/java.time.chrono.IsoChronology + java:/Objects/java.time.chrono.AbstractChronology + java:/Objects/java.time.temporal.ChronoField + java:/Objects/java.net.InetAddressImpl + java:/Objects/java.time.chrono.IsoEra + java:/Objects/java.util.NavigableSet + java:/Objects/java.util.SortedSet + java:/Objects/java.net.InterfaceAddress + java:/Objects/java.net.Inet4Address + java:/Objects/java.security.PublicKey + java:/Objects/java.security.Key + java:/Objects/java.text.FieldPosition + java:/Objects/java.text.ParseException + java:/Objects/java.util.ServiceConfigurationError + java:/Objects/java.nio.file.Path + java:/Objects/java.nio.file.Watchable + java:/Objects/java.nio.file.WatchService + java:/Objects/java.nio.file.WatchKey + java:/Objects/java.nio.file.WatchEvent + java:/Objects/java.text.ParsePosition + java:/Objects/java.time.format.DateTimeFormatterBuilder + java:/Objects/java.time.format.DateTimePrintContext + java:/Objects/java.time.format.DecimalStyle + java:/Objects/java.time.format.DateTimeParseException + java:/Objects/java.time.DateTimeException + java:/Objects/java.io.FileSystem + java:/Objects/java.time.format.FormatStyle + java:/Objects/java.security.NoSuchAlgorithmException + java:/Objects/java.security.SecureRandomSpi + java:/Objects/java.security.SecureRandomParameters + java:/Objects/java.time.format.DateTimeParseContext + java:/Objects/java.time.format.Parsed + java:/Objects/java.io.BufferedReader + java:/Objects/java.io.Reader + java:/Objects/java.time.format.SignStyle + java:/Objects/java.security.InvalidKeyException + java:/Objects/java.security.KeyException + java:/Objects/java.security.Provider + java:/Objects/java.util.Properties + java:/Objects/java.util.InvalidPropertiesFormatException + java:/Objects/java.io.NotSerializableException + java:/Objects/jdk.internal.misc.JavaLangAccess + java:/Objects/java.nio.charset.CharacterCodingException + java:/Objects/java.security.NoSuchProviderException + java:/Objects/java.lang.LayerInstantiationException + java:/Objects/java.security.MessageDigest + java:/Objects/java.security.MessageDigestSpi + java:/Objects/java.security.DigestException + java:/Objects/java.time.format.DateTimeTextProvider + java:/Objects/sun.security.util.MessageDigestSpi2 + java:/Objects/javax.crypto.SecretKey + java:/Objects/javax.security.auth.Destroyable + java:/Objects/javax.security.auth.DestroyFailedException + java:/Objects/jdk.internal.module.ModuleTarget + java:/Objects/java.nio.file.FileSystem + java:/Objects/java.nio.file.FileStore + java:/Objects/java.nio.file.attribute.FileStoreAttributeView + java:/Objects/java.nio.file.attribute.AttributeView + java:/Objects/java.nio.file.LinkOption + java:/Objects/java.nio.file.OpenOption + java:/Objects/java.nio.file.PathMatcher + java:/Objects/java.security.SignatureException + java:/Objects/java.nio.file.attribute.UserPrincipalLookupService + java:/Objects/java.nio.file.attribute.GroupPrincipal + java:/Objects/java.nio.file.attribute.UserPrincipal + java:/Objects/java.nio.file.spi.FileSystemProvider + java:/Objects/java.nio.file.AccessMode + java:/Objects/java.nio.charset.CharsetDecoder + java:/Objects/java.nio.charset.CoderResult + java:/Objects/java.nio.file.attribute.FileAttributeView + java:/Objects/java.util.LinkedList + java:/Objects/java.util.AbstractSequentialList + java:/Objects/sun.util.resources.Bundles + java:/Objects/jdk.internal.misc.JavaUtilResourceBundleAccess + java:/Objects/java.util.EnumSet + java:/Objects/java.security.cert.CRL + java:/Objects/java.security.PrivilegedExceptionAction + java:/Objects/java.security.PrivilegedActionException + java:/Objects/java.lang.module.ModuleReader + java:/Objects/java.nio.file.CopyOption + java:/Objects/java.nio.file.attribute.FileAttribute + java:/Objects/java.nio.channels.AsynchronousFileChannel + java:/Objects/java.nio.channels.AsynchronousChannel + java:/Objects/java.nio.channels.Channel + java:/Objects/java.nio.channels.SeekableByteChannel + java:/Objects/java.nio.channels.ByteChannel + java:/Objects/java.nio.channels.ReadableByteChannel + java:/Objects/java.nio.file.DirectoryStream + java:/Objects/sun.util.resources.OpenListResourceBundle + java:/Objects/java.nio.channels.FileChannel + java:/Objects/java.nio.channels.spi.AbstractInterruptibleChannel + java:/Objects/java.nio.channels.InterruptibleChannel + java:/Objects/java.nio.file.attribute.BasicFileAttributes + java:/Objects/java.nio.file.attribute.FileTime + java:/Objects/java.nio.channels.FileLock + java:/Objects/java.nio.channels.WritableByteChannel + java:/Objects/java.nio.channels.CompletionHandler + java:/Objects/java.nio.channels.GatheringByteChannel + java:/Objects/java.nio.channels.ScatteringByteChannel + java:/Objects/java.nio.MappedByteBuffer + java:/Objects/sun.util.resources.TimeZoneNamesBundle + java:/Objects/java.nio.channels.AsynchronousCloseException + java:/Objects/java.nio.channels.ClosedChannelException + java:/Objects/sun.nio.cs.StreamEncoder + java:/Objects/sun.util.resources.ParallelListResourceBundle + java:/Objects/java.util.concurrent.atomic.AtomicMarkableReference + java:/Objects/java.nio.charset.CodingErrorAction + java:/Objects/java.util.spi.CalendarDataProvider + java:/Objects/java.io.Console + java:/Objects/java.util.spi.CalendarNameProvider + java:/Objects/java.io.FileOutputStream + java:/Objects/jdk.internal.misc.JavaIOFileDescriptorAccess + java:/Objects/sun.util.spi.CalendarProvider + java:/Objects/java.text.spi.CollatorProvider + java:/Objects/java.text.Collator + java:/Objects/java.text.CollationKey + java:/Objects/java.util.spi.CurrencyNameProvider + java:/Objects/java.text.spi.DateFormatProvider + java:/Objects/java.text.DateFormat + java:/Objects/java.text.NumberFormat + java:/Objects/java.util.Currency + java:/Objects/java.util.HashSet + java:/Objects/java.text.spi.DateFormatSymbolsProvider + java:/Objects/java.text.spi.DecimalFormatSymbolsProvider + java:/Objects/java.text.DecimalFormatSymbols + java:/Objects/sun.text.spi.JavaTimeDateTimePatternProvider + java:/Objects/java.text.spi.NumberFormatProvider + java:/Objects/java.util.spi.TimeZoneNameProvider + java:/Objects/org.eclipse.viatra.query.runtime.api.IPatternMatch + java:/Objects/org.eclipse.viatra.query.runtime.api.IQuerySpecification + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQueryHeader + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IInputKey + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PTraceable + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PDisjunction + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PBody + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PVariable + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryMetaContext + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.InputKeyImplication + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IPosetComparator + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.Tuple + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.AbstractTuple + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.ITuple + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.TypeJudgement + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.VariableDeferredPConstraint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.DeferredPConstraint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.BasePConstraint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.QueryHintOption + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IMatcherCapability + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryBackendContext + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendHintProvider + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PProblem + java:/Objects/org.eclipse.viatra.query.runtime.matchers.planning.QueryProcessingException + java:/Objects/org.eclipse.viatra.query.runtime.matchers.ViatraQueryRuntimeException + java:/Objects/org.eclipse.viatra.query.runtime.matchers.planning.SubPlan + java:/Objects/org.eclipse.viatra.query.runtime.matchers.planning.operations.POperation + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackend + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryResultProvider + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IUpdateable + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.TupleMask + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.IModifiableTuple + java:/Objects/org.eclipse.viatra.query.runtime.matchers.util.Accuracy + java:/Objects/org.apache.log4j.Logger + java:/Objects/org.apache.log4j.Category + java:/Objects/org.apache.log4j.spi.AppenderAttachable + java:/Objects/org.apache.log4j.Appender + java:/Objects/org.apache.log4j.spi.Filter + java:/Objects/org.apache.log4j.spi.OptionHandler + java:/Objects/org.apache.log4j.spi.LoggingEvent + java:/Objects/org.apache.log4j.Priority + java:/Objects/org.apache.log4j.Level + java:/Objects/org.apache.log4j.spi.ThrowableInformation + java:/Objects/org.apache.log4j.spi.LocationInfo + java:/Objects/java.io.StringWriter + java:/Objects/org.apache.log4j.spi.LoggerRepository + java:/Objects/org.apache.log4j.spi.HierarchyEventListener + java:/Objects/org.apache.log4j.helpers.AppenderAttachableImpl + java:/Objects/org.apache.log4j.spi.ErrorHandler + java:/Objects/org.apache.log4j.spi.LoggerFactory + java:/Objects/org.apache.log4j.Layout + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.analysis.QueryAnalyzer + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryCacheContext + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryResultProviderAccess + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContext + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContextListener + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IndexingService + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryEngine + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IBaseIndex + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.ViatraBaseIndexChangeListener + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IIndexingErrorListener + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IInstanceObserver + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.QueryScope + java:/Objects/org.eclipse.viatra.query.runtime.internal.apiimpl.EngineContextFactory + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IEngineContext + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseMatcher + java:/Objects/org.eclipse.viatra.query.runtime.internal.apiimpl.QueryResultWrapper + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseQuerySpecification + java:/Objects/java.lang.ExceptionInInitializerError + java:/Objects/org.eclipse.viatra.query.runtime.exception.ViatraQueryException + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.QueryInitializationException + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseQueryGroup + java:/Objects/org.eclipse.viatra.query.runtime.api.IQueryGroup + java:/Objects/org.eclipse.viatra.query.runtime.api.AdvancedViatraQueryEngine + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryEngineLifecycleListener + java:/Objects/org.eclipse.viatra.query.runtime.api.IMatchUpdateListener + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryModelUpdateListener + java:/Objects/java.lang.Override + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.BasePQuery + java:/Objects/org.eclipse.emf.ecore.EClassifier + java:/Objects/org.eclipse.emf.ecore.ENamedElement + java:/Objects/org.eclipse.emf.ecore.EModelElement + java:/Objects/org.eclipse.emf.ecore.EObject + java:/Objects/org.eclipse.emf.common.notify.Notifier + java:/Objects/org.eclipse.emf.common.util.EList + java:/Objects/org.eclipse.emf.common.notify.Adapter + java:/Objects/org.eclipse.emf.common.notify.Notification + java:/Objects/org.eclipse.emf.common.util.TreeIterator + java:/Objects/org.eclipse.emf.ecore.EClass + java:/Objects/org.eclipse.emf.ecore.EAttribute + java:/Objects/org.eclipse.emf.ecore.EStructuralFeature + java:/Objects/org.eclipse.emf.ecore.ETypedElement + java:/Objects/org.eclipse.emf.ecore.EGenericType + java:/Objects/org.eclipse.emf.ecore.ETypeParameter + java:/Objects/org.eclipse.emf.ecore.EAnnotation + java:/Objects/org.eclipse.emf.common.util.EMap + java:/Objects/org.eclipse.emf.ecore.EReference + java:/Objects/org.eclipse.emf.ecore.InternalEObject + java:/Objects/org.eclipse.emf.common.notify.NotificationChain + java:/Objects/org.eclipse.emf.ecore.resource.Resource + java:/Objects/org.eclipse.emf.common.util.URI + java:/Objects/org.eclipse.emf.common.util.Pool + java:/Objects/org.eclipse.emf.common.util.WeakInterningHashSet + java:/Objects/org.eclipse.emf.common.util.InterningSet + java:/Objects/java.util.concurrent.locks.ReentrantReadWriteLock + java:/Objects/java.util.concurrent.locks.ReadWriteLock + java:/Objects/java.lang.IllegalMonitorStateException + java:/Objects/org.eclipse.emf.common.util.SegmentSequence + java:/Objects/org.eclipse.emf.common.util.CommonUtil + java:/Objects/org.eclipse.emf.ecore.resource.ResourceSet + java:/Objects/org.eclipse.emf.common.notify.AdapterFactory + java:/Objects/org.eclipse.emf.ecore.EPackage + java:/Objects/org.eclipse.emf.ecore.EFactory + java:/Objects/org.eclipse.emf.ecore.EDataType + java:/Objects/org.eclipse.emf.common.CommonPlugin + java:/Objects/org.eclipse.emf.common.EMFPlugin + java:/Objects/org.eclipse.emf.common.util.DelegatingResourceLocator + java:/Objects/org.eclipse.emf.common.util.ResourceLocator + java:/Objects/org.eclipse.emf.common.util.Logger + java:/Objects/org.eclipse.core.runtime.Plugin + java:/Objects/org.osgi.framework.BundleActivator + java:/Objects/org.osgi.framework.BundleContext + java:/Objects/org.osgi.framework.BundleReference + java:/Objects/org.osgi.framework.Bundle + java:/Objects/org.osgi.framework.ServiceReference + java:/Objects/java.security.cert.X509Certificate + java:/Objects/java.security.cert.X509Extension + java:/Objects/java.security.cert.CertificateExpiredException + java:/Objects/java.security.cert.CertificateNotYetValidException + java:/Objects/java.security.cert.CertificateParsingException + java:/Objects/javax.security.auth.x500.X500Principal + java:/Objects/sun.security.x509.X500Name + java:/Objects/sun.security.x509.GeneralNameInterface + java:/Objects/sun.security.util.DerOutputStream + java:/Objects/java.io.ByteArrayOutputStream + java:/Objects/sun.security.util.DerEncoder + java:/Objects/sun.security.util.DerValue + java:/Objects/sun.security.util.DerInputBuffer + java:/Objects/java.io.ByteArrayInputStream + java:/Objects/sun.security.util.BitArray + java:/Objects/sun.security.util.DerInputStream + java:/Objects/sun.security.util.ObjectIdentifier + java:/Objects/sun.security.util.ByteArrayLexOrder + java:/Objects/sun.security.util.ByteArrayTagOrder + java:/Objects/sun.security.x509.RDN + java:/Objects/sun.security.x509.AVA + java:/Objects/java.lang.Byte + java:/Objects/org.osgi.framework.Version + java:/Objects/org.osgi.framework.BundleException + java:/Objects/org.osgi.framework.BundleListener + java:/Objects/java.util.EventListener + java:/Objects/org.osgi.framework.BundleEvent + java:/Objects/java.util.EventObject + java:/Objects/org.osgi.framework.FrameworkListener + java:/Objects/org.osgi.framework.FrameworkEvent + java:/Objects/org.osgi.framework.ServiceListener + java:/Objects/org.osgi.framework.ServiceEvent + java:/Objects/org.osgi.framework.InvalidSyntaxException + java:/Objects/org.osgi.framework.Filter + java:/Objects/org.osgi.framework.ServiceObjects + java:/Objects/org.osgi.framework.ServiceRegistration + java:/Objects/org.osgi.framework.ServiceFactory + java:/Objects/org.eclipse.core.runtime.IPath + java:/Objects/org.eclipse.osgi.service.debug.DebugOptions + java:/Objects/org.eclipse.osgi.service.debug.DebugTrace + java:/Objects/org.eclipse.core.runtime.ILog + java:/Objects/org.eclipse.core.runtime.ILogListener + java:/Objects/org.eclipse.core.runtime.IStatus + java:/Objects/org.eclipse.core.runtime.Preferences + java:/Objects/org.eclipse.core.runtime.CoreException + java:/Objects/org.eclipse.core.runtime.ListenerList + java:/Objects/org.osgi.util.tracker.ServiceTracker + java:/Objects/org.osgi.util.tracker.ServiceTrackerCustomizer + java:/Objects/org.osgi.framework.AllServiceListener + java:/Objects/org.osgi.util.tracker.AbstractTracked + java:/Objects/org.eclipse.emf.ecore.EOperation + java:/Objects/org.eclipse.emf.ecore.EParameter + java:/Objects/org.eclipse.emf.ecore.util.FeatureMap + java:/Objects/org.eclipse.emf.ecore.util.InternalEList + java:/Objects/org.eclipse.emf.ecore.util.EContentsEList + java:/Objects/org.eclipse.emf.ecore.util.AbstractSequentialInternalEList + java:/Objects/org.eclipse.emf.ecore.resource.URIConverter + java:/Objects/java.io.InputStreamReader + java:/Objects/sun.nio.cs.StreamDecoder + java:/Objects/java.io.FileInputStream + java:/Objects/org.eclipse.emf.ecore.resource.ContentHandler + java:/Objects/org.eclipse.emf.ecore.resource.URIHandler + java:/Objects/org.eclipse.emf.ecore.EEnumLiteral + java:/Objects/org.eclipse.emf.common.util.Enumerator + java:/Objects/org.eclipse.emf.ecore.EEnum + java:/Objects/modes3.Segment + java:/Objects/modes3.Train + java:/Objects/java.lang.SuppressWarnings + java:/Objects/modes3.Turnout + ../src/modes3/run/Modes3ModelGenerator.xtend + java:/Objects/org.eclipse.xtend.lib.annotations.FinalFieldsConstructor + java:/Objects/org.eclipse.xtend.lib.macro.Active + java:/Objects/com.google.common.annotations.Beta + java:/Objects/com.google.common.annotations.GwtCompatible + java:/Objects/org.eclipse.xtend.lib.annotations.FinalFieldsConstructorProcessor + java:/Objects/org.eclipse.xtend.lib.macro.TransformationParticipant + java:/Objects/org.eclipse.xtext.xbase.lib.Extension + java:/Objects/org.eclipse.xtend.lib.macro.TransformationContext + java:/Objects/org.eclipse.xtend.lib.macro.services.Tracability + java:/Objects/org.eclipse.xtend.lib.macro.declaration.Element + java:/Objects/org.eclipse.xtend.lib.macro.services.ProblemSupport + java:/Objects/org.eclipse.xtend.lib.macro.services.Problem + java:/Objects/org.eclipse.xtext.xbase.lib.Procedures + java:/Objects/org.eclipse.xtend.lib.macro.services.TypeReferenceProvider + java:/Objects/org.eclipse.xtend.lib.macro.declaration.TypeReference + java:/Objects/org.eclipse.xtend.lib.macro.declaration.ResolvedMethod + java:/Objects/org.eclipse.xtend.lib.macro.declaration.ResolvedExecutable + java:/Objects/org.eclipse.xtend.lib.macro.declaration.ExecutableDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.TypeParameterDeclarator + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MemberDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.Declaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.AnnotationTarget + java:/Objects/org.eclipse.xtend.lib.macro.declaration.NamedElement + java:/Objects/org.eclipse.xtend.lib.macro.declaration.CompilationUnit + java:/Objects/org.eclipse.xtend.lib.macro.file.Path + java:/Objects/com.google.common.collect.ImmutableList + java:/Objects/com.google.common.collect.ImmutableCollection + java:/Objects/com.google.common.collect.UnmodifiableIterator + java:/Objects/com.google.common.annotations.VisibleForTesting + java:/Objects/com.google.common.collect.UnmodifiableListIterator + java:/Objects/com.google.common.base.Splitter + java:/Objects/com.google.common.base.AbstractIterator + java:/Objects/com.google.common.base.CharMatcher + java:/Objects/com.google.common.base.Predicate + java:/Objects/com.google.common.annotations.GwtIncompatible + java:/Objects/java.util.BitSet + java:/Objects/com.google.common.base.CommonPattern + java:/Objects/com.google.common.base.CommonMatcher + java:/Objects/org.eclipse.xtend.lib.macro.declaration.TypeDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.Type + java:/Objects/org.eclipse.xtend.lib.macro.declaration.AnnotationReference + java:/Objects/org.eclipse.xtend.lib.macro.declaration.AnnotationTypeDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.AnnotationTypeElementDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.expression.Expression + java:/Objects/org.eclipse.xtend.lib.macro.declaration.Modifier + java:/Objects/org.eclipse.xtend.lib.macro.declaration.Visibility + java:/Objects/org.eclipse.xtend.lib.macro.declaration.EnumerationValueDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.EnumerationTypeDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.ConstructorDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.ParameterDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.FieldDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MethodDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.TypeParameterDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.ClassDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.InterfaceDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.ResolvedConstructor + java:/Objects/org.eclipse.xtend.lib.macro.declaration.ResolvedParameter + java:/Objects/org.eclipse.xtend.lib.macro.declaration.ResolvedTypeParameter + java:/Objects/org.eclipse.xtend.lib.macro.services.TypeLookup + java:/Objects/org.eclipse.xtend.lib.macro.services.GlobalTypeLookup + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableAnnotationTypeDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableTypeDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableMemberDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableAnnotationTarget + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableNamedElement + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableElement + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableConstructorDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableExecutableDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclarator + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.CompilationStrategy + java:/Objects/org.eclipse.xtend2.lib.StringConcatenationClient + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableMethodDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableParameterDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableEnumerationTypeDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableEnumerationValueDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableInterfaceDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.declaration.MutableAnnotationTypeElementDeclaration + java:/Objects/org.eclipse.xtend.lib.macro.file.FileSystemSupport + java:/Objects/org.eclipse.xtend.lib.macro.file.FileLocations + java:/Objects/org.eclipse.xtend.lib.macro.services.AnnotationReferenceProvider + java:/Objects/org.eclipse.xtend.lib.macro.services.AnnotationReferenceBuildContext + java:/Objects/org.eclipse.xtend.lib.macro.services.Associator + java:/Objects/org.eclipse.xtend.lib.annotations.Data + java:/Objects/org.eclipse.xtend.lib.annotations.DataProcessor + java:/Objects/org.eclipse.xtend.lib.macro.AbstractClassProcessor + java:/Objects/org.eclipse.xtend.lib.macro.RegisterGlobalsParticipant + java:/Objects/org.eclipse.xtend.lib.macro.RegisterGlobalsContext + java:/Objects/org.eclipse.xtend.lib.macro.services.UpstreamTypeLookup + java:/Objects/org.eclipse.xtend.lib.macro.services.SourceTypeLookup + java:/Objects/org.eclipse.xtend.lib.macro.CodeGenerationParticipant + java:/Objects/org.eclipse.xtend.lib.macro.CodeGenerationContext + java:/Objects/org.eclipse.xtend.lib.macro.file.MutableFileSystemSupport + java:/Objects/org.eclipse.xtend.lib.macro.ValidationParticipant + java:/Objects/org.eclipse.xtend.lib.macro.ValidationContext + java:/Objects/org.eclipse.xtend.lib.annotations.Accessors + java:/Objects/org.eclipse.xtend.lib.annotations.AccessorsProcessor + java:/Objects/org.eclipse.xtend.lib.annotations.AccessorType + java:/Objects/org.eclipse.xtext.xbase.lib.ArrayLiterals + java:/Objects/org.eclipse.xtext.xbase.lib.Pure + java:/Objects/org.eclipse.xtext.xbase.lib.Inline + java:/Objects/org.eclipse.xtext.xbase.lib.CollectionLiterals + java:/Objects/org.eclipse.xtext.xbase.lib.Pair + java:/Objects/java.util.LinkedHashSet + java:/Objects/java.util.TreeMap + java:/Objects/java.util.NavigableMap + java:/Objects/java.util.TreeSet + java:/Objects/org.eclipse.xtext.xbase.lib.InputOutput + java:/Objects/org.eclipse.xtext.xbase.lib.ArrayExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.BigDecimalExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.BigIntegerExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.BooleanExtensions + java:/Objects/com.google.common.primitives.Booleans + java:/Objects/org.eclipse.xtext.xbase.lib.ByteExtensions + java:/Objects/java.lang.Math + java:/Objects/org.eclipse.xtext.xbase.lib.CharacterExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.CollectionExtensions + java:/Objects/com.google.common.collect.Iterables + java:/Objects/com.google.common.collect.FluentIterable + java:/Objects/com.google.common.base.Function + java:/Objects/com.google.common.base.Optional + java:/Objects/com.google.common.base.Supplier + java:/Objects/com.google.common.collect.ImmutableListMultimap + java:/Objects/com.google.common.collect.ImmutableMultimap + java:/Objects/com.google.common.collect.BaseImmutableMultimap + java:/Objects/com.google.common.collect.AbstractMultimap + java:/Objects/com.google.common.collect.Multimap + java:/Objects/com.google.common.collect.Multiset + java:/Objects/com.google.common.collect.Multimaps + java:/Objects/com.google.common.collect.Maps + java:/Objects/com.google.common.collect.ImmutableMap + java:/Objects/com.google.common.collect.ImmutableSet + java:/Objects/com.google.common.collect.ImmutableSetMultimap + java:/Objects/com.google.common.collect.SetMultimap + java:/Objects/com.google.common.collect.Serialization + java:/Objects/com.google.common.collect.ImmutableMultiset + java:/Objects/com.google.common.collect.ImmutableMultisetGwtSerializationDependencies + java:/Objects/com.google.common.collect.IndexedImmutableSet + java:/Objects/com.google.common.collect.AbstractListMultimap + java:/Objects/com.google.common.collect.AbstractMapBasedMultimap + java:/Objects/com.google.common.collect.AbstractSetMultimap + java:/Objects/com.google.common.collect.AbstractSortedSetMultimap + java:/Objects/com.google.common.collect.SortedSetMultimap + java:/Objects/com.google.common.collect.AbstractMultiset + java:/Objects/com.google.common.collect.Multisets + java:/Objects/com.google.common.collect.Sets + java:/Objects/com.google.common.collect.ForwardingCollection + java:/Objects/com.google.common.collect.ForwardingObject + java:/Objects/com.google.common.collect.CartesianList + java:/Objects/com.google.common.collect.ForwardingNavigableSet + java:/Objects/com.google.common.collect.ForwardingSortedSet + java:/Objects/com.google.common.collect.ForwardingSet + java:/Objects/com.google.common.collect.Ordering + java:/Objects/com.google.common.collect.Collections2 + java:/Objects/com.google.common.collect.AbstractIterator + java:/Objects/java.util.concurrent.CopyOnWriteArraySet + java:/Objects/java.util.concurrent.CopyOnWriteArrayList + java:/Objects/com.google.common.collect.Range + java:/Objects/com.google.common.collect.RangeGwtSerializationDependencies + java:/Objects/com.google.common.collect.Cut + java:/Objects/com.google.common.collect.DiscreteDomain + java:/Objects/com.google.common.collect.BoundType + java:/Objects/java.util.EnumMap + java:/Objects/com.google.common.collect.ListMultimap + java:/Objects/com.google.common.collect.ForwardingMultimap + java:/Objects/com.google.common.collect.FilteredMultimap + java:/Objects/com.google.common.collect.FilteredSetMultimap + java:/Objects/com.google.common.base.Converter + java:/Objects/com.google.common.collect.BiMap + java:/Objects/com.google.common.collect.ForwardingMap + java:/Objects/com.google.common.collect.AbstractNavigableMap + java:/Objects/com.google.common.collect.MapDifference + java:/Objects/com.google.common.collect.SortedMapDifference + java:/Objects/com.google.common.collect.ForwardingSortedMap + java:/Objects/com.google.common.base.Equivalence + java:/Objects/java.util.function.BiPredicate + java:/Objects/java.util.IdentityHashMap + java:/Objects/com.google.common.collect.ForwardingMultiset + java:/Objects/com.google.common.collect.SortedMultiset + java:/Objects/com.google.common.collect.SortedMultisetBridge + java:/Objects/com.google.common.collect.SortedIterable + java:/Objects/com.google.common.base.Joiner + java:/Objects/com.google.common.collect.ImmutableSortedSet + java:/Objects/com.google.common.collect.ImmutableSortedSetFauxverideShim + java:/Objects/com.google.common.collect.RegularImmutableSortedSet + java:/Objects/com.google.common.collect.ImmutableSortedMap + java:/Objects/com.google.common.collect.ImmutableSortedMapFauxverideShim + java:/Objects/java.util.Collections + java:/Objects/java.util.AbstractQueue + java:/Objects/org.eclipse.xtext.xbase.lib.ComparableExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.DoubleExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.FloatExtensions + java:/Objects/java.lang.Float + java:/Objects/org.eclipse.xtext.xbase.lib.FunctionExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.Functions + java:/Objects/org.eclipse.xtext.xbase.lib.IntegerExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.ExclusiveRange + java:/Objects/org.eclipse.xtext.xbase.lib.IntegerRange + java:/Objects/org.eclipse.xtext.xbase.lib.IterableExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.IteratorExtensions + java:/Objects/com.google.common.collect.Iterators + java:/Objects/com.google.common.collect.AbstractIndexedListIterator + java:/Objects/com.google.common.collect.PeekingIterator + java:/Objects/org.eclipse.xtext.xbase.lib.ListExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.LongExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.MapExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.internal.UnmodifiableMergingMapView + java:/Objects/org.eclipse.xtext.xbase.lib.ObjectExtensions + java:/Objects/com.google.common.base.Objects + java:/Objects/com.google.common.base.ExtraObjectsMethodsForWeb + java:/Objects/org.eclipse.xtext.xbase.lib.ProcedureExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.ShortExtensions + java:/Objects/java.lang.Short + java:/Objects/org.eclipse.xtext.xbase.lib.StringExtensions + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bold + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + backgroundColor + foregroundColor + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + labelColor + backgroundColor + foregroundColor + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + backgroundColor + foregroundColor + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + backgroundColor + foregroundColor + + + + + + + + + + + + + + + + + + + + + + + + + + bold + + + + + + + + + + + bold + + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + italic + + + + + + + + + + + + + + diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.ecore b/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.ecore new file mode 100644 index 00000000..aa50b778 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.ecore @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.genmodel b/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.genmodel new file mode 100644 index 00000000..1a6c7a84 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.genmodel @@ -0,0 +1,30 @@ + + + modes3.ecore + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/output/solution.partialinterpretation b/Domains/ca.mcgill.rtgmrt.example.modes3/output/solution.partialinterpretation new file mode 100644 index 00000000..bbf46091 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/output/solution.partialinterpretation @@ -0,0 +1,1068 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/output/solution1.gml b/Domains/ca.mcgill.rtgmrt.example.modes3/output/solution1.gml new file mode 100644 index 00000000..66b57d1a --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/output/solution1.gml @@ -0,0 +1,1191 @@ +graph +[ + node + [ + id 0 + graphics + [ + w 269.5 + h 54 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "o 1" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + Modes3ModelRoot class DefinedPart + Modes3ModelRoot class + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 1 + graphics + [ + w 41.800000000000004 + h 26 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "true" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 2 + graphics + [ + w 50.6 + h 26 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "false" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 3 + graphics + [ + w 115.50000000000001 + h 54 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "null" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + Segment class + Turnout class + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 4 + graphics + [ + w 100.10000000000001 + h 40 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "null" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + Train class + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 5 + graphics + [ + w 115.50000000000001 + h 40 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "null" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + Segment class + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 6 + graphics + [ + w 100.10000000000001 + h 40 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "null" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + Train class + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 7 + graphics + [ + w 115.50000000000001 + h 40 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "null" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + Segment class + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 8 + graphics + [ + w 100.10000000000001 + h 40 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "null" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + Train class + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 9 + graphics + [ + w 115.50000000000001 + h 40 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "null" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + Segment class + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 10 + graphics + [ + w 100.10000000000001 + h 40 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "null" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + Train class + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 11 + graphics + [ + w 115.50000000000001 + h 40 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "null" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + Segment class + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 12 + graphics + [ + w 100.10000000000001 + h 40 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "null" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + Train class + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 13 + graphics + [ + w 15.400000000000002 + h 26 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "?" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 14 + graphics + [ + w 15.400000000000002 + h 26 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "?" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 15 + graphics + [ + w 15.400000000000002 + h 26 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "?" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + + node + [ + id 16 + graphics + [ + w 103.4 + h 26 + type "rectangle" + fill "#FFFFFF" + fill2 "#FFFFFF" + outline "#000000" + ] + LabelGraphics + [ + text "New Objects" + outline "#000000" + fill "#FFFFFF" + fontSize 16 + fontName "Monospace" + autoSizePolicy "node_width" + anchor "t" + borderDistance 0.0 + ] + LabelGraphics + [ + text " + " + fontSize 14 + fontName "Consolas" + alignment "left" + anchor "tl" + borderDistance 6 + ] + ] + edge + [ + source 5 + target 3 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "connectedTo reference Segment" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 3 + target 5 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "connectedTo reference Segment" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 7 + target 3 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "connectedTo reference Segment" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 3 + target 7 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "connectedTo reference Segment" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 7 + target 9 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "connectedTo reference Segment" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 9 + target 7 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "connectedTo reference Segment" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 11 + target 5 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "connectedTo reference Segment" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 5 + target 11 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "connectedTo reference Segment" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 5 + target 6 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "occupiedBy reference Segment" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 3 + target 4 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "occupiedBy reference Segment" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 7 + target 8 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "occupiedBy reference Segment" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 9 + target 10 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "occupiedBy reference Segment" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 11 + target 12 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "occupiedBy reference Segment" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 0 + target 4 + graphics + [ + fill "#000000" + width 3 + targetArrow "standard" + ] + LabelGraphics + [ + text "trains reference Modes3ModelRoot" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 0 + target 6 + graphics + [ + fill "#000000" + width 3 + targetArrow "standard" + ] + LabelGraphics + [ + text "trains reference Modes3ModelRoot" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 0 + target 8 + graphics + [ + fill "#000000" + width 3 + targetArrow "standard" + ] + LabelGraphics + [ + text "trains reference Modes3ModelRoot" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 0 + target 10 + graphics + [ + fill "#000000" + width 3 + targetArrow "standard" + ] + LabelGraphics + [ + text "trains reference Modes3ModelRoot" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 0 + target 12 + graphics + [ + fill "#000000" + width 3 + targetArrow "standard" + ] + LabelGraphics + [ + text "trains reference Modes3ModelRoot" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 0 + target 5 + graphics + [ + fill "#000000" + width 3 + targetArrow "standard" + ] + LabelGraphics + [ + text "segments reference Modes3ModelRoot" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 0 + target 7 + graphics + [ + fill "#000000" + width 3 + targetArrow "standard" + ] + LabelGraphics + [ + text "segments reference Modes3ModelRoot" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 0 + target 9 + graphics + [ + fill "#000000" + width 3 + targetArrow "standard" + ] + LabelGraphics + [ + text "segments reference Modes3ModelRoot" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 0 + target 11 + graphics + [ + fill "#000000" + width 3 + targetArrow "standard" + ] + LabelGraphics + [ + text "segments reference Modes3ModelRoot" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 0 + target 3 + graphics + [ + fill "#000000" + width 3 + targetArrow "standard" + ] + LabelGraphics + [ + text "turnouts reference Modes3ModelRoot" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 3 + target 9 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "straight reference Turnout" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 3 + target 5 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "divergent reference Turnout" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 6 + target 5 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "location reference Train" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 4 + target 3 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "location reference Train" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 8 + target 7 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "location reference Train" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 10 + target 9 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "location reference Train" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] + edge + [ + source 12 + target 11 + graphics + [ + fill "#000000" + targetArrow "standard" + ] + LabelGraphics + [ + text "location reference Train" + fontSize 14 + fontName "Consolas" + configuration "AutoFlippingLabel" + model "six_pos" + position "thead" + ] + ] +] + diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/output/solution1.partialinterpretation b/Domains/ca.mcgill.rtgmrt.example.modes3/output/solution1.partialinterpretation new file mode 100644 index 00000000..8b50e17f --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/output/solution1.partialinterpretation @@ -0,0 +1,1037 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/output/solution1.png b/Domains/ca.mcgill.rtgmrt.example.modes3/output/solution1.png new file mode 100644 index 00000000..b6fa6e4e Binary files /dev/null and b/Domains/ca.mcgill.rtgmrt.example.modes3/output/solution1.png differ diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/plugin.properties b/Domains/ca.mcgill.rtgmrt.example.modes3/plugin.properties new file mode 100644 index 00000000..4eba0dd8 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/plugin.properties @@ -0,0 +1,4 @@ +# + +pluginName = ca.mcgill.rtgmrt.example.modes3 +providerName = www.example.org diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/plugin.xml b/Domains/ca.mcgill.rtgmrt.example.modes3/plugin.xml new file mode 100644 index 00000000..7341e19c --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/plugin.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql new file mode 100644 index 00000000..982e6cec --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql @@ -0,0 +1,112 @@ +package modes3.queries + +import "http://www.ece.mcgill.ca/wcet/modes3" + +@Constraint(message = "turnoutInSegments", severity = "error", key = { T }) +pattern turnoutInSegments(T : Turnout) { + Modes3ModelRoot.segments(_, T); +} + +pattern connectedTo(S1 : Segment, S2 : Segment) { + Segment.connectedTo(S1, S2); +} + +@Constraint(message = "connectedToNotSymmetric", severity = "error", key = { S1, S2 }) +pattern connectedToNotSymmetric(S1 : Segment, S2 : Segment) { + Segment.connectedTo(S1, S2); + neg find connectedTo(S2, S1); +} + +@Constraint(message = "connectedToReflexive", severity = "error", key = { S }) +pattern connectedToReflexive(S : Segment) { + Segment.connectedTo(S, S); +} + +pattern turnoutOutput(T : Turnout, S : Segment) { + Turnout.straight(T, S); +} or { + Turnout.divergent(T, S); +} + +@Constraint(message = "outputReflexive", severity = "error", key = { T }) +pattern outputReflexive(T : Turnout) { + find turnoutOutput(T, T); +} + +@Constraint(message = "turnoutOutputsAreSame", severity = "error", key = { T }) +pattern turnoutOutputsAreSame(T : Turnout) { + Turnout.straight(T, S); + Turnout.divergent(T, S); +} + +pattern turnout(T : Turnout) { + Turnout(T); +} + +pattern output(S1 : Segment, S2 : Segment) { + Segment.connectedTo(S1, S2); +} or { + find turnoutOutput(S1, S2); +} + +//@Constraint(message = "noInputOfSegment", severity = "error", key = { S }) +//pattern noInputOfSegment(S : Segment) { +// neg find turnout(S); +// neg find output(_, S); +//} + +@Constraint(message = "tooManyInputsOfSegment", severity = "error", key = { S }) +pattern tooManyInputsOfSegment(S : Segment) { + neg find turnout(S); + find output(I1, S); + find output(I2, S); + find output(I3, S); + I1 != I2; + I1 != I3; + I2 != I3; +} + +@Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) +pattern turnoutConnectedToBothOutputs(T : Turnout) { + Turnout.straight(T, Straight); + Turnout.divergent(T, Divergent); + Segment.connectedTo(T, Straight); + Segment.connectedTo(T, Divergent); +} + +pattern extraInputOfTurnout(T : Turnout, S : Segment) { + Turnout.straight(T, Straight); + Turnout.divergent(T, Divergent); + find output(S, T); + S != Straight; + S != Divergent; +} + +@Constraint(message = "noExtraInputOfTurnout", severity = "error", key = { T }) +pattern noExtraInputOfTurnout(T : Turnout) { + neg find extraInputOfTurnout(T, _); +} + +@Constraint(message = "tooManyExtraInputsOfTurnout", severity = "error", key = { T }) +pattern tooManyExtraInputsOfTurnout(T : Turnout) { + find extraInputOfTurnout(T, I1); + find extraInputOfTurnout(T, I2); + I1 != I2; +} + +pattern adjacent(S1 : Segment, S2 : Segment) { + find output(S1, S2); +} or { + find turnoutOutput(S2, S1); +} + +pattern reachable(S1 : Segment, S2 : Segment) { + S1 == S2; +} or { + find adjacent+(S1, S2); +} + +@Constraint(message = "unreachable", severity = "error", key = { S1, S2 }) +pattern unreachable(S1 : Segment, S2 : Segment) { + neg find reachable(S1, S2); +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3ModelGenerator.xtend b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3ModelGenerator.xtend new file mode 100644 index 00000000..71d1798f --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3ModelGenerator.xtend @@ -0,0 +1,222 @@ +package modes3.run + +import com.google.common.collect.ImmutableList +import com.google.common.collect.ImmutableSet +import hu.bme.mit.inf.dslreasoner.ecore2logic.EReferenceMapper_RelationsOverTypes_Trace +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration +import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor +import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsFactory +import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsPackage +import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition +import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage +import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult +import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic +import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration +import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor +import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.Viatra2LogicAnnotationsPackage +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorConstraints +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorSolver +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.StateCoderStrategy +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration +import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser +import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace +import java.util.List +import modes3.Modes3Factory +import modes3.Modes3Package +import modes3.queries.Modes3Queries +import org.eclipse.emf.ecore.EClass +import org.eclipse.emf.ecore.EObject +import org.eclipse.emf.ecore.resource.Resource +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl +import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions +import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchEMFBackendFactory +import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory +import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDefinition +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink + +@FinalFieldsConstructor +class Modes3ModelGenerator { + val MonitoringQuery monitoringQuery + val int modelSize + + val ecore2Logic = new Ecore2Logic + val instanceModel2Logic = new InstanceModel2Logic + val viatra2Logic = new Viatra2Logic(ecore2Logic) + val solver = new ViatraReasoner + extension val LogicProblemBuilder = new LogicProblemBuilder + + def generate() { + val metamodel = createMetamodelDescriptor() + val metamodelLogic = ecore2Logic.transformMetamodel(metamodel, new Ecore2LogicConfiguration) + val segment = ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.segment) + val connectedTo = ecore2Logic.relationOfReference(metamodelLogic.trace, + Modes3Package.eINSTANCE.segment_ConnectedTo) + val connectedToIndicator = (metamodelLogic.trace. + referenceMapperTrace as EReferenceMapper_RelationsOverTypes_Trace).indicators.get( + Modes3Package.eINSTANCE.segment_ConnectedTo) + val inverseAssertion = Assertion( + '''oppositeReference «connectedTo.name» «connectedTo.name»''', + Forall[ + val src = addVar('''src''', segment) + val trg = addVar('''trg''', segment) + connectedToIndicator.call(src, trg) <=> connectedToIndicator.call(trg, src) + ] + ) + metamodelLogic.output.assertions += inverseAssertion + val inverseAnnotation = Ecore2logicannotationsFactory.eINSTANCE.createInverseRelationAssertion => [ + target = inverseAssertion + inverseA = connectedTo + inverseB = connectedTo + ] + metamodelLogic.output.annotations += inverseAnnotation + val initialModel = loadInitialModel() + val initialModelLogic = instanceModel2Logic.transform(metamodelLogic, initialModel) + val queries = loadQueries + val logic = viatra2Logic.transformQueries(queries, initialModelLogic, new Viatra2LogicConfiguration) + val config = new ViatraReasonerConfiguration => [ + runtimeLimit = 3600 + typeScopes => [ + minNewElements = modelSize + maxNewElements = modelSize + minNewElementsByType => [ + put(ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.turnout), 1) + ] + maxNewElementsByType => [ + put(ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.train), 5) + ] + ] + solutionScope.numberOfRequiredSolutions = 1 + nameNewElements = false + typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis + stateCoderStrategy = StateCoderStrategy::Neighbourhood + scopePropagatorStrategy = new ScopePropagatorStrategy.Polyhedral( + PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp) +// unitPropagationPatternGenerators += new Modes3UnitPropagationGenerator(ecore2Logic, metamodelLogic.trace) + debugConfiguration.partialInterpretatioVisualiser = null + ] + val workspace = new FileSystemWorkspace("output/", "") + val solution = solver.solve(logic.output, config, workspace) + if (solution instanceof ModelResult) { + println("Saving generated solutions") + val representations = solution.representation + for (representationIndex : 0 ..< representations.size) { + val representation = representations.get(representationIndex) + val representationNumber = representationIndex + 1 + if (representation instanceof PartialInterpretation) { + workspace.writeModel(representation, '''solution«representationNumber».partialinterpretation''') + val partialInterpretation2GML = new PartialInterpretation2Gml + val gml = partialInterpretation2GML.transform(representation) + workspace.writeText('''solution«representationNumber».gml''', gml) + if (representation.newElements.size < 160) { + if (representation instanceof PartialInterpretation) { + representation.problem.types.forEach[println(name)] + val rootType = (representation.problem.types.findFirst [ + name == "Modes3ModelRoot class DefinedPart" + ] as TypeDefinition) + val rootIntepretation = representation.partialtypeinterpratation.filter( + PartialComplexTypeInterpretation).findFirst [ + interpretationOf.name == "Modes3ModelRoot class" + ] + rootIntepretation.elements.removeAll(rootType.elements) + representation.problem.elements.removeAll(rootType.elements) + for (relationInterpretation : representation.partialrelationinterpretation) { + relationInterpretation.relationlinks.removeIf [ link | + if (link instanceof BinaryElementRelationLink) { + rootType.elements.contains(link.param1) || rootType.elements.contains(link.param2) + } else { + false + } + ] + } + rootType.elements.clear + } + val visualiser = new GraphvizVisualiser + val visualisation = visualiser.visualiseConcretization(representation) + visualisation.writeToFile(workspace, '''solution«representationNumber».png''') + } + } else { + workspace.writeText('''solution«representationNumber».txt''', representation.toString) + } + } + } else { + println("Failed to solver problem") + val partial = logic.output + workspace.writeModel(partial, "solution.partialinterpretation") + } + } + + static def createMetamodelDescriptor() { + val eClasses = ImmutableList.copyOf(Modes3Package.eINSTANCE.EClassifiers.filter(EClass)) + new EcoreMetamodelDescriptor( + eClasses, + emptySet, + false, + emptyList, + emptyList, + ImmutableList.copyOf(eClasses.flatMap[EReferences]), + emptyList + ) + } + + static def List loadInitialModel() { + #[Modes3Factory.eINSTANCE.createModes3ModelRoot] + } + + def loadQueries() { + val patternsBuilder = ImmutableList.builder + patternsBuilder.addAll(Modes3Queries.instance.specifications) + val patterns = patternsBuilder.build + val validationPatterns = ImmutableSet.copyOf(patterns.filter [ pattern | + pattern.allAnnotations.exists[name == "Constraint"] + ]) + new ViatraQuerySetDescriptor( + patterns, + validationPatterns, + emptyMap + ) + } + + def static init() { + EMFPatternLanguageStandaloneSetup.doSetup + ViatraQueryEngineOptions.setSystemDefaultBackends(ReteBackendFactory.INSTANCE, ReteBackendFactory.INSTANCE, + LocalSearchEMFBackendFactory.INSTANCE) + LogiclanguagePackage.eINSTANCE.class + LogicproblemPackage.eINSTANCE.class + PartialinterpretationPackage.eINSTANCE.class + Ecore2logicannotationsPackage.eINSTANCE.class + Viatra2LogicAnnotationsPackage.eINSTANCE.class + Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("ecore", new XMIResourceFactoryImpl) + Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("logicproblem", new XMIResourceFactoryImpl) + Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("partialinterpretation", + new XMIResourceFactoryImpl) + } + + def static void main(String[] args) { + if (args.length != 2) { + System.err.println("Usage: ") + } + val monitoringQuery = MonitoringQuery.valueOf(args.get(0)) + val modelSize = Integer.parseInt(args.get(1)) + init() + val generator = new Modes3ModelGenerator(monitoringQuery, modelSize) + generator.generate() + } + + private static enum MonitoringQuery { + closeTrains, + misalignedTurnout + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3UnitPropagationGenerator.xtend b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3UnitPropagationGenerator.xtend new file mode 100644 index 00000000..61bd2814 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3UnitPropagationGenerator.xtend @@ -0,0 +1,205 @@ +package modes3.run + +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.UnitPropagationPatternGenerator +import java.util.Map +import modes3.Modes3Package +import modes3.queries.ExtraInputOfTurnout +import modes3.queries.Output +import modes3.queries.TurnoutOutput +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery +import org.eclipse.xtend2.lib.StringConcatenationClient + +class Modes3UnitPropagationGenerator implements UnitPropagationPatternGenerator { + static val MUST_NOT_CONNECTED_TO = "mustNotConnectedTo" + static val MUST_NOT_CONNECTED_TO_HELPER = "mustNotConnectedTo_helper" + static val MUST_NOT_TURNOUT_OUTPUT = "mustNotTurnoutOutput" + static val MUST_NOT_STRAIGHT = "mustNotStraight" + static val MUST_NOT_DIVERGENT = "mustNotDivergent" + + val Type segmentType + val Type turnoutType + val Relation connectedToRelation + val Relation straightRelation + val Relation divergentRelation + + new(extension Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { + extension val Modes3Package = Modes3Package.eINSTANCE + segmentType = ecore2LogicTrace.TypeofEClass(segment) + turnoutType = ecore2LogicTrace.TypeofEClass(turnout) + connectedToRelation = ecore2LogicTrace.relationOfReference(segment_ConnectedTo) + straightRelation = ecore2LogicTrace.relationOfReference(turnout_Straight) + divergentRelation = ecore2LogicTrace.relationOfReference(turnout_Divergent) + } + + override getMustPatterns() { + emptyMap + } + + override getMustNotPatterns() { + #{ + connectedToRelation -> MUST_NOT_CONNECTED_TO, + straightRelation -> MUST_NOT_STRAIGHT, + divergentRelation -> MUST_NOT_DIVERGENT + } + } + + override getAdditionalPatterns(extension PatternGenerator generator, Map fqnToPQuery) { + val StringConcatenationClient parameters = ''' + problem: LogicProblem, interpretation: PartialInterpretation, + source: DefinedElement, target: DefinedElement + ''' + + val StringConcatenationClient commonParameterConstraints = ''' + find interpretation(problem, interpretation); + find mustExist(problem, interpretation, source); + find mustExist(problem, interpretation, target); + ''' + + ''' + pattern «MUST_NOT_CONNECTED_TO_HELPER»(«parameters») { + // connectedToReflexive unit propagation + «commonParameterConstraints» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "source")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "target")» + source == target; + } or { + // tooManyInputsOfSegment unit propagation + «commonParameterConstraints» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "source")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "target")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "input1")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "input2")» + neg «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» + «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["input1", "source"], Modality.MUST, true, false)» + «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["input2", "source"], Modality.MUST, true, false)» + input1 != input2; + input1 != target; + input2 != target; + } or { + // turnoutConnectedToBothOutputs unit propagation 1 + «commonParameterConstraints» + «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "source")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "target")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "divergent")» + «referRelation(straightRelation, "source", "target", Modality.MUST, fqnToPQuery)» + «referRelation(divergentRelation, "source", "divergent", Modality.MUST, fqnToPQuery)» + «referRelation(connectedToRelation, "source", "divergent", Modality.MUST, fqnToPQuery)» + } or { + // turnoutConnectedToBothOutputs unit propagation 2 + «commonParameterConstraints» + «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "source")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "target")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "straight")» + «referRelation(straightRelation, "source", "straight", Modality.MUST, fqnToPQuery)» + «referRelation(divergentRelation, "source", "target", Modality.MUST, fqnToPQuery)» + «referRelation(connectedToRelation, "source", "straight", Modality.MUST, fqnToPQuery)» + } or { + // tooManyExtraInputsOfTurnout unit propagation + «commonParameterConstraints» + «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "source")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "target")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "extraInput")» + «relationDefinitionIndexer.referPattern(fqnToPQuery.get(TurnoutOutput.instance.fullyQualifiedName), #["source", "target"], Modality.MAY, false, false)» + «relationDefinitionIndexer.referPattern(fqnToPQuery.get(ExtraInputOfTurnout.instance.fullyQualifiedName), #["source", "extraInput"], Modality.MUST, true, false)» + target != extraInput; + } + + pattern «MUST_NOT_CONNECTED_TO»(«parameters») { + find «MUST_NOT_CONNECTED_TO_HELPER»(problem, interpretation, source, target); + } or { + find «MUST_NOT_CONNECTED_TO_HELPER»(problem, interpretation, target, source); + } + + pattern «MUST_NOT_TURNOUT_OUTPUT»(«parameters») { + // outputReflexive unit propagation + «commonParameterConstraints» + «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "source")» + «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "target")» + source == target; + } or { + // tooManyInputsOfSegment unit propagation + «commonParameterConstraints» + «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "source")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "target")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "input1")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "input2")» + neg «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "target")» + «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["input1", "target"], Modality.MUST, true, false)» + «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["input2", "target"], Modality.MUST, true, false)» + input1 != input2; + input1 != source; + input2 != source; + } + + pattern «MUST_NOT_STRAIGHT»(«parameters») { + find «MUST_NOT_TURNOUT_OUTPUT»(problem, interpretation, source, target); + } or { + // turnoutOutputsAreSame unit propagation + «commonParameterConstraints» + «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "source")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "target")» + «referRelation(divergentRelation, "source", "target", Modality.MUST, fqnToPQuery)» + } or { + // turnoutConnectedToBothOutputs unit propagation + «commonParameterConstraints» + «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "source")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "target")» + «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "divergent")» + «referRelation(connectedToRelation, "source", "target", Modality.MUST, fqnToPQuery)» + «referRelation(divergentRelation, "source", "divergent", Modality.MUST, fqnToPQuery)» + «referRelation(connectedToRelation, "source", "divergent", Modality.MUST, fqnToPQuery)» + } or { + // tooManyExtraInputsOfTurnout unit propagation + «commonParameterConstraints» + «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "source")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "target")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "extraInput")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "potentialExtraInput")» + «relationDefinitionIndexer.referPattern(fqnToPQuery.get(ExtraInputOfTurnout.instance.fullyQualifiedName), #["source", "extraInput"], Modality.MUST, true, false)» + «referRelation(connectedToRelation, "source", "potentialExtraInput", Modality.MUST, fqnToPQuery)» + neg «referRelation(divergentRelation, "source", "potentialExtraInput", Modality.MAY, fqnToPQuery)» + extraInput != potentialExtraInput; + extraInput != target; + potentialExtraInput != target; + } + + pattern «MUST_NOT_DIVERGENT»(«parameters») { + find «MUST_NOT_TURNOUT_OUTPUT»(problem, interpretation, source, target); + } or { + // turnoutOutputsAreSame unit propagation + «commonParameterConstraints» + «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "source")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "target")» + «referRelation(straightRelation, "source", "target", Modality.MUST, fqnToPQuery)» + } or { + // turnoutConnectedToBothOutputs unit propagation + «commonParameterConstraints» + «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "source")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "target")» + «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "straight")» + «referRelation(connectedToRelation, "source", "target", Modality.MUST, fqnToPQuery)» + «referRelation(straightRelation, "source", "straight", Modality.MUST, fqnToPQuery)» + «referRelation(connectedToRelation, "source", "straight", Modality.MUST, fqnToPQuery)» + } or { + // tooManyExtraInputsOfTurnout unit propagation + «commonParameterConstraints» + «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "source")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "target")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "extraInput")» + «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "potentialExtraInput")» + «relationDefinitionIndexer.referPattern(fqnToPQuery.get(ExtraInputOfTurnout.instance.fullyQualifiedName), #["source", "extraInput"], Modality.MUST, true, false)» + «referRelation(connectedToRelation, "source", "potentialExtraInput", Modality.MUST, fqnToPQuery)» + neg «referRelation(straightRelation, "source", "potentialExtraInput", Modality.MAY, fqnToPQuery)» + extraInput != potentialExtraInput; + extraInput != target; + potentialExtraInput != target; + } + ''' + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/.gitignore b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/.gitignore new file mode 100644 index 00000000..e3a0ad7e --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/.gitignore @@ -0,0 +1,26 @@ +/.ConnectedToReflexive.java._trace +/.Modes3Queries.java._trace +/.StraightReflexive.java._trace +/.DivergentReflexive.java._trace +/.TurnoutOutputsAreSame.java._trace +/.Adjacent.java._trace +/.Output.java._trace +/.OutputReflexive.java._trace +/.TooManyAdjacentSegmentsOfSegment.java._trace +/.Turnout.java._trace +/.ConnectedTo.java._trace +/.TurnoutNotConnectedToOutput.java._trace +/.DisjointNetwork.java._trace +/.Reachable.java._trace +/.Unreachable.java._trace +/.TurnoutInSegments.java._trace +/.ConnectedToNotSymmetric.java._trace +/.TurnoutConnectedToBothOutputs.java._trace +/.TooManyAdjacentTurnouts.java._trace +/.NoAdjacentSegmentOfSegment.java._trace +/.TurnoutOutput.java._trace +/.NoInputOfSegment.java._trace +/.TooManyInputsOfSegment.java._trace +/.ExtraInputOfTurnout.java._trace +/.NoExtraInputOfTurnout.java._trace +/.TooManyExtraInputsOfTurnout.java._trace diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Adjacent.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Adjacent.java new file mode 100644 index 00000000..e87f9c18 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Adjacent.java @@ -0,0 +1,719 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Segment; +import modes3.queries.Output; +import modes3.queries.TurnoutOutput; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         pattern adjacent(S1 : Segment, S2 : Segment) {
+ *         	find output(S1, S2);
+ *         } or {
+ *         	find turnoutOutput(S2, S1);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class Adjacent extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.adjacent pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Segment fS1; + + private Segment fS2; + + private static List parameterNames = makeImmutableList("S1", "S2"); + + private Match(final Segment pS1, final Segment pS2) { + this.fS1 = pS1; + this.fS2 = pS2; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "S1": return this.fS1; + case "S2": return this.fS2; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fS1; + case 1: return this.fS2; + default: return null; + } + } + + public Segment getS1() { + return this.fS1; + } + + public Segment getS2() { + return this.fS2; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("S1".equals(parameterName) ) { + this.fS1 = (Segment) newValue; + return true; + } + if ("S2".equals(parameterName) ) { + this.fS2 = (Segment) newValue; + return true; + } + return false; + } + + public void setS1(final Segment pS1) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS1 = pS1; + } + + public void setS2(final Segment pS2) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS2 = pS2; + } + + @Override + public String patternName() { + return "modes3.queries.adjacent"; + } + + @Override + public List parameterNames() { + return Adjacent.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fS1, fS2}; + } + + @Override + public Adjacent.Match toImmutable() { + return isMutable() ? newMatch(fS1, fS2) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); + result.append("\"S2\"=" + prettyPrintValue(fS2)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fS1, fS2); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof Adjacent.Match)) { + Adjacent.Match other = (Adjacent.Match) obj; + return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public Adjacent specification() { + return Adjacent.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static Adjacent.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static Adjacent.Match newMutableMatch(final Segment pS1, final Segment pS2) { + return new Mutable(pS1, pS2); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the (partial) match object. + * + */ + public static Adjacent.Match newMatch(final Segment pS1, final Segment pS2) { + return new Immutable(pS1, pS2); + } + + private static final class Mutable extends Adjacent.Match { + Mutable(final Segment pS1, final Segment pS2) { + super(pS1, pS2); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends Adjacent.Match { + Immutable(final Segment pS1, final Segment pS2) { + super(pS1, pS2); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.adjacent pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * pattern adjacent(S1 : Segment, S2 : Segment) {
+   * 	find output(S1, S2);
+   * } or {
+   * 	find turnoutOutput(S2, S1);
+   * }
+   * 
+ * + * @see Match + * @see Adjacent + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static Adjacent.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static Adjacent.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_S1 = 0; + + private static final int POSITION_S2 = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Adjacent.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Segment pS1, final Segment pS2) { + return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Segment pS1, final Segment pS2) { + return rawStreamAllMatches(new Object[]{pS1, pS2}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Segment pS1, final Segment pS2) { + return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Segment pS1, final Segment pS2) { + return rawHasMatch(new Object[]{pS1, pS2}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Segment pS1, final Segment pS2) { + return rawCountMatches(new Object[]{pS1, pS2}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the (partial) match object. + * + */ + public Adjacent.Match newMatch(final Segment pS1, final Segment pS2) { + return Adjacent.Match.newMatch(pS1, pS2); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS1(final Object[] parameters) { + return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1() { + return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1() { + return rawStreamAllValuesOfS1(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1(final Adjacent.Match partialMatch) { + return rawStreamAllValuesOfS1(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1(final Segment pS2) { + return rawStreamAllValuesOfS1(new Object[]{null, pS2}); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1(final Adjacent.Match partialMatch) { + return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1(final Segment pS2) { + return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS2(final Object[] parameters) { + return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2() { + return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2() { + return rawStreamAllValuesOfS2(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2(final Adjacent.Match partialMatch) { + return rawStreamAllValuesOfS2(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2(final Segment pS1) { + return rawStreamAllValuesOfS2(new Object[]{pS1, null}); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2(final Adjacent.Match partialMatch) { + return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2(final Segment pS1) { + return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); + } + + @Override + protected Adjacent.Match tupleToMatch(final Tuple t) { + try { + return Adjacent.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected Adjacent.Match arrayToMatch(final Object[] match) { + try { + return Adjacent.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected Adjacent.Match arrayToMatchMutable(final Object[] match) { + try { + return Adjacent.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return Adjacent.instance(); + } + } + + private Adjacent() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static Adjacent instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected Adjacent.Matcher instantiate(final ViatraQueryEngine engine) { + return Adjacent.Matcher.on(engine); + } + + @Override + public Adjacent.Matcher instantiate() { + return Adjacent.Matcher.create(); + } + + @Override + public Adjacent.Match newEmptyMatch() { + return Adjacent.Match.newEmptyMatch(); + } + + @Override + public Adjacent.Match newMatch(final Object... parameters) { + return Adjacent.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link Adjacent} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link Adjacent#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final Adjacent INSTANCE = new Adjacent(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final Adjacent.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_S1, parameter_S2); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.adjacent"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("S1","S2"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_S1 = body.getOrCreateVariableByName("S1"); + PVariable var_S2 = body.getOrCreateVariableByName("S2"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_S1, parameter_S1), + new ExportedParameter(body, var_S2, parameter_S2) + )); + // find output(S1, S2) + new PositivePatternCall(body, Tuples.flatTupleOf(var_S1, var_S2), Output.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + { + PBody body = new PBody(this); + PVariable var_S1 = body.getOrCreateVariableByName("S1"); + PVariable var_S2 = body.getOrCreateVariableByName("S2"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_S1, parameter_S1), + new ExportedParameter(body, var_S2, parameter_S2) + )); + // find turnoutOutput(S2, S1) + new PositivePatternCall(body, Tuples.flatTupleOf(var_S2, var_S1), TurnoutOutput.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedTo.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedTo.java new file mode 100644 index 00000000..a0f14958 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedTo.java @@ -0,0 +1,704 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Segment; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         pattern connectedTo(S1 : Segment, S2 : Segment) {
+ *         	Segment.connectedTo(S1, S2);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class ConnectedTo extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.connectedTo pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Segment fS1; + + private Segment fS2; + + private static List parameterNames = makeImmutableList("S1", "S2"); + + private Match(final Segment pS1, final Segment pS2) { + this.fS1 = pS1; + this.fS2 = pS2; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "S1": return this.fS1; + case "S2": return this.fS2; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fS1; + case 1: return this.fS2; + default: return null; + } + } + + public Segment getS1() { + return this.fS1; + } + + public Segment getS2() { + return this.fS2; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("S1".equals(parameterName) ) { + this.fS1 = (Segment) newValue; + return true; + } + if ("S2".equals(parameterName) ) { + this.fS2 = (Segment) newValue; + return true; + } + return false; + } + + public void setS1(final Segment pS1) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS1 = pS1; + } + + public void setS2(final Segment pS2) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS2 = pS2; + } + + @Override + public String patternName() { + return "modes3.queries.connectedTo"; + } + + @Override + public List parameterNames() { + return ConnectedTo.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fS1, fS2}; + } + + @Override + public ConnectedTo.Match toImmutable() { + return isMutable() ? newMatch(fS1, fS2) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); + result.append("\"S2\"=" + prettyPrintValue(fS2)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fS1, fS2); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof ConnectedTo.Match)) { + ConnectedTo.Match other = (ConnectedTo.Match) obj; + return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public ConnectedTo specification() { + return ConnectedTo.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static ConnectedTo.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static ConnectedTo.Match newMutableMatch(final Segment pS1, final Segment pS2) { + return new Mutable(pS1, pS2); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the (partial) match object. + * + */ + public static ConnectedTo.Match newMatch(final Segment pS1, final Segment pS2) { + return new Immutable(pS1, pS2); + } + + private static final class Mutable extends ConnectedTo.Match { + Mutable(final Segment pS1, final Segment pS2) { + super(pS1, pS2); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends ConnectedTo.Match { + Immutable(final Segment pS1, final Segment pS2) { + super(pS1, pS2); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.connectedTo pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * pattern connectedTo(S1 : Segment, S2 : Segment) {
+   * 	Segment.connectedTo(S1, S2);
+   * }
+   * 
+ * + * @see Match + * @see ConnectedTo + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static ConnectedTo.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static ConnectedTo.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_S1 = 0; + + private static final int POSITION_S2 = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ConnectedTo.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Segment pS1, final Segment pS2) { + return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Segment pS1, final Segment pS2) { + return rawStreamAllMatches(new Object[]{pS1, pS2}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Segment pS1, final Segment pS2) { + return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Segment pS1, final Segment pS2) { + return rawHasMatch(new Object[]{pS1, pS2}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Segment pS1, final Segment pS2) { + return rawCountMatches(new Object[]{pS1, pS2}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the (partial) match object. + * + */ + public ConnectedTo.Match newMatch(final Segment pS1, final Segment pS2) { + return ConnectedTo.Match.newMatch(pS1, pS2); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS1(final Object[] parameters) { + return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1() { + return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1() { + return rawStreamAllValuesOfS1(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1(final ConnectedTo.Match partialMatch) { + return rawStreamAllValuesOfS1(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1(final Segment pS2) { + return rawStreamAllValuesOfS1(new Object[]{null, pS2}); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1(final ConnectedTo.Match partialMatch) { + return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1(final Segment pS2) { + return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS2(final Object[] parameters) { + return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2() { + return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2() { + return rawStreamAllValuesOfS2(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2(final ConnectedTo.Match partialMatch) { + return rawStreamAllValuesOfS2(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2(final Segment pS1) { + return rawStreamAllValuesOfS2(new Object[]{pS1, null}); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2(final ConnectedTo.Match partialMatch) { + return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2(final Segment pS1) { + return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); + } + + @Override + protected ConnectedTo.Match tupleToMatch(final Tuple t) { + try { + return ConnectedTo.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected ConnectedTo.Match arrayToMatch(final Object[] match) { + try { + return ConnectedTo.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected ConnectedTo.Match arrayToMatchMutable(final Object[] match) { + try { + return ConnectedTo.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return ConnectedTo.instance(); + } + } + + private ConnectedTo() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static ConnectedTo instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected ConnectedTo.Matcher instantiate(final ViatraQueryEngine engine) { + return ConnectedTo.Matcher.on(engine); + } + + @Override + public ConnectedTo.Matcher instantiate() { + return ConnectedTo.Matcher.create(); + } + + @Override + public ConnectedTo.Match newEmptyMatch() { + return ConnectedTo.Match.newEmptyMatch(); + } + + @Override + public ConnectedTo.Match newMatch(final Object... parameters) { + return ConnectedTo.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link ConnectedTo} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link ConnectedTo#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final ConnectedTo INSTANCE = new ConnectedTo(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final ConnectedTo.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_S1, parameter_S2); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.connectedTo"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("S1","S2"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_S1 = body.getOrCreateVariableByName("S1"); + PVariable var_S2 = body.getOrCreateVariableByName("S2"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_S1, parameter_S1), + new ExportedParameter(body, var_S2, parameter_S2) + )); + // Segment.connectedTo(S1, S2) + new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S1, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_0_, var_S2); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedToNotSymmetric.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedToNotSymmetric.java new file mode 100644 index 00000000..91b74c7e --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedToNotSymmetric.java @@ -0,0 +1,724 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Segment; +import modes3.queries.ConnectedTo; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}Constraint(message = "connectedToNotSymmetric", severity = "error", key = { S1, S2 })
+ *         pattern connectedToNotSymmetric(S1 : Segment, S2 : Segment) {
+ *         	Segment.connectedTo(S1, S2);
+ *         	neg find connectedTo(S2, S1);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class ConnectedToNotSymmetric extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.connectedToNotSymmetric pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Segment fS1; + + private Segment fS2; + + private static List parameterNames = makeImmutableList("S1", "S2"); + + private Match(final Segment pS1, final Segment pS2) { + this.fS1 = pS1; + this.fS2 = pS2; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "S1": return this.fS1; + case "S2": return this.fS2; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fS1; + case 1: return this.fS2; + default: return null; + } + } + + public Segment getS1() { + return this.fS1; + } + + public Segment getS2() { + return this.fS2; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("S1".equals(parameterName) ) { + this.fS1 = (Segment) newValue; + return true; + } + if ("S2".equals(parameterName) ) { + this.fS2 = (Segment) newValue; + return true; + } + return false; + } + + public void setS1(final Segment pS1) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS1 = pS1; + } + + public void setS2(final Segment pS2) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS2 = pS2; + } + + @Override + public String patternName() { + return "modes3.queries.connectedToNotSymmetric"; + } + + @Override + public List parameterNames() { + return ConnectedToNotSymmetric.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fS1, fS2}; + } + + @Override + public ConnectedToNotSymmetric.Match toImmutable() { + return isMutable() ? newMatch(fS1, fS2) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); + result.append("\"S2\"=" + prettyPrintValue(fS2)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fS1, fS2); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof ConnectedToNotSymmetric.Match)) { + ConnectedToNotSymmetric.Match other = (ConnectedToNotSymmetric.Match) obj; + return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public ConnectedToNotSymmetric specification() { + return ConnectedToNotSymmetric.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static ConnectedToNotSymmetric.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static ConnectedToNotSymmetric.Match newMutableMatch(final Segment pS1, final Segment pS2) { + return new Mutable(pS1, pS2); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the (partial) match object. + * + */ + public static ConnectedToNotSymmetric.Match newMatch(final Segment pS1, final Segment pS2) { + return new Immutable(pS1, pS2); + } + + private static final class Mutable extends ConnectedToNotSymmetric.Match { + Mutable(final Segment pS1, final Segment pS2) { + super(pS1, pS2); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends ConnectedToNotSymmetric.Match { + Immutable(final Segment pS1, final Segment pS2) { + super(pS1, pS2); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.connectedToNotSymmetric pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}Constraint(message = "connectedToNotSymmetric", severity = "error", key = { S1, S2 })
+   * pattern connectedToNotSymmetric(S1 : Segment, S2 : Segment) {
+   * 	Segment.connectedTo(S1, S2);
+   * 	neg find connectedTo(S2, S1);
+   * }
+   * 
+ * + * @see Match + * @see ConnectedToNotSymmetric + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static ConnectedToNotSymmetric.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static ConnectedToNotSymmetric.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_S1 = 0; + + private static final int POSITION_S2 = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ConnectedToNotSymmetric.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Segment pS1, final Segment pS2) { + return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Segment pS1, final Segment pS2) { + return rawStreamAllMatches(new Object[]{pS1, pS2}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Segment pS1, final Segment pS2) { + return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Segment pS1, final Segment pS2) { + return rawHasMatch(new Object[]{pS1, pS2}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Segment pS1, final Segment pS2) { + return rawCountMatches(new Object[]{pS1, pS2}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the (partial) match object. + * + */ + public ConnectedToNotSymmetric.Match newMatch(final Segment pS1, final Segment pS2) { + return ConnectedToNotSymmetric.Match.newMatch(pS1, pS2); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS1(final Object[] parameters) { + return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1() { + return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1() { + return rawStreamAllValuesOfS1(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1(final ConnectedToNotSymmetric.Match partialMatch) { + return rawStreamAllValuesOfS1(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1(final Segment pS2) { + return rawStreamAllValuesOfS1(new Object[]{null, pS2}); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1(final ConnectedToNotSymmetric.Match partialMatch) { + return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1(final Segment pS2) { + return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS2(final Object[] parameters) { + return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2() { + return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2() { + return rawStreamAllValuesOfS2(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2(final ConnectedToNotSymmetric.Match partialMatch) { + return rawStreamAllValuesOfS2(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2(final Segment pS1) { + return rawStreamAllValuesOfS2(new Object[]{pS1, null}); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2(final ConnectedToNotSymmetric.Match partialMatch) { + return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2(final Segment pS1) { + return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); + } + + @Override + protected ConnectedToNotSymmetric.Match tupleToMatch(final Tuple t) { + try { + return ConnectedToNotSymmetric.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected ConnectedToNotSymmetric.Match arrayToMatch(final Object[] match) { + try { + return ConnectedToNotSymmetric.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected ConnectedToNotSymmetric.Match arrayToMatchMutable(final Object[] match) { + try { + return ConnectedToNotSymmetric.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return ConnectedToNotSymmetric.instance(); + } + } + + private ConnectedToNotSymmetric() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static ConnectedToNotSymmetric instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected ConnectedToNotSymmetric.Matcher instantiate(final ViatraQueryEngine engine) { + return ConnectedToNotSymmetric.Matcher.on(engine); + } + + @Override + public ConnectedToNotSymmetric.Matcher instantiate() { + return ConnectedToNotSymmetric.Matcher.create(); + } + + @Override + public ConnectedToNotSymmetric.Match newEmptyMatch() { + return ConnectedToNotSymmetric.Match.newEmptyMatch(); + } + + @Override + public ConnectedToNotSymmetric.Match newMatch(final Object... parameters) { + return ConnectedToNotSymmetric.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link ConnectedToNotSymmetric} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link ConnectedToNotSymmetric#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final ConnectedToNotSymmetric INSTANCE = new ConnectedToNotSymmetric(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final ConnectedToNotSymmetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_S1, parameter_S2); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.connectedToNotSymmetric"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("S1","S2"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_S1 = body.getOrCreateVariableByName("S1"); + PVariable var_S2 = body.getOrCreateVariableByName("S2"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_S1, parameter_S1), + new ExportedParameter(body, var_S2, parameter_S2) + )); + // Segment.connectedTo(S1, S2) + new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S1, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_0_, var_S2); + // neg find connectedTo(S2, S1) + new NegativePatternCall(body, Tuples.flatTupleOf(var_S2, var_S1), ConnectedTo.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("message", "connectedToNotSymmetric"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("S1"), + new ParameterReference("S2") + })); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedToReflexive.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedToReflexive.java new file mode 100644 index 00000000..948fec73 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedToReflexive.java @@ -0,0 +1,563 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Segment; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}Constraint(message = "connectedToReflexive", severity = "error", key = { S })
+ *         pattern connectedToReflexive(S : Segment) {
+ *         	Segment.connectedTo(S, S);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class ConnectedToReflexive extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.connectedToReflexive pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Segment fS; + + private static List parameterNames = makeImmutableList("S"); + + private Match(final Segment pS) { + this.fS = pS; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "S": return this.fS; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fS; + default: return null; + } + } + + public Segment getS() { + return this.fS; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("S".equals(parameterName) ) { + this.fS = (Segment) newValue; + return true; + } + return false; + } + + public void setS(final Segment pS) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS = pS; + } + + @Override + public String patternName() { + return "modes3.queries.connectedToReflexive"; + } + + @Override + public List parameterNames() { + return ConnectedToReflexive.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fS}; + } + + @Override + public ConnectedToReflexive.Match toImmutable() { + return isMutable() ? newMatch(fS) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"S\"=" + prettyPrintValue(fS)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fS); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof ConnectedToReflexive.Match)) { + ConnectedToReflexive.Match other = (ConnectedToReflexive.Match) obj; + return Objects.equals(fS, other.fS); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public ConnectedToReflexive specification() { + return ConnectedToReflexive.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static ConnectedToReflexive.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static ConnectedToReflexive.Match newMutableMatch(final Segment pS) { + return new Mutable(pS); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the (partial) match object. + * + */ + public static ConnectedToReflexive.Match newMatch(final Segment pS) { + return new Immutable(pS); + } + + private static final class Mutable extends ConnectedToReflexive.Match { + Mutable(final Segment pS) { + super(pS); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends ConnectedToReflexive.Match { + Immutable(final Segment pS) { + super(pS); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.connectedToReflexive pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}Constraint(message = "connectedToReflexive", severity = "error", key = { S })
+   * pattern connectedToReflexive(S : Segment) {
+   * 	Segment.connectedTo(S, S);
+   * }
+   * 
+ * + * @see Match + * @see ConnectedToReflexive + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static ConnectedToReflexive.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static ConnectedToReflexive.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_S = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ConnectedToReflexive.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Segment pS) { + return rawStreamAllMatches(new Object[]{pS}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Segment pS) { + return rawStreamAllMatches(new Object[]{pS}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Segment pS) { + return rawGetOneArbitraryMatch(new Object[]{pS}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Segment pS) { + return rawHasMatch(new Object[]{pS}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Segment pS) { + return rawCountMatches(new Object[]{pS}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Segment pS, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pS}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the (partial) match object. + * + */ + public ConnectedToReflexive.Match newMatch(final Segment pS) { + return ConnectedToReflexive.Match.newMatch(pS); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS(final Object[] parameters) { + return rawStreamAllValues(POSITION_S, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS() { + return rawStreamAllValuesOfS(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS() { + return rawStreamAllValuesOfS(emptyArray()); + } + + @Override + protected ConnectedToReflexive.Match tupleToMatch(final Tuple t) { + try { + return ConnectedToReflexive.Match.newMatch((Segment) t.get(POSITION_S)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected ConnectedToReflexive.Match arrayToMatch(final Object[] match) { + try { + return ConnectedToReflexive.Match.newMatch((Segment) match[POSITION_S]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected ConnectedToReflexive.Match arrayToMatchMutable(final Object[] match) { + try { + return ConnectedToReflexive.Match.newMutableMatch((Segment) match[POSITION_S]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return ConnectedToReflexive.instance(); + } + } + + private ConnectedToReflexive() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static ConnectedToReflexive instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected ConnectedToReflexive.Matcher instantiate(final ViatraQueryEngine engine) { + return ConnectedToReflexive.Matcher.on(engine); + } + + @Override + public ConnectedToReflexive.Matcher instantiate() { + return ConnectedToReflexive.Matcher.create(); + } + + @Override + public ConnectedToReflexive.Match newEmptyMatch() { + return ConnectedToReflexive.Match.newEmptyMatch(); + } + + @Override + public ConnectedToReflexive.Match newMatch(final Object... parameters) { + return ConnectedToReflexive.Match.newMatch((modes3.Segment) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link ConnectedToReflexive} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link ConnectedToReflexive#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final ConnectedToReflexive INSTANCE = new ConnectedToReflexive(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final ConnectedToReflexive.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_S = new PParameter("S", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_S); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.connectedToReflexive"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("S"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_S = body.getOrCreateVariableByName("S"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_S, parameter_S) + )); + // Segment.connectedTo(S, S) + new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_0_, var_S); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("message", "connectedToReflexive"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("S") + })); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ExtraInputOfTurnout.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ExtraInputOfTurnout.java new file mode 100644 index 00000000..62e2a54d --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ExtraInputOfTurnout.java @@ -0,0 +1,730 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Segment; +import modes3.Turnout; +import modes3.queries.Output; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         pattern extraInputOfTurnout(T : Turnout, S : Segment) {
+ *         	Turnout.straight(T, Straight);
+ *         	Turnout.divergent(T, Divergent);
+ *         	find output(S, T);
+ *         	S != Straight;
+ *         	S != Divergent;
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class ExtraInputOfTurnout extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.extraInputOfTurnout pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Turnout fT; + + private Segment fS; + + private static List parameterNames = makeImmutableList("T", "S"); + + private Match(final Turnout pT, final Segment pS) { + this.fT = pT; + this.fS = pS; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "T": return this.fT; + case "S": return this.fS; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fT; + case 1: return this.fS; + default: return null; + } + } + + public Turnout getT() { + return this.fT; + } + + public Segment getS() { + return this.fS; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("T".equals(parameterName) ) { + this.fT = (Turnout) newValue; + return true; + } + if ("S".equals(parameterName) ) { + this.fS = (Segment) newValue; + return true; + } + return false; + } + + public void setT(final Turnout pT) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fT = pT; + } + + public void setS(final Segment pS) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS = pS; + } + + @Override + public String patternName() { + return "modes3.queries.extraInputOfTurnout"; + } + + @Override + public List parameterNames() { + return ExtraInputOfTurnout.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fT, fS}; + } + + @Override + public ExtraInputOfTurnout.Match toImmutable() { + return isMutable() ? newMatch(fT, fS) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"T\"=" + prettyPrintValue(fT) + ", "); + result.append("\"S\"=" + prettyPrintValue(fS)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fT, fS); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof ExtraInputOfTurnout.Match)) { + ExtraInputOfTurnout.Match other = (ExtraInputOfTurnout.Match) obj; + return Objects.equals(fT, other.fT) && Objects.equals(fS, other.fS); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public ExtraInputOfTurnout specification() { + return ExtraInputOfTurnout.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static ExtraInputOfTurnout.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static ExtraInputOfTurnout.Match newMutableMatch(final Turnout pT, final Segment pS) { + return new Mutable(pT, pS); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the (partial) match object. + * + */ + public static ExtraInputOfTurnout.Match newMatch(final Turnout pT, final Segment pS) { + return new Immutable(pT, pS); + } + + private static final class Mutable extends ExtraInputOfTurnout.Match { + Mutable(final Turnout pT, final Segment pS) { + super(pT, pS); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends ExtraInputOfTurnout.Match { + Immutable(final Turnout pT, final Segment pS) { + super(pT, pS); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.extraInputOfTurnout pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * pattern extraInputOfTurnout(T : Turnout, S : Segment) {
+   * 	Turnout.straight(T, Straight);
+   * 	Turnout.divergent(T, Divergent);
+   * 	find output(S, T);
+   * 	S != Straight;
+   * 	S != Divergent;
+   * }
+   * 
+ * + * @see Match + * @see ExtraInputOfTurnout + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static ExtraInputOfTurnout.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static ExtraInputOfTurnout.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_T = 0; + + private static final int POSITION_S = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ExtraInputOfTurnout.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Turnout pT, final Segment pS) { + return rawStreamAllMatches(new Object[]{pT, pS}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Turnout pT, final Segment pS) { + return rawStreamAllMatches(new Object[]{pT, pS}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Turnout pT, final Segment pS) { + return rawGetOneArbitraryMatch(new Object[]{pT, pS}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Turnout pT, final Segment pS) { + return rawHasMatch(new Object[]{pT, pS}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Turnout pT, final Segment pS) { + return rawCountMatches(new Object[]{pT, pS}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Turnout pT, final Segment pS, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pT, pS}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the (partial) match object. + * + */ + public ExtraInputOfTurnout.Match newMatch(final Turnout pT, final Segment pS) { + return ExtraInputOfTurnout.Match.newMatch(pT, pS); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfT(final Object[] parameters) { + return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for T. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfT(final ExtraInputOfTurnout.Match partialMatch) { + return rawStreamAllValuesOfT(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for T. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfT(final Segment pS) { + return rawStreamAllValuesOfT(new Object[]{null, pS}); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfT(final ExtraInputOfTurnout.Match partialMatch) { + return rawStreamAllValuesOfT(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfT(final Segment pS) { + return rawStreamAllValuesOfT(new Object[]{null, pS}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS(final Object[] parameters) { + return rawStreamAllValues(POSITION_S, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS() { + return rawStreamAllValuesOfS(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS() { + return rawStreamAllValuesOfS(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for S. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS(final ExtraInputOfTurnout.Match partialMatch) { + return rawStreamAllValuesOfS(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for S. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS(final Turnout pT) { + return rawStreamAllValuesOfS(new Object[]{pT, null}); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS(final ExtraInputOfTurnout.Match partialMatch) { + return rawStreamAllValuesOfS(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS(final Turnout pT) { + return rawStreamAllValuesOfS(new Object[]{pT, null}).collect(Collectors.toSet()); + } + + @Override + protected ExtraInputOfTurnout.Match tupleToMatch(final Tuple t) { + try { + return ExtraInputOfTurnout.Match.newMatch((Turnout) t.get(POSITION_T), (Segment) t.get(POSITION_S)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected ExtraInputOfTurnout.Match arrayToMatch(final Object[] match) { + try { + return ExtraInputOfTurnout.Match.newMatch((Turnout) match[POSITION_T], (Segment) match[POSITION_S]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected ExtraInputOfTurnout.Match arrayToMatchMutable(final Object[] match) { + try { + return ExtraInputOfTurnout.Match.newMutableMatch((Turnout) match[POSITION_T], (Segment) match[POSITION_S]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return ExtraInputOfTurnout.instance(); + } + } + + private ExtraInputOfTurnout() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static ExtraInputOfTurnout instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected ExtraInputOfTurnout.Matcher instantiate(final ViatraQueryEngine engine) { + return ExtraInputOfTurnout.Matcher.on(engine); + } + + @Override + public ExtraInputOfTurnout.Matcher instantiate() { + return ExtraInputOfTurnout.Matcher.create(); + } + + @Override + public ExtraInputOfTurnout.Match newEmptyMatch() { + return ExtraInputOfTurnout.Match.newEmptyMatch(); + } + + @Override + public ExtraInputOfTurnout.Match newMatch(final Object... parameters) { + return ExtraInputOfTurnout.Match.newMatch((modes3.Turnout) parameters[0], (modes3.Segment) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link ExtraInputOfTurnout} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link ExtraInputOfTurnout#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final ExtraInputOfTurnout INSTANCE = new ExtraInputOfTurnout(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final ExtraInputOfTurnout.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); + + private final PParameter parameter_S = new PParameter("S", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_T, parameter_S); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.extraInputOfTurnout"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("T","S"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_T = body.getOrCreateVariableByName("T"); + PVariable var_S = body.getOrCreateVariableByName("S"); + PVariable var_Straight = body.getOrCreateVariableByName("Straight"); + PVariable var_Divergent = body.getOrCreateVariableByName("Divergent"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_T, parameter_T), + new ExportedParameter(body, var_S, parameter_S) + )); + // Turnout.straight(T, Straight) + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "straight"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_0_, var_Straight); + // Turnout.divergent(T, Divergent) + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "divergent"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_1_, var_Divergent); + // find output(S, T) + new PositivePatternCall(body, Tuples.flatTupleOf(var_S, var_T), Output.instance().getInternalQueryRepresentation()); + // S != Straight + new Inequality(body, var_S, var_Straight); + // S != Divergent + new Inequality(body, var_S, var_Divergent); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Modes3Queries.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Modes3Queries.java new file mode 100644 index 00000000..01ec77a1 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Modes3Queries.java @@ -0,0 +1,229 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import modes3.queries.Adjacent; +import modes3.queries.ConnectedTo; +import modes3.queries.ConnectedToNotSymmetric; +import modes3.queries.ConnectedToReflexive; +import modes3.queries.ExtraInputOfTurnout; +import modes3.queries.NoExtraInputOfTurnout; +import modes3.queries.Output; +import modes3.queries.OutputReflexive; +import modes3.queries.Reachable; +import modes3.queries.TooManyExtraInputsOfTurnout; +import modes3.queries.TooManyInputsOfSegment; +import modes3.queries.Turnout; +import modes3.queries.TurnoutConnectedToBothOutputs; +import modes3.queries.TurnoutInSegments; +import modes3.queries.TurnoutOutput; +import modes3.queries.TurnoutOutputsAreSame; +import modes3.queries.Unreachable; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; + +/** + * A pattern group formed of all public patterns defined in Modes3Queries.vql. + * + *

Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare + * a VIATRA Query engine for matching all patterns originally defined in file Modes3Queries.vql, + * in order to achieve better performance than one-by-one on-demand matcher initialization. + * + *

From package modes3.queries, the group contains the definition of the following patterns:

    + *
  • turnoutInSegments
  • + *
  • connectedTo
  • + *
  • connectedToNotSymmetric
  • + *
  • connectedToReflexive
  • + *
  • turnoutOutput
  • + *
  • outputReflexive
  • + *
  • turnoutOutputsAreSame
  • + *
  • turnout
  • + *
  • output
  • + *
  • tooManyInputsOfSegment
  • + *
  • turnoutConnectedToBothOutputs
  • + *
  • extraInputOfTurnout
  • + *
  • noExtraInputOfTurnout
  • + *
  • tooManyExtraInputsOfTurnout
  • + *
  • adjacent
  • + *
  • reachable
  • + *
  • unreachable
  • + *
+ * + * @see IQueryGroup + * + */ +@SuppressWarnings("all") +public final class Modes3Queries extends BaseGeneratedPatternGroup { + /** + * Access the pattern group. + * + * @return the singleton instance of the group + * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications + * + */ + public static Modes3Queries instance() { + if (INSTANCE == null) { + INSTANCE = new Modes3Queries(); + } + return INSTANCE; + } + + private static Modes3Queries INSTANCE; + + private Modes3Queries() { + querySpecifications.add(TurnoutInSegments.instance()); + querySpecifications.add(ConnectedTo.instance()); + querySpecifications.add(ConnectedToNotSymmetric.instance()); + querySpecifications.add(ConnectedToReflexive.instance()); + querySpecifications.add(TurnoutOutput.instance()); + querySpecifications.add(OutputReflexive.instance()); + querySpecifications.add(TurnoutOutputsAreSame.instance()); + querySpecifications.add(Turnout.instance()); + querySpecifications.add(Output.instance()); + querySpecifications.add(TooManyInputsOfSegment.instance()); + querySpecifications.add(TurnoutConnectedToBothOutputs.instance()); + querySpecifications.add(ExtraInputOfTurnout.instance()); + querySpecifications.add(NoExtraInputOfTurnout.instance()); + querySpecifications.add(TooManyExtraInputsOfTurnout.instance()); + querySpecifications.add(Adjacent.instance()); + querySpecifications.add(Reachable.instance()); + querySpecifications.add(Unreachable.instance()); + } + + public TurnoutInSegments getTurnoutInSegments() { + return TurnoutInSegments.instance(); + } + + public TurnoutInSegments.Matcher getTurnoutInSegments(final ViatraQueryEngine engine) { + return TurnoutInSegments.Matcher.on(engine); + } + + public ConnectedTo getConnectedTo() { + return ConnectedTo.instance(); + } + + public ConnectedTo.Matcher getConnectedTo(final ViatraQueryEngine engine) { + return ConnectedTo.Matcher.on(engine); + } + + public ConnectedToNotSymmetric getConnectedToNotSymmetric() { + return ConnectedToNotSymmetric.instance(); + } + + public ConnectedToNotSymmetric.Matcher getConnectedToNotSymmetric(final ViatraQueryEngine engine) { + return ConnectedToNotSymmetric.Matcher.on(engine); + } + + public ConnectedToReflexive getConnectedToReflexive() { + return ConnectedToReflexive.instance(); + } + + public ConnectedToReflexive.Matcher getConnectedToReflexive(final ViatraQueryEngine engine) { + return ConnectedToReflexive.Matcher.on(engine); + } + + public TurnoutOutput getTurnoutOutput() { + return TurnoutOutput.instance(); + } + + public TurnoutOutput.Matcher getTurnoutOutput(final ViatraQueryEngine engine) { + return TurnoutOutput.Matcher.on(engine); + } + + public OutputReflexive getOutputReflexive() { + return OutputReflexive.instance(); + } + + public OutputReflexive.Matcher getOutputReflexive(final ViatraQueryEngine engine) { + return OutputReflexive.Matcher.on(engine); + } + + public TurnoutOutputsAreSame getTurnoutOutputsAreSame() { + return TurnoutOutputsAreSame.instance(); + } + + public TurnoutOutputsAreSame.Matcher getTurnoutOutputsAreSame(final ViatraQueryEngine engine) { + return TurnoutOutputsAreSame.Matcher.on(engine); + } + + public Turnout getTurnout() { + return Turnout.instance(); + } + + public Turnout.Matcher getTurnout(final ViatraQueryEngine engine) { + return Turnout.Matcher.on(engine); + } + + public Output getOutput() { + return Output.instance(); + } + + public Output.Matcher getOutput(final ViatraQueryEngine engine) { + return Output.Matcher.on(engine); + } + + public TooManyInputsOfSegment getTooManyInputsOfSegment() { + return TooManyInputsOfSegment.instance(); + } + + public TooManyInputsOfSegment.Matcher getTooManyInputsOfSegment(final ViatraQueryEngine engine) { + return TooManyInputsOfSegment.Matcher.on(engine); + } + + public TurnoutConnectedToBothOutputs getTurnoutConnectedToBothOutputs() { + return TurnoutConnectedToBothOutputs.instance(); + } + + public TurnoutConnectedToBothOutputs.Matcher getTurnoutConnectedToBothOutputs(final ViatraQueryEngine engine) { + return TurnoutConnectedToBothOutputs.Matcher.on(engine); + } + + public ExtraInputOfTurnout getExtraInputOfTurnout() { + return ExtraInputOfTurnout.instance(); + } + + public ExtraInputOfTurnout.Matcher getExtraInputOfTurnout(final ViatraQueryEngine engine) { + return ExtraInputOfTurnout.Matcher.on(engine); + } + + public NoExtraInputOfTurnout getNoExtraInputOfTurnout() { + return NoExtraInputOfTurnout.instance(); + } + + public NoExtraInputOfTurnout.Matcher getNoExtraInputOfTurnout(final ViatraQueryEngine engine) { + return NoExtraInputOfTurnout.Matcher.on(engine); + } + + public TooManyExtraInputsOfTurnout getTooManyExtraInputsOfTurnout() { + return TooManyExtraInputsOfTurnout.instance(); + } + + public TooManyExtraInputsOfTurnout.Matcher getTooManyExtraInputsOfTurnout(final ViatraQueryEngine engine) { + return TooManyExtraInputsOfTurnout.Matcher.on(engine); + } + + public Adjacent getAdjacent() { + return Adjacent.instance(); + } + + public Adjacent.Matcher getAdjacent(final ViatraQueryEngine engine) { + return Adjacent.Matcher.on(engine); + } + + public Reachable getReachable() { + return Reachable.instance(); + } + + public Reachable.Matcher getReachable(final ViatraQueryEngine engine) { + return Reachable.Matcher.on(engine); + } + + public Unreachable getUnreachable() { + return Unreachable.instance(); + } + + public Unreachable.Matcher getUnreachable(final ViatraQueryEngine engine) { + return Unreachable.Matcher.on(engine); + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/NoExtraInputOfTurnout.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/NoExtraInputOfTurnout.java new file mode 100644 index 00000000..621d736f --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/NoExtraInputOfTurnout.java @@ -0,0 +1,560 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Turnout; +import modes3.queries.ExtraInputOfTurnout; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}Constraint(message = "noExtraInputOfTurnout", severity = "error", key = { T })
+ *         pattern noExtraInputOfTurnout(T : Turnout) {
+ *         	neg find extraInputOfTurnout(T, _);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class NoExtraInputOfTurnout extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.noExtraInputOfTurnout pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Turnout fT; + + private static List parameterNames = makeImmutableList("T"); + + private Match(final Turnout pT) { + this.fT = pT; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "T": return this.fT; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fT; + default: return null; + } + } + + public Turnout getT() { + return this.fT; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("T".equals(parameterName) ) { + this.fT = (Turnout) newValue; + return true; + } + return false; + } + + public void setT(final Turnout pT) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fT = pT; + } + + @Override + public String patternName() { + return "modes3.queries.noExtraInputOfTurnout"; + } + + @Override + public List parameterNames() { + return NoExtraInputOfTurnout.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fT}; + } + + @Override + public NoExtraInputOfTurnout.Match toImmutable() { + return isMutable() ? newMatch(fT) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"T\"=" + prettyPrintValue(fT)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fT); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof NoExtraInputOfTurnout.Match)) { + NoExtraInputOfTurnout.Match other = (NoExtraInputOfTurnout.Match) obj; + return Objects.equals(fT, other.fT); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public NoExtraInputOfTurnout specification() { + return NoExtraInputOfTurnout.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static NoExtraInputOfTurnout.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static NoExtraInputOfTurnout.Match newMutableMatch(final Turnout pT) { + return new Mutable(pT); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the (partial) match object. + * + */ + public static NoExtraInputOfTurnout.Match newMatch(final Turnout pT) { + return new Immutable(pT); + } + + private static final class Mutable extends NoExtraInputOfTurnout.Match { + Mutable(final Turnout pT) { + super(pT); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends NoExtraInputOfTurnout.Match { + Immutable(final Turnout pT) { + super(pT); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.noExtraInputOfTurnout pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}Constraint(message = "noExtraInputOfTurnout", severity = "error", key = { T })
+   * pattern noExtraInputOfTurnout(T : Turnout) {
+   * 	neg find extraInputOfTurnout(T, _);
+   * }
+   * 
+ * + * @see Match + * @see NoExtraInputOfTurnout + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static NoExtraInputOfTurnout.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static NoExtraInputOfTurnout.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_T = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NoExtraInputOfTurnout.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Turnout pT) { + return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Turnout pT) { + return rawStreamAllMatches(new Object[]{pT}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Turnout pT) { + return rawGetOneArbitraryMatch(new Object[]{pT}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Turnout pT) { + return rawHasMatch(new Object[]{pT}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Turnout pT) { + return rawCountMatches(new Object[]{pT}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Turnout pT, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pT}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the (partial) match object. + * + */ + public NoExtraInputOfTurnout.Match newMatch(final Turnout pT) { + return NoExtraInputOfTurnout.Match.newMatch(pT); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfT(final Object[] parameters) { + return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()); + } + + @Override + protected NoExtraInputOfTurnout.Match tupleToMatch(final Tuple t) { + try { + return NoExtraInputOfTurnout.Match.newMatch((Turnout) t.get(POSITION_T)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected NoExtraInputOfTurnout.Match arrayToMatch(final Object[] match) { + try { + return NoExtraInputOfTurnout.Match.newMatch((Turnout) match[POSITION_T]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected NoExtraInputOfTurnout.Match arrayToMatchMutable(final Object[] match) { + try { + return NoExtraInputOfTurnout.Match.newMutableMatch((Turnout) match[POSITION_T]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return NoExtraInputOfTurnout.instance(); + } + } + + private NoExtraInputOfTurnout() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static NoExtraInputOfTurnout instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected NoExtraInputOfTurnout.Matcher instantiate(final ViatraQueryEngine engine) { + return NoExtraInputOfTurnout.Matcher.on(engine); + } + + @Override + public NoExtraInputOfTurnout.Matcher instantiate() { + return NoExtraInputOfTurnout.Matcher.create(); + } + + @Override + public NoExtraInputOfTurnout.Match newEmptyMatch() { + return NoExtraInputOfTurnout.Match.newEmptyMatch(); + } + + @Override + public NoExtraInputOfTurnout.Match newMatch(final Object... parameters) { + return NoExtraInputOfTurnout.Match.newMatch((modes3.Turnout) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link NoExtraInputOfTurnout} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link NoExtraInputOfTurnout#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final NoExtraInputOfTurnout INSTANCE = new NoExtraInputOfTurnout(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final NoExtraInputOfTurnout.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_T); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.noExtraInputOfTurnout"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("T"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_T = body.getOrCreateVariableByName("T"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_T, parameter_T) + )); + // neg find extraInputOfTurnout(T, _) + new NegativePatternCall(body, Tuples.flatTupleOf(var_T, var___0_), ExtraInputOfTurnout.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("message", "noExtraInputOfTurnout"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("T") + })); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Output.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Output.java new file mode 100644 index 00000000..615b33af --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Output.java @@ -0,0 +1,724 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Segment; +import modes3.queries.TurnoutOutput; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         pattern output(S1 : Segment, S2 : Segment) {
+ *         	Segment.connectedTo(S1, S2);
+ *         } or {
+ *         	find turnoutOutput(S1, S2);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class Output extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.output pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Segment fS1; + + private Segment fS2; + + private static List parameterNames = makeImmutableList("S1", "S2"); + + private Match(final Segment pS1, final Segment pS2) { + this.fS1 = pS1; + this.fS2 = pS2; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "S1": return this.fS1; + case "S2": return this.fS2; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fS1; + case 1: return this.fS2; + default: return null; + } + } + + public Segment getS1() { + return this.fS1; + } + + public Segment getS2() { + return this.fS2; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("S1".equals(parameterName) ) { + this.fS1 = (Segment) newValue; + return true; + } + if ("S2".equals(parameterName) ) { + this.fS2 = (Segment) newValue; + return true; + } + return false; + } + + public void setS1(final Segment pS1) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS1 = pS1; + } + + public void setS2(final Segment pS2) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS2 = pS2; + } + + @Override + public String patternName() { + return "modes3.queries.output"; + } + + @Override + public List parameterNames() { + return Output.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fS1, fS2}; + } + + @Override + public Output.Match toImmutable() { + return isMutable() ? newMatch(fS1, fS2) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); + result.append("\"S2\"=" + prettyPrintValue(fS2)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fS1, fS2); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof Output.Match)) { + Output.Match other = (Output.Match) obj; + return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public Output specification() { + return Output.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static Output.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static Output.Match newMutableMatch(final Segment pS1, final Segment pS2) { + return new Mutable(pS1, pS2); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the (partial) match object. + * + */ + public static Output.Match newMatch(final Segment pS1, final Segment pS2) { + return new Immutable(pS1, pS2); + } + + private static final class Mutable extends Output.Match { + Mutable(final Segment pS1, final Segment pS2) { + super(pS1, pS2); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends Output.Match { + Immutable(final Segment pS1, final Segment pS2) { + super(pS1, pS2); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.output pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * pattern output(S1 : Segment, S2 : Segment) {
+   * 	Segment.connectedTo(S1, S2);
+   * } or {
+   * 	find turnoutOutput(S1, S2);
+   * }
+   * 
+ * + * @see Match + * @see Output + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static Output.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static Output.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_S1 = 0; + + private static final int POSITION_S2 = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Output.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Segment pS1, final Segment pS2) { + return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Segment pS1, final Segment pS2) { + return rawStreamAllMatches(new Object[]{pS1, pS2}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Segment pS1, final Segment pS2) { + return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Segment pS1, final Segment pS2) { + return rawHasMatch(new Object[]{pS1, pS2}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Segment pS1, final Segment pS2) { + return rawCountMatches(new Object[]{pS1, pS2}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the (partial) match object. + * + */ + public Output.Match newMatch(final Segment pS1, final Segment pS2) { + return Output.Match.newMatch(pS1, pS2); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS1(final Object[] parameters) { + return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1() { + return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1() { + return rawStreamAllValuesOfS1(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1(final Output.Match partialMatch) { + return rawStreamAllValuesOfS1(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1(final Segment pS2) { + return rawStreamAllValuesOfS1(new Object[]{null, pS2}); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1(final Output.Match partialMatch) { + return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1(final Segment pS2) { + return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS2(final Object[] parameters) { + return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2() { + return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2() { + return rawStreamAllValuesOfS2(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2(final Output.Match partialMatch) { + return rawStreamAllValuesOfS2(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2(final Segment pS1) { + return rawStreamAllValuesOfS2(new Object[]{pS1, null}); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2(final Output.Match partialMatch) { + return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2(final Segment pS1) { + return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); + } + + @Override + protected Output.Match tupleToMatch(final Tuple t) { + try { + return Output.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected Output.Match arrayToMatch(final Object[] match) { + try { + return Output.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected Output.Match arrayToMatchMutable(final Object[] match) { + try { + return Output.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return Output.instance(); + } + } + + private Output() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static Output instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected Output.Matcher instantiate(final ViatraQueryEngine engine) { + return Output.Matcher.on(engine); + } + + @Override + public Output.Matcher instantiate() { + return Output.Matcher.create(); + } + + @Override + public Output.Match newEmptyMatch() { + return Output.Match.newEmptyMatch(); + } + + @Override + public Output.Match newMatch(final Object... parameters) { + return Output.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link Output} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link Output#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final Output INSTANCE = new Output(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final Output.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_S1, parameter_S2); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.output"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("S1","S2"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_S1 = body.getOrCreateVariableByName("S1"); + PVariable var_S2 = body.getOrCreateVariableByName("S2"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_S1, parameter_S1), + new ExportedParameter(body, var_S2, parameter_S2) + )); + // Segment.connectedTo(S1, S2) + new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S1, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_0_, var_S2); + bodies.add(body); + } + { + PBody body = new PBody(this); + PVariable var_S1 = body.getOrCreateVariableByName("S1"); + PVariable var_S2 = body.getOrCreateVariableByName("S2"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_S1, parameter_S1), + new ExportedParameter(body, var_S2, parameter_S2) + )); + // find turnoutOutput(S1, S2) + new PositivePatternCall(body, Tuples.flatTupleOf(var_S1, var_S2), TurnoutOutput.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/OutputReflexive.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/OutputReflexive.java new file mode 100644 index 00000000..3d90ede5 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/OutputReflexive.java @@ -0,0 +1,559 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Turnout; +import modes3.queries.TurnoutOutput; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}Constraint(message = "outputReflexive", severity = "error", key = { T })
+ *         pattern outputReflexive(T : Turnout) {
+ *         	find turnoutOutput(T, T);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class OutputReflexive extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.outputReflexive pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Turnout fT; + + private static List parameterNames = makeImmutableList("T"); + + private Match(final Turnout pT) { + this.fT = pT; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "T": return this.fT; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fT; + default: return null; + } + } + + public Turnout getT() { + return this.fT; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("T".equals(parameterName) ) { + this.fT = (Turnout) newValue; + return true; + } + return false; + } + + public void setT(final Turnout pT) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fT = pT; + } + + @Override + public String patternName() { + return "modes3.queries.outputReflexive"; + } + + @Override + public List parameterNames() { + return OutputReflexive.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fT}; + } + + @Override + public OutputReflexive.Match toImmutable() { + return isMutable() ? newMatch(fT) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"T\"=" + prettyPrintValue(fT)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fT); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof OutputReflexive.Match)) { + OutputReflexive.Match other = (OutputReflexive.Match) obj; + return Objects.equals(fT, other.fT); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public OutputReflexive specification() { + return OutputReflexive.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static OutputReflexive.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static OutputReflexive.Match newMutableMatch(final Turnout pT) { + return new Mutable(pT); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the (partial) match object. + * + */ + public static OutputReflexive.Match newMatch(final Turnout pT) { + return new Immutable(pT); + } + + private static final class Mutable extends OutputReflexive.Match { + Mutable(final Turnout pT) { + super(pT); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends OutputReflexive.Match { + Immutable(final Turnout pT) { + super(pT); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.outputReflexive pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}Constraint(message = "outputReflexive", severity = "error", key = { T })
+   * pattern outputReflexive(T : Turnout) {
+   * 	find turnoutOutput(T, T);
+   * }
+   * 
+ * + * @see Match + * @see OutputReflexive + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static OutputReflexive.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static OutputReflexive.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_T = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(OutputReflexive.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Turnout pT) { + return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Turnout pT) { + return rawStreamAllMatches(new Object[]{pT}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Turnout pT) { + return rawGetOneArbitraryMatch(new Object[]{pT}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Turnout pT) { + return rawHasMatch(new Object[]{pT}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Turnout pT) { + return rawCountMatches(new Object[]{pT}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Turnout pT, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pT}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the (partial) match object. + * + */ + public OutputReflexive.Match newMatch(final Turnout pT) { + return OutputReflexive.Match.newMatch(pT); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfT(final Object[] parameters) { + return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()); + } + + @Override + protected OutputReflexive.Match tupleToMatch(final Tuple t) { + try { + return OutputReflexive.Match.newMatch((Turnout) t.get(POSITION_T)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected OutputReflexive.Match arrayToMatch(final Object[] match) { + try { + return OutputReflexive.Match.newMatch((Turnout) match[POSITION_T]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected OutputReflexive.Match arrayToMatchMutable(final Object[] match) { + try { + return OutputReflexive.Match.newMutableMatch((Turnout) match[POSITION_T]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return OutputReflexive.instance(); + } + } + + private OutputReflexive() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static OutputReflexive instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected OutputReflexive.Matcher instantiate(final ViatraQueryEngine engine) { + return OutputReflexive.Matcher.on(engine); + } + + @Override + public OutputReflexive.Matcher instantiate() { + return OutputReflexive.Matcher.create(); + } + + @Override + public OutputReflexive.Match newEmptyMatch() { + return OutputReflexive.Match.newEmptyMatch(); + } + + @Override + public OutputReflexive.Match newMatch(final Object... parameters) { + return OutputReflexive.Match.newMatch((modes3.Turnout) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link OutputReflexive} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link OutputReflexive#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final OutputReflexive INSTANCE = new OutputReflexive(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final OutputReflexive.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_T); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.outputReflexive"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("T"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_T = body.getOrCreateVariableByName("T"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_T, parameter_T) + )); + // find turnoutOutput(T, T) + new PositivePatternCall(body, Tuples.flatTupleOf(var_T, var_T), TurnoutOutput.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("message", "outputReflexive"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("T") + })); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Reachable.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Reachable.java new file mode 100644 index 00000000..93d43c21 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Reachable.java @@ -0,0 +1,719 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Segment; +import modes3.queries.Adjacent; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         pattern reachable(S1 : Segment, S2 : Segment) {
+ *         	S1 == S2;
+ *         } or {
+ *         	find adjacent+(S1, S2);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class Reachable extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.reachable pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Segment fS1; + + private Segment fS2; + + private static List parameterNames = makeImmutableList("S1", "S2"); + + private Match(final Segment pS1, final Segment pS2) { + this.fS1 = pS1; + this.fS2 = pS2; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "S1": return this.fS1; + case "S2": return this.fS2; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fS1; + case 1: return this.fS2; + default: return null; + } + } + + public Segment getS1() { + return this.fS1; + } + + public Segment getS2() { + return this.fS2; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("S1".equals(parameterName) ) { + this.fS1 = (Segment) newValue; + return true; + } + if ("S2".equals(parameterName) ) { + this.fS2 = (Segment) newValue; + return true; + } + return false; + } + + public void setS1(final Segment pS1) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS1 = pS1; + } + + public void setS2(final Segment pS2) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS2 = pS2; + } + + @Override + public String patternName() { + return "modes3.queries.reachable"; + } + + @Override + public List parameterNames() { + return Reachable.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fS1, fS2}; + } + + @Override + public Reachable.Match toImmutable() { + return isMutable() ? newMatch(fS1, fS2) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); + result.append("\"S2\"=" + prettyPrintValue(fS2)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fS1, fS2); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof Reachable.Match)) { + Reachable.Match other = (Reachable.Match) obj; + return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public Reachable specification() { + return Reachable.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static Reachable.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static Reachable.Match newMutableMatch(final Segment pS1, final Segment pS2) { + return new Mutable(pS1, pS2); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the (partial) match object. + * + */ + public static Reachable.Match newMatch(final Segment pS1, final Segment pS2) { + return new Immutable(pS1, pS2); + } + + private static final class Mutable extends Reachable.Match { + Mutable(final Segment pS1, final Segment pS2) { + super(pS1, pS2); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends Reachable.Match { + Immutable(final Segment pS1, final Segment pS2) { + super(pS1, pS2); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.reachable pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * pattern reachable(S1 : Segment, S2 : Segment) {
+   * 	S1 == S2;
+   * } or {
+   * 	find adjacent+(S1, S2);
+   * }
+   * 
+ * + * @see Match + * @see Reachable + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static Reachable.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static Reachable.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_S1 = 0; + + private static final int POSITION_S2 = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Reachable.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Segment pS1, final Segment pS2) { + return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Segment pS1, final Segment pS2) { + return rawStreamAllMatches(new Object[]{pS1, pS2}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Segment pS1, final Segment pS2) { + return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Segment pS1, final Segment pS2) { + return rawHasMatch(new Object[]{pS1, pS2}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Segment pS1, final Segment pS2) { + return rawCountMatches(new Object[]{pS1, pS2}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the (partial) match object. + * + */ + public Reachable.Match newMatch(final Segment pS1, final Segment pS2) { + return Reachable.Match.newMatch(pS1, pS2); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS1(final Object[] parameters) { + return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1() { + return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1() { + return rawStreamAllValuesOfS1(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1(final Reachable.Match partialMatch) { + return rawStreamAllValuesOfS1(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1(final Segment pS2) { + return rawStreamAllValuesOfS1(new Object[]{null, pS2}); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1(final Reachable.Match partialMatch) { + return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1(final Segment pS2) { + return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS2(final Object[] parameters) { + return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2() { + return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2() { + return rawStreamAllValuesOfS2(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2(final Reachable.Match partialMatch) { + return rawStreamAllValuesOfS2(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2(final Segment pS1) { + return rawStreamAllValuesOfS2(new Object[]{pS1, null}); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2(final Reachable.Match partialMatch) { + return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2(final Segment pS1) { + return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); + } + + @Override + protected Reachable.Match tupleToMatch(final Tuple t) { + try { + return Reachable.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected Reachable.Match arrayToMatch(final Object[] match) { + try { + return Reachable.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected Reachable.Match arrayToMatchMutable(final Object[] match) { + try { + return Reachable.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return Reachable.instance(); + } + } + + private Reachable() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static Reachable instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected Reachable.Matcher instantiate(final ViatraQueryEngine engine) { + return Reachable.Matcher.on(engine); + } + + @Override + public Reachable.Matcher instantiate() { + return Reachable.Matcher.create(); + } + + @Override + public Reachable.Match newEmptyMatch() { + return Reachable.Match.newEmptyMatch(); + } + + @Override + public Reachable.Match newMatch(final Object... parameters) { + return Reachable.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link Reachable} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link Reachable#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final Reachable INSTANCE = new Reachable(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final Reachable.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_S1, parameter_S2); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.reachable"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("S1","S2"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_S1 = body.getOrCreateVariableByName("S1"); + PVariable var_S2 = body.getOrCreateVariableByName("S2"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_S1, parameter_S1), + new ExportedParameter(body, var_S2, parameter_S2) + )); + // S1 == S2 + new Equality(body, var_S1, var_S2); + bodies.add(body); + } + { + PBody body = new PBody(this); + PVariable var_S1 = body.getOrCreateVariableByName("S1"); + PVariable var_S2 = body.getOrCreateVariableByName("S2"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_S1, parameter_S1), + new ExportedParameter(body, var_S2, parameter_S2) + )); + // find adjacent+(S1, S2) + new BinaryTransitiveClosure(body, Tuples.flatTupleOf(var_S1, var_S2), Adjacent.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyExtraInputsOfTurnout.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyExtraInputsOfTurnout.java new file mode 100644 index 00000000..9f417795 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyExtraInputsOfTurnout.java @@ -0,0 +1,570 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Turnout; +import modes3.queries.ExtraInputOfTurnout; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}Constraint(message = "tooManyExtraInputsOfTurnout", severity = "error", key = { T })
+ *         pattern tooManyExtraInputsOfTurnout(T : Turnout) {
+ *         	find extraInputOfTurnout(T, I1);
+ *         	find extraInputOfTurnout(T, I2);
+ *         	I1 != I2;
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class TooManyExtraInputsOfTurnout extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.tooManyExtraInputsOfTurnout pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Turnout fT; + + private static List parameterNames = makeImmutableList("T"); + + private Match(final Turnout pT) { + this.fT = pT; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "T": return this.fT; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fT; + default: return null; + } + } + + public Turnout getT() { + return this.fT; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("T".equals(parameterName) ) { + this.fT = (Turnout) newValue; + return true; + } + return false; + } + + public void setT(final Turnout pT) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fT = pT; + } + + @Override + public String patternName() { + return "modes3.queries.tooManyExtraInputsOfTurnout"; + } + + @Override + public List parameterNames() { + return TooManyExtraInputsOfTurnout.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fT}; + } + + @Override + public TooManyExtraInputsOfTurnout.Match toImmutable() { + return isMutable() ? newMatch(fT) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"T\"=" + prettyPrintValue(fT)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fT); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof TooManyExtraInputsOfTurnout.Match)) { + TooManyExtraInputsOfTurnout.Match other = (TooManyExtraInputsOfTurnout.Match) obj; + return Objects.equals(fT, other.fT); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public TooManyExtraInputsOfTurnout specification() { + return TooManyExtraInputsOfTurnout.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static TooManyExtraInputsOfTurnout.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static TooManyExtraInputsOfTurnout.Match newMutableMatch(final Turnout pT) { + return new Mutable(pT); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the (partial) match object. + * + */ + public static TooManyExtraInputsOfTurnout.Match newMatch(final Turnout pT) { + return new Immutable(pT); + } + + private static final class Mutable extends TooManyExtraInputsOfTurnout.Match { + Mutable(final Turnout pT) { + super(pT); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends TooManyExtraInputsOfTurnout.Match { + Immutable(final Turnout pT) { + super(pT); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.tooManyExtraInputsOfTurnout pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}Constraint(message = "tooManyExtraInputsOfTurnout", severity = "error", key = { T })
+   * pattern tooManyExtraInputsOfTurnout(T : Turnout) {
+   * 	find extraInputOfTurnout(T, I1);
+   * 	find extraInputOfTurnout(T, I2);
+   * 	I1 != I2;
+   * }
+   * 
+ * + * @see Match + * @see TooManyExtraInputsOfTurnout + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static TooManyExtraInputsOfTurnout.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static TooManyExtraInputsOfTurnout.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_T = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TooManyExtraInputsOfTurnout.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Turnout pT) { + return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Turnout pT) { + return rawStreamAllMatches(new Object[]{pT}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Turnout pT) { + return rawGetOneArbitraryMatch(new Object[]{pT}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Turnout pT) { + return rawHasMatch(new Object[]{pT}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Turnout pT) { + return rawCountMatches(new Object[]{pT}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Turnout pT, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pT}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the (partial) match object. + * + */ + public TooManyExtraInputsOfTurnout.Match newMatch(final Turnout pT) { + return TooManyExtraInputsOfTurnout.Match.newMatch(pT); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfT(final Object[] parameters) { + return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()); + } + + @Override + protected TooManyExtraInputsOfTurnout.Match tupleToMatch(final Tuple t) { + try { + return TooManyExtraInputsOfTurnout.Match.newMatch((Turnout) t.get(POSITION_T)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected TooManyExtraInputsOfTurnout.Match arrayToMatch(final Object[] match) { + try { + return TooManyExtraInputsOfTurnout.Match.newMatch((Turnout) match[POSITION_T]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected TooManyExtraInputsOfTurnout.Match arrayToMatchMutable(final Object[] match) { + try { + return TooManyExtraInputsOfTurnout.Match.newMutableMatch((Turnout) match[POSITION_T]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return TooManyExtraInputsOfTurnout.instance(); + } + } + + private TooManyExtraInputsOfTurnout() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TooManyExtraInputsOfTurnout instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected TooManyExtraInputsOfTurnout.Matcher instantiate(final ViatraQueryEngine engine) { + return TooManyExtraInputsOfTurnout.Matcher.on(engine); + } + + @Override + public TooManyExtraInputsOfTurnout.Matcher instantiate() { + return TooManyExtraInputsOfTurnout.Matcher.create(); + } + + @Override + public TooManyExtraInputsOfTurnout.Match newEmptyMatch() { + return TooManyExtraInputsOfTurnout.Match.newEmptyMatch(); + } + + @Override + public TooManyExtraInputsOfTurnout.Match newMatch(final Object... parameters) { + return TooManyExtraInputsOfTurnout.Match.newMatch((modes3.Turnout) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link TooManyExtraInputsOfTurnout} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link TooManyExtraInputsOfTurnout#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final TooManyExtraInputsOfTurnout INSTANCE = new TooManyExtraInputsOfTurnout(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final TooManyExtraInputsOfTurnout.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_T); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.tooManyExtraInputsOfTurnout"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("T"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_T = body.getOrCreateVariableByName("T"); + PVariable var_I1 = body.getOrCreateVariableByName("I1"); + PVariable var_I2 = body.getOrCreateVariableByName("I2"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_T, parameter_T) + )); + // find extraInputOfTurnout(T, I1) + new PositivePatternCall(body, Tuples.flatTupleOf(var_T, var_I1), ExtraInputOfTurnout.instance().getInternalQueryRepresentation()); + // find extraInputOfTurnout(T, I2) + new PositivePatternCall(body, Tuples.flatTupleOf(var_T, var_I2), ExtraInputOfTurnout.instance().getInternalQueryRepresentation()); + // I1 != I2 + new Inequality(body, var_I1, var_I2); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("message", "tooManyExtraInputsOfTurnout"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("T") + })); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfSegment.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfSegment.java new file mode 100644 index 00000000..e5e8827c --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfSegment.java @@ -0,0 +1,601 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Segment; +import modes3.queries.Output; +import modes3.queries.Turnout; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         //{@literal @}Constraint(message = "noInputOfSegment", severity = "error", key = { S })
+ *         //pattern noInputOfSegment(S : Segment) {
+ *         //	neg find turnout(S);
+ *         //	neg find output(_, S);
+ *         //}
+ *         
+ *         {@literal @}Constraint(message = "tooManyInputsOfSegment", severity = "error", key = { S })
+ *         pattern tooManyInputsOfSegment(S : Segment) {
+ *         	neg find turnout(S);
+ *         	find output(I1, S);
+ *         	find output(I2, S);
+ *         	find output(I3, S);
+ *         	I1 != I2;
+ *         	I1 != I3;
+ *         	I2 != I3;
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class TooManyInputsOfSegment extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.tooManyInputsOfSegment pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Segment fS; + + private static List parameterNames = makeImmutableList("S"); + + private Match(final Segment pS) { + this.fS = pS; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "S": return this.fS; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fS; + default: return null; + } + } + + public Segment getS() { + return this.fS; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("S".equals(parameterName) ) { + this.fS = (Segment) newValue; + return true; + } + return false; + } + + public void setS(final Segment pS) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS = pS; + } + + @Override + public String patternName() { + return "modes3.queries.tooManyInputsOfSegment"; + } + + @Override + public List parameterNames() { + return TooManyInputsOfSegment.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fS}; + } + + @Override + public TooManyInputsOfSegment.Match toImmutable() { + return isMutable() ? newMatch(fS) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"S\"=" + prettyPrintValue(fS)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fS); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof TooManyInputsOfSegment.Match)) { + TooManyInputsOfSegment.Match other = (TooManyInputsOfSegment.Match) obj; + return Objects.equals(fS, other.fS); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public TooManyInputsOfSegment specification() { + return TooManyInputsOfSegment.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static TooManyInputsOfSegment.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static TooManyInputsOfSegment.Match newMutableMatch(final Segment pS) { + return new Mutable(pS); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the (partial) match object. + * + */ + public static TooManyInputsOfSegment.Match newMatch(final Segment pS) { + return new Immutable(pS); + } + + private static final class Mutable extends TooManyInputsOfSegment.Match { + Mutable(final Segment pS) { + super(pS); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends TooManyInputsOfSegment.Match { + Immutable(final Segment pS) { + super(pS); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.tooManyInputsOfSegment pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * //{@literal @}Constraint(message = "noInputOfSegment", severity = "error", key = { S })
+   * //pattern noInputOfSegment(S : Segment) {
+   * //	neg find turnout(S);
+   * //	neg find output(_, S);
+   * //}
+   * 
+   * {@literal @}Constraint(message = "tooManyInputsOfSegment", severity = "error", key = { S })
+   * pattern tooManyInputsOfSegment(S : Segment) {
+   * 	neg find turnout(S);
+   * 	find output(I1, S);
+   * 	find output(I2, S);
+   * 	find output(I3, S);
+   * 	I1 != I2;
+   * 	I1 != I3;
+   * 	I2 != I3;
+   * }
+   * 
+ * + * @see Match + * @see TooManyInputsOfSegment + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static TooManyInputsOfSegment.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static TooManyInputsOfSegment.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_S = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TooManyInputsOfSegment.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Segment pS) { + return rawStreamAllMatches(new Object[]{pS}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Segment pS) { + return rawStreamAllMatches(new Object[]{pS}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Segment pS) { + return rawGetOneArbitraryMatch(new Object[]{pS}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Segment pS) { + return rawHasMatch(new Object[]{pS}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Segment pS) { + return rawCountMatches(new Object[]{pS}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Segment pS, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pS}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the (partial) match object. + * + */ + public TooManyInputsOfSegment.Match newMatch(final Segment pS) { + return TooManyInputsOfSegment.Match.newMatch(pS); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS(final Object[] parameters) { + return rawStreamAllValues(POSITION_S, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS() { + return rawStreamAllValuesOfS(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS() { + return rawStreamAllValuesOfS(emptyArray()); + } + + @Override + protected TooManyInputsOfSegment.Match tupleToMatch(final Tuple t) { + try { + return TooManyInputsOfSegment.Match.newMatch((Segment) t.get(POSITION_S)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected TooManyInputsOfSegment.Match arrayToMatch(final Object[] match) { + try { + return TooManyInputsOfSegment.Match.newMatch((Segment) match[POSITION_S]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected TooManyInputsOfSegment.Match arrayToMatchMutable(final Object[] match) { + try { + return TooManyInputsOfSegment.Match.newMutableMatch((Segment) match[POSITION_S]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return TooManyInputsOfSegment.instance(); + } + } + + private TooManyInputsOfSegment() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TooManyInputsOfSegment instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected TooManyInputsOfSegment.Matcher instantiate(final ViatraQueryEngine engine) { + return TooManyInputsOfSegment.Matcher.on(engine); + } + + @Override + public TooManyInputsOfSegment.Matcher instantiate() { + return TooManyInputsOfSegment.Matcher.create(); + } + + @Override + public TooManyInputsOfSegment.Match newEmptyMatch() { + return TooManyInputsOfSegment.Match.newEmptyMatch(); + } + + @Override + public TooManyInputsOfSegment.Match newMatch(final Object... parameters) { + return TooManyInputsOfSegment.Match.newMatch((modes3.Segment) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link TooManyInputsOfSegment} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link TooManyInputsOfSegment#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final TooManyInputsOfSegment INSTANCE = new TooManyInputsOfSegment(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final TooManyInputsOfSegment.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_S = new PParameter("S", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_S); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.tooManyInputsOfSegment"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("S"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_S = body.getOrCreateVariableByName("S"); + PVariable var_I1 = body.getOrCreateVariableByName("I1"); + PVariable var_I2 = body.getOrCreateVariableByName("I2"); + PVariable var_I3 = body.getOrCreateVariableByName("I3"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_S, parameter_S) + )); + // neg find turnout(S) + new NegativePatternCall(body, Tuples.flatTupleOf(var_S), Turnout.instance().getInternalQueryRepresentation()); + // find output(I1, S) + new PositivePatternCall(body, Tuples.flatTupleOf(var_I1, var_S), Output.instance().getInternalQueryRepresentation()); + // find output(I2, S) + new PositivePatternCall(body, Tuples.flatTupleOf(var_I2, var_S), Output.instance().getInternalQueryRepresentation()); + // find output(I3, S) + new PositivePatternCall(body, Tuples.flatTupleOf(var_I3, var_S), Output.instance().getInternalQueryRepresentation()); + // I1 != I2 + new Inequality(body, var_I1, var_I2); + // I1 != I3 + new Inequality(body, var_I1, var_I3); + // I2 != I3 + new Inequality(body, var_I2, var_I3); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("message", "tooManyInputsOfSegment"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("S") + })); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Turnout.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Turnout.java new file mode 100644 index 00000000..34c7631c --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Turnout.java @@ -0,0 +1,543 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         pattern turnout(T : Turnout) {
+ *         	Turnout(T);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class Turnout extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.turnout pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private modes3.Turnout fT; + + private static List parameterNames = makeImmutableList("T"); + + private Match(final modes3.Turnout pT) { + this.fT = pT; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "T": return this.fT; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fT; + default: return null; + } + } + + public modes3.Turnout getT() { + return this.fT; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("T".equals(parameterName) ) { + this.fT = (modes3.Turnout) newValue; + return true; + } + return false; + } + + public void setT(final modes3.Turnout pT) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fT = pT; + } + + @Override + public String patternName() { + return "modes3.queries.turnout"; + } + + @Override + public List parameterNames() { + return Turnout.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fT}; + } + + @Override + public Turnout.Match toImmutable() { + return isMutable() ? newMatch(fT) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"T\"=" + prettyPrintValue(fT)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fT); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof Turnout.Match)) { + Turnout.Match other = (Turnout.Match) obj; + return Objects.equals(fT, other.fT); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public Turnout specification() { + return Turnout.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static Turnout.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static Turnout.Match newMutableMatch(final modes3.Turnout pT) { + return new Mutable(pT); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the (partial) match object. + * + */ + public static Turnout.Match newMatch(final modes3.Turnout pT) { + return new Immutable(pT); + } + + private static final class Mutable extends Turnout.Match { + Mutable(final modes3.Turnout pT) { + super(pT); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends Turnout.Match { + Immutable(final modes3.Turnout pT) { + super(pT); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.turnout pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * pattern turnout(T : Turnout) {
+   * 	Turnout(T);
+   * }
+   * 
+ * + * @see Match + * @see Turnout + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static Turnout.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static Turnout.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_T = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Turnout.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final modes3.Turnout pT) { + return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final modes3.Turnout pT) { + return rawStreamAllMatches(new Object[]{pT}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final modes3.Turnout pT) { + return rawGetOneArbitraryMatch(new Object[]{pT}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final modes3.Turnout pT) { + return rawHasMatch(new Object[]{pT}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final modes3.Turnout pT) { + return rawCountMatches(new Object[]{pT}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final modes3.Turnout pT, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pT}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the (partial) match object. + * + */ + public Turnout.Match newMatch(final modes3.Turnout pT) { + return Turnout.Match.newMatch(pT); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfT(final Object[] parameters) { + return rawStreamAllValues(POSITION_T, parameters).map(modes3.Turnout.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()); + } + + @Override + protected Turnout.Match tupleToMatch(final Tuple t) { + try { + return Turnout.Match.newMatch((modes3.Turnout) t.get(POSITION_T)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected Turnout.Match arrayToMatch(final Object[] match) { + try { + return Turnout.Match.newMatch((modes3.Turnout) match[POSITION_T]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected Turnout.Match arrayToMatchMutable(final Object[] match) { + try { + return Turnout.Match.newMutableMatch((modes3.Turnout) match[POSITION_T]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return Turnout.instance(); + } + } + + private Turnout() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static Turnout instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected Turnout.Matcher instantiate(final ViatraQueryEngine engine) { + return Turnout.Matcher.on(engine); + } + + @Override + public Turnout.Matcher instantiate() { + return Turnout.Matcher.create(); + } + + @Override + public Turnout.Match newEmptyMatch() { + return Turnout.Match.newEmptyMatch(); + } + + @Override + public Turnout.Match newMatch(final Object... parameters) { + return Turnout.Match.newMatch((modes3.Turnout) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link Turnout} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link Turnout#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final Turnout INSTANCE = new Turnout(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final Turnout.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_T); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.turnout"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("T"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_T = body.getOrCreateVariableByName("T"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_T, parameter_T) + )); + // Turnout(T) + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutConnectedToBothOutputs.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutConnectedToBothOutputs.java new file mode 100644 index 00000000..674bb275 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutConnectedToBothOutputs.java @@ -0,0 +1,589 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Turnout; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T })
+ *         pattern turnoutConnectedToBothOutputs(T : Turnout) {
+ *         	Turnout.straight(T, Straight);
+ *         	Turnout.divergent(T, Divergent);
+ *         	Segment.connectedTo(T, Straight);
+ *         	Segment.connectedTo(T, Divergent);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class TurnoutConnectedToBothOutputs extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.turnoutConnectedToBothOutputs pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Turnout fT; + + private static List parameterNames = makeImmutableList("T"); + + private Match(final Turnout pT) { + this.fT = pT; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "T": return this.fT; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fT; + default: return null; + } + } + + public Turnout getT() { + return this.fT; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("T".equals(parameterName) ) { + this.fT = (Turnout) newValue; + return true; + } + return false; + } + + public void setT(final Turnout pT) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fT = pT; + } + + @Override + public String patternName() { + return "modes3.queries.turnoutConnectedToBothOutputs"; + } + + @Override + public List parameterNames() { + return TurnoutConnectedToBothOutputs.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fT}; + } + + @Override + public TurnoutConnectedToBothOutputs.Match toImmutable() { + return isMutable() ? newMatch(fT) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"T\"=" + prettyPrintValue(fT)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fT); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof TurnoutConnectedToBothOutputs.Match)) { + TurnoutConnectedToBothOutputs.Match other = (TurnoutConnectedToBothOutputs.Match) obj; + return Objects.equals(fT, other.fT); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public TurnoutConnectedToBothOutputs specification() { + return TurnoutConnectedToBothOutputs.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static TurnoutConnectedToBothOutputs.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static TurnoutConnectedToBothOutputs.Match newMutableMatch(final Turnout pT) { + return new Mutable(pT); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the (partial) match object. + * + */ + public static TurnoutConnectedToBothOutputs.Match newMatch(final Turnout pT) { + return new Immutable(pT); + } + + private static final class Mutable extends TurnoutConnectedToBothOutputs.Match { + Mutable(final Turnout pT) { + super(pT); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends TurnoutConnectedToBothOutputs.Match { + Immutable(final Turnout pT) { + super(pT); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.turnoutConnectedToBothOutputs pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T })
+   * pattern turnoutConnectedToBothOutputs(T : Turnout) {
+   * 	Turnout.straight(T, Straight);
+   * 	Turnout.divergent(T, Divergent);
+   * 	Segment.connectedTo(T, Straight);
+   * 	Segment.connectedTo(T, Divergent);
+   * }
+   * 
+ * + * @see Match + * @see TurnoutConnectedToBothOutputs + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static TurnoutConnectedToBothOutputs.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static TurnoutConnectedToBothOutputs.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_T = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TurnoutConnectedToBothOutputs.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Turnout pT) { + return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Turnout pT) { + return rawStreamAllMatches(new Object[]{pT}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Turnout pT) { + return rawGetOneArbitraryMatch(new Object[]{pT}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Turnout pT) { + return rawHasMatch(new Object[]{pT}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Turnout pT) { + return rawCountMatches(new Object[]{pT}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Turnout pT, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pT}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the (partial) match object. + * + */ + public TurnoutConnectedToBothOutputs.Match newMatch(final Turnout pT) { + return TurnoutConnectedToBothOutputs.Match.newMatch(pT); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfT(final Object[] parameters) { + return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()); + } + + @Override + protected TurnoutConnectedToBothOutputs.Match tupleToMatch(final Tuple t) { + try { + return TurnoutConnectedToBothOutputs.Match.newMatch((Turnout) t.get(POSITION_T)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected TurnoutConnectedToBothOutputs.Match arrayToMatch(final Object[] match) { + try { + return TurnoutConnectedToBothOutputs.Match.newMatch((Turnout) match[POSITION_T]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected TurnoutConnectedToBothOutputs.Match arrayToMatchMutable(final Object[] match) { + try { + return TurnoutConnectedToBothOutputs.Match.newMutableMatch((Turnout) match[POSITION_T]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return TurnoutConnectedToBothOutputs.instance(); + } + } + + private TurnoutConnectedToBothOutputs() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TurnoutConnectedToBothOutputs instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected TurnoutConnectedToBothOutputs.Matcher instantiate(final ViatraQueryEngine engine) { + return TurnoutConnectedToBothOutputs.Matcher.on(engine); + } + + @Override + public TurnoutConnectedToBothOutputs.Matcher instantiate() { + return TurnoutConnectedToBothOutputs.Matcher.create(); + } + + @Override + public TurnoutConnectedToBothOutputs.Match newEmptyMatch() { + return TurnoutConnectedToBothOutputs.Match.newEmptyMatch(); + } + + @Override + public TurnoutConnectedToBothOutputs.Match newMatch(final Object... parameters) { + return TurnoutConnectedToBothOutputs.Match.newMatch((modes3.Turnout) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link TurnoutConnectedToBothOutputs} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link TurnoutConnectedToBothOutputs#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final TurnoutConnectedToBothOutputs INSTANCE = new TurnoutConnectedToBothOutputs(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final TurnoutConnectedToBothOutputs.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_T); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.turnoutConnectedToBothOutputs"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("T"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_T = body.getOrCreateVariableByName("T"); + PVariable var_Straight = body.getOrCreateVariableByName("Straight"); + PVariable var_Divergent = body.getOrCreateVariableByName("Divergent"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_T, parameter_T) + )); + // Turnout.straight(T, Straight) + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "straight"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_0_, var_Straight); + // Turnout.divergent(T, Divergent) + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "divergent"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_1_, var_Divergent); + // Segment.connectedTo(T, Straight) + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_2_, var_Straight); + // Segment.connectedTo(T, Divergent) + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_3_, var_Divergent); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("message", "turnoutConnectedToBothOutputs"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("T") + })); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutInSegments.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutInSegments.java new file mode 100644 index 00000000..9c9a5d18 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutInSegments.java @@ -0,0 +1,564 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Turnout; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}Constraint(message = "turnoutInSegments", severity = "error", key = { T })
+ *         pattern turnoutInSegments(T : Turnout) {
+ *         	Modes3ModelRoot.segments(_, T);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class TurnoutInSegments extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.turnoutInSegments pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Turnout fT; + + private static List parameterNames = makeImmutableList("T"); + + private Match(final Turnout pT) { + this.fT = pT; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "T": return this.fT; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fT; + default: return null; + } + } + + public Turnout getT() { + return this.fT; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("T".equals(parameterName) ) { + this.fT = (Turnout) newValue; + return true; + } + return false; + } + + public void setT(final Turnout pT) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fT = pT; + } + + @Override + public String patternName() { + return "modes3.queries.turnoutInSegments"; + } + + @Override + public List parameterNames() { + return TurnoutInSegments.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fT}; + } + + @Override + public TurnoutInSegments.Match toImmutable() { + return isMutable() ? newMatch(fT) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"T\"=" + prettyPrintValue(fT)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fT); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof TurnoutInSegments.Match)) { + TurnoutInSegments.Match other = (TurnoutInSegments.Match) obj; + return Objects.equals(fT, other.fT); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public TurnoutInSegments specification() { + return TurnoutInSegments.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static TurnoutInSegments.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static TurnoutInSegments.Match newMutableMatch(final Turnout pT) { + return new Mutable(pT); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the (partial) match object. + * + */ + public static TurnoutInSegments.Match newMatch(final Turnout pT) { + return new Immutable(pT); + } + + private static final class Mutable extends TurnoutInSegments.Match { + Mutable(final Turnout pT) { + super(pT); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends TurnoutInSegments.Match { + Immutable(final Turnout pT) { + super(pT); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.turnoutInSegments pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}Constraint(message = "turnoutInSegments", severity = "error", key = { T })
+   * pattern turnoutInSegments(T : Turnout) {
+   * 	Modes3ModelRoot.segments(_, T);
+   * }
+   * 
+ * + * @see Match + * @see TurnoutInSegments + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static TurnoutInSegments.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static TurnoutInSegments.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_T = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TurnoutInSegments.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Turnout pT) { + return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Turnout pT) { + return rawStreamAllMatches(new Object[]{pT}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Turnout pT) { + return rawGetOneArbitraryMatch(new Object[]{pT}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Turnout pT) { + return rawHasMatch(new Object[]{pT}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Turnout pT) { + return rawCountMatches(new Object[]{pT}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Turnout pT, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pT}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the (partial) match object. + * + */ + public TurnoutInSegments.Match newMatch(final Turnout pT) { + return TurnoutInSegments.Match.newMatch(pT); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfT(final Object[] parameters) { + return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()); + } + + @Override + protected TurnoutInSegments.Match tupleToMatch(final Tuple t) { + try { + return TurnoutInSegments.Match.newMatch((Turnout) t.get(POSITION_T)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected TurnoutInSegments.Match arrayToMatch(final Object[] match) { + try { + return TurnoutInSegments.Match.newMatch((Turnout) match[POSITION_T]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected TurnoutInSegments.Match arrayToMatchMutable(final Object[] match) { + try { + return TurnoutInSegments.Match.newMutableMatch((Turnout) match[POSITION_T]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return TurnoutInSegments.instance(); + } + } + + private TurnoutInSegments() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TurnoutInSegments instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected TurnoutInSegments.Matcher instantiate(final ViatraQueryEngine engine) { + return TurnoutInSegments.Matcher.on(engine); + } + + @Override + public TurnoutInSegments.Matcher instantiate() { + return TurnoutInSegments.Matcher.create(); + } + + @Override + public TurnoutInSegments.Match newEmptyMatch() { + return TurnoutInSegments.Match.newEmptyMatch(); + } + + @Override + public TurnoutInSegments.Match newMatch(final Object... parameters) { + return TurnoutInSegments.Match.newMatch((modes3.Turnout) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link TurnoutInSegments} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link TurnoutInSegments#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final TurnoutInSegments INSTANCE = new TurnoutInSegments(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final TurnoutInSegments.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_T); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.turnoutInSegments"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("T"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_T = body.getOrCreateVariableByName("T"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_T, parameter_T) + )); + // Modes3ModelRoot.segments(_, T) + new TypeConstraint(body, Tuples.flatTupleOf(var___0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Modes3ModelRoot"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var___0_, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Modes3ModelRoot", "segments"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_0_, var_T); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("message", "turnoutInSegments"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("T") + })); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutOutput.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutOutput.java new file mode 100644 index 00000000..87cccfde --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutOutput.java @@ -0,0 +1,727 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Segment; +import modes3.Turnout; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         pattern turnoutOutput(T : Turnout, S : Segment) {
+ *         	Turnout.straight(T, S);
+ *         } or {
+ *         	Turnout.divergent(T, S);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class TurnoutOutput extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.turnoutOutput pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Turnout fT; + + private Segment fS; + + private static List parameterNames = makeImmutableList("T", "S"); + + private Match(final Turnout pT, final Segment pS) { + this.fT = pT; + this.fS = pS; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "T": return this.fT; + case "S": return this.fS; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fT; + case 1: return this.fS; + default: return null; + } + } + + public Turnout getT() { + return this.fT; + } + + public Segment getS() { + return this.fS; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("T".equals(parameterName) ) { + this.fT = (Turnout) newValue; + return true; + } + if ("S".equals(parameterName) ) { + this.fS = (Segment) newValue; + return true; + } + return false; + } + + public void setT(final Turnout pT) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fT = pT; + } + + public void setS(final Segment pS) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS = pS; + } + + @Override + public String patternName() { + return "modes3.queries.turnoutOutput"; + } + + @Override + public List parameterNames() { + return TurnoutOutput.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fT, fS}; + } + + @Override + public TurnoutOutput.Match toImmutable() { + return isMutable() ? newMatch(fT, fS) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"T\"=" + prettyPrintValue(fT) + ", "); + result.append("\"S\"=" + prettyPrintValue(fS)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fT, fS); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof TurnoutOutput.Match)) { + TurnoutOutput.Match other = (TurnoutOutput.Match) obj; + return Objects.equals(fT, other.fT) && Objects.equals(fS, other.fS); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public TurnoutOutput specification() { + return TurnoutOutput.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static TurnoutOutput.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static TurnoutOutput.Match newMutableMatch(final Turnout pT, final Segment pS) { + return new Mutable(pT, pS); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the (partial) match object. + * + */ + public static TurnoutOutput.Match newMatch(final Turnout pT, final Segment pS) { + return new Immutable(pT, pS); + } + + private static final class Mutable extends TurnoutOutput.Match { + Mutable(final Turnout pT, final Segment pS) { + super(pT, pS); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends TurnoutOutput.Match { + Immutable(final Turnout pT, final Segment pS) { + super(pT, pS); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.turnoutOutput pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * pattern turnoutOutput(T : Turnout, S : Segment) {
+   * 	Turnout.straight(T, S);
+   * } or {
+   * 	Turnout.divergent(T, S);
+   * }
+   * 
+ * + * @see Match + * @see TurnoutOutput + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static TurnoutOutput.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static TurnoutOutput.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_T = 0; + + private static final int POSITION_S = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TurnoutOutput.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Turnout pT, final Segment pS) { + return rawStreamAllMatches(new Object[]{pT, pS}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Turnout pT, final Segment pS) { + return rawStreamAllMatches(new Object[]{pT, pS}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Turnout pT, final Segment pS) { + return rawGetOneArbitraryMatch(new Object[]{pT, pS}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Turnout pT, final Segment pS) { + return rawHasMatch(new Object[]{pT, pS}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Turnout pT, final Segment pS) { + return rawCountMatches(new Object[]{pT, pS}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Turnout pT, final Segment pS, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pT, pS}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param pS the fixed value of pattern parameter S, or null if not bound. + * @return the (partial) match object. + * + */ + public TurnoutOutput.Match newMatch(final Turnout pT, final Segment pS) { + return TurnoutOutput.Match.newMatch(pT, pS); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfT(final Object[] parameters) { + return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for T. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfT(final TurnoutOutput.Match partialMatch) { + return rawStreamAllValuesOfT(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for T. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfT(final Segment pS) { + return rawStreamAllValuesOfT(new Object[]{null, pS}); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfT(final TurnoutOutput.Match partialMatch) { + return rawStreamAllValuesOfT(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfT(final Segment pS) { + return rawStreamAllValuesOfT(new Object[]{null, pS}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS(final Object[] parameters) { + return rawStreamAllValues(POSITION_S, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS() { + return rawStreamAllValuesOfS(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS() { + return rawStreamAllValuesOfS(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for S. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS(final TurnoutOutput.Match partialMatch) { + return rawStreamAllValuesOfS(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for S. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS(final Turnout pT) { + return rawStreamAllValuesOfS(new Object[]{pT, null}); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS(final TurnoutOutput.Match partialMatch) { + return rawStreamAllValuesOfS(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS(final Turnout pT) { + return rawStreamAllValuesOfS(new Object[]{pT, null}).collect(Collectors.toSet()); + } + + @Override + protected TurnoutOutput.Match tupleToMatch(final Tuple t) { + try { + return TurnoutOutput.Match.newMatch((Turnout) t.get(POSITION_T), (Segment) t.get(POSITION_S)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected TurnoutOutput.Match arrayToMatch(final Object[] match) { + try { + return TurnoutOutput.Match.newMatch((Turnout) match[POSITION_T], (Segment) match[POSITION_S]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected TurnoutOutput.Match arrayToMatchMutable(final Object[] match) { + try { + return TurnoutOutput.Match.newMutableMatch((Turnout) match[POSITION_T], (Segment) match[POSITION_S]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return TurnoutOutput.instance(); + } + } + + private TurnoutOutput() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TurnoutOutput instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected TurnoutOutput.Matcher instantiate(final ViatraQueryEngine engine) { + return TurnoutOutput.Matcher.on(engine); + } + + @Override + public TurnoutOutput.Matcher instantiate() { + return TurnoutOutput.Matcher.create(); + } + + @Override + public TurnoutOutput.Match newEmptyMatch() { + return TurnoutOutput.Match.newEmptyMatch(); + } + + @Override + public TurnoutOutput.Match newMatch(final Object... parameters) { + return TurnoutOutput.Match.newMatch((modes3.Turnout) parameters[0], (modes3.Segment) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link TurnoutOutput} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link TurnoutOutput#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final TurnoutOutput INSTANCE = new TurnoutOutput(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final TurnoutOutput.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); + + private final PParameter parameter_S = new PParameter("S", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_T, parameter_S); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.turnoutOutput"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("T","S"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_T = body.getOrCreateVariableByName("T"); + PVariable var_S = body.getOrCreateVariableByName("S"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_T, parameter_T), + new ExportedParameter(body, var_S, parameter_S) + )); + // Turnout.straight(T, S) + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "straight"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_0_, var_S); + bodies.add(body); + } + { + PBody body = new PBody(this); + PVariable var_T = body.getOrCreateVariableByName("T"); + PVariable var_S = body.getOrCreateVariableByName("S"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_T, parameter_T), + new ExportedParameter(body, var_S, parameter_S) + )); + // Turnout.divergent(T, S) + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "divergent"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_0_, var_S); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutOutputsAreSame.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutOutputsAreSame.java new file mode 100644 index 00000000..ba59d45c --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutOutputsAreSame.java @@ -0,0 +1,572 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Turnout; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}Constraint(message = "turnoutOutputsAreSame", severity = "error", key = { T })
+ *         pattern turnoutOutputsAreSame(T : Turnout) {
+ *         	Turnout.straight(T, S);
+ *         	Turnout.divergent(T, S);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class TurnoutOutputsAreSame extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.turnoutOutputsAreSame pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Turnout fT; + + private static List parameterNames = makeImmutableList("T"); + + private Match(final Turnout pT) { + this.fT = pT; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "T": return this.fT; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fT; + default: return null; + } + } + + public Turnout getT() { + return this.fT; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("T".equals(parameterName) ) { + this.fT = (Turnout) newValue; + return true; + } + return false; + } + + public void setT(final Turnout pT) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fT = pT; + } + + @Override + public String patternName() { + return "modes3.queries.turnoutOutputsAreSame"; + } + + @Override + public List parameterNames() { + return TurnoutOutputsAreSame.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fT}; + } + + @Override + public TurnoutOutputsAreSame.Match toImmutable() { + return isMutable() ? newMatch(fT) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"T\"=" + prettyPrintValue(fT)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fT); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof TurnoutOutputsAreSame.Match)) { + TurnoutOutputsAreSame.Match other = (TurnoutOutputsAreSame.Match) obj; + return Objects.equals(fT, other.fT); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public TurnoutOutputsAreSame specification() { + return TurnoutOutputsAreSame.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static TurnoutOutputsAreSame.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static TurnoutOutputsAreSame.Match newMutableMatch(final Turnout pT) { + return new Mutable(pT); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the (partial) match object. + * + */ + public static TurnoutOutputsAreSame.Match newMatch(final Turnout pT) { + return new Immutable(pT); + } + + private static final class Mutable extends TurnoutOutputsAreSame.Match { + Mutable(final Turnout pT) { + super(pT); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends TurnoutOutputsAreSame.Match { + Immutable(final Turnout pT) { + super(pT); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.turnoutOutputsAreSame pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}Constraint(message = "turnoutOutputsAreSame", severity = "error", key = { T })
+   * pattern turnoutOutputsAreSame(T : Turnout) {
+   * 	Turnout.straight(T, S);
+   * 	Turnout.divergent(T, S);
+   * }
+   * 
+ * + * @see Match + * @see TurnoutOutputsAreSame + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static TurnoutOutputsAreSame.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static TurnoutOutputsAreSame.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_T = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TurnoutOutputsAreSame.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Turnout pT) { + return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Turnout pT) { + return rawStreamAllMatches(new Object[]{pT}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Turnout pT) { + return rawGetOneArbitraryMatch(new Object[]{pT}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Turnout pT) { + return rawHasMatch(new Object[]{pT}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Turnout pT) { + return rawCountMatches(new Object[]{pT}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Turnout pT, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pT}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pT the fixed value of pattern parameter T, or null if not bound. + * @return the (partial) match object. + * + */ + public TurnoutOutputsAreSame.Match newMatch(final Turnout pT) { + return TurnoutOutputsAreSame.Match.newMatch(pT); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfT(final Object[] parameters) { + return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for T. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfT() { + return rawStreamAllValuesOfT(emptyArray()); + } + + @Override + protected TurnoutOutputsAreSame.Match tupleToMatch(final Tuple t) { + try { + return TurnoutOutputsAreSame.Match.newMatch((Turnout) t.get(POSITION_T)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected TurnoutOutputsAreSame.Match arrayToMatch(final Object[] match) { + try { + return TurnoutOutputsAreSame.Match.newMatch((Turnout) match[POSITION_T]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected TurnoutOutputsAreSame.Match arrayToMatchMutable(final Object[] match) { + try { + return TurnoutOutputsAreSame.Match.newMutableMatch((Turnout) match[POSITION_T]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return TurnoutOutputsAreSame.instance(); + } + } + + private TurnoutOutputsAreSame() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TurnoutOutputsAreSame instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected TurnoutOutputsAreSame.Matcher instantiate(final ViatraQueryEngine engine) { + return TurnoutOutputsAreSame.Matcher.on(engine); + } + + @Override + public TurnoutOutputsAreSame.Matcher instantiate() { + return TurnoutOutputsAreSame.Matcher.create(); + } + + @Override + public TurnoutOutputsAreSame.Match newEmptyMatch() { + return TurnoutOutputsAreSame.Match.newEmptyMatch(); + } + + @Override + public TurnoutOutputsAreSame.Match newMatch(final Object... parameters) { + return TurnoutOutputsAreSame.Match.newMatch((modes3.Turnout) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link TurnoutOutputsAreSame} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link TurnoutOutputsAreSame#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final TurnoutOutputsAreSame INSTANCE = new TurnoutOutputsAreSame(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final TurnoutOutputsAreSame.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_T); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.turnoutOutputsAreSame"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("T"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_T = body.getOrCreateVariableByName("T"); + PVariable var_S = body.getOrCreateVariableByName("S"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_T, parameter_T) + )); + // Turnout.straight(T, S) + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "straight"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_0_, var_S); + // Turnout.divergent(T, S) + new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "divergent"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new Equality(body, var__virtual_1_, var_S); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("message", "turnoutOutputsAreSame"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("T") + })); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Unreachable.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Unreachable.java new file mode 100644 index 00000000..a1b76f83 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Unreachable.java @@ -0,0 +1,714 @@ +/** + * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql + */ +package modes3.queries; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import modes3.Segment; +import modes3.queries.Reachable; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}Constraint(message = "unreachable", severity = "error", key = { S1, S2 })
+ *         pattern unreachable(S1 : Segment, S2 : Segment) {
+ *         	neg find reachable(S1, S2);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class Unreachable extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the modes3.queries.unreachable pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Segment fS1; + + private Segment fS2; + + private static List parameterNames = makeImmutableList("S1", "S2"); + + private Match(final Segment pS1, final Segment pS2) { + this.fS1 = pS1; + this.fS2 = pS2; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "S1": return this.fS1; + case "S2": return this.fS2; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fS1; + case 1: return this.fS2; + default: return null; + } + } + + public Segment getS1() { + return this.fS1; + } + + public Segment getS2() { + return this.fS2; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("S1".equals(parameterName) ) { + this.fS1 = (Segment) newValue; + return true; + } + if ("S2".equals(parameterName) ) { + this.fS2 = (Segment) newValue; + return true; + } + return false; + } + + public void setS1(final Segment pS1) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS1 = pS1; + } + + public void setS2(final Segment pS2) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fS2 = pS2; + } + + @Override + public String patternName() { + return "modes3.queries.unreachable"; + } + + @Override + public List parameterNames() { + return Unreachable.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fS1, fS2}; + } + + @Override + public Unreachable.Match toImmutable() { + return isMutable() ? newMatch(fS1, fS2) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); + result.append("\"S2\"=" + prettyPrintValue(fS2)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fS1, fS2); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof Unreachable.Match)) { + Unreachable.Match other = (Unreachable.Match) obj; + return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public Unreachable specification() { + return Unreachable.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static Unreachable.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static Unreachable.Match newMutableMatch(final Segment pS1, final Segment pS2) { + return new Mutable(pS1, pS2); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the (partial) match object. + * + */ + public static Unreachable.Match newMatch(final Segment pS1, final Segment pS2) { + return new Immutable(pS1, pS2); + } + + private static final class Mutable extends Unreachable.Match { + Mutable(final Segment pS1, final Segment pS2) { + super(pS1, pS2); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends Unreachable.Match { + Immutable(final Segment pS1, final Segment pS2) { + super(pS1, pS2); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the modes3.queries.unreachable pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}Constraint(message = "unreachable", severity = "error", key = { S1, S2 })
+   * pattern unreachable(S1 : Segment, S2 : Segment) {
+   * 	neg find reachable(S1, S2);
+   * }
+   * 
+ * + * @see Match + * @see Unreachable + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static Unreachable.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static Unreachable.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_S1 = 0; + + private static final int POSITION_S2 = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Unreachable.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Segment pS1, final Segment pS2) { + return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Segment pS1, final Segment pS2) { + return rawStreamAllMatches(new Object[]{pS1, pS2}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Segment pS1, final Segment pS2) { + return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Segment pS1, final Segment pS2) { + return rawHasMatch(new Object[]{pS1, pS2}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Segment pS1, final Segment pS2) { + return rawCountMatches(new Object[]{pS1, pS2}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pS1 the fixed value of pattern parameter S1, or null if not bound. + * @param pS2 the fixed value of pattern parameter S2, or null if not bound. + * @return the (partial) match object. + * + */ + public Unreachable.Match newMatch(final Segment pS1, final Segment pS2) { + return Unreachable.Match.newMatch(pS1, pS2); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS1(final Object[] parameters) { + return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1() { + return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1() { + return rawStreamAllValuesOfS1(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1(final Unreachable.Match partialMatch) { + return rawStreamAllValuesOfS1(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS1(final Segment pS2) { + return rawStreamAllValuesOfS1(new Object[]{null, pS2}); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1(final Unreachable.Match partialMatch) { + return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S1. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS1(final Segment pS2) { + return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfS2(final Object[] parameters) { + return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2() { + return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2() { + return rawStreamAllValuesOfS2(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2(final Unreachable.Match partialMatch) { + return rawStreamAllValuesOfS2(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfS2(final Segment pS1) { + return rawStreamAllValuesOfS2(new Object[]{pS1, null}); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2(final Unreachable.Match partialMatch) { + return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for S2. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfS2(final Segment pS1) { + return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); + } + + @Override + protected Unreachable.Match tupleToMatch(final Tuple t) { + try { + return Unreachable.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected Unreachable.Match arrayToMatch(final Object[] match) { + try { + return Unreachable.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected Unreachable.Match arrayToMatchMutable(final Object[] match) { + try { + return Unreachable.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return Unreachable.instance(); + } + } + + private Unreachable() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static Unreachable instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected Unreachable.Matcher instantiate(final ViatraQueryEngine engine) { + return Unreachable.Matcher.on(engine); + } + + @Override + public Unreachable.Matcher instantiate() { + return Unreachable.Matcher.create(); + } + + @Override + public Unreachable.Match newEmptyMatch() { + return Unreachable.Match.newEmptyMatch(); + } + + @Override + public Unreachable.Match newMatch(final Object... parameters) { + return Unreachable.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link Unreachable} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link Unreachable#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final Unreachable INSTANCE = new Unreachable(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final Unreachable.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_S1, parameter_S2); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "modes3.queries.unreachable"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("S1","S2"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_S1 = body.getOrCreateVariableByName("S1"); + PVariable var_S2 = body.getOrCreateVariableByName("S2"); + new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_S1, parameter_S1), + new ExportedParameter(body, var_S2, parameter_S2) + )); + // neg find reachable(S1, S2) + new NegativePatternCall(body, Tuples.flatTupleOf(var_S1, var_S2), Reachable.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("message", "unreachable"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("S1"), + new ParameterReference("S2") + })); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3ModelGenerator.xtendbin b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3ModelGenerator.xtendbin new file mode 100644 index 00000000..4f542a67 Binary files /dev/null and b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3ModelGenerator.xtendbin differ diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3UnitPropagationGenerator.xtendbin b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3UnitPropagationGenerator.xtendbin new file mode 100644 index 00000000..28e763b9 Binary files /dev/null and b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3UnitPropagationGenerator.xtendbin differ diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.gitignore b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.gitignore new file mode 100644 index 00000000..53dcf60f --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.gitignore @@ -0,0 +1,2 @@ +/.Modes3ModelGenerator.java._trace +/.Modes3UnitPropagationGenerator.java._trace diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java new file mode 100644 index 00000000..c7364257 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java @@ -0,0 +1,381 @@ +package modes3.run; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import hu.bme.mit.inf.dslreasoner.ecore2logic.EReferenceMapper_RelationsOverTypes_Trace; +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration; +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; +import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; +import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsFactory; +import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsPackage; +import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion; +import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder; +import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput; +import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes; +import hu.bme.mit.inf.dslreasoner.logic.model.builder.VariableContext; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Assertion; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Iff; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.SymbolicValue; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TermDescription; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Variable; +import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.Annotation; +import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; +import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage; +import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; +import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult; +import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic; +import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration; +import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicTrace; +import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; +import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.Viatra2LogicAnnotationsPackage; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorConstraints; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorSolver; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy; +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic; +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink; +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation; +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation; +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage; +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.RelationLink; +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.StateCoderStrategy; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; +import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser; +import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; +import java.util.function.Predicate; +import modes3.Modes3Factory; +import modes3.Modes3ModelRoot; +import modes3.Modes3Package; +import modes3.queries.Modes3Queries; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EEnum; +import org.eclipse.emf.ecore.EEnumLiteral; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; +import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions; +import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchEMFBackendFactory; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory; +import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor; +import org.eclipse.xtend2.lib.StringConcatenation; +import org.eclipse.xtext.xbase.lib.CollectionLiterals; +import org.eclipse.xtext.xbase.lib.Exceptions; +import org.eclipse.xtext.xbase.lib.ExclusiveRange; +import org.eclipse.xtext.xbase.lib.Extension; +import org.eclipse.xtext.xbase.lib.Functions.Function1; +import org.eclipse.xtext.xbase.lib.InputOutput; +import org.eclipse.xtext.xbase.lib.IterableExtensions; +import org.eclipse.xtext.xbase.lib.ObjectExtensions; +import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; + +@FinalFieldsConstructor +@SuppressWarnings("all") +public class Modes3ModelGenerator { + private enum MonitoringQuery { + closeTrains, + + misalignedTurnout; + } + + private final Modes3ModelGenerator.MonitoringQuery monitoringQuery; + + private final int modelSize; + + private final Ecore2Logic ecore2Logic = new Ecore2Logic(); + + private final InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic(); + + private final Viatra2Logic viatra2Logic = new Viatra2Logic(this.ecore2Logic); + + private final ViatraReasoner solver = new ViatraReasoner(); + + @Extension + private final LogicProblemBuilder _logicProblemBuilder = new LogicProblemBuilder(); + + public URI generate() { + try { + URI _xblockexpression = null; + { + final EcoreMetamodelDescriptor metamodel = Modes3ModelGenerator.createMetamodelDescriptor(); + Ecore2LogicConfiguration _ecore2LogicConfiguration = new Ecore2LogicConfiguration(); + final TracedOutput metamodelLogic = this.ecore2Logic.transformMetamodel(metamodel, _ecore2LogicConfiguration); + final Type segment = this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getSegment()); + final RelationDeclaration connectedTo = this.ecore2Logic.relationOfReference(metamodelLogic.getTrace(), + Modes3Package.eINSTANCE.getSegment_ConnectedTo()); + final RelationDeclaration connectedToIndicator = ((EReferenceMapper_RelationsOverTypes_Trace) metamodelLogic.getTrace().referenceMapperTrace).indicators.get( + Modes3Package.eINSTANCE.getSegment_ConnectedTo()); + StringConcatenation _builder = new StringConcatenation(); + _builder.append("oppositeReference "); + String _name = connectedTo.getName(); + _builder.append(_name); + _builder.append(" "); + String _name_1 = connectedTo.getName(); + _builder.append(_name_1); + final Function1 _function = (VariableContext it) -> { + Iff _xblockexpression_1 = null; + { + StringConcatenation _builder_1 = new StringConcatenation(); + _builder_1.append("src"); + final Variable src = it.addVar(_builder_1, segment); + StringConcatenation _builder_2 = new StringConcatenation(); + _builder_2.append("trg"); + final Variable trg = it.addVar(_builder_2, segment); + SymbolicValue _call = this._logicProblemBuilder.call(connectedToIndicator, src, trg); + SymbolicValue _call_1 = this._logicProblemBuilder.call(connectedToIndicator, trg, src); + _xblockexpression_1 = this._logicProblemBuilder.operator_spaceship(_call, _call_1); + } + return _xblockexpression_1; + }; + final Assertion inverseAssertion = this._logicProblemBuilder.Assertion(_builder, + this._logicProblemBuilder.Forall(_function)); + EList _assertions = metamodelLogic.getOutput().getAssertions(); + _assertions.add(inverseAssertion); + InverseRelationAssertion _createInverseRelationAssertion = Ecore2logicannotationsFactory.eINSTANCE.createInverseRelationAssertion(); + final Procedure1 _function_1 = (InverseRelationAssertion it) -> { + it.setTarget(inverseAssertion); + it.setInverseA(connectedTo); + it.setInverseB(connectedTo); + }; + final InverseRelationAssertion inverseAnnotation = ObjectExtensions.operator_doubleArrow(_createInverseRelationAssertion, _function_1); + EList _annotations = metamodelLogic.getOutput().getAnnotations(); + _annotations.add(inverseAnnotation); + final List initialModel = Modes3ModelGenerator.loadInitialModel(); + final TracedOutput initialModelLogic = this.instanceModel2Logic.transform(metamodelLogic, initialModel); + final ViatraQuerySetDescriptor queries = this.loadQueries(); + Viatra2LogicConfiguration _viatra2LogicConfiguration = new Viatra2LogicConfiguration(); + final TracedOutput logic = this.viatra2Logic.transformQueries(queries, initialModelLogic, _viatra2LogicConfiguration); + ViatraReasonerConfiguration _viatraReasonerConfiguration = new ViatraReasonerConfiguration(); + final Procedure1 _function_2 = (ViatraReasonerConfiguration it) -> { + it.runtimeLimit = 3600; + final Procedure1 _function_3 = (TypeScopes it_1) -> { + it_1.minNewElements = this.modelSize; + it_1.maxNewElements = this.modelSize; + final Procedure1> _function_4 = (Map it_2) -> { + it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTurnout()), Integer.valueOf(1)); + }; + ObjectExtensions.>operator_doubleArrow( + it_1.minNewElementsByType, _function_4); + final Procedure1> _function_5 = (Map it_2) -> { + it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTrain()), Integer.valueOf(5)); + }; + ObjectExtensions.>operator_doubleArrow( + it_1.maxNewElementsByType, _function_5); + }; + ObjectExtensions.operator_doubleArrow( + it.typeScopes, _function_3); + it.solutionScope.numberOfRequiredSolutions = 1; + it.nameNewElements = false; + it.typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis; + it.stateCoderStrategy = StateCoderStrategy.Neighbourhood; + ScopePropagatorStrategy.Polyhedral _polyhedral = new ScopePropagatorStrategy.Polyhedral( + PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp); + it.scopePropagatorStrategy = _polyhedral; + it.debugConfiguration.partialInterpretatioVisualiser = null; + }; + final ViatraReasonerConfiguration config = ObjectExtensions.operator_doubleArrow(_viatraReasonerConfiguration, _function_2); + final FileSystemWorkspace workspace = new FileSystemWorkspace("output/", ""); + final LogicResult solution = this.solver.solve(logic.getOutput(), config, workspace); + URI _xifexpression = null; + if ((solution instanceof ModelResult)) { + InputOutput.println("Saving generated solutions"); + final EList representations = ((ModelResult)solution).getRepresentation(); + int _size = representations.size(); + ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); + for (final Integer representationIndex : _doubleDotLessThan) { + { + final Object representation = representations.get((representationIndex).intValue()); + final int representationNumber = ((representationIndex).intValue() + 1); + if ((representation instanceof PartialInterpretation)) { + StringConcatenation _builder_1 = new StringConcatenation(); + _builder_1.append("solution"); + _builder_1.append(representationNumber); + _builder_1.append(".partialinterpretation"); + workspace.writeModel(((EObject)representation), _builder_1.toString()); + final PartialInterpretation2Gml partialInterpretation2GML = new PartialInterpretation2Gml(); + final String gml = partialInterpretation2GML.transform(((PartialInterpretation)representation)); + StringConcatenation _builder_2 = new StringConcatenation(); + _builder_2.append("solution"); + _builder_2.append(representationNumber); + _builder_2.append(".gml"); + workspace.writeText(_builder_2.toString(), gml); + int _size_1 = ((PartialInterpretation)representation).getNewElements().size(); + boolean _lessThan = (_size_1 < 160); + if (_lessThan) { + if ((representation instanceof PartialInterpretation)) { + final Consumer _function_3 = (Type it) -> { + InputOutput.println(it.getName()); + }; + ((PartialInterpretation)representation).getProblem().getTypes().forEach(_function_3); + final Function1 _function_4 = (Type it) -> { + String _name_2 = it.getName(); + return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class DefinedPart")); + }; + Type _findFirst = IterableExtensions.findFirst(((PartialInterpretation)representation).getProblem().getTypes(), _function_4); + final TypeDefinition rootType = ((TypeDefinition) _findFirst); + final Function1 _function_5 = (PartialComplexTypeInterpretation it) -> { + String _name_2 = it.getInterpretationOf().getName(); + return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class")); + }; + final PartialComplexTypeInterpretation rootIntepretation = IterableExtensions.findFirst(Iterables.filter(((PartialInterpretation)representation).getPartialtypeinterpratation(), + PartialComplexTypeInterpretation.class), _function_5); + rootIntepretation.getElements().removeAll(rootType.getElements()); + ((PartialInterpretation)representation).getProblem().getElements().removeAll(rootType.getElements()); + EList _partialrelationinterpretation = ((PartialInterpretation)representation).getPartialrelationinterpretation(); + for (final PartialRelationInterpretation relationInterpretation : _partialrelationinterpretation) { + final Predicate _function_6 = (RelationLink link) -> { + boolean _xifexpression_1 = false; + if ((link instanceof BinaryElementRelationLink)) { + _xifexpression_1 = (rootType.getElements().contains(((BinaryElementRelationLink)link).getParam1()) || rootType.getElements().contains(((BinaryElementRelationLink)link).getParam2())); + } else { + _xifexpression_1 = false; + } + return _xifexpression_1; + }; + relationInterpretation.getRelationlinks().removeIf(_function_6); + } + rootType.getElements().clear(); + } + final GraphvizVisualiser visualiser = new GraphvizVisualiser(); + final PartialInterpretationVisualisation visualisation = visualiser.visualiseConcretization(((PartialInterpretation)representation)); + StringConcatenation _builder_3 = new StringConcatenation(); + _builder_3.append("solution"); + _builder_3.append(representationNumber); + _builder_3.append(".png"); + visualisation.writeToFile(workspace, _builder_3.toString()); + } + } else { + StringConcatenation _builder_4 = new StringConcatenation(); + _builder_4.append("solution"); + _builder_4.append(representationNumber); + _builder_4.append(".txt"); + workspace.writeText(_builder_4.toString(), representation.toString()); + } + } + } + } else { + URI _xblockexpression_1 = null; + { + InputOutput.println("Failed to solver problem"); + final LogicProblem partial = logic.getOutput(); + _xblockexpression_1 = workspace.writeModel(partial, "solution.partialinterpretation"); + } + _xifexpression = _xblockexpression_1; + } + _xblockexpression = _xifexpression; + } + return _xblockexpression; + } catch (Throwable _e) { + throw Exceptions.sneakyThrow(_e); + } + } + + public static EcoreMetamodelDescriptor createMetamodelDescriptor() { + EcoreMetamodelDescriptor _xblockexpression = null; + { + final ImmutableList eClasses = ImmutableList.copyOf(Iterables.filter(Modes3Package.eINSTANCE.getEClassifiers(), EClass.class)); + Set _emptySet = CollectionLiterals.emptySet(); + List _emptyList = CollectionLiterals.emptyList(); + List _emptyList_1 = CollectionLiterals.emptyList(); + final Function1> _function = (EClass it) -> { + return it.getEReferences(); + }; + ImmutableList _copyOf = ImmutableList.copyOf(IterableExtensions.flatMap(eClasses, _function)); + List _emptyList_2 = CollectionLiterals.emptyList(); + _xblockexpression = new EcoreMetamodelDescriptor(eClasses, _emptySet, + false, _emptyList, _emptyList_1, _copyOf, _emptyList_2); + } + return _xblockexpression; + } + + public static List loadInitialModel() { + Modes3ModelRoot _createModes3ModelRoot = Modes3Factory.eINSTANCE.createModes3ModelRoot(); + return Collections.unmodifiableList(CollectionLiterals.newArrayList(_createModes3ModelRoot)); + } + + public ViatraQuerySetDescriptor loadQueries() { + ViatraQuerySetDescriptor _xblockexpression = null; + { + final ImmutableList.Builder> patternsBuilder = ImmutableList.>builder(); + patternsBuilder.addAll(Modes3Queries.instance().getSpecifications()); + final ImmutableList> patterns = patternsBuilder.build(); + final Function1, Boolean> _function = (IQuerySpecification pattern) -> { + final Function1 _function_1 = (PAnnotation it) -> { + String _name = it.getName(); + return Boolean.valueOf(Objects.equal(_name, "Constraint")); + }; + return Boolean.valueOf(IterableExtensions.exists(pattern.getAllAnnotations(), _function_1)); + }; + final ImmutableSet> validationPatterns = ImmutableSet.>copyOf(IterableExtensions.>filter(patterns, _function)); + Map, EStructuralFeature> _emptyMap = CollectionLiterals., EStructuralFeature>emptyMap(); + _xblockexpression = new ViatraQuerySetDescriptor(patterns, validationPatterns, _emptyMap); + } + return _xblockexpression; + } + + public static Object init() { + Object _xblockexpression = null; + { + EMFPatternLanguageStandaloneSetup.doSetup(); + ViatraQueryEngineOptions.setSystemDefaultBackends(ReteBackendFactory.INSTANCE, ReteBackendFactory.INSTANCE, + LocalSearchEMFBackendFactory.INSTANCE); + LogiclanguagePackage.eINSTANCE.getClass(); + LogicproblemPackage.eINSTANCE.getClass(); + PartialinterpretationPackage.eINSTANCE.getClass(); + Ecore2logicannotationsPackage.eINSTANCE.getClass(); + Viatra2LogicAnnotationsPackage.eINSTANCE.getClass(); + Map _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); + XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); + _extensionToFactoryMap.put("ecore", _xMIResourceFactoryImpl); + Map _extensionToFactoryMap_1 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); + XMIResourceFactoryImpl _xMIResourceFactoryImpl_1 = new XMIResourceFactoryImpl(); + _extensionToFactoryMap_1.put("logicproblem", _xMIResourceFactoryImpl_1); + Map _extensionToFactoryMap_2 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); + XMIResourceFactoryImpl _xMIResourceFactoryImpl_2 = new XMIResourceFactoryImpl(); + _xblockexpression = _extensionToFactoryMap_2.put("partialinterpretation", _xMIResourceFactoryImpl_2); + } + return _xblockexpression; + } + + public static void main(final String[] args) { + int _length = args.length; + boolean _notEquals = (_length != 2); + if (_notEquals) { + System.err.println("Usage: "); + } + final Modes3ModelGenerator.MonitoringQuery monitoringQuery = Modes3ModelGenerator.MonitoringQuery.valueOf(args[0]); + final int modelSize = Integer.parseInt(args[1]); + Modes3ModelGenerator.init(); + final Modes3ModelGenerator generator = new Modes3ModelGenerator(monitoringQuery, modelSize); + generator.generate(); + } + + public Modes3ModelGenerator(final Modes3ModelGenerator.MonitoringQuery monitoringQuery, final int modelSize) { + super(); + this.monitoringQuery = monitoringQuery; + this.modelSize = modelSize; + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3UnitPropagationGenerator.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3UnitPropagationGenerator.java new file mode 100644 index 00000000..91adaaaa --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3UnitPropagationGenerator.java @@ -0,0 +1,585 @@ +package modes3.run; + +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.UnitPropagationPatternGenerator; +import java.util.Collections; +import java.util.Map; +import modes3.Modes3Package; +import modes3.queries.ExtraInputOfTurnout; +import modes3.queries.Output; +import modes3.queries.TurnoutOutput; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; +import org.eclipse.xtend2.lib.StringConcatenationClient; +import org.eclipse.xtext.xbase.lib.CollectionLiterals; +import org.eclipse.xtext.xbase.lib.Extension; +import org.eclipse.xtext.xbase.lib.Pair; + +@SuppressWarnings("all") +public class Modes3UnitPropagationGenerator implements UnitPropagationPatternGenerator { + private static final String MUST_NOT_CONNECTED_TO = "mustNotConnectedTo"; + + private static final String MUST_NOT_CONNECTED_TO_HELPER = "mustNotConnectedTo_helper"; + + private static final String MUST_NOT_TURNOUT_OUTPUT = "mustNotTurnoutOutput"; + + private static final String MUST_NOT_STRAIGHT = "mustNotStraight"; + + private static final String MUST_NOT_DIVERGENT = "mustNotDivergent"; + + private final Type segmentType; + + private final Type turnoutType; + + private final Relation connectedToRelation; + + private final Relation straightRelation; + + private final Relation divergentRelation; + + public Modes3UnitPropagationGenerator(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { + @Extension + final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; + this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); + this.turnoutType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTurnout()); + this.connectedToRelation = ecore2Logic.relationOfReference(ecore2LogicTrace, Modes3Package.getSegment_ConnectedTo()); + this.straightRelation = ecore2Logic.relationOfReference(ecore2LogicTrace, Modes3Package.getTurnout_Straight()); + this.divergentRelation = ecore2Logic.relationOfReference(ecore2LogicTrace, Modes3Package.getTurnout_Divergent()); + } + + @Override + public Map getMustPatterns() { + return CollectionLiterals.emptyMap(); + } + + @Override + public Map getMustNotPatterns() { + Pair _mappedTo = Pair.of(this.connectedToRelation, Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO); + Pair _mappedTo_1 = Pair.of(this.straightRelation, Modes3UnitPropagationGenerator.MUST_NOT_STRAIGHT); + Pair _mappedTo_2 = Pair.of(this.divergentRelation, Modes3UnitPropagationGenerator.MUST_NOT_DIVERGENT); + return Collections.unmodifiableMap(CollectionLiterals.newHashMap(_mappedTo, _mappedTo_1, _mappedTo_2)); + } + + @Override + public StringConcatenationClient getAdditionalPatterns(@Extension final PatternGenerator generator, final Map fqnToPQuery) { + StringConcatenationClient _xblockexpression = null; + { + StringConcatenationClient _client = new StringConcatenationClient() { + @Override + protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { + _builder.append("problem: LogicProblem, interpretation: PartialInterpretation,"); + _builder.newLine(); + _builder.append("source: DefinedElement, target: DefinedElement"); + _builder.newLine(); + } + }; + final StringConcatenationClient parameters = _client; + StringConcatenationClient _client_1 = new StringConcatenationClient() { + @Override + protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { + _builder.append("find interpretation(problem, interpretation);"); + _builder.newLine(); + _builder.append("find mustExist(problem, interpretation, source);"); + _builder.newLine(); + _builder.append("find mustExist(problem, interpretation, target);"); + _builder.newLine(); + } + }; + final StringConcatenationClient commonParameterConstraints = _client_1; + StringConcatenationClient _client_2 = new StringConcatenationClient() { + @Override + protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { + _builder.append("pattern "); + _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO_HELPER); + _builder.append("("); + _builder.append(parameters); + _builder.append(") {"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("// connectedToReflexive unit propagation"); + _builder.newLine(); + _builder.append("\t"); + _builder.append(commonParameterConstraints, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "source"); + _builder.append(_referInstanceOf, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_1 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "target"); + _builder.append(_referInstanceOf_1, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("source == target;"); + _builder.newLine(); + _builder.append("} or {"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("// tooManyInputsOfSegment unit propagation"); + _builder.newLine(); + _builder.append("\t"); + _builder.append(commonParameterConstraints, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_2 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "source"); + _builder.append(_referInstanceOf_2, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_3 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "target"); + _builder.append(_referInstanceOf_3, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_4 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "input1"); + _builder.append(_referInstanceOf_4, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_5 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "input2"); + _builder.append(_referInstanceOf_5, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("neg "); + CharSequence _referInstanceOf_6 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); + _builder.append(_referInstanceOf_6, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referPattern = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "input1", "source" }, Modality.MUST, true, false); + _builder.append(_referPattern, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referPattern_1 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "input2", "source" }, Modality.MUST, true, false); + _builder.append(_referPattern_1, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("input1 != input2;"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("input1 != target;"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("input2 != target;"); + _builder.newLine(); + _builder.append("} or {"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("// turnoutConnectedToBothOutputs unit propagation 1"); + _builder.newLine(); + _builder.append("\t"); + _builder.append(commonParameterConstraints, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_7 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "source"); + _builder.append(_referInstanceOf_7, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_8 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "target"); + _builder.append(_referInstanceOf_8, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_9 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "divergent"); + _builder.append(_referInstanceOf_9, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_1 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "divergent", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_1, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_2 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "divergent", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_2, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("} or {"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("// turnoutConnectedToBothOutputs unit propagation 2"); + _builder.newLine(); + _builder.append("\t"); + _builder.append(commonParameterConstraints, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_10 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "source"); + _builder.append(_referInstanceOf_10, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_11 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "target"); + _builder.append(_referInstanceOf_11, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_12 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "straight"); + _builder.append(_referInstanceOf_12, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_3 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "straight", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_3, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_4 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_4, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_5 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "straight", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_5, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("} or {"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("// tooManyExtraInputsOfTurnout unit propagation"); + _builder.newLine(); + _builder.append("\t"); + _builder.append(commonParameterConstraints, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_13 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "source"); + _builder.append(_referInstanceOf_13, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_14 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "target"); + _builder.append(_referInstanceOf_14, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_15 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "extraInput"); + _builder.append(_referInstanceOf_15, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referPattern_2 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(TurnoutOutput.instance().getFullyQualifiedName()), new String[] { "source", "target" }, Modality.MAY, false, false); + _builder.append(_referPattern_2, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referPattern_3 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(ExtraInputOfTurnout.instance().getFullyQualifiedName()), new String[] { "source", "extraInput" }, Modality.MUST, true, false); + _builder.append(_referPattern_3, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("target != extraInput;"); + _builder.newLine(); + _builder.append("}"); + _builder.newLine(); + _builder.newLine(); + _builder.append("pattern "); + _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO); + _builder.append("("); + _builder.append(parameters); + _builder.append(") {"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("find "); + _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO_HELPER, "\t"); + _builder.append("(problem, interpretation, source, target);"); + _builder.newLineIfNotEmpty(); + _builder.append("} or {"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("find "); + _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO_HELPER, "\t"); + _builder.append("(problem, interpretation, target, source);"); + _builder.newLineIfNotEmpty(); + _builder.append("}"); + _builder.newLine(); + _builder.newLine(); + _builder.append("pattern "); + _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_TURNOUT_OUTPUT); + _builder.append("("); + _builder.append(parameters); + _builder.append(") {"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("// outputReflexive unit propagation"); + _builder.newLine(); + _builder.append("\t"); + _builder.append(commonParameterConstraints, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_16 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "source"); + _builder.append(_referInstanceOf_16, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_17 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "target"); + _builder.append(_referInstanceOf_17, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("source == target;"); + _builder.newLine(); + _builder.append("} or {"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("// tooManyInputsOfSegment unit propagation"); + _builder.newLine(); + _builder.append("\t"); + _builder.append(commonParameterConstraints, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_18 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "source"); + _builder.append(_referInstanceOf_18, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_19 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "target"); + _builder.append(_referInstanceOf_19, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_20 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "input1"); + _builder.append(_referInstanceOf_20, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_21 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "input2"); + _builder.append(_referInstanceOf_21, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("neg "); + CharSequence _referInstanceOf_22 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "target"); + _builder.append(_referInstanceOf_22, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referPattern_4 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "input1", "target" }, Modality.MUST, true, false); + _builder.append(_referPattern_4, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referPattern_5 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "input2", "target" }, Modality.MUST, true, false); + _builder.append(_referPattern_5, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("input1 != input2;"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("input1 != source;"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("input2 != source;"); + _builder.newLine(); + _builder.append("}"); + _builder.newLine(); + _builder.newLine(); + _builder.append("pattern "); + _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_STRAIGHT); + _builder.append("("); + _builder.append(parameters); + _builder.append(") {"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("find "); + _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_TURNOUT_OUTPUT, "\t"); + _builder.append("(problem, interpretation, source, target);"); + _builder.newLineIfNotEmpty(); + _builder.append("} or {"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("// turnoutOutputsAreSame unit propagation"); + _builder.newLine(); + _builder.append("\t"); + _builder.append(commonParameterConstraints, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_23 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "source"); + _builder.append(_referInstanceOf_23, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_24 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "target"); + _builder.append(_referInstanceOf_24, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_6 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_6, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("} or {"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("// turnoutConnectedToBothOutputs unit propagation"); + _builder.newLine(); + _builder.append("\t"); + _builder.append(commonParameterConstraints, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_25 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "source"); + _builder.append(_referInstanceOf_25, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_26 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "target"); + _builder.append(_referInstanceOf_26, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_27 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "divergent"); + _builder.append(_referInstanceOf_27, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_7 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "target", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_7, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_8 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "divergent", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_8, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_9 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "divergent", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_9, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("} or {"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("// tooManyExtraInputsOfTurnout unit propagation"); + _builder.newLine(); + _builder.append("\t"); + _builder.append(commonParameterConstraints, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_28 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "source"); + _builder.append(_referInstanceOf_28, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_29 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "target"); + _builder.append(_referInstanceOf_29, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_30 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "extraInput"); + _builder.append(_referInstanceOf_30, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_31 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "potentialExtraInput"); + _builder.append(_referInstanceOf_31, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referPattern_6 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(ExtraInputOfTurnout.instance().getFullyQualifiedName()), new String[] { "source", "extraInput" }, Modality.MUST, true, false); + _builder.append(_referPattern_6, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_10 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "potentialExtraInput", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_10, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("neg "); + CharSequence _referRelation_11 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "potentialExtraInput", Modality.MAY, fqnToPQuery); + _builder.append(_referRelation_11, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("extraInput != potentialExtraInput;"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("extraInput != target;"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("potentialExtraInput != target;"); + _builder.newLine(); + _builder.append("}"); + _builder.newLine(); + _builder.newLine(); + _builder.append("pattern "); + _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_DIVERGENT); + _builder.append("("); + _builder.append(parameters); + _builder.append(") {"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("find "); + _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_TURNOUT_OUTPUT, "\t"); + _builder.append("(problem, interpretation, source, target);"); + _builder.newLineIfNotEmpty(); + _builder.append("} or {"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("// turnoutOutputsAreSame unit propagation"); + _builder.newLine(); + _builder.append("\t"); + _builder.append(commonParameterConstraints, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_32 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "source"); + _builder.append(_referInstanceOf_32, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_33 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "target"); + _builder.append(_referInstanceOf_33, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_12 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_12, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("} or {"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("// turnoutConnectedToBothOutputs unit propagation"); + _builder.newLine(); + _builder.append("\t"); + _builder.append(commonParameterConstraints, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_34 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "source"); + _builder.append(_referInstanceOf_34, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_35 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "target"); + _builder.append(_referInstanceOf_35, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_36 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "straight"); + _builder.append(_referInstanceOf_36, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_13 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "target", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_13, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_14 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "straight", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_14, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_15 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "straight", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_15, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("} or {"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("// tooManyExtraInputsOfTurnout unit propagation"); + _builder.newLine(); + _builder.append("\t"); + _builder.append(commonParameterConstraints, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_37 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "source"); + _builder.append(_referInstanceOf_37, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_38 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "target"); + _builder.append(_referInstanceOf_38, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_39 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "extraInput"); + _builder.append(_referInstanceOf_39, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referInstanceOf_40 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "potentialExtraInput"); + _builder.append(_referInstanceOf_40, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referPattern_7 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(ExtraInputOfTurnout.instance().getFullyQualifiedName()), new String[] { "source", "extraInput" }, Modality.MUST, true, false); + _builder.append(_referPattern_7, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + CharSequence _referRelation_16 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "potentialExtraInput", Modality.MUST, fqnToPQuery); + _builder.append(_referRelation_16, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("neg "); + CharSequence _referRelation_17 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "potentialExtraInput", Modality.MAY, fqnToPQuery); + _builder.append(_referRelation_17, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("extraInput != potentialExtraInput;"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("extraInput != target;"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("potentialExtraInput != target;"); + _builder.newLine(); + _builder.append("}"); + _builder.newLine(); + } + }; + _xblockexpression = _client_2; + } + return _xblockexpression; + } +} diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend index 56beacfa..431ae386 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend @@ -17,6 +17,7 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Z3Polyhe import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.GeneratedPatterns import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.ModalPatternQueries import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternProvider +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.UnitPropagationPatternGenerator import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.rules.GoalConstraintProvider import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.rules.RefinementRuleProvider import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation @@ -116,6 +117,7 @@ class ModelGenerationMethodProvider { boolean calculateObjectCreationCosts, ScopePropagatorStrategy scopePropagatorStrategy, Collection hints, + Collection unitPropagationPatternGenerators, DocumentationLevel debugLevel ) { val statistics = new ModelGenerationStatistics @@ -126,7 +128,8 @@ class ModelGenerationMethodProvider { val relationConstraints = relationConstraintCalculator.calculateRelationConstraints(logicProblem) val queries = patternProvider.generateQueries(logicProblem, emptySolution, statistics, existingQueries, - workspace, typeInferenceMethod, scopePropagatorStrategy, relationConstraints, hints, writeFiles) + workspace, typeInferenceMethod, scopePropagatorStrategy, relationConstraints, hints, + unitPropagationPatternGenerators, writeFiles) val scopePropagator = createScopePropagator(scopePropagatorStrategy, emptySolution, hints, queries, statistics) scopePropagator.propagateAllScopeConstraints diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend index 80bc3844..a3efcf76 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend @@ -25,12 +25,13 @@ import java.util.HashMap import java.util.Map import org.eclipse.emf.ecore.EAttribute import org.eclipse.emf.ecore.EReference +import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery import org.eclipse.xtend.lib.annotations.Accessors +import org.eclipse.xtend.lib.annotations.Data +import org.eclipse.xtend2.lib.StringConcatenationClient import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* -import org.eclipse.xtend.lib.annotations.Data -import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint @Data class PatternGeneratorResult { CharSequence patternText @@ -38,6 +39,14 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint HashMap constraint2CurrentPreconditionName } +interface UnitPropagationPatternGenerator { + def Map getMustPatterns() + + def Map getMustNotPatterns() + + def StringConcatenationClient getAdditionalPatterns(PatternGenerator generator, Map fqn2PQuery) +} + class PatternGenerator { @Accessors(PUBLIC_GETTER) val TypeIndexer typeIndexer // = new TypeIndexer(this) @Accessors(PUBLIC_GETTER) val RelationDeclarationIndexer relationDeclarationIndexer = new RelationDeclarationIndexer( @@ -157,7 +166,8 @@ class PatternGenerator { Map fqn2PQuery, TypeAnalysisResult typeAnalysisResult, RelationConstraints constraints, - Collection hints + Collection hints, + Collection unitPropagationPatternGenerators ) { val first = ''' @@ -313,7 +323,7 @@ class PatternGenerator { ////////// // 1.2 Relation Declaration Indexers ////////// - «relationDeclarationIndexer.generateRelationIndexers(problem,problem.relations.filter(RelationDeclaration),fqn2PQuery)» + «relationDeclarationIndexer.generateRelationIndexers(problem,problem.relations.filter(RelationDeclaration),unitPropagationPatternGenerators,fqn2PQuery)» ////////// // 1.3 Relation Definition Indexers @@ -367,6 +377,9 @@ class PatternGenerator { «FOR hint : hints» «hint.getAdditionalPatterns(this)» «ENDFOR» + «FOR generator : unitPropagationPatternGenerators» + «generator.getAdditionalPatterns(this, fqn2PQuery)» + «ENDFOR» ////////// // 6 Unit Propagations diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend index d57705ce..21fd1989 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend @@ -36,9 +36,9 @@ import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* public Map>> unfinishedWFQueries public Map multiplicityConstraintQueries public IQuerySpecification> hasElementInContainmentQuery - public Map>> refineObjectQueries + public Map>> refineObjectQueries public Map>> refineTypeQueries - public Map, IQuerySpecification>> refinerelationQueries + public Map, IQuerySpecification>> refinerelationQueries public Map>> mustUnitPropagationPreconditionPatterns public Map>> currentUnitPropagationPreconditionPatterns public Map modalRelationQueries @@ -56,7 +56,7 @@ class ModalPatternQueries { class UnifinishedMultiplicityQueries { val IQuerySpecification> existingMultiplicityQuery val IQuerySpecification> existingInverseMultiplicityQuery - + def Set>> getAllQueries() { val builder = ImmutableSet.builder if (existingMultiplicityQuery !== null) { @@ -75,8 +75,9 @@ class PatternProvider { def generateQueries(LogicProblem problem, PartialInterpretation emptySolution, ModelGenerationStatistics statistics, Set existingQueries, ReasonerWorkspace workspace, TypeInferenceMethod typeInferenceMethod, - ScopePropagatorStrategy scopePropagatorStrategy, RelationConstraints relationConstraints, - Collection hints, boolean writeToFile) { + ScopePropagatorStrategy scopePropagatorStrategy, RelationConstraints relationConstraints, + Collection hints, + Collection unitPropagationPatternGenerators, boolean writeToFile) { val fqn2Query = existingQueries.toMap[it.fullyQualifiedName] val PatternGenerator patternGenerator = new PatternGenerator(typeInferenceMethod, scopePropagatorStrategy) val typeAnalysisResult = if (patternGenerator.requiresTypeAnalysis) { @@ -89,15 +90,15 @@ class PatternProvider { null } val patternGeneratorResult = patternGenerator.transformBaseProperties(problem, emptySolution, fqn2Query, - typeAnalysisResult, relationConstraints, hints) + typeAnalysisResult, relationConstraints, hints, unitPropagationPatternGenerators) if (writeToFile) { workspace.writeText('''generated3valued.vql_deactivated''', patternGeneratorResult.patternText) } val ParseUtil parseUtil = new ParseUtil val generatedQueries = parseUtil.parse(patternGeneratorResult.patternText) val runtimeQueries = calclulateRuntimeQueries(patternGenerator, problem, emptySolution, typeAnalysisResult, - patternGeneratorResult.constraint2MustPreconditionName, patternGeneratorResult.constraint2CurrentPreconditionName, - relationConstraints, generatedQueries) + patternGeneratorResult.constraint2MustPreconditionName, + patternGeneratorResult.constraint2CurrentPreconditionName, relationConstraints, generatedQueries) return runtimeQueries } @@ -111,12 +112,13 @@ class PatternProvider { RelationConstraints relationConstraints, Map>> queries ) { - val Map>> - invalidWFQueries = patternGenerator.invalidIndexer.getInvalidateByWfQueryNames(problem).mapValues[it.lookup(queries)] - val Map>> - unfinishedWFQueries = patternGenerator.unfinishedIndexer.getUnfinishedWFQueryNames(problem).mapValues[it.lookup(queries)] - - val unfinishedMultiplicities = patternGenerator.unfinishedIndexer.getUnfinishedMultiplicityQueries(relationConstraints.multiplicityConstraints) + val Map>> invalidWFQueries = patternGenerator. + invalidIndexer.getInvalidateByWfQueryNames(problem).mapValues[it.lookup(queries)] + val Map>> unfinishedWFQueries = patternGenerator. + unfinishedIndexer.getUnfinishedWFQueryNames(problem).mapValues[it.lookup(queries)] + + val unfinishedMultiplicities = patternGenerator.unfinishedIndexer.getUnfinishedMultiplicityQueries( + relationConstraints.multiplicityConstraints) val multiplicityConstraintQueries = unfinishedMultiplicities.mapValues [ new UnifinishedMultiplicityQueries(existingMultiplicityQueryName?.lookup(queries), existingInverseMultiplicityQueryName?.lookup(queries)) @@ -124,16 +126,20 @@ class PatternProvider { val hasElementInContainmentQuery = patternGenerator.typeRefinementGenerator.hasElementInContainmentName.lookup( queries) - val Map>> - refineObjectsQueries = patternGenerator.typeRefinementGenerator.getRefineObjectQueryNames(problem,emptySolution,typeAnalysisResult).mapValues[it.lookup(queries)] - val Map>> - refineTypeQueries = patternGenerator.typeRefinementGenerator.getRefineTypeQueryNames(problem,emptySolution,typeAnalysisResult).mapValues[it.lookup(queries)] - val Map, IQuerySpecification>> - refineRelationQueries = patternGenerator.relationRefinementGenerator.getRefineRelationQueries(problem).mapValues[it.lookup(queries)] - val Map>> - mustUnitPropagationPreconditionPatterns = mustUnitPropagationTrace.mapValues[it.lookup(queries)] - val Map>> - currentUnitPropagationPreconditionPatterns = currentUnitPropagationTrace.mapValues[it.lookup(queries)] + val Map>> refineObjectsQueries = patternGenerator. + typeRefinementGenerator.getRefineObjectQueryNames(problem, emptySolution, typeAnalysisResult).mapValues [ + it.lookup(queries) + ] + val Map>> refineTypeQueries = patternGenerator. + typeRefinementGenerator.getRefineTypeQueryNames(problem, emptySolution, typeAnalysisResult).mapValues [ + it.lookup(queries) + ] + val Map, IQuerySpecification>> refineRelationQueries = patternGenerator. + relationRefinementGenerator.getRefineRelationQueries(problem).mapValues[it.lookup(queries)] + val Map>> mustUnitPropagationPreconditionPatterns = mustUnitPropagationTrace. + mapValues[it.lookup(queries)] + val Map>> currentUnitPropagationPreconditionPatterns = currentUnitPropagationTrace. + mapValues[it.lookup(queries)] val modalRelationQueries = problem.relations.filter(RelationDefinition).toMap([it], [ relationDefinition | val indexer = patternGenerator.relationDefinitionIndexer @@ -143,7 +149,7 @@ class PatternProvider { indexer.relationDefinitionName(relationDefinition, Modality.CURRENT).lookup(queries) ) ]) - + return new GeneratedPatterns( invalidWFQueries, unfinishedWFQueries, diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDeclarationIndexer.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDeclarationIndexer.xtend index b4403979..29d3eb61 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDeclarationIndexer.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDeclarationIndexer.xtend @@ -1,10 +1,13 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns +import com.google.common.collect.ImmutableMap +import com.google.common.collect.ImmutableSet import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.UpperMultiplicityAssertion import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality +import java.util.Collection import java.util.HashMap import java.util.List import java.util.Map @@ -14,41 +17,40 @@ import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* class RelationDeclarationIndexer { val PatternGenerator base; - + new(PatternGenerator base) { this.base = base } - - def generateRelationIndexers(LogicProblem problem, Iterable relations, Map fqn2PQuery) { + + def generateRelationIndexers(LogicProblem problem, Iterable relations, + Iterable unitPropagationPatternGenerators, Map fqn2PQuery) { val upperMultiplicities = new HashMap - problem.annotations.filter(UpperMultiplicityAssertion).forEach[ - upperMultiplicities.put(it.relation,it.upper) + problem.annotations.filter(UpperMultiplicityAssertion).forEach [ + upperMultiplicities.put(it.relation, it.upper) ] - + val mustNotRelations = ImmutableMap.copyOf(unitPropagationPatternGenerators.flatMap[mustNotPatterns.entrySet]. + groupBy[key].mapValues[ImmutableSet.copyOf(map[value])]) + return ''' - «FOR relation : relations» - «IF base.isDerived(relation)» - «generateDerivedMustRelation(problem,relation,base.getDerivedDefinition(relation).patternFullyQualifiedName.lookup(fqn2PQuery))» - «generateDerivedMayRelation(problem,relation,base.getDerivedDefinition(relation).patternFullyQualifiedName.lookup(fqn2PQuery))» - «ELSE» - «generateMustRelation(problem,relation)» - «generateMayRelation(problem,relation,upperMultiplicities,base.getContainments(problem),base.getInverseRelations(problem),fqn2PQuery)» - «ENDIF» - «ENDFOR» + «FOR relation : relations» + «IF base.isDerived(relation)» + «generateDerivedMustRelation(problem,relation,base.getDerivedDefinition(relation).patternFullyQualifiedName.lookup(fqn2PQuery))» + «generateDerivedMayRelation(problem,relation,base.getDerivedDefinition(relation).patternFullyQualifiedName.lookup(fqn2PQuery))» + «ELSE» + «generateMustRelation(problem, relation)» + «generateMayRelation(problem, relation, upperMultiplicities, base.getContainments(problem), base.getInverseRelations(problem), mustNotRelations.get(relation) ?: emptySet, fqn2PQuery)» + «ENDIF» + «ENDFOR» ''' } - + def private patternName(RelationDeclaration r, Modality modality) { '''«modality.name.toLowerCase»InRelation«base.canonizeName(r.name)»''' } - - def referRelation( - RelationDeclaration referred, - String sourceVariable, - String targetVariable, - Modality modality) - '''find «referred.patternName(modality)»(problem,interpretation,«sourceVariable»,«targetVariable»);''' - + + def referRelation(RelationDeclaration referred, String sourceVariable, String targetVariable, + Modality modality) '''find «referred.patternName(modality)»(problem,interpretation,«sourceVariable»,«targetVariable»);''' + def generateMustRelation(LogicProblem problem, RelationDeclaration relation) ''' /** * Matcher for detecting tuples t where []«relation.name»(source,target) @@ -65,59 +67,64 @@ class RelationDeclarationIndexer { BinaryElementRelationLink.param2(link,target); } ''' + def generateMayRelation(LogicProblem problem, RelationDeclaration relation, - Map upperMultiplicities, - List containments, - HashMap inverseRelations, - Map fqn2PQuery) - { + Map upperMultiplicities, List containments, + HashMap inverseRelations, Collection mustNotRelations, + Map fqn2PQuery) { return ''' - /** - * Matcher for detecting tuples t where <>«relation.name»(source,target) - */ - private pattern «relation.patternName(Modality.MAY)»( - problem:LogicProblem, interpretation:PartialInterpretation, - source: DefinedElement, target:DefinedElement) - { - find interpretation(problem,interpretation); - // The two endpoint of the link have to exist - find mayExist(problem, interpretation, source); - find mayExist(problem, interpretation, target); - // Type consistency - «base.typeIndexer.referInstanceOfByReference(relation.parameters.get(0),Modality.MAY,"source")» - «base.typeIndexer.referInstanceOfByReference(relation.parameters.get(1),Modality.MAY,"target")» - «IF upperMultiplicities.containsKey(relation)» - // There are "numberOfExistingReferences" currently existing instances of the reference from the source, - // the upper bound of the multiplicity should be considered. - numberOfExistingReferences == count «referRelation(relation,"source","_",Modality.MUST)» - numberOfExistingReferences != «upperMultiplicities.get(relation)»; - «ENDIF» - «IF inverseRelations.containsKey(relation) && upperMultiplicities.containsKey(inverseRelations.get(relation))» - // There are "numberOfExistingReferences" currently existing instances of the reference to the target, - // the upper bound of the opposite reference multiplicity should be considered. - numberOfExistingOppositeReferences == count «base.referRelation(inverseRelations.get(relation),"target","_",Modality.MUST,fqn2PQuery)» - numberOfExistingOppositeReferences != «upperMultiplicities.get(inverseRelations.get(relation))»; - «ENDIF» - «IF containments.contains(relation)» - // The reference is containment, then a new reference cannot be create if: - // 1. Multiple parents - neg «base.containmentIndexer.referMustContaint("_","target")» - // 2. Circle in the containment hierarchy - neg «base.containmentIndexer.referTransitiveMustContains("target","source")» - «ENDIF» - «IF inverseRelations.containsKey(relation) && containments.contains(inverseRelations.get(relation))» - // The eOpposite of the reference is containment, then a referene cannot be created if - // 1. Multiple parents - neg «base.containmentIndexer.referMustContaint("source","_")» - // 2. Circle in the containment hierarchy - neg «base.containmentIndexer.referTransitiveMustContains("source","target")» - «ENDIF» - } or { - «relation.referRelation("source","target",Modality.MUST)» - } - ''' + /** + * Matcher for detecting tuples t where <>«relation.name»(source,target) + */ + private pattern «relation.patternName(Modality.MAY)»( + problem:LogicProblem, interpretation:PartialInterpretation, + source: DefinedElement, target:DefinedElement) + { + find interpretation(problem,interpretation); + // The two endpoint of the link have to exist + find mayExist(problem, interpretation, source); + find mayExist(problem, interpretation, target); + // Type consistency + «base.typeIndexer.referInstanceOfByReference(relation.parameters.get(0),Modality.MAY,"source")» + «base.typeIndexer.referInstanceOfByReference(relation.parameters.get(1),Modality.MAY,"target")» + «IF upperMultiplicities.containsKey(relation)» + // There are "numberOfExistingReferences" currently existing instances of the reference from the source, + // the upper bound of the multiplicity should be considered. + numberOfExistingReferences == count «referRelation(relation,"source","_",Modality.MUST)» + numberOfExistingReferences != «upperMultiplicities.get(relation)»; + «ENDIF» + «IF inverseRelations.containsKey(relation) && upperMultiplicities.containsKey(inverseRelations.get(relation))» + // There are "numberOfExistingReferences" currently existing instances of the reference to the target, + // the upper bound of the opposite reference multiplicity should be considered. + numberOfExistingOppositeReferences == count «base.referRelation(inverseRelations.get(relation),"target","_",Modality.MUST,fqn2PQuery)» + numberOfExistingOppositeReferences != «upperMultiplicities.get(inverseRelations.get(relation))»; + «ENDIF» + «IF containments.contains(relation)» + // The reference is containment, then a new reference cannot be create if: + // 1. Multiple parents + neg «base.containmentIndexer.referMustContaint("_","target")» + // 2. Circle in the containment hierarchy + neg «base.containmentIndexer.referTransitiveMustContains("target","source")» + «ENDIF» + «IF inverseRelations.containsKey(relation) && containments.contains(inverseRelations.get(relation))» + // The eOpposite of the reference is containment, then a referene cannot be created if + // 1. Multiple parents + neg «base.containmentIndexer.referMustContaint("source","_")» + // 2. Circle in the containment hierarchy + neg «base.containmentIndexer.referTransitiveMustContains("source","target")» + «ENDIF» + «IF mustNotRelations.empty» + // ![] unit propagation relations + «FOR mustNotRelation : mustNotRelations» + neg find «mustNotRelation»(problem, interpretation, source, target); + «ENDFOR» + «ENDIF» + } or { + «relation.referRelation("source","target",Modality.MUST)» + } + ''' } - + def generateDerivedMustRelation(LogicProblem problem, RelationDeclaration relation, PQuery definition) ''' /** * Matcher for detecting tuples t where []«relation.name»(source,target) @@ -129,6 +136,7 @@ class RelationDeclarationIndexer { «base.relationDefinitionIndexer.referPattern(definition,#["source","target"],Modality::MUST,true,false)» } ''' + def generateDerivedMayRelation(LogicProblem problem, RelationDeclaration relation, PQuery definition) ''' /** * Matcher for detecting tuples t where []«relation.name»(source,target) @@ -140,4 +148,4 @@ class RelationDeclarationIndexer { «base.relationDefinitionIndexer.referPattern(definition,#["source","target"],Modality::MAY,true,false)» } ''' -} \ No newline at end of file +} diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend index c333feca..67d25208 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend @@ -91,6 +91,7 @@ class ViatraReasoner extends LogicReasoner { viatraConfig.calculateObjectCreationCosts, viatraConfig.scopePropagatorStrategy, viatraConfig.hints, + viatraConfig.unitPropagationPatternGenerators, viatraConfig.documentationLevel ) diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend index 0173124c..a2ed6016 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend @@ -6,9 +6,11 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethod import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorConstraints import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorSolver import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.UnitPropagationPatternGenerator import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualiser import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold @@ -16,7 +18,6 @@ import java.util.LinkedList import java.util.List import java.util.Set import org.eclipse.xtext.xbase.lib.Functions.Function1 -import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint enum StateCoderStrategy { Neighbourhood, @@ -77,6 +78,8 @@ class ViatraReasonerConfiguration extends LogicSolverConfiguration { public var List hints = newArrayList public var List costObjectives = newArrayList + + public var List unitPropagationPatternGenerators = newArrayList } class DiversityDescriptor { -- cgit v1.2.3-70-g09d2