diff options
author | 2020-11-04 01:16:22 -0500 | |
---|---|---|
committer | 2020-11-04 01:16:22 -0500 | |
commit | 93243cb3faf1ccd733081fcf380559ac03c9ad35 (patch) | |
tree | 421f9f174eb77c387b5acaa05f01e64a62cab3a7 /Domains | |
parent | add realistic solver (diff) | |
parent | Optimizing generator with linear objective functions (diff) | |
download | VIATRA-Generator-93243cb3faf1ccd733081fcf380559ac03c9ad35.tar.gz VIATRA-Generator-93243cb3faf1ccd733081fcf380559ac03c9ad35.tar.zst VIATRA-Generator-93243cb3faf1ccd733081fcf380559ac03c9ad35.zip |
merge with current master, comment numerical solver related logging
Diffstat (limited to 'Domains')
189 files changed, 46893 insertions, 422 deletions
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/.project b/Domains/Examples/ModelGenExampleFAM_plugin/.project index 70920828..570f8a60 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/.project +++ b/Domains/Examples/ModelGenExampleFAM_plugin/.project | |||
@@ -6,12 +6,12 @@ | |||
6 | </projects> | 6 | </projects> |
7 | <buildSpec> | 7 | <buildSpec> |
8 | <buildCommand> | 8 | <buildCommand> |
9 | <name>org.eclipse.viatra.query.tooling.ui.projectbuilder</name> | 9 | <name>org.eclipse.xtext.ui.shared.xtextBuilder</name> |
10 | <arguments> | 10 | <arguments> |
11 | </arguments> | 11 | </arguments> |
12 | </buildCommand> | 12 | </buildCommand> |
13 | <buildCommand> | 13 | <buildCommand> |
14 | <name>org.eclipse.xtext.ui.shared.xtextBuilder</name> | 14 | <name>org.eclipse.viatra.query.tooling.ui.projectbuilder</name> |
15 | <arguments> | 15 | <arguments> |
16 | </arguments> | 16 | </arguments> |
17 | </buildCommand> | 17 | </buildCommand> |
@@ -33,8 +33,8 @@ | |||
33 | </buildSpec> | 33 | </buildSpec> |
34 | <natures> | 34 | <natures> |
35 | <nature>org.eclipse.jdt.core.javanature</nature> | 35 | <nature>org.eclipse.jdt.core.javanature</nature> |
36 | <nature>org.eclipse.xtext.ui.shared.xtextNature</nature> | ||
37 | <nature>org.eclipse.viatra.query.projectnature</nature> | 36 | <nature>org.eclipse.viatra.query.projectnature</nature> |
38 | <nature>org.eclipse.pde.PluginNature</nature> | 37 | <nature>org.eclipse.pde.PluginNature</nature> |
38 | <nature>org.eclipse.xtext.ui.shared.xtextNature</nature> | ||
39 | </natures> | 39 | </natures> |
40 | </projectDescription> | 40 | </projectDescription> |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/FunctionType.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/FunctionType.java index 59fe3fb2..9f2316a0 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/FunctionType.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/FunctionType.java | |||
@@ -205,6 +205,7 @@ public enum FunctionType implements Enumerator { | |||
205 | * <!-- end-user-doc --> | 205 | * <!-- end-user-doc --> |
206 | * @generated | 206 | * @generated |
207 | */ | 207 | */ |
208 | @Override | ||
208 | public int getValue() { | 209 | public int getValue() { |
209 | return value; | 210 | return value; |
210 | } | 211 | } |
@@ -214,6 +215,7 @@ public enum FunctionType implements Enumerator { | |||
214 | * <!-- end-user-doc --> | 215 | * <!-- end-user-doc --> |
215 | * @generated | 216 | * @generated |
216 | */ | 217 | */ |
218 | @Override | ||
217 | public String getName() { | 219 | public String getName() { |
218 | return name; | 220 | return name; |
219 | } | 221 | } |
@@ -223,6 +225,7 @@ public enum FunctionType implements Enumerator { | |||
223 | * <!-- end-user-doc --> | 225 | * <!-- end-user-doc --> |
224 | * @generated | 226 | * @generated |
225 | */ | 227 | */ |
228 | @Override | ||
226 | public String getLiteral() { | 229 | public String getLiteral() { |
227 | return literal; | 230 | return literal; |
228 | } | 231 | } |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/FunctionalData.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/FunctionalData.java index 39639f99..59fa0fd4 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/FunctionalData.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/FunctionalData.java | |||
@@ -60,13 +60,13 @@ public interface FunctionalData extends EObject { | |||
60 | * </p> | 60 | * </p> |
61 | * <!-- end-user-doc --> | 61 | * <!-- end-user-doc --> |
62 | * @return the value of the '<em>Interface</em>' container reference. | 62 | * @return the value of the '<em>Interface</em>' container reference. |
63 | * @see #setInterface(FunctionalInterface) | 63 | * @see #setInterface(functionalarchitecture.FunctionalInterface) |
64 | * @see functionalarchitecture.FunctionalarchitecturePackage#getFunctionalData_Interface() | 64 | * @see functionalarchitecture.FunctionalarchitecturePackage#getFunctionalData_Interface() |
65 | * @see functionalarchitecture.FunctionalInterface#getData | 65 | * @see functionalarchitecture.FunctionalInterface#getData |
66 | * @model opposite="data" transient="false" | 66 | * @model opposite="data" transient="false" |
67 | * @generated | 67 | * @generated |
68 | */ | 68 | */ |
69 | FunctionalInterface getInterface(); | 69 | functionalarchitecture.FunctionalInterface getInterface(); |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * Sets the value of the '{@link functionalarchitecture.FunctionalData#getInterface <em>Interface</em>}' container reference. | 72 | * Sets the value of the '{@link functionalarchitecture.FunctionalData#getInterface <em>Interface</em>}' container reference. |
@@ -76,6 +76,6 @@ public interface FunctionalData extends EObject { | |||
76 | * @see #getInterface() | 76 | * @see #getInterface() |
77 | * @generated | 77 | * @generated |
78 | */ | 78 | */ |
79 | void setInterface(FunctionalInterface value); | 79 | void setInterface(functionalarchitecture.FunctionalInterface value); |
80 | 80 | ||
81 | } // FunctionalData | 81 | } // FunctionalData |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/FunctionalElement.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/FunctionalElement.java index f5a2ff19..5d1d3254 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/FunctionalElement.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/FunctionalElement.java | |||
@@ -33,13 +33,13 @@ public interface FunctionalElement extends EObject { | |||
33 | * </p> | 33 | * </p> |
34 | * <!-- end-user-doc --> | 34 | * <!-- end-user-doc --> |
35 | * @return the value of the '<em>Interface</em>' containment reference. | 35 | * @return the value of the '<em>Interface</em>' containment reference. |
36 | * @see #setInterface(FunctionalInterface) | 36 | * @see #setInterface(functionalarchitecture.FunctionalInterface) |
37 | * @see functionalarchitecture.FunctionalarchitecturePackage#getFunctionalElement_Interface() | 37 | * @see functionalarchitecture.FunctionalarchitecturePackage#getFunctionalElement_Interface() |
38 | * @see functionalarchitecture.FunctionalInterface#getElement | 38 | * @see functionalarchitecture.FunctionalInterface#getElement |
39 | * @model opposite="element" containment="true" | 39 | * @model opposite="element" containment="true" |
40 | * @generated | 40 | * @generated |
41 | */ | 41 | */ |
42 | FunctionalInterface getInterface(); | 42 | functionalarchitecture.FunctionalInterface getInterface(); |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Sets the value of the '{@link functionalarchitecture.FunctionalElement#getInterface <em>Interface</em>}' containment reference. | 45 | * Sets the value of the '{@link functionalarchitecture.FunctionalElement#getInterface <em>Interface</em>}' containment reference. |
@@ -49,7 +49,7 @@ public interface FunctionalElement extends EObject { | |||
49 | * @see #getInterface() | 49 | * @see #getInterface() |
50 | * @generated | 50 | * @generated |
51 | */ | 51 | */ |
52 | void setInterface(FunctionalInterface value); | 52 | void setInterface(functionalarchitecture.FunctionalInterface value); |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * Returns the value of the '<em><b>Model</b></em>' reference. | 55 | * Returns the value of the '<em><b>Model</b></em>' reference. |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FAMTerminatorImpl.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FAMTerminatorImpl.java index 382e0170..94cd240a 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FAMTerminatorImpl.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FAMTerminatorImpl.java | |||
@@ -55,6 +55,7 @@ public class FAMTerminatorImpl extends MinimalEObjectImpl.Container implements F | |||
55 | * <!-- end-user-doc --> | 55 | * <!-- end-user-doc --> |
56 | * @generated | 56 | * @generated |
57 | */ | 57 | */ |
58 | @Override | ||
58 | public FunctionalData getData() { | 59 | public FunctionalData getData() { |
59 | if (eContainerFeatureID() != FunctionalarchitecturePackage.FAM_TERMINATOR__DATA) return null; | 60 | if (eContainerFeatureID() != FunctionalarchitecturePackage.FAM_TERMINATOR__DATA) return null; |
60 | return (FunctionalData)eInternalContainer(); | 61 | return (FunctionalData)eInternalContainer(); |
@@ -75,6 +76,7 @@ public class FAMTerminatorImpl extends MinimalEObjectImpl.Container implements F | |||
75 | * <!-- end-user-doc --> | 76 | * <!-- end-user-doc --> |
76 | * @generated | 77 | * @generated |
77 | */ | 78 | */ |
79 | @Override | ||
78 | public void setData(FunctionalData newData) { | 80 | public void setData(FunctionalData newData) { |
79 | if (newData != eInternalContainer() || (eContainerFeatureID() != FunctionalarchitecturePackage.FAM_TERMINATOR__DATA && newData != null)) { | 81 | if (newData != eInternalContainer() || (eContainerFeatureID() != FunctionalarchitecturePackage.FAM_TERMINATOR__DATA && newData != null)) { |
80 | if (EcoreUtil.isAncestor(this, newData)) | 82 | if (EcoreUtil.isAncestor(this, newData)) |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionImpl.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionImpl.java index 46736c8c..6e89bc65 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionImpl.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionImpl.java | |||
@@ -79,6 +79,7 @@ public class FunctionImpl extends FunctionalElementImpl implements Function { | |||
79 | * <!-- end-user-doc --> | 79 | * <!-- end-user-doc --> |
80 | * @generated | 80 | * @generated |
81 | */ | 81 | */ |
82 | @Override | ||
82 | public EList<FunctionalElement> getSubElements() { | 83 | public EList<FunctionalElement> getSubElements() { |
83 | if (subElements == null) { | 84 | if (subElements == null) { |
84 | subElements = new EObjectContainmentWithInverseEList<FunctionalElement>(FunctionalElement.class, this, FunctionalarchitecturePackage.FUNCTION__SUB_ELEMENTS, FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__PARENT); | 85 | subElements = new EObjectContainmentWithInverseEList<FunctionalElement>(FunctionalElement.class, this, FunctionalarchitecturePackage.FUNCTION__SUB_ELEMENTS, FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__PARENT); |
@@ -91,6 +92,7 @@ public class FunctionImpl extends FunctionalElementImpl implements Function { | |||
91 | * <!-- end-user-doc --> | 92 | * <!-- end-user-doc --> |
92 | * @generated | 93 | * @generated |
93 | */ | 94 | */ |
95 | @Override | ||
94 | public FunctionType getType() { | 96 | public FunctionType getType() { |
95 | return (FunctionType)TYPE__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); | 97 | return (FunctionType)TYPE__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); |
96 | } | 98 | } |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalArchitectureModelImpl.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalArchitectureModelImpl.java index 78f6d6f2..a7d6c919 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalArchitectureModelImpl.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalArchitectureModelImpl.java | |||
@@ -68,6 +68,7 @@ public class FunctionalArchitectureModelImpl extends MinimalEObjectImpl.Containe | |||
68 | * <!-- end-user-doc --> | 68 | * <!-- end-user-doc --> |
69 | * @generated | 69 | * @generated |
70 | */ | 70 | */ |
71 | @Override | ||
71 | public EList<FunctionalElement> getRootElements() { | 72 | public EList<FunctionalElement> getRootElements() { |
72 | if (rootElements == null) { | 73 | if (rootElements == null) { |
73 | rootElements = new EObjectContainmentEList<FunctionalElement>(FunctionalElement.class, this, FunctionalarchitecturePackage.FUNCTIONAL_ARCHITECTURE_MODEL__ROOT_ELEMENTS); | 74 | rootElements = new EObjectContainmentEList<FunctionalElement>(FunctionalElement.class, this, FunctionalarchitecturePackage.FUNCTIONAL_ARCHITECTURE_MODEL__ROOT_ELEMENTS); |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalDataImpl.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalDataImpl.java index 10937e8d..ec8f2cef 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalDataImpl.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalDataImpl.java | |||
@@ -4,7 +4,6 @@ package functionalarchitecture.impl; | |||
4 | 4 | ||
5 | import functionalarchitecture.FAMTerminator; | 5 | import functionalarchitecture.FAMTerminator; |
6 | import functionalarchitecture.FunctionalData; | 6 | import functionalarchitecture.FunctionalData; |
7 | import functionalarchitecture.FunctionalInterface; | ||
8 | import functionalarchitecture.FunctionalarchitecturePackage; | 7 | import functionalarchitecture.FunctionalarchitecturePackage; |
9 | 8 | ||
10 | import org.eclipse.emf.common.notify.Notification; | 9 | import org.eclipse.emf.common.notify.Notification; |
@@ -67,6 +66,7 @@ public abstract class FunctionalDataImpl extends MinimalEObjectImpl.Container im | |||
67 | * <!-- end-user-doc --> | 66 | * <!-- end-user-doc --> |
68 | * @generated | 67 | * @generated |
69 | */ | 68 | */ |
69 | @Override | ||
70 | public FAMTerminator getTerminator() { | 70 | public FAMTerminator getTerminator() { |
71 | return terminator; | 71 | return terminator; |
72 | } | 72 | } |
@@ -91,6 +91,7 @@ public abstract class FunctionalDataImpl extends MinimalEObjectImpl.Container im | |||
91 | * <!-- end-user-doc --> | 91 | * <!-- end-user-doc --> |
92 | * @generated | 92 | * @generated |
93 | */ | 93 | */ |
94 | @Override | ||
94 | public void setTerminator(FAMTerminator newTerminator) { | 95 | public void setTerminator(FAMTerminator newTerminator) { |
95 | if (newTerminator != terminator) { | 96 | if (newTerminator != terminator) { |
96 | NotificationChain msgs = null; | 97 | NotificationChain msgs = null; |
@@ -110,9 +111,10 @@ public abstract class FunctionalDataImpl extends MinimalEObjectImpl.Container im | |||
110 | * <!-- end-user-doc --> | 111 | * <!-- end-user-doc --> |
111 | * @generated | 112 | * @generated |
112 | */ | 113 | */ |
113 | public FunctionalInterface getInterface() { | 114 | @Override |
115 | public functionalarchitecture.FunctionalInterface getInterface() { | ||
114 | if (eContainerFeatureID() != FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE) return null; | 116 | if (eContainerFeatureID() != FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE) return null; |
115 | return (FunctionalInterface)eInternalContainer(); | 117 | return (functionalarchitecture.FunctionalInterface)eInternalContainer(); |
116 | } | 118 | } |
117 | 119 | ||
118 | /** | 120 | /** |
@@ -120,7 +122,7 @@ public abstract class FunctionalDataImpl extends MinimalEObjectImpl.Container im | |||
120 | * <!-- end-user-doc --> | 122 | * <!-- end-user-doc --> |
121 | * @generated | 123 | * @generated |
122 | */ | 124 | */ |
123 | public NotificationChain basicSetInterface(FunctionalInterface newInterface, NotificationChain msgs) { | 125 | public NotificationChain basicSetInterface(functionalarchitecture.FunctionalInterface newInterface, NotificationChain msgs) { |
124 | msgs = eBasicSetContainer((InternalEObject)newInterface, FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE, msgs); | 126 | msgs = eBasicSetContainer((InternalEObject)newInterface, FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE, msgs); |
125 | return msgs; | 127 | return msgs; |
126 | } | 128 | } |
@@ -130,7 +132,8 @@ public abstract class FunctionalDataImpl extends MinimalEObjectImpl.Container im | |||
130 | * <!-- end-user-doc --> | 132 | * <!-- end-user-doc --> |
131 | * @generated | 133 | * @generated |
132 | */ | 134 | */ |
133 | public void setInterface(FunctionalInterface newInterface) { | 135 | @Override |
136 | public void setInterface(functionalarchitecture.FunctionalInterface newInterface) { | ||
134 | if (newInterface != eInternalContainer() || (eContainerFeatureID() != FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE && newInterface != null)) { | 137 | if (newInterface != eInternalContainer() || (eContainerFeatureID() != FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE && newInterface != null)) { |
135 | if (EcoreUtil.isAncestor(this, newInterface)) | 138 | if (EcoreUtil.isAncestor(this, newInterface)) |
136 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); | 139 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
@@ -138,7 +141,7 @@ public abstract class FunctionalDataImpl extends MinimalEObjectImpl.Container im | |||
138 | if (eInternalContainer() != null) | 141 | if (eInternalContainer() != null) |
139 | msgs = eBasicRemoveFromContainer(msgs); | 142 | msgs = eBasicRemoveFromContainer(msgs); |
140 | if (newInterface != null) | 143 | if (newInterface != null) |
141 | msgs = ((InternalEObject)newInterface).eInverseAdd(this, FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE__DATA, FunctionalInterface.class, msgs); | 144 | msgs = ((InternalEObject)newInterface).eInverseAdd(this, FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE__DATA, functionalarchitecture.FunctionalInterface.class, msgs); |
142 | msgs = basicSetInterface(newInterface, msgs); | 145 | msgs = basicSetInterface(newInterface, msgs); |
143 | if (msgs != null) msgs.dispatch(); | 146 | if (msgs != null) msgs.dispatch(); |
144 | } | 147 | } |
@@ -161,7 +164,7 @@ public abstract class FunctionalDataImpl extends MinimalEObjectImpl.Container im | |||
161 | case FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE: | 164 | case FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE: |
162 | if (eInternalContainer() != null) | 165 | if (eInternalContainer() != null) |
163 | msgs = eBasicRemoveFromContainer(msgs); | 166 | msgs = eBasicRemoveFromContainer(msgs); |
164 | return basicSetInterface((FunctionalInterface)otherEnd, msgs); | 167 | return basicSetInterface((functionalarchitecture.FunctionalInterface)otherEnd, msgs); |
165 | } | 168 | } |
166 | return super.eInverseAdd(otherEnd, featureID, msgs); | 169 | return super.eInverseAdd(otherEnd, featureID, msgs); |
167 | } | 170 | } |
@@ -191,7 +194,7 @@ public abstract class FunctionalDataImpl extends MinimalEObjectImpl.Container im | |||
191 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { | 194 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
192 | switch (eContainerFeatureID()) { | 195 | switch (eContainerFeatureID()) { |
193 | case FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE: | 196 | case FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE: |
194 | return eInternalContainer().eInverseRemove(this, FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE__DATA, FunctionalInterface.class, msgs); | 197 | return eInternalContainer().eInverseRemove(this, FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE__DATA, functionalarchitecture.FunctionalInterface.class, msgs); |
195 | } | 198 | } |
196 | return super.eBasicRemoveFromContainerFeature(msgs); | 199 | return super.eBasicRemoveFromContainerFeature(msgs); |
197 | } | 200 | } |
@@ -224,7 +227,7 @@ public abstract class FunctionalDataImpl extends MinimalEObjectImpl.Container im | |||
224 | setTerminator((FAMTerminator)newValue); | 227 | setTerminator((FAMTerminator)newValue); |
225 | return; | 228 | return; |
226 | case FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE: | 229 | case FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE: |
227 | setInterface((FunctionalInterface)newValue); | 230 | setInterface((functionalarchitecture.FunctionalInterface)newValue); |
228 | return; | 231 | return; |
229 | } | 232 | } |
230 | super.eSet(featureID, newValue); | 233 | super.eSet(featureID, newValue); |
@@ -242,7 +245,7 @@ public abstract class FunctionalDataImpl extends MinimalEObjectImpl.Container im | |||
242 | setTerminator((FAMTerminator)null); | 245 | setTerminator((FAMTerminator)null); |
243 | return; | 246 | return; |
244 | case FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE: | 247 | case FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE: |
245 | setInterface((FunctionalInterface)null); | 248 | setInterface((functionalarchitecture.FunctionalInterface)null); |
246 | return; | 249 | return; |
247 | } | 250 | } |
248 | super.eUnset(featureID); | 251 | super.eUnset(featureID); |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalElementImpl.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalElementImpl.java index 809e9ed5..c923caae 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalElementImpl.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalElementImpl.java | |||
@@ -5,7 +5,6 @@ package functionalarchitecture.impl; | |||
5 | import functionalarchitecture.Function; | 5 | import functionalarchitecture.Function; |
6 | import functionalarchitecture.FunctionalArchitectureModel; | 6 | import functionalarchitecture.FunctionalArchitectureModel; |
7 | import functionalarchitecture.FunctionalElement; | 7 | import functionalarchitecture.FunctionalElement; |
8 | import functionalarchitecture.FunctionalInterface; | ||
9 | import functionalarchitecture.FunctionalarchitecturePackage; | 8 | import functionalarchitecture.FunctionalarchitecturePackage; |
10 | 9 | ||
11 | import org.eclipse.emf.common.notify.Notification; | 10 | import org.eclipse.emf.common.notify.Notification; |
@@ -44,7 +43,7 @@ public abstract class FunctionalElementImpl extends MinimalEObjectImpl.Container | |||
44 | * @generated | 43 | * @generated |
45 | * @ordered | 44 | * @ordered |
46 | */ | 45 | */ |
47 | protected FunctionalInterface interface_; | 46 | protected functionalarchitecture.FunctionalInterface interface_; |
48 | 47 | ||
49 | /** | 48 | /** |
50 | * The cached setting delegate for the '{@link #getModel() <em>Model</em>}' reference. | 49 | * The cached setting delegate for the '{@link #getModel() <em>Model</em>}' reference. |
@@ -80,7 +79,8 @@ public abstract class FunctionalElementImpl extends MinimalEObjectImpl.Container | |||
80 | * <!-- end-user-doc --> | 79 | * <!-- end-user-doc --> |
81 | * @generated | 80 | * @generated |
82 | */ | 81 | */ |
83 | public FunctionalInterface getInterface() { | 82 | @Override |
83 | public functionalarchitecture.FunctionalInterface getInterface() { | ||
84 | return interface_; | 84 | return interface_; |
85 | } | 85 | } |
86 | 86 | ||
@@ -89,8 +89,8 @@ public abstract class FunctionalElementImpl extends MinimalEObjectImpl.Container | |||
89 | * <!-- end-user-doc --> | 89 | * <!-- end-user-doc --> |
90 | * @generated | 90 | * @generated |
91 | */ | 91 | */ |
92 | public NotificationChain basicSetInterface(FunctionalInterface newInterface, NotificationChain msgs) { | 92 | public NotificationChain basicSetInterface(functionalarchitecture.FunctionalInterface newInterface, NotificationChain msgs) { |
93 | FunctionalInterface oldInterface = interface_; | 93 | functionalarchitecture.FunctionalInterface oldInterface = interface_; |
94 | interface_ = newInterface; | 94 | interface_ = newInterface; |
95 | if (eNotificationRequired()) { | 95 | if (eNotificationRequired()) { |
96 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__INTERFACE, oldInterface, newInterface); | 96 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__INTERFACE, oldInterface, newInterface); |
@@ -104,13 +104,14 @@ public abstract class FunctionalElementImpl extends MinimalEObjectImpl.Container | |||
104 | * <!-- end-user-doc --> | 104 | * <!-- end-user-doc --> |
105 | * @generated | 105 | * @generated |
106 | */ | 106 | */ |
107 | public void setInterface(FunctionalInterface newInterface) { | 107 | @Override |
108 | public void setInterface(functionalarchitecture.FunctionalInterface newInterface) { | ||
108 | if (newInterface != interface_) { | 109 | if (newInterface != interface_) { |
109 | NotificationChain msgs = null; | 110 | NotificationChain msgs = null; |
110 | if (interface_ != null) | 111 | if (interface_ != null) |
111 | msgs = ((InternalEObject)interface_).eInverseRemove(this, FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE__ELEMENT, FunctionalInterface.class, msgs); | 112 | msgs = ((InternalEObject)interface_).eInverseRemove(this, FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE__ELEMENT, functionalarchitecture.FunctionalInterface.class, msgs); |
112 | if (newInterface != null) | 113 | if (newInterface != null) |
113 | msgs = ((InternalEObject)newInterface).eInverseAdd(this, FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE__ELEMENT, FunctionalInterface.class, msgs); | 114 | msgs = ((InternalEObject)newInterface).eInverseAdd(this, FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE__ELEMENT, functionalarchitecture.FunctionalInterface.class, msgs); |
114 | msgs = basicSetInterface(newInterface, msgs); | 115 | msgs = basicSetInterface(newInterface, msgs); |
115 | if (msgs != null) msgs.dispatch(); | 116 | if (msgs != null) msgs.dispatch(); |
116 | } | 117 | } |
@@ -123,6 +124,7 @@ public abstract class FunctionalElementImpl extends MinimalEObjectImpl.Container | |||
123 | * <!-- end-user-doc --> | 124 | * <!-- end-user-doc --> |
124 | * @generated | 125 | * @generated |
125 | */ | 126 | */ |
127 | @Override | ||
126 | public FunctionalArchitectureModel getModel() { | 128 | public FunctionalArchitectureModel getModel() { |
127 | return (FunctionalArchitectureModel)MODEL__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); | 129 | return (FunctionalArchitectureModel)MODEL__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); |
128 | } | 130 | } |
@@ -141,6 +143,7 @@ public abstract class FunctionalElementImpl extends MinimalEObjectImpl.Container | |||
141 | * <!-- end-user-doc --> | 143 | * <!-- end-user-doc --> |
142 | * @generated | 144 | * @generated |
143 | */ | 145 | */ |
146 | @Override | ||
144 | public void setModel(FunctionalArchitectureModel newModel) { | 147 | public void setModel(FunctionalArchitectureModel newModel) { |
145 | MODEL__ESETTING_DELEGATE.dynamicSet(this, null, 0, newModel); | 148 | MODEL__ESETTING_DELEGATE.dynamicSet(this, null, 0, newModel); |
146 | } | 149 | } |
@@ -150,6 +153,7 @@ public abstract class FunctionalElementImpl extends MinimalEObjectImpl.Container | |||
150 | * <!-- end-user-doc --> | 153 | * <!-- end-user-doc --> |
151 | * @generated | 154 | * @generated |
152 | */ | 155 | */ |
156 | @Override | ||
153 | public Function getParent() { | 157 | public Function getParent() { |
154 | if (eContainerFeatureID() != FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__PARENT) return null; | 158 | if (eContainerFeatureID() != FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__PARENT) return null; |
155 | return (Function)eInternalContainer(); | 159 | return (Function)eInternalContainer(); |
@@ -170,6 +174,7 @@ public abstract class FunctionalElementImpl extends MinimalEObjectImpl.Container | |||
170 | * <!-- end-user-doc --> | 174 | * <!-- end-user-doc --> |
171 | * @generated | 175 | * @generated |
172 | */ | 176 | */ |
177 | @Override | ||
173 | public void setParent(Function newParent) { | 178 | public void setParent(Function newParent) { |
174 | if (newParent != eInternalContainer() || (eContainerFeatureID() != FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__PARENT && newParent != null)) { | 179 | if (newParent != eInternalContainer() || (eContainerFeatureID() != FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__PARENT && newParent != null)) { |
175 | if (EcoreUtil.isAncestor(this, newParent)) | 180 | if (EcoreUtil.isAncestor(this, newParent)) |
@@ -197,7 +202,7 @@ public abstract class FunctionalElementImpl extends MinimalEObjectImpl.Container | |||
197 | case FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__INTERFACE: | 202 | case FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__INTERFACE: |
198 | if (interface_ != null) | 203 | if (interface_ != null) |
199 | msgs = ((InternalEObject)interface_).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__INTERFACE, null, msgs); | 204 | msgs = ((InternalEObject)interface_).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__INTERFACE, null, msgs); |
200 | return basicSetInterface((FunctionalInterface)otherEnd, msgs); | 205 | return basicSetInterface((functionalarchitecture.FunctionalInterface)otherEnd, msgs); |
201 | case FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__PARENT: | 206 | case FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__PARENT: |
202 | if (eInternalContainer() != null) | 207 | if (eInternalContainer() != null) |
203 | msgs = eBasicRemoveFromContainer(msgs); | 208 | msgs = eBasicRemoveFromContainer(msgs); |
@@ -264,7 +269,7 @@ public abstract class FunctionalElementImpl extends MinimalEObjectImpl.Container | |||
264 | public void eSet(int featureID, Object newValue) { | 269 | public void eSet(int featureID, Object newValue) { |
265 | switch (featureID) { | 270 | switch (featureID) { |
266 | case FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__INTERFACE: | 271 | case FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__INTERFACE: |
267 | setInterface((FunctionalInterface)newValue); | 272 | setInterface((functionalarchitecture.FunctionalInterface)newValue); |
268 | return; | 273 | return; |
269 | case FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__MODEL: | 274 | case FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__MODEL: |
270 | setModel((FunctionalArchitectureModel)newValue); | 275 | setModel((FunctionalArchitectureModel)newValue); |
@@ -285,7 +290,7 @@ public abstract class FunctionalElementImpl extends MinimalEObjectImpl.Container | |||
285 | public void eUnset(int featureID) { | 290 | public void eUnset(int featureID) { |
286 | switch (featureID) { | 291 | switch (featureID) { |
287 | case FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__INTERFACE: | 292 | case FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__INTERFACE: |
288 | setInterface((FunctionalInterface)null); | 293 | setInterface((functionalarchitecture.FunctionalInterface)null); |
289 | return; | 294 | return; |
290 | case FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__MODEL: | 295 | case FunctionalarchitecturePackage.FUNCTIONAL_ELEMENT__MODEL: |
291 | setModel((FunctionalArchitectureModel)null); | 296 | setModel((FunctionalArchitectureModel)null); |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalInputImpl.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalInputImpl.java index 9df1ec0c..33a136ed 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalInputImpl.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalInputImpl.java | |||
@@ -66,6 +66,7 @@ public class FunctionalInputImpl extends FunctionalDataImpl implements Functiona | |||
66 | * <!-- end-user-doc --> | 66 | * <!-- end-user-doc --> |
67 | * @generated | 67 | * @generated |
68 | */ | 68 | */ |
69 | @Override | ||
69 | public EList<InformationLink> getIncomingLinks() { | 70 | public EList<InformationLink> getIncomingLinks() { |
70 | if (incomingLinks == null) { | 71 | if (incomingLinks == null) { |
71 | incomingLinks = new EObjectWithInverseResolvingEList<InformationLink>(InformationLink.class, this, FunctionalarchitecturePackage.FUNCTIONAL_INPUT__INCOMING_LINKS, FunctionalarchitecturePackage.INFORMATION_LINK__TO); | 72 | incomingLinks = new EObjectWithInverseResolvingEList<InformationLink>(InformationLink.class, this, FunctionalarchitecturePackage.FUNCTIONAL_INPUT__INCOMING_LINKS, FunctionalarchitecturePackage.INFORMATION_LINK__TO); |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalInterfaceImpl.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalInterfaceImpl.java index 20151886..53aa2dac 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalInterfaceImpl.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalInterfaceImpl.java | |||
@@ -4,7 +4,6 @@ package functionalarchitecture.impl; | |||
4 | 4 | ||
5 | import functionalarchitecture.FunctionalData; | 5 | import functionalarchitecture.FunctionalData; |
6 | import functionalarchitecture.FunctionalElement; | 6 | import functionalarchitecture.FunctionalElement; |
7 | import functionalarchitecture.FunctionalInterface; | ||
8 | import functionalarchitecture.FunctionalarchitecturePackage; | 7 | import functionalarchitecture.FunctionalarchitecturePackage; |
9 | 8 | ||
10 | import java.util.Collection; | 9 | import java.util.Collection; |
@@ -38,7 +37,7 @@ import org.eclipse.emf.ecore.util.InternalEList; | |||
38 | * | 37 | * |
39 | * @generated | 38 | * @generated |
40 | */ | 39 | */ |
41 | public class FunctionalInterfaceImpl extends MinimalEObjectImpl.Container implements FunctionalInterface { | 40 | public class FunctionalInterfaceImpl extends MinimalEObjectImpl.Container implements functionalarchitecture.FunctionalInterface { |
42 | /** | 41 | /** |
43 | * The cached value of the '{@link #getData() <em>Data</em>}' containment reference list. | 42 | * The cached value of the '{@link #getData() <em>Data</em>}' containment reference list. |
44 | * <!-- begin-user-doc --> | 43 | * <!-- begin-user-doc --> |
@@ -73,6 +72,7 @@ public class FunctionalInterfaceImpl extends MinimalEObjectImpl.Container implem | |||
73 | * <!-- end-user-doc --> | 72 | * <!-- end-user-doc --> |
74 | * @generated | 73 | * @generated |
75 | */ | 74 | */ |
75 | @Override | ||
76 | public EList<FunctionalData> getData() { | 76 | public EList<FunctionalData> getData() { |
77 | if (data == null) { | 77 | if (data == null) { |
78 | data = new EObjectContainmentWithInverseEList<FunctionalData>(FunctionalData.class, this, FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE__DATA, FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE); | 78 | data = new EObjectContainmentWithInverseEList<FunctionalData>(FunctionalData.class, this, FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE__DATA, FunctionalarchitecturePackage.FUNCTIONAL_DATA__INTERFACE); |
@@ -85,6 +85,7 @@ public class FunctionalInterfaceImpl extends MinimalEObjectImpl.Container implem | |||
85 | * <!-- end-user-doc --> | 85 | * <!-- end-user-doc --> |
86 | * @generated | 86 | * @generated |
87 | */ | 87 | */ |
88 | @Override | ||
88 | public FunctionalElement getElement() { | 89 | public FunctionalElement getElement() { |
89 | if (eContainerFeatureID() != FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE__ELEMENT) return null; | 90 | if (eContainerFeatureID() != FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE__ELEMENT) return null; |
90 | return (FunctionalElement)eInternalContainer(); | 91 | return (FunctionalElement)eInternalContainer(); |
@@ -105,6 +106,7 @@ public class FunctionalInterfaceImpl extends MinimalEObjectImpl.Container implem | |||
105 | * <!-- end-user-doc --> | 106 | * <!-- end-user-doc --> |
106 | * @generated | 107 | * @generated |
107 | */ | 108 | */ |
109 | @Override | ||
108 | public void setElement(FunctionalElement newElement) { | 110 | public void setElement(FunctionalElement newElement) { |
109 | if (newElement != eInternalContainer() || (eContainerFeatureID() != FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE__ELEMENT && newElement != null)) { | 111 | if (newElement != eInternalContainer() || (eContainerFeatureID() != FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE__ELEMENT && newElement != null)) { |
110 | if (EcoreUtil.isAncestor(this, newElement)) | 112 | if (EcoreUtil.isAncestor(this, newElement)) |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalOutputImpl.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalOutputImpl.java index 1ae2a964..061af113 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalOutputImpl.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalOutputImpl.java | |||
@@ -66,6 +66,7 @@ public class FunctionalOutputImpl extends FunctionalDataImpl implements Function | |||
66 | * <!-- end-user-doc --> | 66 | * <!-- end-user-doc --> |
67 | * @generated | 67 | * @generated |
68 | */ | 68 | */ |
69 | @Override | ||
69 | public EList<InformationLink> getOutgoingLinks() { | 70 | public EList<InformationLink> getOutgoingLinks() { |
70 | if (outgoingLinks == null) { | 71 | if (outgoingLinks == null) { |
71 | outgoingLinks = new EObjectContainmentWithInverseEList<InformationLink>(InformationLink.class, this, FunctionalarchitecturePackage.FUNCTIONAL_OUTPUT__OUTGOING_LINKS, FunctionalarchitecturePackage.INFORMATION_LINK__FROM); | 72 | outgoingLinks = new EObjectContainmentWithInverseEList<InformationLink>(InformationLink.class, this, FunctionalarchitecturePackage.FUNCTIONAL_OUTPUT__OUTGOING_LINKS, FunctionalarchitecturePackage.INFORMATION_LINK__FROM); |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalarchitectureFactoryImpl.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalarchitectureFactoryImpl.java index 56ecfa25..9c9f495a 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalarchitectureFactoryImpl.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalarchitectureFactoryImpl.java | |||
@@ -2,9 +2,15 @@ | |||
2 | */ | 2 | */ |
3 | package functionalarchitecture.impl; | 3 | package functionalarchitecture.impl; |
4 | 4 | ||
5 | import functionalarchitecture.*; | 5 | import functionalarchitecture.FAMTerminator; |
6 | import functionalarchitecture.FunctionalInterface; | 6 | import functionalarchitecture.Function; |
7 | 7 | import functionalarchitecture.FunctionType; | |
8 | import functionalarchitecture.FunctionalArchitectureModel; | ||
9 | import functionalarchitecture.FunctionalInput; | ||
10 | import functionalarchitecture.FunctionalOutput; | ||
11 | import functionalarchitecture.FunctionalarchitectureFactory; | ||
12 | import functionalarchitecture.FunctionalarchitecturePackage; | ||
13 | import functionalarchitecture.InformationLink; | ||
8 | import org.eclipse.emf.ecore.EClass; | 14 | import org.eclipse.emf.ecore.EClass; |
9 | import org.eclipse.emf.ecore.EDataType; | 15 | import org.eclipse.emf.ecore.EDataType; |
10 | import org.eclipse.emf.ecore.EObject; | 16 | import org.eclipse.emf.ecore.EObject; |
@@ -105,6 +111,7 @@ public class FunctionalarchitectureFactoryImpl extends EFactoryImpl implements F | |||
105 | * <!-- end-user-doc --> | 111 | * <!-- end-user-doc --> |
106 | * @generated | 112 | * @generated |
107 | */ | 113 | */ |
114 | @Override | ||
108 | public FunctionalArchitectureModel createFunctionalArchitectureModel() { | 115 | public FunctionalArchitectureModel createFunctionalArchitectureModel() { |
109 | FunctionalArchitectureModelImpl functionalArchitectureModel = new FunctionalArchitectureModelImpl(); | 116 | FunctionalArchitectureModelImpl functionalArchitectureModel = new FunctionalArchitectureModelImpl(); |
110 | return functionalArchitectureModel; | 117 | return functionalArchitectureModel; |
@@ -115,6 +122,7 @@ public class FunctionalarchitectureFactoryImpl extends EFactoryImpl implements F | |||
115 | * <!-- end-user-doc --> | 122 | * <!-- end-user-doc --> |
116 | * @generated | 123 | * @generated |
117 | */ | 124 | */ |
125 | @Override | ||
118 | public Function createFunction() { | 126 | public Function createFunction() { |
119 | FunctionImpl function = new FunctionImpl(); | 127 | FunctionImpl function = new FunctionImpl(); |
120 | return function; | 128 | return function; |
@@ -125,6 +133,7 @@ public class FunctionalarchitectureFactoryImpl extends EFactoryImpl implements F | |||
125 | * <!-- end-user-doc --> | 133 | * <!-- end-user-doc --> |
126 | * @generated | 134 | * @generated |
127 | */ | 135 | */ |
136 | @Override | ||
128 | public FAMTerminator createFAMTerminator() { | 137 | public FAMTerminator createFAMTerminator() { |
129 | FAMTerminatorImpl famTerminator = new FAMTerminatorImpl(); | 138 | FAMTerminatorImpl famTerminator = new FAMTerminatorImpl(); |
130 | return famTerminator; | 139 | return famTerminator; |
@@ -135,6 +144,7 @@ public class FunctionalarchitectureFactoryImpl extends EFactoryImpl implements F | |||
135 | * <!-- end-user-doc --> | 144 | * <!-- end-user-doc --> |
136 | * @generated | 145 | * @generated |
137 | */ | 146 | */ |
147 | @Override | ||
138 | public InformationLink createInformationLink() { | 148 | public InformationLink createInformationLink() { |
139 | InformationLinkImpl informationLink = new InformationLinkImpl(); | 149 | InformationLinkImpl informationLink = new InformationLinkImpl(); |
140 | return informationLink; | 150 | return informationLink; |
@@ -145,7 +155,8 @@ public class FunctionalarchitectureFactoryImpl extends EFactoryImpl implements F | |||
145 | * <!-- end-user-doc --> | 155 | * <!-- end-user-doc --> |
146 | * @generated | 156 | * @generated |
147 | */ | 157 | */ |
148 | public FunctionalInterface createFunctionalInterface() { | 158 | @Override |
159 | public functionalarchitecture.FunctionalInterface createFunctionalInterface() { | ||
149 | FunctionalInterfaceImpl functionalInterface = new FunctionalInterfaceImpl(); | 160 | FunctionalInterfaceImpl functionalInterface = new FunctionalInterfaceImpl(); |
150 | return functionalInterface; | 161 | return functionalInterface; |
151 | } | 162 | } |
@@ -155,6 +166,7 @@ public class FunctionalarchitectureFactoryImpl extends EFactoryImpl implements F | |||
155 | * <!-- end-user-doc --> | 166 | * <!-- end-user-doc --> |
156 | * @generated | 167 | * @generated |
157 | */ | 168 | */ |
169 | @Override | ||
158 | public FunctionalInput createFunctionalInput() { | 170 | public FunctionalInput createFunctionalInput() { |
159 | FunctionalInputImpl functionalInput = new FunctionalInputImpl(); | 171 | FunctionalInputImpl functionalInput = new FunctionalInputImpl(); |
160 | return functionalInput; | 172 | return functionalInput; |
@@ -165,6 +177,7 @@ public class FunctionalarchitectureFactoryImpl extends EFactoryImpl implements F | |||
165 | * <!-- end-user-doc --> | 177 | * <!-- end-user-doc --> |
166 | * @generated | 178 | * @generated |
167 | */ | 179 | */ |
180 | @Override | ||
168 | public FunctionalOutput createFunctionalOutput() { | 181 | public FunctionalOutput createFunctionalOutput() { |
169 | FunctionalOutputImpl functionalOutput = new FunctionalOutputImpl(); | 182 | FunctionalOutputImpl functionalOutput = new FunctionalOutputImpl(); |
170 | return functionalOutput; | 183 | return functionalOutput; |
@@ -195,6 +208,7 @@ public class FunctionalarchitectureFactoryImpl extends EFactoryImpl implements F | |||
195 | * <!-- end-user-doc --> | 208 | * <!-- end-user-doc --> |
196 | * @generated | 209 | * @generated |
197 | */ | 210 | */ |
211 | @Override | ||
198 | public FunctionalarchitecturePackage getFunctionalarchitecturePackage() { | 212 | public FunctionalarchitecturePackage getFunctionalarchitecturePackage() { |
199 | return (FunctionalarchitecturePackage)getEPackage(); | 213 | return (FunctionalarchitecturePackage)getEPackage(); |
200 | } | 214 | } |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalarchitecturePackageImpl.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalarchitecturePackageImpl.java index 22c15533..04945f1c 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalarchitecturePackageImpl.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/FunctionalarchitecturePackageImpl.java | |||
@@ -9,7 +9,6 @@ import functionalarchitecture.FunctionalArchitectureModel; | |||
9 | import functionalarchitecture.FunctionalData; | 9 | import functionalarchitecture.FunctionalData; |
10 | import functionalarchitecture.FunctionalElement; | 10 | import functionalarchitecture.FunctionalElement; |
11 | import functionalarchitecture.FunctionalInput; | 11 | import functionalarchitecture.FunctionalInput; |
12 | import functionalarchitecture.FunctionalInterface; | ||
13 | import functionalarchitecture.FunctionalOutput; | 12 | import functionalarchitecture.FunctionalOutput; |
14 | import functionalarchitecture.FunctionalarchitectureFactory; | 13 | import functionalarchitecture.FunctionalarchitectureFactory; |
15 | import functionalarchitecture.FunctionalarchitecturePackage; | 14 | import functionalarchitecture.FunctionalarchitecturePackage; |
@@ -128,7 +127,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
128 | 127 | ||
129 | /** | 128 | /** |
130 | * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. | 129 | * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. |
131 | * | 130 | * |
132 | * <p>This method is used to initialize {@link FunctionalarchitecturePackage#eINSTANCE} when that field is accessed. | 131 | * <p>This method is used to initialize {@link FunctionalarchitecturePackage#eINSTANCE} when that field is accessed. |
133 | * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. | 132 | * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. |
134 | * <!-- begin-user-doc --> | 133 | * <!-- begin-user-doc --> |
@@ -142,7 +141,8 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
142 | if (isInited) return (FunctionalarchitecturePackage)EPackage.Registry.INSTANCE.getEPackage(FunctionalarchitecturePackage.eNS_URI); | 141 | if (isInited) return (FunctionalarchitecturePackage)EPackage.Registry.INSTANCE.getEPackage(FunctionalarchitecturePackage.eNS_URI); |
143 | 142 | ||
144 | // Obtain or create and register package | 143 | // Obtain or create and register package |
145 | FunctionalarchitecturePackageImpl theFunctionalarchitecturePackage = (FunctionalarchitecturePackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof FunctionalarchitecturePackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new FunctionalarchitecturePackageImpl()); | 144 | Object registeredFunctionalarchitecturePackage = EPackage.Registry.INSTANCE.get(eNS_URI); |
145 | FunctionalarchitecturePackageImpl theFunctionalarchitecturePackage = registeredFunctionalarchitecturePackage instanceof FunctionalarchitecturePackageImpl ? (FunctionalarchitecturePackageImpl)registeredFunctionalarchitecturePackage : new FunctionalarchitecturePackageImpl(); | ||
146 | 146 | ||
147 | isInited = true; | 147 | isInited = true; |
148 | 148 | ||
@@ -155,7 +155,6 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
155 | // Mark meta-data to indicate it can't be changed | 155 | // Mark meta-data to indicate it can't be changed |
156 | theFunctionalarchitecturePackage.freeze(); | 156 | theFunctionalarchitecturePackage.freeze(); |
157 | 157 | ||
158 | |||
159 | // Update the registry and return the package | 158 | // Update the registry and return the package |
160 | EPackage.Registry.INSTANCE.put(FunctionalarchitecturePackage.eNS_URI, theFunctionalarchitecturePackage); | 159 | EPackage.Registry.INSTANCE.put(FunctionalarchitecturePackage.eNS_URI, theFunctionalarchitecturePackage); |
161 | return theFunctionalarchitecturePackage; | 160 | return theFunctionalarchitecturePackage; |
@@ -166,6 +165,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
166 | * <!-- end-user-doc --> | 165 | * <!-- end-user-doc --> |
167 | * @generated | 166 | * @generated |
168 | */ | 167 | */ |
168 | @Override | ||
169 | public EClass getFunctionalElement() { | 169 | public EClass getFunctionalElement() { |
170 | return functionalElementEClass; | 170 | return functionalElementEClass; |
171 | } | 171 | } |
@@ -175,6 +175,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
175 | * <!-- end-user-doc --> | 175 | * <!-- end-user-doc --> |
176 | * @generated | 176 | * @generated |
177 | */ | 177 | */ |
178 | @Override | ||
178 | public EReference getFunctionalElement_Interface() { | 179 | public EReference getFunctionalElement_Interface() { |
179 | return (EReference)functionalElementEClass.getEStructuralFeatures().get(0); | 180 | return (EReference)functionalElementEClass.getEStructuralFeatures().get(0); |
180 | } | 181 | } |
@@ -184,6 +185,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
184 | * <!-- end-user-doc --> | 185 | * <!-- end-user-doc --> |
185 | * @generated | 186 | * @generated |
186 | */ | 187 | */ |
188 | @Override | ||
187 | public EReference getFunctionalElement_Model() { | 189 | public EReference getFunctionalElement_Model() { |
188 | return (EReference)functionalElementEClass.getEStructuralFeatures().get(1); | 190 | return (EReference)functionalElementEClass.getEStructuralFeatures().get(1); |
189 | } | 191 | } |
@@ -193,6 +195,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
193 | * <!-- end-user-doc --> | 195 | * <!-- end-user-doc --> |
194 | * @generated | 196 | * @generated |
195 | */ | 197 | */ |
198 | @Override | ||
196 | public EReference getFunctionalElement_Parent() { | 199 | public EReference getFunctionalElement_Parent() { |
197 | return (EReference)functionalElementEClass.getEStructuralFeatures().get(2); | 200 | return (EReference)functionalElementEClass.getEStructuralFeatures().get(2); |
198 | } | 201 | } |
@@ -202,6 +205,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
202 | * <!-- end-user-doc --> | 205 | * <!-- end-user-doc --> |
203 | * @generated | 206 | * @generated |
204 | */ | 207 | */ |
208 | @Override | ||
205 | public EClass getFunctionalArchitectureModel() { | 209 | public EClass getFunctionalArchitectureModel() { |
206 | return functionalArchitectureModelEClass; | 210 | return functionalArchitectureModelEClass; |
207 | } | 211 | } |
@@ -211,6 +215,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
211 | * <!-- end-user-doc --> | 215 | * <!-- end-user-doc --> |
212 | * @generated | 216 | * @generated |
213 | */ | 217 | */ |
218 | @Override | ||
214 | public EReference getFunctionalArchitectureModel_RootElements() { | 219 | public EReference getFunctionalArchitectureModel_RootElements() { |
215 | return (EReference)functionalArchitectureModelEClass.getEStructuralFeatures().get(0); | 220 | return (EReference)functionalArchitectureModelEClass.getEStructuralFeatures().get(0); |
216 | } | 221 | } |
@@ -220,6 +225,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
220 | * <!-- end-user-doc --> | 225 | * <!-- end-user-doc --> |
221 | * @generated | 226 | * @generated |
222 | */ | 227 | */ |
228 | @Override | ||
223 | public EClass getFunction() { | 229 | public EClass getFunction() { |
224 | return functionEClass; | 230 | return functionEClass; |
225 | } | 231 | } |
@@ -229,6 +235,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
229 | * <!-- end-user-doc --> | 235 | * <!-- end-user-doc --> |
230 | * @generated | 236 | * @generated |
231 | */ | 237 | */ |
238 | @Override | ||
232 | public EReference getFunction_SubElements() { | 239 | public EReference getFunction_SubElements() { |
233 | return (EReference)functionEClass.getEStructuralFeatures().get(0); | 240 | return (EReference)functionEClass.getEStructuralFeatures().get(0); |
234 | } | 241 | } |
@@ -238,6 +245,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
238 | * <!-- end-user-doc --> | 245 | * <!-- end-user-doc --> |
239 | * @generated | 246 | * @generated |
240 | */ | 247 | */ |
248 | @Override | ||
241 | public EAttribute getFunction_Type() { | 249 | public EAttribute getFunction_Type() { |
242 | return (EAttribute)functionEClass.getEStructuralFeatures().get(1); | 250 | return (EAttribute)functionEClass.getEStructuralFeatures().get(1); |
243 | } | 251 | } |
@@ -247,6 +255,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
247 | * <!-- end-user-doc --> | 255 | * <!-- end-user-doc --> |
248 | * @generated | 256 | * @generated |
249 | */ | 257 | */ |
258 | @Override | ||
250 | public EClass getFAMTerminator() { | 259 | public EClass getFAMTerminator() { |
251 | return famTerminatorEClass; | 260 | return famTerminatorEClass; |
252 | } | 261 | } |
@@ -256,6 +265,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
256 | * <!-- end-user-doc --> | 265 | * <!-- end-user-doc --> |
257 | * @generated | 266 | * @generated |
258 | */ | 267 | */ |
268 | @Override | ||
259 | public EReference getFAMTerminator_Data() { | 269 | public EReference getFAMTerminator_Data() { |
260 | return (EReference)famTerminatorEClass.getEStructuralFeatures().get(0); | 270 | return (EReference)famTerminatorEClass.getEStructuralFeatures().get(0); |
261 | } | 271 | } |
@@ -265,6 +275,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
265 | * <!-- end-user-doc --> | 275 | * <!-- end-user-doc --> |
266 | * @generated | 276 | * @generated |
267 | */ | 277 | */ |
278 | @Override | ||
268 | public EClass getInformationLink() { | 279 | public EClass getInformationLink() { |
269 | return informationLinkEClass; | 280 | return informationLinkEClass; |
270 | } | 281 | } |
@@ -274,6 +285,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
274 | * <!-- end-user-doc --> | 285 | * <!-- end-user-doc --> |
275 | * @generated | 286 | * @generated |
276 | */ | 287 | */ |
288 | @Override | ||
277 | public EReference getInformationLink_From() { | 289 | public EReference getInformationLink_From() { |
278 | return (EReference)informationLinkEClass.getEStructuralFeatures().get(0); | 290 | return (EReference)informationLinkEClass.getEStructuralFeatures().get(0); |
279 | } | 291 | } |
@@ -283,6 +295,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
283 | * <!-- end-user-doc --> | 295 | * <!-- end-user-doc --> |
284 | * @generated | 296 | * @generated |
285 | */ | 297 | */ |
298 | @Override | ||
286 | public EReference getInformationLink_To() { | 299 | public EReference getInformationLink_To() { |
287 | return (EReference)informationLinkEClass.getEStructuralFeatures().get(1); | 300 | return (EReference)informationLinkEClass.getEStructuralFeatures().get(1); |
288 | } | 301 | } |
@@ -292,6 +305,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
292 | * <!-- end-user-doc --> | 305 | * <!-- end-user-doc --> |
293 | * @generated | 306 | * @generated |
294 | */ | 307 | */ |
308 | @Override | ||
295 | public EClass getFunctionalInterface() { | 309 | public EClass getFunctionalInterface() { |
296 | return functionalInterfaceEClass; | 310 | return functionalInterfaceEClass; |
297 | } | 311 | } |
@@ -301,6 +315,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
301 | * <!-- end-user-doc --> | 315 | * <!-- end-user-doc --> |
302 | * @generated | 316 | * @generated |
303 | */ | 317 | */ |
318 | @Override | ||
304 | public EReference getFunctionalInterface_Data() { | 319 | public EReference getFunctionalInterface_Data() { |
305 | return (EReference)functionalInterfaceEClass.getEStructuralFeatures().get(0); | 320 | return (EReference)functionalInterfaceEClass.getEStructuralFeatures().get(0); |
306 | } | 321 | } |
@@ -310,6 +325,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
310 | * <!-- end-user-doc --> | 325 | * <!-- end-user-doc --> |
311 | * @generated | 326 | * @generated |
312 | */ | 327 | */ |
328 | @Override | ||
313 | public EReference getFunctionalInterface_Element() { | 329 | public EReference getFunctionalInterface_Element() { |
314 | return (EReference)functionalInterfaceEClass.getEStructuralFeatures().get(1); | 330 | return (EReference)functionalInterfaceEClass.getEStructuralFeatures().get(1); |
315 | } | 331 | } |
@@ -319,6 +335,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
319 | * <!-- end-user-doc --> | 335 | * <!-- end-user-doc --> |
320 | * @generated | 336 | * @generated |
321 | */ | 337 | */ |
338 | @Override | ||
322 | public EClass getFunctionalInput() { | 339 | public EClass getFunctionalInput() { |
323 | return functionalInputEClass; | 340 | return functionalInputEClass; |
324 | } | 341 | } |
@@ -328,6 +345,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
328 | * <!-- end-user-doc --> | 345 | * <!-- end-user-doc --> |
329 | * @generated | 346 | * @generated |
330 | */ | 347 | */ |
348 | @Override | ||
331 | public EReference getFunctionalInput_IncomingLinks() { | 349 | public EReference getFunctionalInput_IncomingLinks() { |
332 | return (EReference)functionalInputEClass.getEStructuralFeatures().get(0); | 350 | return (EReference)functionalInputEClass.getEStructuralFeatures().get(0); |
333 | } | 351 | } |
@@ -337,6 +355,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
337 | * <!-- end-user-doc --> | 355 | * <!-- end-user-doc --> |
338 | * @generated | 356 | * @generated |
339 | */ | 357 | */ |
358 | @Override | ||
340 | public EClass getFunctionalOutput() { | 359 | public EClass getFunctionalOutput() { |
341 | return functionalOutputEClass; | 360 | return functionalOutputEClass; |
342 | } | 361 | } |
@@ -346,6 +365,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
346 | * <!-- end-user-doc --> | 365 | * <!-- end-user-doc --> |
347 | * @generated | 366 | * @generated |
348 | */ | 367 | */ |
368 | @Override | ||
349 | public EReference getFunctionalOutput_OutgoingLinks() { | 369 | public EReference getFunctionalOutput_OutgoingLinks() { |
350 | return (EReference)functionalOutputEClass.getEStructuralFeatures().get(0); | 370 | return (EReference)functionalOutputEClass.getEStructuralFeatures().get(0); |
351 | } | 371 | } |
@@ -355,6 +375,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
355 | * <!-- end-user-doc --> | 375 | * <!-- end-user-doc --> |
356 | * @generated | 376 | * @generated |
357 | */ | 377 | */ |
378 | @Override | ||
358 | public EClass getFunctionalData() { | 379 | public EClass getFunctionalData() { |
359 | return functionalDataEClass; | 380 | return functionalDataEClass; |
360 | } | 381 | } |
@@ -364,6 +385,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
364 | * <!-- end-user-doc --> | 385 | * <!-- end-user-doc --> |
365 | * @generated | 386 | * @generated |
366 | */ | 387 | */ |
388 | @Override | ||
367 | public EReference getFunctionalData_Terminator() { | 389 | public EReference getFunctionalData_Terminator() { |
368 | return (EReference)functionalDataEClass.getEStructuralFeatures().get(0); | 390 | return (EReference)functionalDataEClass.getEStructuralFeatures().get(0); |
369 | } | 391 | } |
@@ -373,6 +395,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
373 | * <!-- end-user-doc --> | 395 | * <!-- end-user-doc --> |
374 | * @generated | 396 | * @generated |
375 | */ | 397 | */ |
398 | @Override | ||
376 | public EReference getFunctionalData_Interface() { | 399 | public EReference getFunctionalData_Interface() { |
377 | return (EReference)functionalDataEClass.getEStructuralFeatures().get(1); | 400 | return (EReference)functionalDataEClass.getEStructuralFeatures().get(1); |
378 | } | 401 | } |
@@ -382,6 +405,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
382 | * <!-- end-user-doc --> | 405 | * <!-- end-user-doc --> |
383 | * @generated | 406 | * @generated |
384 | */ | 407 | */ |
408 | @Override | ||
385 | public EEnum getFunctionType() { | 409 | public EEnum getFunctionType() { |
386 | return functionTypeEEnum; | 410 | return functionTypeEEnum; |
387 | } | 411 | } |
@@ -391,6 +415,7 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
391 | * <!-- end-user-doc --> | 415 | * <!-- end-user-doc --> |
392 | * @generated | 416 | * @generated |
393 | */ | 417 | */ |
418 | @Override | ||
394 | public FunctionalarchitectureFactory getFunctionalarchitectureFactory() { | 419 | public FunctionalarchitectureFactory getFunctionalarchitectureFactory() { |
395 | return (FunctionalarchitectureFactory)getEFactoryInstance(); | 420 | return (FunctionalarchitectureFactory)getEFactoryInstance(); |
396 | } | 421 | } |
@@ -503,9 +528,9 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
503 | initEReference(getInformationLink_From(), this.getFunctionalOutput(), this.getFunctionalOutput_OutgoingLinks(), "from", null, 0, 1, InformationLink.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | 528 | initEReference(getInformationLink_From(), this.getFunctionalOutput(), this.getFunctionalOutput_OutgoingLinks(), "from", null, 0, 1, InformationLink.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); |
504 | initEReference(getInformationLink_To(), this.getFunctionalInput(), this.getFunctionalInput_IncomingLinks(), "to", null, 1, 1, InformationLink.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | 529 | initEReference(getInformationLink_To(), this.getFunctionalInput(), this.getFunctionalInput_IncomingLinks(), "to", null, 1, 1, InformationLink.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); |
505 | 530 | ||
506 | initEClass(functionalInterfaceEClass, FunctionalInterface.class, "FunctionalInterface", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | 531 | initEClass(functionalInterfaceEClass, functionalarchitecture.FunctionalInterface.class, "FunctionalInterface", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); |
507 | initEReference(getFunctionalInterface_Data(), this.getFunctionalData(), this.getFunctionalData_Interface(), "data", null, 0, -1, FunctionalInterface.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | 532 | initEReference(getFunctionalInterface_Data(), this.getFunctionalData(), this.getFunctionalData_Interface(), "data", null, 0, -1, functionalarchitecture.FunctionalInterface.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); |
508 | initEReference(getFunctionalInterface_Element(), this.getFunctionalElement(), this.getFunctionalElement_Interface(), "element", null, 0, 1, FunctionalInterface.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | 533 | initEReference(getFunctionalInterface_Element(), this.getFunctionalElement(), this.getFunctionalElement_Interface(), "element", null, 0, 1, functionalarchitecture.FunctionalInterface.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); |
509 | 534 | ||
510 | initEClass(functionalInputEClass, FunctionalInput.class, "FunctionalInput", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | 535 | initEClass(functionalInputEClass, FunctionalInput.class, "FunctionalInput", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); |
511 | initEReference(getFunctionalInput_IncomingLinks(), this.getInformationLink(), this.getInformationLink_To(), "IncomingLinks", null, 0, -1, FunctionalInput.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | 536 | initEReference(getFunctionalInput_IncomingLinks(), this.getInformationLink(), this.getInformationLink_To(), "IncomingLinks", null, 0, -1, FunctionalInput.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); |
@@ -540,12 +565,12 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
540 | * @generated | 565 | * @generated |
541 | */ | 566 | */ |
542 | protected void createEcoreAnnotations() { | 567 | protected void createEcoreAnnotations() { |
543 | String source = "http://www.eclipse.org/emf/2002/Ecore"; | 568 | String source = "http://www.eclipse.org/emf/2002/Ecore"; |
544 | addAnnotation | 569 | addAnnotation |
545 | (this, | 570 | (this, |
546 | source, | 571 | source, |
547 | new String[] { | 572 | new String[] { |
548 | "settingDelegates", "org.eclipse.viatra.query.querybasedfeature" | 573 | "settingDelegates", "org.eclipse.viatra.query.querybasedfeature" |
549 | }); | 574 | }); |
550 | } | 575 | } |
551 | 576 | ||
@@ -556,18 +581,18 @@ public class FunctionalarchitecturePackageImpl extends EPackageImpl implements F | |||
556 | * @generated | 581 | * @generated |
557 | */ | 582 | */ |
558 | protected void createOrgAnnotations() { | 583 | protected void createOrgAnnotations() { |
559 | String source = "org.eclipse.viatra.query.querybasedfeature"; | 584 | String source = "org.eclipse.viatra.query.querybasedfeature"; |
560 | addAnnotation | 585 | addAnnotation |
561 | (getFunctionalElement_Model(), | 586 | (getFunctionalElement_Model(), |
562 | source, | 587 | source, |
563 | new String[] { | 588 | new String[] { |
564 | "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.transima.fam.model" | 589 | "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.transima.fam.model" |
565 | }); | 590 | }); |
566 | addAnnotation | 591 | addAnnotation |
567 | (getFunction_Type(), | 592 | (getFunction_Type(), |
568 | source, | 593 | source, |
569 | new String[] { | 594 | new String[] { |
570 | "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.transima.fam.type" | 595 | "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.transima.fam.type" |
571 | }); | 596 | }); |
572 | } | 597 | } |
573 | 598 | ||
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/InformationLinkImpl.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/InformationLinkImpl.java index 4b46fef8..ead4f9e9 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/InformationLinkImpl.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/impl/InformationLinkImpl.java | |||
@@ -67,6 +67,7 @@ public class InformationLinkImpl extends MinimalEObjectImpl.Container implements | |||
67 | * <!-- end-user-doc --> | 67 | * <!-- end-user-doc --> |
68 | * @generated | 68 | * @generated |
69 | */ | 69 | */ |
70 | @Override | ||
70 | public FunctionalOutput getFrom() { | 71 | public FunctionalOutput getFrom() { |
71 | if (eContainerFeatureID() != FunctionalarchitecturePackage.INFORMATION_LINK__FROM) return null; | 72 | if (eContainerFeatureID() != FunctionalarchitecturePackage.INFORMATION_LINK__FROM) return null; |
72 | return (FunctionalOutput)eInternalContainer(); | 73 | return (FunctionalOutput)eInternalContainer(); |
@@ -87,6 +88,7 @@ public class InformationLinkImpl extends MinimalEObjectImpl.Container implements | |||
87 | * <!-- end-user-doc --> | 88 | * <!-- end-user-doc --> |
88 | * @generated | 89 | * @generated |
89 | */ | 90 | */ |
91 | @Override | ||
90 | public void setFrom(FunctionalOutput newFrom) { | 92 | public void setFrom(FunctionalOutput newFrom) { |
91 | if (newFrom != eInternalContainer() || (eContainerFeatureID() != FunctionalarchitecturePackage.INFORMATION_LINK__FROM && newFrom != null)) { | 93 | if (newFrom != eInternalContainer() || (eContainerFeatureID() != FunctionalarchitecturePackage.INFORMATION_LINK__FROM && newFrom != null)) { |
92 | if (EcoreUtil.isAncestor(this, newFrom)) | 94 | if (EcoreUtil.isAncestor(this, newFrom)) |
@@ -108,6 +110,7 @@ public class InformationLinkImpl extends MinimalEObjectImpl.Container implements | |||
108 | * <!-- end-user-doc --> | 110 | * <!-- end-user-doc --> |
109 | * @generated | 111 | * @generated |
110 | */ | 112 | */ |
113 | @Override | ||
111 | public FunctionalInput getTo() { | 114 | public FunctionalInput getTo() { |
112 | if (to != null && to.eIsProxy()) { | 115 | if (to != null && to.eIsProxy()) { |
113 | InternalEObject oldTo = (InternalEObject)to; | 116 | InternalEObject oldTo = (InternalEObject)to; |
@@ -149,6 +152,7 @@ public class InformationLinkImpl extends MinimalEObjectImpl.Container implements | |||
149 | * <!-- end-user-doc --> | 152 | * <!-- end-user-doc --> |
150 | * @generated | 153 | * @generated |
151 | */ | 154 | */ |
155 | @Override | ||
152 | public void setTo(FunctionalInput newTo) { | 156 | public void setTo(FunctionalInput newTo) { |
153 | if (newTo != to) { | 157 | if (newTo != to) { |
154 | NotificationChain msgs = null; | 158 | NotificationChain msgs = null; |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/util/FunctionalarchitectureAdapterFactory.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/util/FunctionalarchitectureAdapterFactory.java index f990a7a4..9846bd62 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/util/FunctionalarchitectureAdapterFactory.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/util/FunctionalarchitectureAdapterFactory.java | |||
@@ -2,9 +2,15 @@ | |||
2 | */ | 2 | */ |
3 | package functionalarchitecture.util; | 3 | package functionalarchitecture.util; |
4 | 4 | ||
5 | import functionalarchitecture.*; | 5 | import functionalarchitecture.FAMTerminator; |
6 | import functionalarchitecture.FunctionalInterface; | 6 | import functionalarchitecture.Function; |
7 | 7 | import functionalarchitecture.FunctionalArchitectureModel; | |
8 | import functionalarchitecture.FunctionalData; | ||
9 | import functionalarchitecture.FunctionalElement; | ||
10 | import functionalarchitecture.FunctionalInput; | ||
11 | import functionalarchitecture.FunctionalOutput; | ||
12 | import functionalarchitecture.FunctionalarchitecturePackage; | ||
13 | import functionalarchitecture.InformationLink; | ||
8 | import org.eclipse.emf.common.notify.Adapter; | 14 | import org.eclipse.emf.common.notify.Adapter; |
9 | import org.eclipse.emf.common.notify.Notifier; | 15 | import org.eclipse.emf.common.notify.Notifier; |
10 | 16 | ||
@@ -89,7 +95,7 @@ public class FunctionalarchitectureAdapterFactory extends AdapterFactoryImpl { | |||
89 | return createInformationLinkAdapter(); | 95 | return createInformationLinkAdapter(); |
90 | } | 96 | } |
91 | @Override | 97 | @Override |
92 | public Adapter caseFunctionalInterface(FunctionalInterface object) { | 98 | public Adapter caseFunctionalInterface(functionalarchitecture.FunctionalInterface object) { |
93 | return createFunctionalInterfaceAdapter(); | 99 | return createFunctionalInterfaceAdapter(); |
94 | } | 100 | } |
95 | @Override | 101 | @Override |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/util/FunctionalarchitectureSwitch.java b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/util/FunctionalarchitectureSwitch.java index b481a978..a1bbb480 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/util/FunctionalarchitectureSwitch.java +++ b/Domains/Examples/ModelGenExampleFAM_plugin/ecore-gen/functionalarchitecture/util/FunctionalarchitectureSwitch.java | |||
@@ -2,9 +2,15 @@ | |||
2 | */ | 2 | */ |
3 | package functionalarchitecture.util; | 3 | package functionalarchitecture.util; |
4 | 4 | ||
5 | import functionalarchitecture.*; | 5 | import functionalarchitecture.FAMTerminator; |
6 | import functionalarchitecture.FunctionalInterface; | 6 | import functionalarchitecture.Function; |
7 | 7 | import functionalarchitecture.FunctionalArchitectureModel; | |
8 | import functionalarchitecture.FunctionalData; | ||
9 | import functionalarchitecture.FunctionalElement; | ||
10 | import functionalarchitecture.FunctionalInput; | ||
11 | import functionalarchitecture.FunctionalOutput; | ||
12 | import functionalarchitecture.FunctionalarchitecturePackage; | ||
13 | import functionalarchitecture.InformationLink; | ||
8 | import org.eclipse.emf.ecore.EObject; | 14 | import org.eclipse.emf.ecore.EObject; |
9 | import org.eclipse.emf.ecore.EPackage; | 15 | import org.eclipse.emf.ecore.EPackage; |
10 | 16 | ||
@@ -99,7 +105,7 @@ public class FunctionalarchitectureSwitch<T> extends Switch<T> { | |||
99 | return result; | 105 | return result; |
100 | } | 106 | } |
101 | case FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE: { | 107 | case FunctionalarchitecturePackage.FUNCTIONAL_INTERFACE: { |
102 | FunctionalInterface functionalInterface = (FunctionalInterface)theEObject; | 108 | functionalarchitecture.FunctionalInterface functionalInterface = (functionalarchitecture.FunctionalInterface)theEObject; |
103 | T result = caseFunctionalInterface(functionalInterface); | 109 | T result = caseFunctionalInterface(functionalInterface); |
104 | if (result == null) result = defaultCase(theEObject); | 110 | if (result == null) result = defaultCase(theEObject); |
105 | return result; | 111 | return result; |
@@ -214,7 +220,7 @@ public class FunctionalarchitectureSwitch<T> extends Switch<T> { | |||
214 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | 220 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
215 | * @generated | 221 | * @generated |
216 | */ | 222 | */ |
217 | public T caseFunctionalInterface(FunctionalInterface object) { | 223 | public T caseFunctionalInterface(functionalarchitecture.FunctionalInterface object) { |
218 | return null; | 224 | return null; |
219 | } | 225 | } |
220 | 226 | ||
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/plugin.xml b/Domains/Examples/ModelGenExampleFAM_plugin/plugin.xml index 213ec0ed..8d99d401 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/plugin.xml +++ b/Domains/Examples/ModelGenExampleFAM_plugin/plugin.xml | |||
@@ -12,13 +12,6 @@ | |||
12 | <extension id="hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns" point="org.eclipse.viatra.query.runtime.queryspecification"> | 12 | <extension id="hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns" point="org.eclipse.viatra.query.runtime.queryspecification"> |
13 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns" id="hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns"> | 13 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns" id="hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns"> |
14 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.terminatorAndInformation"/> | 14 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.terminatorAndInformation"/> |
15 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.type"/> | ||
16 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.rootElements"/> | ||
17 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.parent"/> | ||
18 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.model"/> | ||
19 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.hasRoot"/> | ||
20 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.hasInt"/> | ||
21 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.hasLeaf"/> | ||
22 | </group> | 15 | </group> |
23 | </extension> | 16 | </extension> |
24 | </plugin> | 17 | </plugin> |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/src/hu/bme/mit/inf/dslreasoner/domains/transima/fam/FamPatterns.vql b/Domains/Examples/ModelGenExampleFAM_plugin/src/hu/bme/mit/inf/dslreasoner/domains/transima/fam/FamPatterns.vql index f0e48d42..1d9a6b6d 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/src/hu/bme/mit/inf/dslreasoner/domains/transima/fam/FamPatterns.vql +++ b/Domains/Examples/ModelGenExampleFAM_plugin/src/hu/bme/mit/inf/dslreasoner/domains/transima/fam/FamPatterns.vql | |||
@@ -10,7 +10,7 @@ pattern terminatorAndInformation(T : FAMTerminator, I : InformationLink) = { | |||
10 | InformationLink.to(I,In); | 10 | InformationLink.to(I,In); |
11 | FunctionalInput.terminator(In,T); | 11 | FunctionalInput.terminator(In,T); |
12 | } | 12 | } |
13 | 13 | /* | |
14 | @QueryBasedFeature | 14 | @QueryBasedFeature |
15 | pattern type(This : Function, Target : FunctionType) = { | 15 | pattern type(This : Function, Target : FunctionType) = { |
16 | find rootElements(_Model, This); | 16 | find rootElements(_Model, This); |
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 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <classpath> | ||
3 | <classpathentry kind="src" path="ecore-gen"/> | ||
4 | <classpathentry kind="src" path="src"/> | ||
5 | <classpathentry kind="src" path="xtend-gen"/> | ||
6 | <classpathentry kind="src" path="vql-gen"/> | ||
7 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/> | ||
8 | <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
9 | <classpathentry kind="output" path="bin"/> | ||
10 | </classpath> | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/.gitignore b/Domains/ca.mcgill.rtgmrt.example.modes3/.gitignore new file mode 100644 index 00000000..6cef8ea6 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/.gitignore | |||
@@ -0,0 +1,2 @@ | |||
1 | /bin/ | ||
2 | output/ | ||
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 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <projectDescription> | ||
3 | <name>ca.mcgill.rtgmrt.example.modes3</name> | ||
4 | <comment></comment> | ||
5 | <projects> | ||
6 | </projects> | ||
7 | <buildSpec> | ||
8 | <buildCommand> | ||
9 | <name>org.eclipse.viatra.query.tooling.ui.projectbuilder</name> | ||
10 | <arguments> | ||
11 | </arguments> | ||
12 | </buildCommand> | ||
13 | <buildCommand> | ||
14 | <name>org.eclipse.xtext.ui.shared.xtextBuilder</name> | ||
15 | <arguments> | ||
16 | </arguments> | ||
17 | </buildCommand> | ||
18 | <buildCommand> | ||
19 | <name>org.eclipse.jdt.core.javabuilder</name> | ||
20 | <arguments> | ||
21 | </arguments> | ||
22 | </buildCommand> | ||
23 | <buildCommand> | ||
24 | <name>org.eclipse.pde.ManifestBuilder</name> | ||
25 | <arguments> | ||
26 | </arguments> | ||
27 | </buildCommand> | ||
28 | <buildCommand> | ||
29 | <name>org.eclipse.pde.SchemaBuilder</name> | ||
30 | <arguments> | ||
31 | </arguments> | ||
32 | </buildCommand> | ||
33 | </buildSpec> | ||
34 | <natures> | ||
35 | <nature>org.eclipse.jdt.core.javanature</nature> | ||
36 | <nature>org.eclipse.pde.PluginNature</nature> | ||
37 | <nature>org.eclipse.xtext.ui.shared.xtextNature</nature> | ||
38 | <nature>org.eclipse.viatra.query.projectnature</nature> | ||
39 | </natures> | ||
40 | </projectDescription> | ||
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 @@ | |||
1 | BuilderConfiguration.is_project_specific=true | ||
2 | autobuilding=true | ||
3 | eclipse.preferences.version=1 | ||
4 | generateEclipseExtensions=true | ||
5 | generateGeneratedAnnotation=false | ||
6 | generateManifestEntries=true | ||
7 | generateMatchProcessors=false | ||
8 | generateMatchers=NESTED_CLASS | ||
9 | generateSuppressWarnings=true | ||
10 | generatedAnnotationComment= | ||
11 | includeDateInGenerated=false | ||
12 | outlet.DEFAULT_OUTPUT.cleanDirectory=false | ||
13 | outlet.DEFAULT_OUTPUT.cleanupDerived=true | ||
14 | outlet.DEFAULT_OUTPUT.createDirectory=true | ||
15 | outlet.DEFAULT_OUTPUT.derived=true | ||
16 | outlet.DEFAULT_OUTPUT.directory=./vql-gen | ||
17 | outlet.DEFAULT_OUTPUT.hideLocalSyntheticVariables=true | ||
18 | outlet.DEFAULT_OUTPUT.installDslAsPrimarySource=false | ||
19 | outlet.DEFAULT_OUTPUT.keepLocalHistory=true | ||
20 | outlet.DEFAULT_OUTPUT.override=true | ||
21 | outlet.DEFAULT_OUTPUT.sourceFolder.ecore-gen.directory= | ||
22 | outlet.DEFAULT_OUTPUT.sourceFolder.ecore-gen.ignore= | ||
23 | outlet.DEFAULT_OUTPUT.sourceFolder.src.directory= | ||
24 | outlet.DEFAULT_OUTPUT.sourceFolder.src.ignore= | ||
25 | outlet.DEFAULT_OUTPUT.userOutputPerSourceFolder= | ||
26 | targetJavaVersion=JAVA5 | ||
27 | 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..8f900199 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/META-INF/MANIFEST.MF | |||
@@ -0,0 +1,36 @@ | |||
1 | Manifest-Version: 1.0 | ||
2 | Bundle-ManifestVersion: 2 | ||
3 | Bundle-Name: %pluginName | ||
4 | Bundle-SymbolicName: ca.mcgill.rtgmrt.example.modes3;singleton:=true | ||
5 | Bundle-Version: 0.1.0.qualifier | ||
6 | Bundle-ClassPath: . | ||
7 | Bundle-Vendor: %providerName | ||
8 | Bundle-Localization: plugin | ||
9 | Export-Package: modes3, | ||
10 | modes3.impl, | ||
11 | modes3.queries, | ||
12 | modes3.util | ||
13 | Require-Bundle: org.eclipse.viatra.query.runtime, | ||
14 | org.eclipse.viatra.query.runtime.rete, | ||
15 | org.eclipse.viatra.query.runtime.localsearch, | ||
16 | org.eclipse.xtext.xbase.lib, | ||
17 | org.eclipse.emf.ecore;visibility:=reexport, | ||
18 | org.eclipse.core.runtime, | ||
19 | org.eclipse.xtend.lib;bundle-version="2.21.0", | ||
20 | org.eclipse.xtend.lib.macro;bundle-version="2.21.0", | ||
21 | hu.bme.mit.inf.dslreasoner.application;bundle-version="1.0.0", | ||
22 | hu.bme.mit.inf.dslreasoner.logic.model;bundle-version="1.0.0", | ||
23 | hu.bme.mit.inf.dslreasoner.logic2ecore;bundle-version="1.0.0", | ||
24 | hu.bme.mit.inf.dslreasoner.viatra2logic;bundle-version="1.0.0", | ||
25 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatraquery;bundle-version="1.0.0", | ||
26 | hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage;bundle-version="1.0.0", | ||
27 | hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner;bundle-version="1.0.0", | ||
28 | hu.bme.mit.inf.dslreasoner.ecore2logic;bundle-version="1.0.0", | ||
29 | org.eclipse.emf.ecore.xmi;bundle-version="2.16.0", | ||
30 | hu.bme.mit.inf.dslreasoner.visualisation;bundle-version="1.0.0", | ||
31 | org.eclipse.viatra.query.patternlanguage.emf;bundle-version="2.4.0", | ||
32 | org.eclipse.viatra.dse;bundle-version="0.24.0" | ||
33 | Import-Package: org.apache.log4j | ||
34 | Automatic-Module-Name: ca.mcgill.rtgmrt.example.modes3 | ||
35 | Bundle-ActivationPolicy: lazy | ||
36 | Bundle-RequiredExecutionEnvironment: J2SE-1.5 | ||
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 @@ | |||
1 | bin.includes = .,\ | ||
2 | model/,\ | ||
3 | META-INF/,\ | ||
4 | plugin.xml,\ | ||
5 | plugin.properties | ||
6 | jars.compile.order = . | ||
7 | source.. = src/,\ | ||
8 | ecore-gen/,\ | ||
9 | vql-gen/,\ | ||
10 | xtend-gen/ | ||
11 | 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..10ce47a1 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Factory.java | |||
@@ -0,0 +1,78 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3; | ||
4 | |||
5 | import org.eclipse.emf.ecore.EFactory; | ||
6 | |||
7 | /** | ||
8 | * <!-- begin-user-doc --> | ||
9 | * The <b>Factory</b> for the model. | ||
10 | * It provides a create method for each non-abstract class of the model. | ||
11 | * <!-- end-user-doc --> | ||
12 | * @see modes3.Modes3Package | ||
13 | * @generated | ||
14 | */ | ||
15 | public interface Modes3Factory extends EFactory { | ||
16 | /** | ||
17 | * The singleton instance of the factory. | ||
18 | * <!-- begin-user-doc --> | ||
19 | * <!-- end-user-doc --> | ||
20 | * @generated | ||
21 | */ | ||
22 | Modes3Factory eINSTANCE = modes3.impl.Modes3FactoryImpl.init(); | ||
23 | |||
24 | /** | ||
25 | * Returns a new object of class '<em>Segment</em>'. | ||
26 | * <!-- begin-user-doc --> | ||
27 | * <!-- end-user-doc --> | ||
28 | * @return a new object of class '<em>Segment</em>'. | ||
29 | * @generated | ||
30 | */ | ||
31 | Segment createSegment(); | ||
32 | |||
33 | /** | ||
34 | * Returns a new object of class '<em>Model Root</em>'. | ||
35 | * <!-- begin-user-doc --> | ||
36 | * <!-- end-user-doc --> | ||
37 | * @return a new object of class '<em>Model Root</em>'. | ||
38 | * @generated | ||
39 | */ | ||
40 | Modes3ModelRoot createModes3ModelRoot(); | ||
41 | |||
42 | /** | ||
43 | * Returns a new object of class '<em>Turnout</em>'. | ||
44 | * <!-- begin-user-doc --> | ||
45 | * <!-- end-user-doc --> | ||
46 | * @return a new object of class '<em>Turnout</em>'. | ||
47 | * @generated | ||
48 | */ | ||
49 | Turnout createTurnout(); | ||
50 | |||
51 | /** | ||
52 | * Returns a new object of class '<em>Train</em>'. | ||
53 | * <!-- begin-user-doc --> | ||
54 | * <!-- end-user-doc --> | ||
55 | * @return a new object of class '<em>Train</em>'. | ||
56 | * @generated | ||
57 | */ | ||
58 | Train createTrain(); | ||
59 | |||
60 | /** | ||
61 | * Returns a new object of class '<em>Simple Segment</em>'. | ||
62 | * <!-- begin-user-doc --> | ||
63 | * <!-- end-user-doc --> | ||
64 | * @return a new object of class '<em>Simple Segment</em>'. | ||
65 | * @generated | ||
66 | */ | ||
67 | SimpleSegment createSimpleSegment(); | ||
68 | |||
69 | /** | ||
70 | * Returns the package supported by this factory. | ||
71 | * <!-- begin-user-doc --> | ||
72 | * <!-- end-user-doc --> | ||
73 | * @return the package supported by this factory. | ||
74 | * @generated | ||
75 | */ | ||
76 | Modes3Package getModes3Package(); | ||
77 | |||
78 | } //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..d46ee305 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3ModelRoot.java | |||
@@ -0,0 +1,87 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3; | ||
4 | |||
5 | import org.eclipse.emf.common.util.EList; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | |||
9 | /** | ||
10 | * <!-- begin-user-doc --> | ||
11 | * A representation of the model object '<em><b>Model Root</b></em>'. | ||
12 | * <!-- end-user-doc --> | ||
13 | * | ||
14 | * <p> | ||
15 | * The following features are supported: | ||
16 | * </p> | ||
17 | * <ul> | ||
18 | * <li>{@link modes3.Modes3ModelRoot#getId <em>Id</em>}</li> | ||
19 | * <li>{@link modes3.Modes3ModelRoot#getTrains <em>Trains</em>}</li> | ||
20 | * <li>{@link modes3.Modes3ModelRoot#getSegments <em>Segments</em>}</li> | ||
21 | * <li>{@link modes3.Modes3ModelRoot#getTurnouts <em>Turnouts</em>}</li> | ||
22 | * </ul> | ||
23 | * | ||
24 | * @see modes3.Modes3Package#getModes3ModelRoot() | ||
25 | * @model | ||
26 | * @generated | ||
27 | */ | ||
28 | public interface Modes3ModelRoot extends EObject { | ||
29 | /** | ||
30 | * Returns the value of the '<em><b>Id</b></em>' attribute. | ||
31 | * <!-- begin-user-doc --> | ||
32 | * <!-- end-user-doc --> | ||
33 | * @return the value of the '<em>Id</em>' attribute. | ||
34 | * @see #setId(int) | ||
35 | * @see modes3.Modes3Package#getModes3ModelRoot_Id() | ||
36 | * @model | ||
37 | * @generated | ||
38 | */ | ||
39 | int getId(); | ||
40 | |||
41 | /** | ||
42 | * Sets the value of the '{@link modes3.Modes3ModelRoot#getId <em>Id</em>}' attribute. | ||
43 | * <!-- begin-user-doc --> | ||
44 | * <!-- end-user-doc --> | ||
45 | * @param value the new value of the '<em>Id</em>' attribute. | ||
46 | * @see #getId() | ||
47 | * @generated | ||
48 | */ | ||
49 | void setId(int value); | ||
50 | |||
51 | /** | ||
52 | * Returns the value of the '<em><b>Trains</b></em>' containment reference list. | ||
53 | * The list contents are of type {@link modes3.Train}. | ||
54 | * <!-- begin-user-doc --> | ||
55 | * <!-- end-user-doc --> | ||
56 | * @return the value of the '<em>Trains</em>' containment reference list. | ||
57 | * @see modes3.Modes3Package#getModes3ModelRoot_Trains() | ||
58 | * @model containment="true" | ||
59 | * @generated | ||
60 | */ | ||
61 | EList<Train> getTrains(); | ||
62 | |||
63 | /** | ||
64 | * Returns the value of the '<em><b>Segments</b></em>' containment reference list. | ||
65 | * The list contents are of type {@link modes3.SimpleSegment}. | ||
66 | * <!-- begin-user-doc --> | ||
67 | * <!-- end-user-doc --> | ||
68 | * @return the value of the '<em>Segments</em>' containment reference list. | ||
69 | * @see modes3.Modes3Package#getModes3ModelRoot_Segments() | ||
70 | * @model containment="true" | ||
71 | * @generated | ||
72 | */ | ||
73 | EList<SimpleSegment> getSegments(); | ||
74 | |||
75 | /** | ||
76 | * Returns the value of the '<em><b>Turnouts</b></em>' containment reference list. | ||
77 | * The list contents are of type {@link modes3.Turnout}. | ||
78 | * <!-- begin-user-doc --> | ||
79 | * <!-- end-user-doc --> | ||
80 | * @return the value of the '<em>Turnouts</em>' containment reference list. | ||
81 | * @see modes3.Modes3Package#getModes3ModelRoot_Turnouts() | ||
82 | * @model containment="true" | ||
83 | * @generated | ||
84 | */ | ||
85 | EList<Turnout> getTurnouts(); | ||
86 | |||
87 | } // 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..a19c1955 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Package.java | |||
@@ -0,0 +1,716 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3; | ||
4 | |||
5 | import org.eclipse.emf.ecore.EAttribute; | ||
6 | import org.eclipse.emf.ecore.EClass; | ||
7 | import org.eclipse.emf.ecore.EPackage; | ||
8 | import org.eclipse.emf.ecore.EReference; | ||
9 | |||
10 | /** | ||
11 | * <!-- begin-user-doc --> | ||
12 | * The <b>Package</b> for the model. | ||
13 | * It contains accessors for the meta objects to represent | ||
14 | * <ul> | ||
15 | * <li>each class,</li> | ||
16 | * <li>each feature of each class,</li> | ||
17 | * <li>each operation of each class,</li> | ||
18 | * <li>each enum,</li> | ||
19 | * <li>and each data type</li> | ||
20 | * </ul> | ||
21 | * <!-- end-user-doc --> | ||
22 | * @see modes3.Modes3Factory | ||
23 | * @model kind="package" | ||
24 | * @generated | ||
25 | */ | ||
26 | public interface Modes3Package extends EPackage { | ||
27 | /** | ||
28 | * The package name. | ||
29 | * <!-- begin-user-doc --> | ||
30 | * <!-- end-user-doc --> | ||
31 | * @generated | ||
32 | */ | ||
33 | String eNAME = "modes3"; | ||
34 | |||
35 | /** | ||
36 | * The package namespace URI. | ||
37 | * <!-- begin-user-doc --> | ||
38 | * <!-- end-user-doc --> | ||
39 | * @generated | ||
40 | */ | ||
41 | String eNS_URI = "http://www.ece.mcgill.ca/wcet/modes3"; | ||
42 | |||
43 | /** | ||
44 | * The package namespace name. | ||
45 | * <!-- begin-user-doc --> | ||
46 | * <!-- end-user-doc --> | ||
47 | * @generated | ||
48 | */ | ||
49 | String eNS_PREFIX = "modes3"; | ||
50 | |||
51 | /** | ||
52 | * The singleton instance of the package. | ||
53 | * <!-- begin-user-doc --> | ||
54 | * <!-- end-user-doc --> | ||
55 | * @generated | ||
56 | */ | ||
57 | Modes3Package eINSTANCE = modes3.impl.Modes3PackageImpl.init(); | ||
58 | |||
59 | /** | ||
60 | * The meta object id for the '{@link modes3.impl.SegmentImpl <em>Segment</em>}' class. | ||
61 | * <!-- begin-user-doc --> | ||
62 | * <!-- end-user-doc --> | ||
63 | * @see modes3.impl.SegmentImpl | ||
64 | * @see modes3.impl.Modes3PackageImpl#getSegment() | ||
65 | * @generated | ||
66 | */ | ||
67 | int SEGMENT = 0; | ||
68 | |||
69 | /** | ||
70 | * The feature id for the '<em><b>Connected To</b></em>' reference list. | ||
71 | * <!-- begin-user-doc --> | ||
72 | * <!-- end-user-doc --> | ||
73 | * @generated | ||
74 | * @ordered | ||
75 | */ | ||
76 | int SEGMENT__CONNECTED_TO = 0; | ||
77 | |||
78 | /** | ||
79 | * The feature id for the '<em><b>Occupied By</b></em>' reference. | ||
80 | * <!-- begin-user-doc --> | ||
81 | * <!-- end-user-doc --> | ||
82 | * @generated | ||
83 | * @ordered | ||
84 | */ | ||
85 | int SEGMENT__OCCUPIED_BY = 1; | ||
86 | |||
87 | /** | ||
88 | * The feature id for the '<em><b>Id</b></em>' attribute. | ||
89 | * <!-- begin-user-doc --> | ||
90 | * <!-- end-user-doc --> | ||
91 | * @generated | ||
92 | * @ordered | ||
93 | */ | ||
94 | int SEGMENT__ID = 2; | ||
95 | |||
96 | /** | ||
97 | * The number of structural features of the '<em>Segment</em>' class. | ||
98 | * <!-- begin-user-doc --> | ||
99 | * <!-- end-user-doc --> | ||
100 | * @generated | ||
101 | * @ordered | ||
102 | */ | ||
103 | int SEGMENT_FEATURE_COUNT = 3; | ||
104 | |||
105 | /** | ||
106 | * The number of operations of the '<em>Segment</em>' class. | ||
107 | * <!-- begin-user-doc --> | ||
108 | * <!-- end-user-doc --> | ||
109 | * @generated | ||
110 | * @ordered | ||
111 | */ | ||
112 | int SEGMENT_OPERATION_COUNT = 0; | ||
113 | |||
114 | /** | ||
115 | * The meta object id for the '{@link modes3.impl.Modes3ModelRootImpl <em>Model Root</em>}' class. | ||
116 | * <!-- begin-user-doc --> | ||
117 | * <!-- end-user-doc --> | ||
118 | * @see modes3.impl.Modes3ModelRootImpl | ||
119 | * @see modes3.impl.Modes3PackageImpl#getModes3ModelRoot() | ||
120 | * @generated | ||
121 | */ | ||
122 | int MODES3_MODEL_ROOT = 1; | ||
123 | |||
124 | /** | ||
125 | * The feature id for the '<em><b>Id</b></em>' attribute. | ||
126 | * <!-- begin-user-doc --> | ||
127 | * <!-- end-user-doc --> | ||
128 | * @generated | ||
129 | * @ordered | ||
130 | */ | ||
131 | int MODES3_MODEL_ROOT__ID = 0; | ||
132 | |||
133 | /** | ||
134 | * The feature id for the '<em><b>Trains</b></em>' containment reference list. | ||
135 | * <!-- begin-user-doc --> | ||
136 | * <!-- end-user-doc --> | ||
137 | * @generated | ||
138 | * @ordered | ||
139 | */ | ||
140 | int MODES3_MODEL_ROOT__TRAINS = 1; | ||
141 | |||
142 | /** | ||
143 | * The feature id for the '<em><b>Segments</b></em>' containment reference list. | ||
144 | * <!-- begin-user-doc --> | ||
145 | * <!-- end-user-doc --> | ||
146 | * @generated | ||
147 | * @ordered | ||
148 | */ | ||
149 | int MODES3_MODEL_ROOT__SEGMENTS = 2; | ||
150 | |||
151 | /** | ||
152 | * The feature id for the '<em><b>Turnouts</b></em>' containment reference list. | ||
153 | * <!-- begin-user-doc --> | ||
154 | * <!-- end-user-doc --> | ||
155 | * @generated | ||
156 | * @ordered | ||
157 | */ | ||
158 | int MODES3_MODEL_ROOT__TURNOUTS = 3; | ||
159 | |||
160 | /** | ||
161 | * The number of structural features of the '<em>Model Root</em>' class. | ||
162 | * <!-- begin-user-doc --> | ||
163 | * <!-- end-user-doc --> | ||
164 | * @generated | ||
165 | * @ordered | ||
166 | */ | ||
167 | int MODES3_MODEL_ROOT_FEATURE_COUNT = 4; | ||
168 | |||
169 | /** | ||
170 | * The number of operations of the '<em>Model Root</em>' class. | ||
171 | * <!-- begin-user-doc --> | ||
172 | * <!-- end-user-doc --> | ||
173 | * @generated | ||
174 | * @ordered | ||
175 | */ | ||
176 | int MODES3_MODEL_ROOT_OPERATION_COUNT = 0; | ||
177 | |||
178 | /** | ||
179 | * The meta object id for the '{@link modes3.impl.TurnoutImpl <em>Turnout</em>}' class. | ||
180 | * <!-- begin-user-doc --> | ||
181 | * <!-- end-user-doc --> | ||
182 | * @see modes3.impl.TurnoutImpl | ||
183 | * @see modes3.impl.Modes3PackageImpl#getTurnout() | ||
184 | * @generated | ||
185 | */ | ||
186 | int TURNOUT = 2; | ||
187 | |||
188 | /** | ||
189 | * The feature id for the '<em><b>Connected To</b></em>' reference list. | ||
190 | * <!-- begin-user-doc --> | ||
191 | * <!-- end-user-doc --> | ||
192 | * @generated | ||
193 | * @ordered | ||
194 | */ | ||
195 | int TURNOUT__CONNECTED_TO = SEGMENT__CONNECTED_TO; | ||
196 | |||
197 | /** | ||
198 | * The feature id for the '<em><b>Occupied By</b></em>' reference. | ||
199 | * <!-- begin-user-doc --> | ||
200 | * <!-- end-user-doc --> | ||
201 | * @generated | ||
202 | * @ordered | ||
203 | */ | ||
204 | int TURNOUT__OCCUPIED_BY = SEGMENT__OCCUPIED_BY; | ||
205 | |||
206 | /** | ||
207 | * The feature id for the '<em><b>Id</b></em>' attribute. | ||
208 | * <!-- begin-user-doc --> | ||
209 | * <!-- end-user-doc --> | ||
210 | * @generated | ||
211 | * @ordered | ||
212 | */ | ||
213 | int TURNOUT__ID = SEGMENT__ID; | ||
214 | |||
215 | /** | ||
216 | * The feature id for the '<em><b>Straight</b></em>' reference. | ||
217 | * <!-- begin-user-doc --> | ||
218 | * <!-- end-user-doc --> | ||
219 | * @generated | ||
220 | * @ordered | ||
221 | */ | ||
222 | int TURNOUT__STRAIGHT = SEGMENT_FEATURE_COUNT + 0; | ||
223 | |||
224 | /** | ||
225 | * The feature id for the '<em><b>Divergent</b></em>' reference. | ||
226 | * <!-- begin-user-doc --> | ||
227 | * <!-- end-user-doc --> | ||
228 | * @generated | ||
229 | * @ordered | ||
230 | */ | ||
231 | int TURNOUT__DIVERGENT = SEGMENT_FEATURE_COUNT + 1; | ||
232 | |||
233 | /** | ||
234 | * The number of structural features of the '<em>Turnout</em>' class. | ||
235 | * <!-- begin-user-doc --> | ||
236 | * <!-- end-user-doc --> | ||
237 | * @generated | ||
238 | * @ordered | ||
239 | */ | ||
240 | int TURNOUT_FEATURE_COUNT = SEGMENT_FEATURE_COUNT + 2; | ||
241 | |||
242 | /** | ||
243 | * The number of operations of the '<em>Turnout</em>' class. | ||
244 | * <!-- begin-user-doc --> | ||
245 | * <!-- end-user-doc --> | ||
246 | * @generated | ||
247 | * @ordered | ||
248 | */ | ||
249 | int TURNOUT_OPERATION_COUNT = SEGMENT_OPERATION_COUNT + 0; | ||
250 | |||
251 | /** | ||
252 | * The meta object id for the '{@link modes3.impl.TrainImpl <em>Train</em>}' class. | ||
253 | * <!-- begin-user-doc --> | ||
254 | * <!-- end-user-doc --> | ||
255 | * @see modes3.impl.TrainImpl | ||
256 | * @see modes3.impl.Modes3PackageImpl#getTrain() | ||
257 | * @generated | ||
258 | */ | ||
259 | int TRAIN = 3; | ||
260 | |||
261 | /** | ||
262 | * The feature id for the '<em><b>Location</b></em>' reference. | ||
263 | * <!-- begin-user-doc --> | ||
264 | * <!-- end-user-doc --> | ||
265 | * @generated | ||
266 | * @ordered | ||
267 | */ | ||
268 | int TRAIN__LOCATION = 0; | ||
269 | |||
270 | /** | ||
271 | * The feature id for the '<em><b>Id</b></em>' attribute. | ||
272 | * <!-- begin-user-doc --> | ||
273 | * <!-- end-user-doc --> | ||
274 | * @generated | ||
275 | * @ordered | ||
276 | */ | ||
277 | int TRAIN__ID = 1; | ||
278 | |||
279 | /** | ||
280 | * The feature id for the '<em><b>Speed</b></em>' attribute. | ||
281 | * <!-- begin-user-doc --> | ||
282 | * <!-- end-user-doc --> | ||
283 | * @generated | ||
284 | * @ordered | ||
285 | */ | ||
286 | int TRAIN__SPEED = 2; | ||
287 | |||
288 | /** | ||
289 | * The number of structural features of the '<em>Train</em>' class. | ||
290 | * <!-- begin-user-doc --> | ||
291 | * <!-- end-user-doc --> | ||
292 | * @generated | ||
293 | * @ordered | ||
294 | */ | ||
295 | int TRAIN_FEATURE_COUNT = 3; | ||
296 | |||
297 | /** | ||
298 | * The number of operations of the '<em>Train</em>' class. | ||
299 | * <!-- begin-user-doc --> | ||
300 | * <!-- end-user-doc --> | ||
301 | * @generated | ||
302 | * @ordered | ||
303 | */ | ||
304 | int TRAIN_OPERATION_COUNT = 0; | ||
305 | |||
306 | |||
307 | /** | ||
308 | * The meta object id for the '{@link modes3.impl.SimpleSegmentImpl <em>Simple Segment</em>}' class. | ||
309 | * <!-- begin-user-doc --> | ||
310 | * <!-- end-user-doc --> | ||
311 | * @see modes3.impl.SimpleSegmentImpl | ||
312 | * @see modes3.impl.Modes3PackageImpl#getSimpleSegment() | ||
313 | * @generated | ||
314 | */ | ||
315 | int SIMPLE_SEGMENT = 4; | ||
316 | |||
317 | /** | ||
318 | * The feature id for the '<em><b>Connected To</b></em>' reference list. | ||
319 | * <!-- begin-user-doc --> | ||
320 | * <!-- end-user-doc --> | ||
321 | * @generated | ||
322 | * @ordered | ||
323 | */ | ||
324 | int SIMPLE_SEGMENT__CONNECTED_TO = SEGMENT__CONNECTED_TO; | ||
325 | |||
326 | /** | ||
327 | * The feature id for the '<em><b>Occupied By</b></em>' reference. | ||
328 | * <!-- begin-user-doc --> | ||
329 | * <!-- end-user-doc --> | ||
330 | * @generated | ||
331 | * @ordered | ||
332 | */ | ||
333 | int SIMPLE_SEGMENT__OCCUPIED_BY = SEGMENT__OCCUPIED_BY; | ||
334 | |||
335 | /** | ||
336 | * The feature id for the '<em><b>Id</b></em>' attribute. | ||
337 | * <!-- begin-user-doc --> | ||
338 | * <!-- end-user-doc --> | ||
339 | * @generated | ||
340 | * @ordered | ||
341 | */ | ||
342 | int SIMPLE_SEGMENT__ID = SEGMENT__ID; | ||
343 | |||
344 | /** | ||
345 | * The number of structural features of the '<em>Simple Segment</em>' class. | ||
346 | * <!-- begin-user-doc --> | ||
347 | * <!-- end-user-doc --> | ||
348 | * @generated | ||
349 | * @ordered | ||
350 | */ | ||
351 | int SIMPLE_SEGMENT_FEATURE_COUNT = SEGMENT_FEATURE_COUNT + 0; | ||
352 | |||
353 | /** | ||
354 | * The number of operations of the '<em>Simple Segment</em>' class. | ||
355 | * <!-- begin-user-doc --> | ||
356 | * <!-- end-user-doc --> | ||
357 | * @generated | ||
358 | * @ordered | ||
359 | */ | ||
360 | int SIMPLE_SEGMENT_OPERATION_COUNT = SEGMENT_OPERATION_COUNT + 0; | ||
361 | |||
362 | |||
363 | /** | ||
364 | * Returns the meta object for class '{@link modes3.Segment <em>Segment</em>}'. | ||
365 | * <!-- begin-user-doc --> | ||
366 | * <!-- end-user-doc --> | ||
367 | * @return the meta object for class '<em>Segment</em>'. | ||
368 | * @see modes3.Segment | ||
369 | * @generated | ||
370 | */ | ||
371 | EClass getSegment(); | ||
372 | |||
373 | /** | ||
374 | * Returns the meta object for the reference list '{@link modes3.Segment#getConnectedTo <em>Connected To</em>}'. | ||
375 | * <!-- begin-user-doc --> | ||
376 | * <!-- end-user-doc --> | ||
377 | * @return the meta object for the reference list '<em>Connected To</em>'. | ||
378 | * @see modes3.Segment#getConnectedTo() | ||
379 | * @see #getSegment() | ||
380 | * @generated | ||
381 | */ | ||
382 | EReference getSegment_ConnectedTo(); | ||
383 | |||
384 | /** | ||
385 | * Returns the meta object for the reference '{@link modes3.Segment#getOccupiedBy <em>Occupied By</em>}'. | ||
386 | * <!-- begin-user-doc --> | ||
387 | * <!-- end-user-doc --> | ||
388 | * @return the meta object for the reference '<em>Occupied By</em>'. | ||
389 | * @see modes3.Segment#getOccupiedBy() | ||
390 | * @see #getSegment() | ||
391 | * @generated | ||
392 | */ | ||
393 | EReference getSegment_OccupiedBy(); | ||
394 | |||
395 | /** | ||
396 | * Returns the meta object for the attribute '{@link modes3.Segment#getId <em>Id</em>}'. | ||
397 | * <!-- begin-user-doc --> | ||
398 | * <!-- end-user-doc --> | ||
399 | * @return the meta object for the attribute '<em>Id</em>'. | ||
400 | * @see modes3.Segment#getId() | ||
401 | * @see #getSegment() | ||
402 | * @generated | ||
403 | */ | ||
404 | EAttribute getSegment_Id(); | ||
405 | |||
406 | /** | ||
407 | * Returns the meta object for class '{@link modes3.Modes3ModelRoot <em>Model Root</em>}'. | ||
408 | * <!-- begin-user-doc --> | ||
409 | * <!-- end-user-doc --> | ||
410 | * @return the meta object for class '<em>Model Root</em>'. | ||
411 | * @see modes3.Modes3ModelRoot | ||
412 | * @generated | ||
413 | */ | ||
414 | EClass getModes3ModelRoot(); | ||
415 | |||
416 | /** | ||
417 | * Returns the meta object for the attribute '{@link modes3.Modes3ModelRoot#getId <em>Id</em>}'. | ||
418 | * <!-- begin-user-doc --> | ||
419 | * <!-- end-user-doc --> | ||
420 | * @return the meta object for the attribute '<em>Id</em>'. | ||
421 | * @see modes3.Modes3ModelRoot#getId() | ||
422 | * @see #getModes3ModelRoot() | ||
423 | * @generated | ||
424 | */ | ||
425 | EAttribute getModes3ModelRoot_Id(); | ||
426 | |||
427 | /** | ||
428 | * Returns the meta object for the containment reference list '{@link modes3.Modes3ModelRoot#getTrains <em>Trains</em>}'. | ||
429 | * <!-- begin-user-doc --> | ||
430 | * <!-- end-user-doc --> | ||
431 | * @return the meta object for the containment reference list '<em>Trains</em>'. | ||
432 | * @see modes3.Modes3ModelRoot#getTrains() | ||
433 | * @see #getModes3ModelRoot() | ||
434 | * @generated | ||
435 | */ | ||
436 | EReference getModes3ModelRoot_Trains(); | ||
437 | |||
438 | /** | ||
439 | * Returns the meta object for the containment reference list '{@link modes3.Modes3ModelRoot#getSegments <em>Segments</em>}'. | ||
440 | * <!-- begin-user-doc --> | ||
441 | * <!-- end-user-doc --> | ||
442 | * @return the meta object for the containment reference list '<em>Segments</em>'. | ||
443 | * @see modes3.Modes3ModelRoot#getSegments() | ||
444 | * @see #getModes3ModelRoot() | ||
445 | * @generated | ||
446 | */ | ||
447 | EReference getModes3ModelRoot_Segments(); | ||
448 | |||
449 | /** | ||
450 | * Returns the meta object for the containment reference list '{@link modes3.Modes3ModelRoot#getTurnouts <em>Turnouts</em>}'. | ||
451 | * <!-- begin-user-doc --> | ||
452 | * <!-- end-user-doc --> | ||
453 | * @return the meta object for the containment reference list '<em>Turnouts</em>'. | ||
454 | * @see modes3.Modes3ModelRoot#getTurnouts() | ||
455 | * @see #getModes3ModelRoot() | ||
456 | * @generated | ||
457 | */ | ||
458 | EReference getModes3ModelRoot_Turnouts(); | ||
459 | |||
460 | /** | ||
461 | * Returns the meta object for class '{@link modes3.Turnout <em>Turnout</em>}'. | ||
462 | * <!-- begin-user-doc --> | ||
463 | * <!-- end-user-doc --> | ||
464 | * @return the meta object for class '<em>Turnout</em>'. | ||
465 | * @see modes3.Turnout | ||
466 | * @generated | ||
467 | */ | ||
468 | EClass getTurnout(); | ||
469 | |||
470 | /** | ||
471 | * Returns the meta object for the reference '{@link modes3.Turnout#getStraight <em>Straight</em>}'. | ||
472 | * <!-- begin-user-doc --> | ||
473 | * <!-- end-user-doc --> | ||
474 | * @return the meta object for the reference '<em>Straight</em>'. | ||
475 | * @see modes3.Turnout#getStraight() | ||
476 | * @see #getTurnout() | ||
477 | * @generated | ||
478 | */ | ||
479 | EReference getTurnout_Straight(); | ||
480 | |||
481 | /** | ||
482 | * Returns the meta object for the reference '{@link modes3.Turnout#getDivergent <em>Divergent</em>}'. | ||
483 | * <!-- begin-user-doc --> | ||
484 | * <!-- end-user-doc --> | ||
485 | * @return the meta object for the reference '<em>Divergent</em>'. | ||
486 | * @see modes3.Turnout#getDivergent() | ||
487 | * @see #getTurnout() | ||
488 | * @generated | ||
489 | */ | ||
490 | EReference getTurnout_Divergent(); | ||
491 | |||
492 | /** | ||
493 | * Returns the meta object for class '{@link modes3.Train <em>Train</em>}'. | ||
494 | * <!-- begin-user-doc --> | ||
495 | * <!-- end-user-doc --> | ||
496 | * @return the meta object for class '<em>Train</em>'. | ||
497 | * @see modes3.Train | ||
498 | * @generated | ||
499 | */ | ||
500 | EClass getTrain(); | ||
501 | |||
502 | /** | ||
503 | * Returns the meta object for the reference '{@link modes3.Train#getLocation <em>Location</em>}'. | ||
504 | * <!-- begin-user-doc --> | ||
505 | * <!-- end-user-doc --> | ||
506 | * @return the meta object for the reference '<em>Location</em>'. | ||
507 | * @see modes3.Train#getLocation() | ||
508 | * @see #getTrain() | ||
509 | * @generated | ||
510 | */ | ||
511 | EReference getTrain_Location(); | ||
512 | |||
513 | /** | ||
514 | * Returns the meta object for the attribute '{@link modes3.Train#getId <em>Id</em>}'. | ||
515 | * <!-- begin-user-doc --> | ||
516 | * <!-- end-user-doc --> | ||
517 | * @return the meta object for the attribute '<em>Id</em>'. | ||
518 | * @see modes3.Train#getId() | ||
519 | * @see #getTrain() | ||
520 | * @generated | ||
521 | */ | ||
522 | EAttribute getTrain_Id(); | ||
523 | |||
524 | /** | ||
525 | * Returns the meta object for the attribute '{@link modes3.Train#getSpeed <em>Speed</em>}'. | ||
526 | * <!-- begin-user-doc --> | ||
527 | * <!-- end-user-doc --> | ||
528 | * @return the meta object for the attribute '<em>Speed</em>'. | ||
529 | * @see modes3.Train#getSpeed() | ||
530 | * @see #getTrain() | ||
531 | * @generated | ||
532 | */ | ||
533 | EAttribute getTrain_Speed(); | ||
534 | |||
535 | /** | ||
536 | * Returns the meta object for class '{@link modes3.SimpleSegment <em>Simple Segment</em>}'. | ||
537 | * <!-- begin-user-doc --> | ||
538 | * <!-- end-user-doc --> | ||
539 | * @return the meta object for class '<em>Simple Segment</em>'. | ||
540 | * @see modes3.SimpleSegment | ||
541 | * @generated | ||
542 | */ | ||
543 | EClass getSimpleSegment(); | ||
544 | |||
545 | /** | ||
546 | * Returns the factory that creates the instances of the model. | ||
547 | * <!-- begin-user-doc --> | ||
548 | * <!-- end-user-doc --> | ||
549 | * @return the factory that creates the instances of the model. | ||
550 | * @generated | ||
551 | */ | ||
552 | Modes3Factory getModes3Factory(); | ||
553 | |||
554 | /** | ||
555 | * <!-- begin-user-doc --> | ||
556 | * Defines literals for the meta objects that represent | ||
557 | * <ul> | ||
558 | * <li>each class,</li> | ||
559 | * <li>each feature of each class,</li> | ||
560 | * <li>each operation of each class,</li> | ||
561 | * <li>each enum,</li> | ||
562 | * <li>and each data type</li> | ||
563 | * </ul> | ||
564 | * <!-- end-user-doc --> | ||
565 | * @generated | ||
566 | */ | ||
567 | interface Literals { | ||
568 | /** | ||
569 | * The meta object literal for the '{@link modes3.impl.SegmentImpl <em>Segment</em>}' class. | ||
570 | * <!-- begin-user-doc --> | ||
571 | * <!-- end-user-doc --> | ||
572 | * @see modes3.impl.SegmentImpl | ||
573 | * @see modes3.impl.Modes3PackageImpl#getSegment() | ||
574 | * @generated | ||
575 | */ | ||
576 | EClass SEGMENT = eINSTANCE.getSegment(); | ||
577 | |||
578 | /** | ||
579 | * The meta object literal for the '<em><b>Connected To</b></em>' reference list feature. | ||
580 | * <!-- begin-user-doc --> | ||
581 | * <!-- end-user-doc --> | ||
582 | * @generated | ||
583 | */ | ||
584 | EReference SEGMENT__CONNECTED_TO = eINSTANCE.getSegment_ConnectedTo(); | ||
585 | |||
586 | /** | ||
587 | * The meta object literal for the '<em><b>Occupied By</b></em>' reference feature. | ||
588 | * <!-- begin-user-doc --> | ||
589 | * <!-- end-user-doc --> | ||
590 | * @generated | ||
591 | */ | ||
592 | EReference SEGMENT__OCCUPIED_BY = eINSTANCE.getSegment_OccupiedBy(); | ||
593 | |||
594 | /** | ||
595 | * The meta object literal for the '<em><b>Id</b></em>' attribute feature. | ||
596 | * <!-- begin-user-doc --> | ||
597 | * <!-- end-user-doc --> | ||
598 | * @generated | ||
599 | */ | ||
600 | EAttribute SEGMENT__ID = eINSTANCE.getSegment_Id(); | ||
601 | |||
602 | /** | ||
603 | * The meta object literal for the '{@link modes3.impl.Modes3ModelRootImpl <em>Model Root</em>}' class. | ||
604 | * <!-- begin-user-doc --> | ||
605 | * <!-- end-user-doc --> | ||
606 | * @see modes3.impl.Modes3ModelRootImpl | ||
607 | * @see modes3.impl.Modes3PackageImpl#getModes3ModelRoot() | ||
608 | * @generated | ||
609 | */ | ||
610 | EClass MODES3_MODEL_ROOT = eINSTANCE.getModes3ModelRoot(); | ||
611 | |||
612 | /** | ||
613 | * The meta object literal for the '<em><b>Id</b></em>' attribute feature. | ||
614 | * <!-- begin-user-doc --> | ||
615 | * <!-- end-user-doc --> | ||
616 | * @generated | ||
617 | */ | ||
618 | EAttribute MODES3_MODEL_ROOT__ID = eINSTANCE.getModes3ModelRoot_Id(); | ||
619 | |||
620 | /** | ||
621 | * The meta object literal for the '<em><b>Trains</b></em>' containment reference list feature. | ||
622 | * <!-- begin-user-doc --> | ||
623 | * <!-- end-user-doc --> | ||
624 | * @generated | ||
625 | */ | ||
626 | EReference MODES3_MODEL_ROOT__TRAINS = eINSTANCE.getModes3ModelRoot_Trains(); | ||
627 | |||
628 | /** | ||
629 | * The meta object literal for the '<em><b>Segments</b></em>' containment reference list feature. | ||
630 | * <!-- begin-user-doc --> | ||
631 | * <!-- end-user-doc --> | ||
632 | * @generated | ||
633 | */ | ||
634 | EReference MODES3_MODEL_ROOT__SEGMENTS = eINSTANCE.getModes3ModelRoot_Segments(); | ||
635 | |||
636 | /** | ||
637 | * The meta object literal for the '<em><b>Turnouts</b></em>' containment reference list feature. | ||
638 | * <!-- begin-user-doc --> | ||
639 | * <!-- end-user-doc --> | ||
640 | * @generated | ||
641 | */ | ||
642 | EReference MODES3_MODEL_ROOT__TURNOUTS = eINSTANCE.getModes3ModelRoot_Turnouts(); | ||
643 | |||
644 | /** | ||
645 | * The meta object literal for the '{@link modes3.impl.TurnoutImpl <em>Turnout</em>}' class. | ||
646 | * <!-- begin-user-doc --> | ||
647 | * <!-- end-user-doc --> | ||
648 | * @see modes3.impl.TurnoutImpl | ||
649 | * @see modes3.impl.Modes3PackageImpl#getTurnout() | ||
650 | * @generated | ||
651 | */ | ||
652 | EClass TURNOUT = eINSTANCE.getTurnout(); | ||
653 | |||
654 | /** | ||
655 | * The meta object literal for the '<em><b>Straight</b></em>' reference feature. | ||
656 | * <!-- begin-user-doc --> | ||
657 | * <!-- end-user-doc --> | ||
658 | * @generated | ||
659 | */ | ||
660 | EReference TURNOUT__STRAIGHT = eINSTANCE.getTurnout_Straight(); | ||
661 | |||
662 | /** | ||
663 | * The meta object literal for the '<em><b>Divergent</b></em>' reference feature. | ||
664 | * <!-- begin-user-doc --> | ||
665 | * <!-- end-user-doc --> | ||
666 | * @generated | ||
667 | */ | ||
668 | EReference TURNOUT__DIVERGENT = eINSTANCE.getTurnout_Divergent(); | ||
669 | |||
670 | /** | ||
671 | * The meta object literal for the '{@link modes3.impl.TrainImpl <em>Train</em>}' class. | ||
672 | * <!-- begin-user-doc --> | ||
673 | * <!-- end-user-doc --> | ||
674 | * @see modes3.impl.TrainImpl | ||
675 | * @see modes3.impl.Modes3PackageImpl#getTrain() | ||
676 | * @generated | ||
677 | */ | ||
678 | EClass TRAIN = eINSTANCE.getTrain(); | ||
679 | |||
680 | /** | ||
681 | * The meta object literal for the '<em><b>Location</b></em>' reference feature. | ||
682 | * <!-- begin-user-doc --> | ||
683 | * <!-- end-user-doc --> | ||
684 | * @generated | ||
685 | */ | ||
686 | EReference TRAIN__LOCATION = eINSTANCE.getTrain_Location(); | ||
687 | |||
688 | /** | ||
689 | * The meta object literal for the '<em><b>Id</b></em>' attribute feature. | ||
690 | * <!-- begin-user-doc --> | ||
691 | * <!-- end-user-doc --> | ||
692 | * @generated | ||
693 | */ | ||
694 | EAttribute TRAIN__ID = eINSTANCE.getTrain_Id(); | ||
695 | |||
696 | /** | ||
697 | * The meta object literal for the '<em><b>Speed</b></em>' attribute feature. | ||
698 | * <!-- begin-user-doc --> | ||
699 | * <!-- end-user-doc --> | ||
700 | * @generated | ||
701 | */ | ||
702 | EAttribute TRAIN__SPEED = eINSTANCE.getTrain_Speed(); | ||
703 | |||
704 | /** | ||
705 | * The meta object literal for the '{@link modes3.impl.SimpleSegmentImpl <em>Simple Segment</em>}' class. | ||
706 | * <!-- begin-user-doc --> | ||
707 | * <!-- end-user-doc --> | ||
708 | * @see modes3.impl.SimpleSegmentImpl | ||
709 | * @see modes3.impl.Modes3PackageImpl#getSimpleSegment() | ||
710 | * @generated | ||
711 | */ | ||
712 | EClass SIMPLE_SEGMENT = eINSTANCE.getSimpleSegment(); | ||
713 | |||
714 | } | ||
715 | |||
716 | } //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 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3; | ||
4 | |||
5 | import org.eclipse.emf.common.util.EList; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | |||
9 | /** | ||
10 | * <!-- begin-user-doc --> | ||
11 | * A representation of the model object '<em><b>Segment</b></em>'. | ||
12 | * <!-- end-user-doc --> | ||
13 | * | ||
14 | * <p> | ||
15 | * The following features are supported: | ||
16 | * </p> | ||
17 | * <ul> | ||
18 | * <li>{@link modes3.Segment#getConnectedTo <em>Connected To</em>}</li> | ||
19 | * <li>{@link modes3.Segment#getOccupiedBy <em>Occupied By</em>}</li> | ||
20 | * <li>{@link modes3.Segment#getId <em>Id</em>}</li> | ||
21 | * </ul> | ||
22 | * | ||
23 | * @see modes3.Modes3Package#getSegment() | ||
24 | * @model | ||
25 | * @generated | ||
26 | */ | ||
27 | public interface Segment extends EObject { | ||
28 | /** | ||
29 | * Returns the value of the '<em><b>Connected To</b></em>' reference list. | ||
30 | * The list contents are of type {@link modes3.Segment}. | ||
31 | * <!-- begin-user-doc --> | ||
32 | * <!-- end-user-doc --> | ||
33 | * @return the value of the '<em>Connected To</em>' reference list. | ||
34 | * @see modes3.Modes3Package#getSegment_ConnectedTo() | ||
35 | * @model upper="2" | ||
36 | * @generated | ||
37 | */ | ||
38 | EList<Segment> getConnectedTo(); | ||
39 | |||
40 | /** | ||
41 | * Returns the value of the '<em><b>Occupied By</b></em>' reference. | ||
42 | * It is bidirectional and its opposite is '{@link modes3.Train#getLocation <em>Location</em>}'. | ||
43 | * <!-- begin-user-doc --> | ||
44 | * <!-- end-user-doc --> | ||
45 | * @return the value of the '<em>Occupied By</em>' reference. | ||
46 | * @see #setOccupiedBy(Train) | ||
47 | * @see modes3.Modes3Package#getSegment_OccupiedBy() | ||
48 | * @see modes3.Train#getLocation | ||
49 | * @model opposite="location" | ||
50 | * @generated | ||
51 | */ | ||
52 | Train getOccupiedBy(); | ||
53 | |||
54 | /** | ||
55 | * Sets the value of the '{@link modes3.Segment#getOccupiedBy <em>Occupied By</em>}' reference. | ||
56 | * <!-- begin-user-doc --> | ||
57 | * <!-- end-user-doc --> | ||
58 | * @param value the new value of the '<em>Occupied By</em>' reference. | ||
59 | * @see #getOccupiedBy() | ||
60 | * @generated | ||
61 | */ | ||
62 | void setOccupiedBy(Train value); | ||
63 | |||
64 | /** | ||
65 | * Returns the value of the '<em><b>Id</b></em>' attribute. | ||
66 | * <!-- begin-user-doc --> | ||
67 | * <!-- end-user-doc --> | ||
68 | * @return the value of the '<em>Id</em>' attribute. | ||
69 | * @see #setId(int) | ||
70 | * @see modes3.Modes3Package#getSegment_Id() | ||
71 | * @model | ||
72 | * @generated | ||
73 | */ | ||
74 | int getId(); | ||
75 | |||
76 | /** | ||
77 | * Sets the value of the '{@link modes3.Segment#getId <em>Id</em>}' attribute. | ||
78 | * <!-- begin-user-doc --> | ||
79 | * <!-- end-user-doc --> | ||
80 | * @param value the new value of the '<em>Id</em>' attribute. | ||
81 | * @see #getId() | ||
82 | * @generated | ||
83 | */ | ||
84 | void setId(int value); | ||
85 | |||
86 | } // Segment | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/SimpleSegment.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/SimpleSegment.java new file mode 100644 index 00000000..da77510f --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/SimpleSegment.java | |||
@@ -0,0 +1,17 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3; | ||
4 | |||
5 | |||
6 | /** | ||
7 | * <!-- begin-user-doc --> | ||
8 | * A representation of the model object '<em><b>Simple Segment</b></em>'. | ||
9 | * <!-- end-user-doc --> | ||
10 | * | ||
11 | * | ||
12 | * @see modes3.Modes3Package#getSimpleSegment() | ||
13 | * @model | ||
14 | * @generated | ||
15 | */ | ||
16 | public interface SimpleSegment extends Segment { | ||
17 | } // SimpleSegment | ||
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 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3; | ||
4 | |||
5 | import org.eclipse.emf.ecore.EObject; | ||
6 | |||
7 | /** | ||
8 | * <!-- begin-user-doc --> | ||
9 | * A representation of the model object '<em><b>Train</b></em>'. | ||
10 | * <!-- end-user-doc --> | ||
11 | * | ||
12 | * <p> | ||
13 | * The following features are supported: | ||
14 | * </p> | ||
15 | * <ul> | ||
16 | * <li>{@link modes3.Train#getLocation <em>Location</em>}</li> | ||
17 | * <li>{@link modes3.Train#getId <em>Id</em>}</li> | ||
18 | * <li>{@link modes3.Train#getSpeed <em>Speed</em>}</li> | ||
19 | * </ul> | ||
20 | * | ||
21 | * @see modes3.Modes3Package#getTrain() | ||
22 | * @model | ||
23 | * @generated | ||
24 | */ | ||
25 | public interface Train extends EObject { | ||
26 | /** | ||
27 | * Returns the value of the '<em><b>Location</b></em>' reference. | ||
28 | * It is bidirectional and its opposite is '{@link modes3.Segment#getOccupiedBy <em>Occupied By</em>}'. | ||
29 | * <!-- begin-user-doc --> | ||
30 | * <!-- end-user-doc --> | ||
31 | * @return the value of the '<em>Location</em>' reference. | ||
32 | * @see #setLocation(Segment) | ||
33 | * @see modes3.Modes3Package#getTrain_Location() | ||
34 | * @see modes3.Segment#getOccupiedBy | ||
35 | * @model opposite="occupiedBy" required="true" | ||
36 | * @generated | ||
37 | */ | ||
38 | Segment getLocation(); | ||
39 | |||
40 | /** | ||
41 | * Sets the value of the '{@link modes3.Train#getLocation <em>Location</em>}' reference. | ||
42 | * <!-- begin-user-doc --> | ||
43 | * <!-- end-user-doc --> | ||
44 | * @param value the new value of the '<em>Location</em>' reference. | ||
45 | * @see #getLocation() | ||
46 | * @generated | ||
47 | */ | ||
48 | void setLocation(Segment value); | ||
49 | |||
50 | /** | ||
51 | * Returns the value of the '<em><b>Id</b></em>' attribute. | ||
52 | * <!-- begin-user-doc --> | ||
53 | * <!-- end-user-doc --> | ||
54 | * @return the value of the '<em>Id</em>' attribute. | ||
55 | * @see #setId(int) | ||
56 | * @see modes3.Modes3Package#getTrain_Id() | ||
57 | * @model | ||
58 | * @generated | ||
59 | */ | ||
60 | int getId(); | ||
61 | |||
62 | /** | ||
63 | * Sets the value of the '{@link modes3.Train#getId <em>Id</em>}' attribute. | ||
64 | * <!-- begin-user-doc --> | ||
65 | * <!-- end-user-doc --> | ||
66 | * @param value the new value of the '<em>Id</em>' attribute. | ||
67 | * @see #getId() | ||
68 | * @generated | ||
69 | */ | ||
70 | void setId(int value); | ||
71 | |||
72 | /** | ||
73 | * Returns the value of the '<em><b>Speed</b></em>' attribute. | ||
74 | * <!-- begin-user-doc --> | ||
75 | * <!-- end-user-doc --> | ||
76 | * @return the value of the '<em>Speed</em>' attribute. | ||
77 | * @see #setSpeed(double) | ||
78 | * @see modes3.Modes3Package#getTrain_Speed() | ||
79 | * @model | ||
80 | * @generated | ||
81 | */ | ||
82 | double getSpeed(); | ||
83 | |||
84 | /** | ||
85 | * Sets the value of the '{@link modes3.Train#getSpeed <em>Speed</em>}' attribute. | ||
86 | * <!-- begin-user-doc --> | ||
87 | * <!-- end-user-doc --> | ||
88 | * @param value the new value of the '<em>Speed</em>' attribute. | ||
89 | * @see #getSpeed() | ||
90 | * @generated | ||
91 | */ | ||
92 | void setSpeed(double value); | ||
93 | |||
94 | } // 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 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3; | ||
4 | |||
5 | |||
6 | /** | ||
7 | * <!-- begin-user-doc --> | ||
8 | * A representation of the model object '<em><b>Turnout</b></em>'. | ||
9 | * <!-- end-user-doc --> | ||
10 | * | ||
11 | * <p> | ||
12 | * The following features are supported: | ||
13 | * </p> | ||
14 | * <ul> | ||
15 | * <li>{@link modes3.Turnout#getStraight <em>Straight</em>}</li> | ||
16 | * <li>{@link modes3.Turnout#getDivergent <em>Divergent</em>}</li> | ||
17 | * </ul> | ||
18 | * | ||
19 | * @see modes3.Modes3Package#getTurnout() | ||
20 | * @model | ||
21 | * @generated | ||
22 | */ | ||
23 | public interface Turnout extends Segment { | ||
24 | /** | ||
25 | * Returns the value of the '<em><b>Straight</b></em>' reference. | ||
26 | * <!-- begin-user-doc --> | ||
27 | * <!-- end-user-doc --> | ||
28 | * @return the value of the '<em>Straight</em>' reference. | ||
29 | * @see #setStraight(Segment) | ||
30 | * @see modes3.Modes3Package#getTurnout_Straight() | ||
31 | * @model required="true" | ||
32 | * @generated | ||
33 | */ | ||
34 | Segment getStraight(); | ||
35 | |||
36 | /** | ||
37 | * Sets the value of the '{@link modes3.Turnout#getStraight <em>Straight</em>}' reference. | ||
38 | * <!-- begin-user-doc --> | ||
39 | * <!-- end-user-doc --> | ||
40 | * @param value the new value of the '<em>Straight</em>' reference. | ||
41 | * @see #getStraight() | ||
42 | * @generated | ||
43 | */ | ||
44 | void setStraight(Segment value); | ||
45 | |||
46 | /** | ||
47 | * Returns the value of the '<em><b>Divergent</b></em>' reference. | ||
48 | * <!-- begin-user-doc --> | ||
49 | * <!-- end-user-doc --> | ||
50 | * @return the value of the '<em>Divergent</em>' reference. | ||
51 | * @see #setDivergent(Segment) | ||
52 | * @see modes3.Modes3Package#getTurnout_Divergent() | ||
53 | * @model required="true" | ||
54 | * @generated | ||
55 | */ | ||
56 | Segment getDivergent(); | ||
57 | |||
58 | /** | ||
59 | * Sets the value of the '{@link modes3.Turnout#getDivergent <em>Divergent</em>}' reference. | ||
60 | * <!-- begin-user-doc --> | ||
61 | * <!-- end-user-doc --> | ||
62 | * @param value the new value of the '<em>Divergent</em>' reference. | ||
63 | * @see #getDivergent() | ||
64 | * @generated | ||
65 | */ | ||
66 | void setDivergent(Segment value); | ||
67 | |||
68 | } // 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..60947533 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3FactoryImpl.java | |||
@@ -0,0 +1,139 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.impl; | ||
4 | |||
5 | import modes3.*; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EClass; | ||
8 | import org.eclipse.emf.ecore.EObject; | ||
9 | import org.eclipse.emf.ecore.EPackage; | ||
10 | |||
11 | import org.eclipse.emf.ecore.impl.EFactoryImpl; | ||
12 | |||
13 | import org.eclipse.emf.ecore.plugin.EcorePlugin; | ||
14 | |||
15 | /** | ||
16 | * <!-- begin-user-doc --> | ||
17 | * An implementation of the model <b>Factory</b>. | ||
18 | * <!-- end-user-doc --> | ||
19 | * @generated | ||
20 | */ | ||
21 | public class Modes3FactoryImpl extends EFactoryImpl implements Modes3Factory { | ||
22 | /** | ||
23 | * Creates the default factory implementation. | ||
24 | * <!-- begin-user-doc --> | ||
25 | * <!-- end-user-doc --> | ||
26 | * @generated | ||
27 | */ | ||
28 | public static Modes3Factory init() { | ||
29 | try { | ||
30 | Modes3Factory theModes3Factory = (Modes3Factory)EPackage.Registry.INSTANCE.getEFactory(Modes3Package.eNS_URI); | ||
31 | if (theModes3Factory != null) { | ||
32 | return theModes3Factory; | ||
33 | } | ||
34 | } | ||
35 | catch (Exception exception) { | ||
36 | EcorePlugin.INSTANCE.log(exception); | ||
37 | } | ||
38 | return new Modes3FactoryImpl(); | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * Creates an instance of the factory. | ||
43 | * <!-- begin-user-doc --> | ||
44 | * <!-- end-user-doc --> | ||
45 | * @generated | ||
46 | */ | ||
47 | public Modes3FactoryImpl() { | ||
48 | super(); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * <!-- begin-user-doc --> | ||
53 | * <!-- end-user-doc --> | ||
54 | * @generated | ||
55 | */ | ||
56 | @Override | ||
57 | public EObject create(EClass eClass) { | ||
58 | switch (eClass.getClassifierID()) { | ||
59 | case Modes3Package.SEGMENT: return createSegment(); | ||
60 | case Modes3Package.MODES3_MODEL_ROOT: return createModes3ModelRoot(); | ||
61 | case Modes3Package.TURNOUT: return createTurnout(); | ||
62 | case Modes3Package.TRAIN: return createTrain(); | ||
63 | case Modes3Package.SIMPLE_SEGMENT: return createSimpleSegment(); | ||
64 | default: | ||
65 | throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); | ||
66 | } | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * <!-- begin-user-doc --> | ||
71 | * <!-- end-user-doc --> | ||
72 | * @generated | ||
73 | */ | ||
74 | public Segment createSegment() { | ||
75 | SegmentImpl segment = new SegmentImpl(); | ||
76 | return segment; | ||
77 | } | ||
78 | |||
79 | /** | ||
80 | * <!-- begin-user-doc --> | ||
81 | * <!-- end-user-doc --> | ||
82 | * @generated | ||
83 | */ | ||
84 | public Modes3ModelRoot createModes3ModelRoot() { | ||
85 | Modes3ModelRootImpl modes3ModelRoot = new Modes3ModelRootImpl(); | ||
86 | return modes3ModelRoot; | ||
87 | } | ||
88 | |||
89 | /** | ||
90 | * <!-- begin-user-doc --> | ||
91 | * <!-- end-user-doc --> | ||
92 | * @generated | ||
93 | */ | ||
94 | public Turnout createTurnout() { | ||
95 | TurnoutImpl turnout = new TurnoutImpl(); | ||
96 | return turnout; | ||
97 | } | ||
98 | |||
99 | /** | ||
100 | * <!-- begin-user-doc --> | ||
101 | * <!-- end-user-doc --> | ||
102 | * @generated | ||
103 | */ | ||
104 | public Train createTrain() { | ||
105 | TrainImpl train = new TrainImpl(); | ||
106 | return train; | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * <!-- begin-user-doc --> | ||
111 | * <!-- end-user-doc --> | ||
112 | * @generated | ||
113 | */ | ||
114 | public SimpleSegment createSimpleSegment() { | ||
115 | SimpleSegmentImpl simpleSegment = new SimpleSegmentImpl(); | ||
116 | return simpleSegment; | ||
117 | } | ||
118 | |||
119 | /** | ||
120 | * <!-- begin-user-doc --> | ||
121 | * <!-- end-user-doc --> | ||
122 | * @generated | ||
123 | */ | ||
124 | public Modes3Package getModes3Package() { | ||
125 | return (Modes3Package)getEPackage(); | ||
126 | } | ||
127 | |||
128 | /** | ||
129 | * <!-- begin-user-doc --> | ||
130 | * <!-- end-user-doc --> | ||
131 | * @deprecated | ||
132 | * @generated | ||
133 | */ | ||
134 | @Deprecated | ||
135 | public static Modes3Package getPackage() { | ||
136 | return Modes3Package.eINSTANCE; | ||
137 | } | ||
138 | |||
139 | } //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..ccab1f29 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3ModelRootImpl.java | |||
@@ -0,0 +1,296 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.impl; | ||
4 | |||
5 | import java.util.Collection; | ||
6 | |||
7 | import modes3.Modes3ModelRoot; | ||
8 | import modes3.Modes3Package; | ||
9 | import modes3.SimpleSegment; | ||
10 | import modes3.Train; | ||
11 | import modes3.Turnout; | ||
12 | |||
13 | import org.eclipse.emf.common.notify.Notification; | ||
14 | import org.eclipse.emf.common.notify.NotificationChain; | ||
15 | |||
16 | import org.eclipse.emf.common.util.EList; | ||
17 | |||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.emf.ecore.InternalEObject; | ||
20 | |||
21 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
22 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; | ||
23 | |||
24 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; | ||
25 | import org.eclipse.emf.ecore.util.InternalEList; | ||
26 | |||
27 | /** | ||
28 | * <!-- begin-user-doc --> | ||
29 | * An implementation of the model object '<em><b>Model Root</b></em>'. | ||
30 | * <!-- end-user-doc --> | ||
31 | * <p> | ||
32 | * The following features are implemented: | ||
33 | * </p> | ||
34 | * <ul> | ||
35 | * <li>{@link modes3.impl.Modes3ModelRootImpl#getId <em>Id</em>}</li> | ||
36 | * <li>{@link modes3.impl.Modes3ModelRootImpl#getTrains <em>Trains</em>}</li> | ||
37 | * <li>{@link modes3.impl.Modes3ModelRootImpl#getSegments <em>Segments</em>}</li> | ||
38 | * <li>{@link modes3.impl.Modes3ModelRootImpl#getTurnouts <em>Turnouts</em>}</li> | ||
39 | * </ul> | ||
40 | * | ||
41 | * @generated | ||
42 | */ | ||
43 | public class Modes3ModelRootImpl extends MinimalEObjectImpl.Container implements Modes3ModelRoot { | ||
44 | /** | ||
45 | * The default value of the '{@link #getId() <em>Id</em>}' attribute. | ||
46 | * <!-- begin-user-doc --> | ||
47 | * <!-- end-user-doc --> | ||
48 | * @see #getId() | ||
49 | * @generated | ||
50 | * @ordered | ||
51 | */ | ||
52 | protected static final int ID_EDEFAULT = 0; | ||
53 | |||
54 | /** | ||
55 | * The cached value of the '{@link #getId() <em>Id</em>}' attribute. | ||
56 | * <!-- begin-user-doc --> | ||
57 | * <!-- end-user-doc --> | ||
58 | * @see #getId() | ||
59 | * @generated | ||
60 | * @ordered | ||
61 | */ | ||
62 | protected int id = ID_EDEFAULT; | ||
63 | |||
64 | /** | ||
65 | * The cached value of the '{@link #getTrains() <em>Trains</em>}' containment reference list. | ||
66 | * <!-- begin-user-doc --> | ||
67 | * <!-- end-user-doc --> | ||
68 | * @see #getTrains() | ||
69 | * @generated | ||
70 | * @ordered | ||
71 | */ | ||
72 | protected EList<Train> trains; | ||
73 | |||
74 | /** | ||
75 | * The cached value of the '{@link #getSegments() <em>Segments</em>}' containment reference list. | ||
76 | * <!-- begin-user-doc --> | ||
77 | * <!-- end-user-doc --> | ||
78 | * @see #getSegments() | ||
79 | * @generated | ||
80 | * @ordered | ||
81 | */ | ||
82 | protected EList<SimpleSegment> segments; | ||
83 | |||
84 | /** | ||
85 | * The cached value of the '{@link #getTurnouts() <em>Turnouts</em>}' containment reference list. | ||
86 | * <!-- begin-user-doc --> | ||
87 | * <!-- end-user-doc --> | ||
88 | * @see #getTurnouts() | ||
89 | * @generated | ||
90 | * @ordered | ||
91 | */ | ||
92 | protected EList<Turnout> turnouts; | ||
93 | |||
94 | /** | ||
95 | * <!-- begin-user-doc --> | ||
96 | * <!-- end-user-doc --> | ||
97 | * @generated | ||
98 | */ | ||
99 | protected Modes3ModelRootImpl() { | ||
100 | super(); | ||
101 | } | ||
102 | |||
103 | /** | ||
104 | * <!-- begin-user-doc --> | ||
105 | * <!-- end-user-doc --> | ||
106 | * @generated | ||
107 | */ | ||
108 | @Override | ||
109 | protected EClass eStaticClass() { | ||
110 | return Modes3Package.Literals.MODES3_MODEL_ROOT; | ||
111 | } | ||
112 | |||
113 | /** | ||
114 | * <!-- begin-user-doc --> | ||
115 | * <!-- end-user-doc --> | ||
116 | * @generated | ||
117 | */ | ||
118 | public int getId() { | ||
119 | return id; | ||
120 | } | ||
121 | |||
122 | /** | ||
123 | * <!-- begin-user-doc --> | ||
124 | * <!-- end-user-doc --> | ||
125 | * @generated | ||
126 | */ | ||
127 | public void setId(int newId) { | ||
128 | int oldId = id; | ||
129 | id = newId; | ||
130 | if (eNotificationRequired()) | ||
131 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.MODES3_MODEL_ROOT__ID, oldId, id)); | ||
132 | } | ||
133 | |||
134 | /** | ||
135 | * <!-- begin-user-doc --> | ||
136 | * <!-- end-user-doc --> | ||
137 | * @generated | ||
138 | */ | ||
139 | public EList<Train> getTrains() { | ||
140 | if (trains == null) { | ||
141 | trains = new EObjectContainmentEList<Train>(Train.class, this, Modes3Package.MODES3_MODEL_ROOT__TRAINS); | ||
142 | } | ||
143 | return trains; | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * <!-- begin-user-doc --> | ||
148 | * <!-- end-user-doc --> | ||
149 | * @generated | ||
150 | */ | ||
151 | public EList<SimpleSegment> getSegments() { | ||
152 | if (segments == null) { | ||
153 | segments = new EObjectContainmentEList<SimpleSegment>(SimpleSegment.class, this, Modes3Package.MODES3_MODEL_ROOT__SEGMENTS); | ||
154 | } | ||
155 | return segments; | ||
156 | } | ||
157 | |||
158 | /** | ||
159 | * <!-- begin-user-doc --> | ||
160 | * <!-- end-user-doc --> | ||
161 | * @generated | ||
162 | */ | ||
163 | public EList<Turnout> getTurnouts() { | ||
164 | if (turnouts == null) { | ||
165 | turnouts = new EObjectContainmentEList<Turnout>(Turnout.class, this, Modes3Package.MODES3_MODEL_ROOT__TURNOUTS); | ||
166 | } | ||
167 | return turnouts; | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * <!-- begin-user-doc --> | ||
172 | * <!-- end-user-doc --> | ||
173 | * @generated | ||
174 | */ | ||
175 | @Override | ||
176 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
177 | switch (featureID) { | ||
178 | case Modes3Package.MODES3_MODEL_ROOT__TRAINS: | ||
179 | return ((InternalEList<?>)getTrains()).basicRemove(otherEnd, msgs); | ||
180 | case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: | ||
181 | return ((InternalEList<?>)getSegments()).basicRemove(otherEnd, msgs); | ||
182 | case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: | ||
183 | return ((InternalEList<?>)getTurnouts()).basicRemove(otherEnd, msgs); | ||
184 | } | ||
185 | return super.eInverseRemove(otherEnd, featureID, msgs); | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * <!-- begin-user-doc --> | ||
190 | * <!-- end-user-doc --> | ||
191 | * @generated | ||
192 | */ | ||
193 | @Override | ||
194 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
195 | switch (featureID) { | ||
196 | case Modes3Package.MODES3_MODEL_ROOT__ID: | ||
197 | return getId(); | ||
198 | case Modes3Package.MODES3_MODEL_ROOT__TRAINS: | ||
199 | return getTrains(); | ||
200 | case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: | ||
201 | return getSegments(); | ||
202 | case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: | ||
203 | return getTurnouts(); | ||
204 | } | ||
205 | return super.eGet(featureID, resolve, coreType); | ||
206 | } | ||
207 | |||
208 | /** | ||
209 | * <!-- begin-user-doc --> | ||
210 | * <!-- end-user-doc --> | ||
211 | * @generated | ||
212 | */ | ||
213 | @SuppressWarnings("unchecked") | ||
214 | @Override | ||
215 | public void eSet(int featureID, Object newValue) { | ||
216 | switch (featureID) { | ||
217 | case Modes3Package.MODES3_MODEL_ROOT__ID: | ||
218 | setId((Integer)newValue); | ||
219 | return; | ||
220 | case Modes3Package.MODES3_MODEL_ROOT__TRAINS: | ||
221 | getTrains().clear(); | ||
222 | getTrains().addAll((Collection<? extends Train>)newValue); | ||
223 | return; | ||
224 | case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: | ||
225 | getSegments().clear(); | ||
226 | getSegments().addAll((Collection<? extends SimpleSegment>)newValue); | ||
227 | return; | ||
228 | case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: | ||
229 | getTurnouts().clear(); | ||
230 | getTurnouts().addAll((Collection<? extends Turnout>)newValue); | ||
231 | return; | ||
232 | } | ||
233 | super.eSet(featureID, newValue); | ||
234 | } | ||
235 | |||
236 | /** | ||
237 | * <!-- begin-user-doc --> | ||
238 | * <!-- end-user-doc --> | ||
239 | * @generated | ||
240 | */ | ||
241 | @Override | ||
242 | public void eUnset(int featureID) { | ||
243 | switch (featureID) { | ||
244 | case Modes3Package.MODES3_MODEL_ROOT__ID: | ||
245 | setId(ID_EDEFAULT); | ||
246 | return; | ||
247 | case Modes3Package.MODES3_MODEL_ROOT__TRAINS: | ||
248 | getTrains().clear(); | ||
249 | return; | ||
250 | case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: | ||
251 | getSegments().clear(); | ||
252 | return; | ||
253 | case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: | ||
254 | getTurnouts().clear(); | ||
255 | return; | ||
256 | } | ||
257 | super.eUnset(featureID); | ||
258 | } | ||
259 | |||
260 | /** | ||
261 | * <!-- begin-user-doc --> | ||
262 | * <!-- end-user-doc --> | ||
263 | * @generated | ||
264 | */ | ||
265 | @Override | ||
266 | public boolean eIsSet(int featureID) { | ||
267 | switch (featureID) { | ||
268 | case Modes3Package.MODES3_MODEL_ROOT__ID: | ||
269 | return id != ID_EDEFAULT; | ||
270 | case Modes3Package.MODES3_MODEL_ROOT__TRAINS: | ||
271 | return trains != null && !trains.isEmpty(); | ||
272 | case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: | ||
273 | return segments != null && !segments.isEmpty(); | ||
274 | case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: | ||
275 | return turnouts != null && !turnouts.isEmpty(); | ||
276 | } | ||
277 | return super.eIsSet(featureID); | ||
278 | } | ||
279 | |||
280 | /** | ||
281 | * <!-- begin-user-doc --> | ||
282 | * <!-- end-user-doc --> | ||
283 | * @generated | ||
284 | */ | ||
285 | @Override | ||
286 | public String toString() { | ||
287 | if (eIsProxy()) return super.toString(); | ||
288 | |||
289 | StringBuilder result = new StringBuilder(super.toString()); | ||
290 | result.append(" (id: "); | ||
291 | result.append(id); | ||
292 | result.append(')'); | ||
293 | return result.toString(); | ||
294 | } | ||
295 | |||
296 | } //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..557da4c1 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3PackageImpl.java | |||
@@ -0,0 +1,385 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.impl; | ||
4 | |||
5 | import modes3.Modes3Factory; | ||
6 | import modes3.Modes3ModelRoot; | ||
7 | import modes3.Modes3Package; | ||
8 | import modes3.Segment; | ||
9 | import modes3.SimpleSegment; | ||
10 | import modes3.Train; | ||
11 | import modes3.Turnout; | ||
12 | |||
13 | import org.eclipse.emf.ecore.EAttribute; | ||
14 | import org.eclipse.emf.ecore.EClass; | ||
15 | import org.eclipse.emf.ecore.EPackage; | ||
16 | import org.eclipse.emf.ecore.EReference; | ||
17 | |||
18 | import org.eclipse.emf.ecore.impl.EPackageImpl; | ||
19 | |||
20 | /** | ||
21 | * <!-- begin-user-doc --> | ||
22 | * An implementation of the model <b>Package</b>. | ||
23 | * <!-- end-user-doc --> | ||
24 | * @generated | ||
25 | */ | ||
26 | public class Modes3PackageImpl extends EPackageImpl implements Modes3Package { | ||
27 | /** | ||
28 | * <!-- begin-user-doc --> | ||
29 | * <!-- end-user-doc --> | ||
30 | * @generated | ||
31 | */ | ||
32 | private EClass segmentEClass = null; | ||
33 | |||
34 | /** | ||
35 | * <!-- begin-user-doc --> | ||
36 | * <!-- end-user-doc --> | ||
37 | * @generated | ||
38 | */ | ||
39 | private EClass modes3ModelRootEClass = null; | ||
40 | |||
41 | /** | ||
42 | * <!-- begin-user-doc --> | ||
43 | * <!-- end-user-doc --> | ||
44 | * @generated | ||
45 | */ | ||
46 | private EClass turnoutEClass = null; | ||
47 | |||
48 | /** | ||
49 | * <!-- begin-user-doc --> | ||
50 | * <!-- end-user-doc --> | ||
51 | * @generated | ||
52 | */ | ||
53 | private EClass trainEClass = null; | ||
54 | |||
55 | /** | ||
56 | * <!-- begin-user-doc --> | ||
57 | * <!-- end-user-doc --> | ||
58 | * @generated | ||
59 | */ | ||
60 | private EClass simpleSegmentEClass = null; | ||
61 | |||
62 | /** | ||
63 | * Creates an instance of the model <b>Package</b>, registered with | ||
64 | * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package | ||
65 | * package URI value. | ||
66 | * <p>Note: the correct way to create the package is via the static | ||
67 | * factory method {@link #init init()}, which also performs | ||
68 | * initialization of the package, or returns the registered package, | ||
69 | * if one already exists. | ||
70 | * <!-- begin-user-doc --> | ||
71 | * <!-- end-user-doc --> | ||
72 | * @see org.eclipse.emf.ecore.EPackage.Registry | ||
73 | * @see modes3.Modes3Package#eNS_URI | ||
74 | * @see #init() | ||
75 | * @generated | ||
76 | */ | ||
77 | private Modes3PackageImpl() { | ||
78 | super(eNS_URI, Modes3Factory.eINSTANCE); | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * <!-- begin-user-doc --> | ||
83 | * <!-- end-user-doc --> | ||
84 | * @generated | ||
85 | */ | ||
86 | private static boolean isInited = false; | ||
87 | |||
88 | /** | ||
89 | * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. | ||
90 | * | ||
91 | * <p>This method is used to initialize {@link Modes3Package#eINSTANCE} when that field is accessed. | ||
92 | * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. | ||
93 | * <!-- begin-user-doc --> | ||
94 | * <!-- end-user-doc --> | ||
95 | * @see #eNS_URI | ||
96 | * @see #createPackageContents() | ||
97 | * @see #initializePackageContents() | ||
98 | * @generated | ||
99 | */ | ||
100 | public static Modes3Package init() { | ||
101 | if (isInited) return (Modes3Package)EPackage.Registry.INSTANCE.getEPackage(Modes3Package.eNS_URI); | ||
102 | |||
103 | // Obtain or create and register package | ||
104 | Object registeredModes3Package = EPackage.Registry.INSTANCE.get(eNS_URI); | ||
105 | Modes3PackageImpl theModes3Package = registeredModes3Package instanceof Modes3PackageImpl ? (Modes3PackageImpl)registeredModes3Package : new Modes3PackageImpl(); | ||
106 | |||
107 | isInited = true; | ||
108 | |||
109 | // Create package meta-data objects | ||
110 | theModes3Package.createPackageContents(); | ||
111 | |||
112 | // Initialize created meta-data | ||
113 | theModes3Package.initializePackageContents(); | ||
114 | |||
115 | // Mark meta-data to indicate it can't be changed | ||
116 | theModes3Package.freeze(); | ||
117 | |||
118 | // Update the registry and return the package | ||
119 | EPackage.Registry.INSTANCE.put(Modes3Package.eNS_URI, theModes3Package); | ||
120 | return theModes3Package; | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * <!-- begin-user-doc --> | ||
125 | * <!-- end-user-doc --> | ||
126 | * @generated | ||
127 | */ | ||
128 | public EClass getSegment() { | ||
129 | return segmentEClass; | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * <!-- begin-user-doc --> | ||
134 | * <!-- end-user-doc --> | ||
135 | * @generated | ||
136 | */ | ||
137 | public EReference getSegment_ConnectedTo() { | ||
138 | return (EReference)segmentEClass.getEStructuralFeatures().get(0); | ||
139 | } | ||
140 | |||
141 | /** | ||
142 | * <!-- begin-user-doc --> | ||
143 | * <!-- end-user-doc --> | ||
144 | * @generated | ||
145 | */ | ||
146 | public EReference getSegment_OccupiedBy() { | ||
147 | return (EReference)segmentEClass.getEStructuralFeatures().get(1); | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * <!-- begin-user-doc --> | ||
152 | * <!-- end-user-doc --> | ||
153 | * @generated | ||
154 | */ | ||
155 | public EAttribute getSegment_Id() { | ||
156 | return (EAttribute)segmentEClass.getEStructuralFeatures().get(2); | ||
157 | } | ||
158 | |||
159 | /** | ||
160 | * <!-- begin-user-doc --> | ||
161 | * <!-- end-user-doc --> | ||
162 | * @generated | ||
163 | */ | ||
164 | public EClass getModes3ModelRoot() { | ||
165 | return modes3ModelRootEClass; | ||
166 | } | ||
167 | |||
168 | /** | ||
169 | * <!-- begin-user-doc --> | ||
170 | * <!-- end-user-doc --> | ||
171 | * @generated | ||
172 | */ | ||
173 | public EAttribute getModes3ModelRoot_Id() { | ||
174 | return (EAttribute)modes3ModelRootEClass.getEStructuralFeatures().get(0); | ||
175 | } | ||
176 | |||
177 | /** | ||
178 | * <!-- begin-user-doc --> | ||
179 | * <!-- end-user-doc --> | ||
180 | * @generated | ||
181 | */ | ||
182 | public EReference getModes3ModelRoot_Trains() { | ||
183 | return (EReference)modes3ModelRootEClass.getEStructuralFeatures().get(1); | ||
184 | } | ||
185 | |||
186 | /** | ||
187 | * <!-- begin-user-doc --> | ||
188 | * <!-- end-user-doc --> | ||
189 | * @generated | ||
190 | */ | ||
191 | public EReference getModes3ModelRoot_Segments() { | ||
192 | return (EReference)modes3ModelRootEClass.getEStructuralFeatures().get(2); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * <!-- begin-user-doc --> | ||
197 | * <!-- end-user-doc --> | ||
198 | * @generated | ||
199 | */ | ||
200 | public EReference getModes3ModelRoot_Turnouts() { | ||
201 | return (EReference)modes3ModelRootEClass.getEStructuralFeatures().get(3); | ||
202 | } | ||
203 | |||
204 | /** | ||
205 | * <!-- begin-user-doc --> | ||
206 | * <!-- end-user-doc --> | ||
207 | * @generated | ||
208 | */ | ||
209 | public EClass getTurnout() { | ||
210 | return turnoutEClass; | ||
211 | } | ||
212 | |||
213 | /** | ||
214 | * <!-- begin-user-doc --> | ||
215 | * <!-- end-user-doc --> | ||
216 | * @generated | ||
217 | */ | ||
218 | public EReference getTurnout_Straight() { | ||
219 | return (EReference)turnoutEClass.getEStructuralFeatures().get(0); | ||
220 | } | ||
221 | |||
222 | /** | ||
223 | * <!-- begin-user-doc --> | ||
224 | * <!-- end-user-doc --> | ||
225 | * @generated | ||
226 | */ | ||
227 | public EReference getTurnout_Divergent() { | ||
228 | return (EReference)turnoutEClass.getEStructuralFeatures().get(1); | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * <!-- begin-user-doc --> | ||
233 | * <!-- end-user-doc --> | ||
234 | * @generated | ||
235 | */ | ||
236 | public EClass getTrain() { | ||
237 | return trainEClass; | ||
238 | } | ||
239 | |||
240 | /** | ||
241 | * <!-- begin-user-doc --> | ||
242 | * <!-- end-user-doc --> | ||
243 | * @generated | ||
244 | */ | ||
245 | public EReference getTrain_Location() { | ||
246 | return (EReference)trainEClass.getEStructuralFeatures().get(0); | ||
247 | } | ||
248 | |||
249 | /** | ||
250 | * <!-- begin-user-doc --> | ||
251 | * <!-- end-user-doc --> | ||
252 | * @generated | ||
253 | */ | ||
254 | public EAttribute getTrain_Id() { | ||
255 | return (EAttribute)trainEClass.getEStructuralFeatures().get(1); | ||
256 | } | ||
257 | |||
258 | /** | ||
259 | * <!-- begin-user-doc --> | ||
260 | * <!-- end-user-doc --> | ||
261 | * @generated | ||
262 | */ | ||
263 | public EAttribute getTrain_Speed() { | ||
264 | return (EAttribute)trainEClass.getEStructuralFeatures().get(2); | ||
265 | } | ||
266 | |||
267 | /** | ||
268 | * <!-- begin-user-doc --> | ||
269 | * <!-- end-user-doc --> | ||
270 | * @generated | ||
271 | */ | ||
272 | public EClass getSimpleSegment() { | ||
273 | return simpleSegmentEClass; | ||
274 | } | ||
275 | |||
276 | /** | ||
277 | * <!-- begin-user-doc --> | ||
278 | * <!-- end-user-doc --> | ||
279 | * @generated | ||
280 | */ | ||
281 | public Modes3Factory getModes3Factory() { | ||
282 | return (Modes3Factory)getEFactoryInstance(); | ||
283 | } | ||
284 | |||
285 | /** | ||
286 | * <!-- begin-user-doc --> | ||
287 | * <!-- end-user-doc --> | ||
288 | * @generated | ||
289 | */ | ||
290 | private boolean isCreated = false; | ||
291 | |||
292 | /** | ||
293 | * Creates the meta-model objects for the package. This method is | ||
294 | * guarded to have no affect on any invocation but its first. | ||
295 | * <!-- begin-user-doc --> | ||
296 | * <!-- end-user-doc --> | ||
297 | * @generated | ||
298 | */ | ||
299 | public void createPackageContents() { | ||
300 | if (isCreated) return; | ||
301 | isCreated = true; | ||
302 | |||
303 | // Create classes and their features | ||
304 | segmentEClass = createEClass(SEGMENT); | ||
305 | createEReference(segmentEClass, SEGMENT__CONNECTED_TO); | ||
306 | createEReference(segmentEClass, SEGMENT__OCCUPIED_BY); | ||
307 | createEAttribute(segmentEClass, SEGMENT__ID); | ||
308 | |||
309 | modes3ModelRootEClass = createEClass(MODES3_MODEL_ROOT); | ||
310 | createEAttribute(modes3ModelRootEClass, MODES3_MODEL_ROOT__ID); | ||
311 | createEReference(modes3ModelRootEClass, MODES3_MODEL_ROOT__TRAINS); | ||
312 | createEReference(modes3ModelRootEClass, MODES3_MODEL_ROOT__SEGMENTS); | ||
313 | createEReference(modes3ModelRootEClass, MODES3_MODEL_ROOT__TURNOUTS); | ||
314 | |||
315 | turnoutEClass = createEClass(TURNOUT); | ||
316 | createEReference(turnoutEClass, TURNOUT__STRAIGHT); | ||
317 | createEReference(turnoutEClass, TURNOUT__DIVERGENT); | ||
318 | |||
319 | trainEClass = createEClass(TRAIN); | ||
320 | createEReference(trainEClass, TRAIN__LOCATION); | ||
321 | createEAttribute(trainEClass, TRAIN__ID); | ||
322 | createEAttribute(trainEClass, TRAIN__SPEED); | ||
323 | |||
324 | simpleSegmentEClass = createEClass(SIMPLE_SEGMENT); | ||
325 | } | ||
326 | |||
327 | /** | ||
328 | * <!-- begin-user-doc --> | ||
329 | * <!-- end-user-doc --> | ||
330 | * @generated | ||
331 | */ | ||
332 | private boolean isInitialized = false; | ||
333 | |||
334 | /** | ||
335 | * Complete the initialization of the package and its meta-model. This | ||
336 | * method is guarded to have no affect on any invocation but its first. | ||
337 | * <!-- begin-user-doc --> | ||
338 | * <!-- end-user-doc --> | ||
339 | * @generated | ||
340 | */ | ||
341 | public void initializePackageContents() { | ||
342 | if (isInitialized) return; | ||
343 | isInitialized = true; | ||
344 | |||
345 | // Initialize package | ||
346 | setName(eNAME); | ||
347 | setNsPrefix(eNS_PREFIX); | ||
348 | setNsURI(eNS_URI); | ||
349 | |||
350 | // Create type parameters | ||
351 | |||
352 | // Set bounds for type parameters | ||
353 | |||
354 | // Add supertypes to classes | ||
355 | turnoutEClass.getESuperTypes().add(this.getSegment()); | ||
356 | simpleSegmentEClass.getESuperTypes().add(this.getSegment()); | ||
357 | |||
358 | // Initialize classes, features, and operations; add parameters | ||
359 | initEClass(segmentEClass, Segment.class, "Segment", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | ||
360 | 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); | ||
361 | 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); | ||
362 | 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); | ||
363 | |||
364 | initEClass(modes3ModelRootEClass, Modes3ModelRoot.class, "Modes3ModelRoot", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | ||
365 | 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); | ||
366 | 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); | ||
367 | initEReference(getModes3ModelRoot_Segments(), this.getSimpleSegment(), 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); | ||
368 | 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); | ||
369 | |||
370 | initEClass(turnoutEClass, Turnout.class, "Turnout", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | ||
371 | 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); | ||
372 | 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); | ||
373 | |||
374 | initEClass(trainEClass, Train.class, "Train", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | ||
375 | 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); | ||
376 | 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); | ||
377 | 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); | ||
378 | |||
379 | initEClass(simpleSegmentEClass, SimpleSegment.class, "SimpleSegment", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | ||
380 | |||
381 | // Create resource | ||
382 | createResource(eNS_URI); | ||
383 | } | ||
384 | |||
385 | } //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 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.impl; | ||
4 | |||
5 | import java.util.Collection; | ||
6 | |||
7 | import modes3.Modes3Package; | ||
8 | import modes3.Segment; | ||
9 | import modes3.Train; | ||
10 | |||
11 | import org.eclipse.emf.common.notify.Notification; | ||
12 | import org.eclipse.emf.common.notify.NotificationChain; | ||
13 | |||
14 | import org.eclipse.emf.common.util.EList; | ||
15 | |||
16 | import org.eclipse.emf.ecore.EClass; | ||
17 | import org.eclipse.emf.ecore.InternalEObject; | ||
18 | |||
19 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
20 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; | ||
21 | |||
22 | import org.eclipse.emf.ecore.util.EObjectResolvingEList; | ||
23 | |||
24 | /** | ||
25 | * <!-- begin-user-doc --> | ||
26 | * An implementation of the model object '<em><b>Segment</b></em>'. | ||
27 | * <!-- end-user-doc --> | ||
28 | * <p> | ||
29 | * The following features are implemented: | ||
30 | * </p> | ||
31 | * <ul> | ||
32 | * <li>{@link modes3.impl.SegmentImpl#getConnectedTo <em>Connected To</em>}</li> | ||
33 | * <li>{@link modes3.impl.SegmentImpl#getOccupiedBy <em>Occupied By</em>}</li> | ||
34 | * <li>{@link modes3.impl.SegmentImpl#getId <em>Id</em>}</li> | ||
35 | * </ul> | ||
36 | * | ||
37 | * @generated | ||
38 | */ | ||
39 | public class SegmentImpl extends MinimalEObjectImpl.Container implements Segment { | ||
40 | /** | ||
41 | * The cached value of the '{@link #getConnectedTo() <em>Connected To</em>}' reference list. | ||
42 | * <!-- begin-user-doc --> | ||
43 | * <!-- end-user-doc --> | ||
44 | * @see #getConnectedTo() | ||
45 | * @generated | ||
46 | * @ordered | ||
47 | */ | ||
48 | protected EList<Segment> connectedTo; | ||
49 | |||
50 | /** | ||
51 | * The cached value of the '{@link #getOccupiedBy() <em>Occupied By</em>}' reference. | ||
52 | * <!-- begin-user-doc --> | ||
53 | * <!-- end-user-doc --> | ||
54 | * @see #getOccupiedBy() | ||
55 | * @generated | ||
56 | * @ordered | ||
57 | */ | ||
58 | protected Train occupiedBy; | ||
59 | |||
60 | /** | ||
61 | * The default value of the '{@link #getId() <em>Id</em>}' attribute. | ||
62 | * <!-- begin-user-doc --> | ||
63 | * <!-- end-user-doc --> | ||
64 | * @see #getId() | ||
65 | * @generated | ||
66 | * @ordered | ||
67 | */ | ||
68 | protected static final int ID_EDEFAULT = 0; | ||
69 | |||
70 | /** | ||
71 | * The cached value of the '{@link #getId() <em>Id</em>}' attribute. | ||
72 | * <!-- begin-user-doc --> | ||
73 | * <!-- end-user-doc --> | ||
74 | * @see #getId() | ||
75 | * @generated | ||
76 | * @ordered | ||
77 | */ | ||
78 | protected int id = ID_EDEFAULT; | ||
79 | |||
80 | /** | ||
81 | * <!-- begin-user-doc --> | ||
82 | * <!-- end-user-doc --> | ||
83 | * @generated | ||
84 | */ | ||
85 | protected SegmentImpl() { | ||
86 | super(); | ||
87 | } | ||
88 | |||
89 | /** | ||
90 | * <!-- begin-user-doc --> | ||
91 | * <!-- end-user-doc --> | ||
92 | * @generated | ||
93 | */ | ||
94 | @Override | ||
95 | protected EClass eStaticClass() { | ||
96 | return Modes3Package.Literals.SEGMENT; | ||
97 | } | ||
98 | |||
99 | /** | ||
100 | * <!-- begin-user-doc --> | ||
101 | * <!-- end-user-doc --> | ||
102 | * @generated | ||
103 | */ | ||
104 | public EList<Segment> getConnectedTo() { | ||
105 | if (connectedTo == null) { | ||
106 | connectedTo = new EObjectResolvingEList<Segment>(Segment.class, this, Modes3Package.SEGMENT__CONNECTED_TO); | ||
107 | } | ||
108 | return connectedTo; | ||
109 | } | ||
110 | |||
111 | /** | ||
112 | * <!-- begin-user-doc --> | ||
113 | * <!-- end-user-doc --> | ||
114 | * @generated | ||
115 | */ | ||
116 | public Train getOccupiedBy() { | ||
117 | if (occupiedBy != null && occupiedBy.eIsProxy()) { | ||
118 | InternalEObject oldOccupiedBy = (InternalEObject)occupiedBy; | ||
119 | occupiedBy = (Train)eResolveProxy(oldOccupiedBy); | ||
120 | if (occupiedBy != oldOccupiedBy) { | ||
121 | if (eNotificationRequired()) | ||
122 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, Modes3Package.SEGMENT__OCCUPIED_BY, oldOccupiedBy, occupiedBy)); | ||
123 | } | ||
124 | } | ||
125 | return occupiedBy; | ||
126 | } | ||
127 | |||
128 | /** | ||
129 | * <!-- begin-user-doc --> | ||
130 | * <!-- end-user-doc --> | ||
131 | * @generated | ||
132 | */ | ||
133 | public Train basicGetOccupiedBy() { | ||
134 | return occupiedBy; | ||
135 | } | ||
136 | |||
137 | /** | ||
138 | * <!-- begin-user-doc --> | ||
139 | * <!-- end-user-doc --> | ||
140 | * @generated | ||
141 | */ | ||
142 | public NotificationChain basicSetOccupiedBy(Train newOccupiedBy, NotificationChain msgs) { | ||
143 | Train oldOccupiedBy = occupiedBy; | ||
144 | occupiedBy = newOccupiedBy; | ||
145 | if (eNotificationRequired()) { | ||
146 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Modes3Package.SEGMENT__OCCUPIED_BY, oldOccupiedBy, newOccupiedBy); | ||
147 | if (msgs == null) msgs = notification; else msgs.add(notification); | ||
148 | } | ||
149 | return msgs; | ||
150 | } | ||
151 | |||
152 | /** | ||
153 | * <!-- begin-user-doc --> | ||
154 | * <!-- end-user-doc --> | ||
155 | * @generated | ||
156 | */ | ||
157 | public void setOccupiedBy(Train newOccupiedBy) { | ||
158 | if (newOccupiedBy != occupiedBy) { | ||
159 | NotificationChain msgs = null; | ||
160 | if (occupiedBy != null) | ||
161 | msgs = ((InternalEObject)occupiedBy).eInverseRemove(this, Modes3Package.TRAIN__LOCATION, Train.class, msgs); | ||
162 | if (newOccupiedBy != null) | ||
163 | msgs = ((InternalEObject)newOccupiedBy).eInverseAdd(this, Modes3Package.TRAIN__LOCATION, Train.class, msgs); | ||
164 | msgs = basicSetOccupiedBy(newOccupiedBy, msgs); | ||
165 | if (msgs != null) msgs.dispatch(); | ||
166 | } | ||
167 | else if (eNotificationRequired()) | ||
168 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.SEGMENT__OCCUPIED_BY, newOccupiedBy, newOccupiedBy)); | ||
169 | } | ||
170 | |||
171 | /** | ||
172 | * <!-- begin-user-doc --> | ||
173 | * <!-- end-user-doc --> | ||
174 | * @generated | ||
175 | */ | ||
176 | public int getId() { | ||
177 | return id; | ||
178 | } | ||
179 | |||
180 | /** | ||
181 | * <!-- begin-user-doc --> | ||
182 | * <!-- end-user-doc --> | ||
183 | * @generated | ||
184 | */ | ||
185 | public void setId(int newId) { | ||
186 | int oldId = id; | ||
187 | id = newId; | ||
188 | if (eNotificationRequired()) | ||
189 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.SEGMENT__ID, oldId, id)); | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * <!-- begin-user-doc --> | ||
194 | * <!-- end-user-doc --> | ||
195 | * @generated | ||
196 | */ | ||
197 | @Override | ||
198 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
199 | switch (featureID) { | ||
200 | case Modes3Package.SEGMENT__OCCUPIED_BY: | ||
201 | if (occupiedBy != null) | ||
202 | msgs = ((InternalEObject)occupiedBy).eInverseRemove(this, Modes3Package.TRAIN__LOCATION, Train.class, msgs); | ||
203 | return basicSetOccupiedBy((Train)otherEnd, msgs); | ||
204 | } | ||
205 | return super.eInverseAdd(otherEnd, featureID, msgs); | ||
206 | } | ||
207 | |||
208 | /** | ||
209 | * <!-- begin-user-doc --> | ||
210 | * <!-- end-user-doc --> | ||
211 | * @generated | ||
212 | */ | ||
213 | @Override | ||
214 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
215 | switch (featureID) { | ||
216 | case Modes3Package.SEGMENT__OCCUPIED_BY: | ||
217 | return basicSetOccupiedBy(null, msgs); | ||
218 | } | ||
219 | return super.eInverseRemove(otherEnd, featureID, msgs); | ||
220 | } | ||
221 | |||
222 | /** | ||
223 | * <!-- begin-user-doc --> | ||
224 | * <!-- end-user-doc --> | ||
225 | * @generated | ||
226 | */ | ||
227 | @Override | ||
228 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
229 | switch (featureID) { | ||
230 | case Modes3Package.SEGMENT__CONNECTED_TO: | ||
231 | return getConnectedTo(); | ||
232 | case Modes3Package.SEGMENT__OCCUPIED_BY: | ||
233 | if (resolve) return getOccupiedBy(); | ||
234 | return basicGetOccupiedBy(); | ||
235 | case Modes3Package.SEGMENT__ID: | ||
236 | return getId(); | ||
237 | } | ||
238 | return super.eGet(featureID, resolve, coreType); | ||
239 | } | ||
240 | |||
241 | /** | ||
242 | * <!-- begin-user-doc --> | ||
243 | * <!-- end-user-doc --> | ||
244 | * @generated | ||
245 | */ | ||
246 | @SuppressWarnings("unchecked") | ||
247 | @Override | ||
248 | public void eSet(int featureID, Object newValue) { | ||
249 | switch (featureID) { | ||
250 | case Modes3Package.SEGMENT__CONNECTED_TO: | ||
251 | getConnectedTo().clear(); | ||
252 | getConnectedTo().addAll((Collection<? extends Segment>)newValue); | ||
253 | return; | ||
254 | case Modes3Package.SEGMENT__OCCUPIED_BY: | ||
255 | setOccupiedBy((Train)newValue); | ||
256 | return; | ||
257 | case Modes3Package.SEGMENT__ID: | ||
258 | setId((Integer)newValue); | ||
259 | return; | ||
260 | } | ||
261 | super.eSet(featureID, newValue); | ||
262 | } | ||
263 | |||
264 | /** | ||
265 | * <!-- begin-user-doc --> | ||
266 | * <!-- end-user-doc --> | ||
267 | * @generated | ||
268 | */ | ||
269 | @Override | ||
270 | public void eUnset(int featureID) { | ||
271 | switch (featureID) { | ||
272 | case Modes3Package.SEGMENT__CONNECTED_TO: | ||
273 | getConnectedTo().clear(); | ||
274 | return; | ||
275 | case Modes3Package.SEGMENT__OCCUPIED_BY: | ||
276 | setOccupiedBy((Train)null); | ||
277 | return; | ||
278 | case Modes3Package.SEGMENT__ID: | ||
279 | setId(ID_EDEFAULT); | ||
280 | return; | ||
281 | } | ||
282 | super.eUnset(featureID); | ||
283 | } | ||
284 | |||
285 | /** | ||
286 | * <!-- begin-user-doc --> | ||
287 | * <!-- end-user-doc --> | ||
288 | * @generated | ||
289 | */ | ||
290 | @Override | ||
291 | public boolean eIsSet(int featureID) { | ||
292 | switch (featureID) { | ||
293 | case Modes3Package.SEGMENT__CONNECTED_TO: | ||
294 | return connectedTo != null && !connectedTo.isEmpty(); | ||
295 | case Modes3Package.SEGMENT__OCCUPIED_BY: | ||
296 | return occupiedBy != null; | ||
297 | case Modes3Package.SEGMENT__ID: | ||
298 | return id != ID_EDEFAULT; | ||
299 | } | ||
300 | return super.eIsSet(featureID); | ||
301 | } | ||
302 | |||
303 | /** | ||
304 | * <!-- begin-user-doc --> | ||
305 | * <!-- end-user-doc --> | ||
306 | * @generated | ||
307 | */ | ||
308 | @Override | ||
309 | public String toString() { | ||
310 | if (eIsProxy()) return super.toString(); | ||
311 | |||
312 | StringBuilder result = new StringBuilder(super.toString()); | ||
313 | result.append(" (id: "); | ||
314 | result.append(id); | ||
315 | result.append(')'); | ||
316 | return result.toString(); | ||
317 | } | ||
318 | |||
319 | } //SegmentImpl | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/SimpleSegmentImpl.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/SimpleSegmentImpl.java new file mode 100644 index 00000000..e3fd6c34 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/SimpleSegmentImpl.java | |||
@@ -0,0 +1,37 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.impl; | ||
4 | |||
5 | import modes3.Modes3Package; | ||
6 | import modes3.SimpleSegment; | ||
7 | |||
8 | import org.eclipse.emf.ecore.EClass; | ||
9 | |||
10 | /** | ||
11 | * <!-- begin-user-doc --> | ||
12 | * An implementation of the model object '<em><b>Simple Segment</b></em>'. | ||
13 | * <!-- end-user-doc --> | ||
14 | * | ||
15 | * @generated | ||
16 | */ | ||
17 | public class SimpleSegmentImpl extends SegmentImpl implements SimpleSegment { | ||
18 | /** | ||
19 | * <!-- begin-user-doc --> | ||
20 | * <!-- end-user-doc --> | ||
21 | * @generated | ||
22 | */ | ||
23 | protected SimpleSegmentImpl() { | ||
24 | super(); | ||
25 | } | ||
26 | |||
27 | /** | ||
28 | * <!-- begin-user-doc --> | ||
29 | * <!-- end-user-doc --> | ||
30 | * @generated | ||
31 | */ | ||
32 | @Override | ||
33 | protected EClass eStaticClass() { | ||
34 | return Modes3Package.Literals.SIMPLE_SEGMENT; | ||
35 | } | ||
36 | |||
37 | } //SimpleSegmentImpl | ||
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 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.impl; | ||
4 | |||
5 | import modes3.Modes3Package; | ||
6 | import modes3.Segment; | ||
7 | import modes3.Train; | ||
8 | |||
9 | import org.eclipse.emf.common.notify.Notification; | ||
10 | import org.eclipse.emf.common.notify.NotificationChain; | ||
11 | |||
12 | import org.eclipse.emf.ecore.EClass; | ||
13 | import org.eclipse.emf.ecore.InternalEObject; | ||
14 | |||
15 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
16 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; | ||
17 | |||
18 | /** | ||
19 | * <!-- begin-user-doc --> | ||
20 | * An implementation of the model object '<em><b>Train</b></em>'. | ||
21 | * <!-- end-user-doc --> | ||
22 | * <p> | ||
23 | * The following features are implemented: | ||
24 | * </p> | ||
25 | * <ul> | ||
26 | * <li>{@link modes3.impl.TrainImpl#getLocation <em>Location</em>}</li> | ||
27 | * <li>{@link modes3.impl.TrainImpl#getId <em>Id</em>}</li> | ||
28 | * <li>{@link modes3.impl.TrainImpl#getSpeed <em>Speed</em>}</li> | ||
29 | * </ul> | ||
30 | * | ||
31 | * @generated | ||
32 | */ | ||
33 | public class TrainImpl extends MinimalEObjectImpl.Container implements Train { | ||
34 | /** | ||
35 | * The cached value of the '{@link #getLocation() <em>Location</em>}' reference. | ||
36 | * <!-- begin-user-doc --> | ||
37 | * <!-- end-user-doc --> | ||
38 | * @see #getLocation() | ||
39 | * @generated | ||
40 | * @ordered | ||
41 | */ | ||
42 | protected Segment location; | ||
43 | |||
44 | /** | ||
45 | * The default value of the '{@link #getId() <em>Id</em>}' attribute. | ||
46 | * <!-- begin-user-doc --> | ||
47 | * <!-- end-user-doc --> | ||
48 | * @see #getId() | ||
49 | * @generated | ||
50 | * @ordered | ||
51 | */ | ||
52 | protected static final int ID_EDEFAULT = 0; | ||
53 | |||
54 | /** | ||
55 | * The cached value of the '{@link #getId() <em>Id</em>}' attribute. | ||
56 | * <!-- begin-user-doc --> | ||
57 | * <!-- end-user-doc --> | ||
58 | * @see #getId() | ||
59 | * @generated | ||
60 | * @ordered | ||
61 | */ | ||
62 | protected int id = ID_EDEFAULT; | ||
63 | |||
64 | /** | ||
65 | * The default value of the '{@link #getSpeed() <em>Speed</em>}' attribute. | ||
66 | * <!-- begin-user-doc --> | ||
67 | * <!-- end-user-doc --> | ||
68 | * @see #getSpeed() | ||
69 | * @generated | ||
70 | * @ordered | ||
71 | */ | ||
72 | protected static final double SPEED_EDEFAULT = 0.0; | ||
73 | |||
74 | /** | ||
75 | * The cached value of the '{@link #getSpeed() <em>Speed</em>}' attribute. | ||
76 | * <!-- begin-user-doc --> | ||
77 | * <!-- end-user-doc --> | ||
78 | * @see #getSpeed() | ||
79 | * @generated | ||
80 | * @ordered | ||
81 | */ | ||
82 | protected double speed = SPEED_EDEFAULT; | ||
83 | |||
84 | /** | ||
85 | * <!-- begin-user-doc --> | ||
86 | * <!-- end-user-doc --> | ||
87 | * @generated | ||
88 | */ | ||
89 | protected TrainImpl() { | ||
90 | super(); | ||
91 | } | ||
92 | |||
93 | /** | ||
94 | * <!-- begin-user-doc --> | ||
95 | * <!-- end-user-doc --> | ||
96 | * @generated | ||
97 | */ | ||
98 | @Override | ||
99 | protected EClass eStaticClass() { | ||
100 | return Modes3Package.Literals.TRAIN; | ||
101 | } | ||
102 | |||
103 | /** | ||
104 | * <!-- begin-user-doc --> | ||
105 | * <!-- end-user-doc --> | ||
106 | * @generated | ||
107 | */ | ||
108 | public Segment getLocation() { | ||
109 | if (location != null && location.eIsProxy()) { | ||
110 | InternalEObject oldLocation = (InternalEObject)location; | ||
111 | location = (Segment)eResolveProxy(oldLocation); | ||
112 | if (location != oldLocation) { | ||
113 | if (eNotificationRequired()) | ||
114 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, Modes3Package.TRAIN__LOCATION, oldLocation, location)); | ||
115 | } | ||
116 | } | ||
117 | return location; | ||
118 | } | ||
119 | |||
120 | /** | ||
121 | * <!-- begin-user-doc --> | ||
122 | * <!-- end-user-doc --> | ||
123 | * @generated | ||
124 | */ | ||
125 | public Segment basicGetLocation() { | ||
126 | return location; | ||
127 | } | ||
128 | |||
129 | /** | ||
130 | * <!-- begin-user-doc --> | ||
131 | * <!-- end-user-doc --> | ||
132 | * @generated | ||
133 | */ | ||
134 | public NotificationChain basicSetLocation(Segment newLocation, NotificationChain msgs) { | ||
135 | Segment oldLocation = location; | ||
136 | location = newLocation; | ||
137 | if (eNotificationRequired()) { | ||
138 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__LOCATION, oldLocation, newLocation); | ||
139 | if (msgs == null) msgs = notification; else msgs.add(notification); | ||
140 | } | ||
141 | return msgs; | ||
142 | } | ||
143 | |||
144 | /** | ||
145 | * <!-- begin-user-doc --> | ||
146 | * <!-- end-user-doc --> | ||
147 | * @generated | ||
148 | */ | ||
149 | public void setLocation(Segment newLocation) { | ||
150 | if (newLocation != location) { | ||
151 | NotificationChain msgs = null; | ||
152 | if (location != null) | ||
153 | msgs = ((InternalEObject)location).eInverseRemove(this, Modes3Package.SEGMENT__OCCUPIED_BY, Segment.class, msgs); | ||
154 | if (newLocation != null) | ||
155 | msgs = ((InternalEObject)newLocation).eInverseAdd(this, Modes3Package.SEGMENT__OCCUPIED_BY, Segment.class, msgs); | ||
156 | msgs = basicSetLocation(newLocation, msgs); | ||
157 | if (msgs != null) msgs.dispatch(); | ||
158 | } | ||
159 | else if (eNotificationRequired()) | ||
160 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__LOCATION, newLocation, newLocation)); | ||
161 | } | ||
162 | |||
163 | /** | ||
164 | * <!-- begin-user-doc --> | ||
165 | * <!-- end-user-doc --> | ||
166 | * @generated | ||
167 | */ | ||
168 | public int getId() { | ||
169 | return id; | ||
170 | } | ||
171 | |||
172 | /** | ||
173 | * <!-- begin-user-doc --> | ||
174 | * <!-- end-user-doc --> | ||
175 | * @generated | ||
176 | */ | ||
177 | public void setId(int newId) { | ||
178 | int oldId = id; | ||
179 | id = newId; | ||
180 | if (eNotificationRequired()) | ||
181 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__ID, oldId, id)); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * <!-- begin-user-doc --> | ||
186 | * <!-- end-user-doc --> | ||
187 | * @generated | ||
188 | */ | ||
189 | public double getSpeed() { | ||
190 | return speed; | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * <!-- begin-user-doc --> | ||
195 | * <!-- end-user-doc --> | ||
196 | * @generated | ||
197 | */ | ||
198 | public void setSpeed(double newSpeed) { | ||
199 | double oldSpeed = speed; | ||
200 | speed = newSpeed; | ||
201 | if (eNotificationRequired()) | ||
202 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__SPEED, oldSpeed, speed)); | ||
203 | } | ||
204 | |||
205 | /** | ||
206 | * <!-- begin-user-doc --> | ||
207 | * <!-- end-user-doc --> | ||
208 | * @generated | ||
209 | */ | ||
210 | @Override | ||
211 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
212 | switch (featureID) { | ||
213 | case Modes3Package.TRAIN__LOCATION: | ||
214 | if (location != null) | ||
215 | msgs = ((InternalEObject)location).eInverseRemove(this, Modes3Package.SEGMENT__OCCUPIED_BY, Segment.class, msgs); | ||
216 | return basicSetLocation((Segment)otherEnd, msgs); | ||
217 | } | ||
218 | return super.eInverseAdd(otherEnd, featureID, msgs); | ||
219 | } | ||
220 | |||
221 | /** | ||
222 | * <!-- begin-user-doc --> | ||
223 | * <!-- end-user-doc --> | ||
224 | * @generated | ||
225 | */ | ||
226 | @Override | ||
227 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
228 | switch (featureID) { | ||
229 | case Modes3Package.TRAIN__LOCATION: | ||
230 | return basicSetLocation(null, msgs); | ||
231 | } | ||
232 | return super.eInverseRemove(otherEnd, featureID, msgs); | ||
233 | } | ||
234 | |||
235 | /** | ||
236 | * <!-- begin-user-doc --> | ||
237 | * <!-- end-user-doc --> | ||
238 | * @generated | ||
239 | */ | ||
240 | @Override | ||
241 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
242 | switch (featureID) { | ||
243 | case Modes3Package.TRAIN__LOCATION: | ||
244 | if (resolve) return getLocation(); | ||
245 | return basicGetLocation(); | ||
246 | case Modes3Package.TRAIN__ID: | ||
247 | return getId(); | ||
248 | case Modes3Package.TRAIN__SPEED: | ||
249 | return getSpeed(); | ||
250 | } | ||
251 | return super.eGet(featureID, resolve, coreType); | ||
252 | } | ||
253 | |||
254 | /** | ||
255 | * <!-- begin-user-doc --> | ||
256 | * <!-- end-user-doc --> | ||
257 | * @generated | ||
258 | */ | ||
259 | @Override | ||
260 | public void eSet(int featureID, Object newValue) { | ||
261 | switch (featureID) { | ||
262 | case Modes3Package.TRAIN__LOCATION: | ||
263 | setLocation((Segment)newValue); | ||
264 | return; | ||
265 | case Modes3Package.TRAIN__ID: | ||
266 | setId((Integer)newValue); | ||
267 | return; | ||
268 | case Modes3Package.TRAIN__SPEED: | ||
269 | setSpeed((Double)newValue); | ||
270 | return; | ||
271 | } | ||
272 | super.eSet(featureID, newValue); | ||
273 | } | ||
274 | |||
275 | /** | ||
276 | * <!-- begin-user-doc --> | ||
277 | * <!-- end-user-doc --> | ||
278 | * @generated | ||
279 | */ | ||
280 | @Override | ||
281 | public void eUnset(int featureID) { | ||
282 | switch (featureID) { | ||
283 | case Modes3Package.TRAIN__LOCATION: | ||
284 | setLocation((Segment)null); | ||
285 | return; | ||
286 | case Modes3Package.TRAIN__ID: | ||
287 | setId(ID_EDEFAULT); | ||
288 | return; | ||
289 | case Modes3Package.TRAIN__SPEED: | ||
290 | setSpeed(SPEED_EDEFAULT); | ||
291 | return; | ||
292 | } | ||
293 | super.eUnset(featureID); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * <!-- begin-user-doc --> | ||
298 | * <!-- end-user-doc --> | ||
299 | * @generated | ||
300 | */ | ||
301 | @Override | ||
302 | public boolean eIsSet(int featureID) { | ||
303 | switch (featureID) { | ||
304 | case Modes3Package.TRAIN__LOCATION: | ||
305 | return location != null; | ||
306 | case Modes3Package.TRAIN__ID: | ||
307 | return id != ID_EDEFAULT; | ||
308 | case Modes3Package.TRAIN__SPEED: | ||
309 | return speed != SPEED_EDEFAULT; | ||
310 | } | ||
311 | return super.eIsSet(featureID); | ||
312 | } | ||
313 | |||
314 | /** | ||
315 | * <!-- begin-user-doc --> | ||
316 | * <!-- end-user-doc --> | ||
317 | * @generated | ||
318 | */ | ||
319 | @Override | ||
320 | public String toString() { | ||
321 | if (eIsProxy()) return super.toString(); | ||
322 | |||
323 | StringBuilder result = new StringBuilder(super.toString()); | ||
324 | result.append(" (id: "); | ||
325 | result.append(id); | ||
326 | result.append(", speed: "); | ||
327 | result.append(speed); | ||
328 | result.append(')'); | ||
329 | return result.toString(); | ||
330 | } | ||
331 | |||
332 | } //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 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.impl; | ||
4 | |||
5 | import modes3.Modes3Package; | ||
6 | import modes3.Segment; | ||
7 | import modes3.Turnout; | ||
8 | |||
9 | import org.eclipse.emf.common.notify.Notification; | ||
10 | |||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.emf.ecore.InternalEObject; | ||
13 | |||
14 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
15 | |||
16 | /** | ||
17 | * <!-- begin-user-doc --> | ||
18 | * An implementation of the model object '<em><b>Turnout</b></em>'. | ||
19 | * <!-- end-user-doc --> | ||
20 | * <p> | ||
21 | * The following features are implemented: | ||
22 | * </p> | ||
23 | * <ul> | ||
24 | * <li>{@link modes3.impl.TurnoutImpl#getStraight <em>Straight</em>}</li> | ||
25 | * <li>{@link modes3.impl.TurnoutImpl#getDivergent <em>Divergent</em>}</li> | ||
26 | * </ul> | ||
27 | * | ||
28 | * @generated | ||
29 | */ | ||
30 | public class TurnoutImpl extends SegmentImpl implements Turnout { | ||
31 | /** | ||
32 | * The cached value of the '{@link #getStraight() <em>Straight</em>}' reference. | ||
33 | * <!-- begin-user-doc --> | ||
34 | * <!-- end-user-doc --> | ||
35 | * @see #getStraight() | ||
36 | * @generated | ||
37 | * @ordered | ||
38 | */ | ||
39 | protected Segment straight; | ||
40 | |||
41 | /** | ||
42 | * The cached value of the '{@link #getDivergent() <em>Divergent</em>}' reference. | ||
43 | * <!-- begin-user-doc --> | ||
44 | * <!-- end-user-doc --> | ||
45 | * @see #getDivergent() | ||
46 | * @generated | ||
47 | * @ordered | ||
48 | */ | ||
49 | protected Segment divergent; | ||
50 | |||
51 | /** | ||
52 | * <!-- begin-user-doc --> | ||
53 | * <!-- end-user-doc --> | ||
54 | * @generated | ||
55 | */ | ||
56 | protected TurnoutImpl() { | ||
57 | super(); | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * <!-- begin-user-doc --> | ||
62 | * <!-- end-user-doc --> | ||
63 | * @generated | ||
64 | */ | ||
65 | @Override | ||
66 | protected EClass eStaticClass() { | ||
67 | return Modes3Package.Literals.TURNOUT; | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * <!-- begin-user-doc --> | ||
72 | * <!-- end-user-doc --> | ||
73 | * @generated | ||
74 | */ | ||
75 | public Segment getStraight() { | ||
76 | if (straight != null && straight.eIsProxy()) { | ||
77 | InternalEObject oldStraight = (InternalEObject)straight; | ||
78 | straight = (Segment)eResolveProxy(oldStraight); | ||
79 | if (straight != oldStraight) { | ||
80 | if (eNotificationRequired()) | ||
81 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, Modes3Package.TURNOUT__STRAIGHT, oldStraight, straight)); | ||
82 | } | ||
83 | } | ||
84 | return straight; | ||
85 | } | ||
86 | |||
87 | /** | ||
88 | * <!-- begin-user-doc --> | ||
89 | * <!-- end-user-doc --> | ||
90 | * @generated | ||
91 | */ | ||
92 | public Segment basicGetStraight() { | ||
93 | return straight; | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * <!-- begin-user-doc --> | ||
98 | * <!-- end-user-doc --> | ||
99 | * @generated | ||
100 | */ | ||
101 | public void setStraight(Segment newStraight) { | ||
102 | Segment oldStraight = straight; | ||
103 | straight = newStraight; | ||
104 | if (eNotificationRequired()) | ||
105 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TURNOUT__STRAIGHT, oldStraight, straight)); | ||
106 | } | ||
107 | |||
108 | /** | ||
109 | * <!-- begin-user-doc --> | ||
110 | * <!-- end-user-doc --> | ||
111 | * @generated | ||
112 | */ | ||
113 | public Segment getDivergent() { | ||
114 | if (divergent != null && divergent.eIsProxy()) { | ||
115 | InternalEObject oldDivergent = (InternalEObject)divergent; | ||
116 | divergent = (Segment)eResolveProxy(oldDivergent); | ||
117 | if (divergent != oldDivergent) { | ||
118 | if (eNotificationRequired()) | ||
119 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, Modes3Package.TURNOUT__DIVERGENT, oldDivergent, divergent)); | ||
120 | } | ||
121 | } | ||
122 | return divergent; | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * <!-- begin-user-doc --> | ||
127 | * <!-- end-user-doc --> | ||
128 | * @generated | ||
129 | */ | ||
130 | public Segment basicGetDivergent() { | ||
131 | return divergent; | ||
132 | } | ||
133 | |||
134 | /** | ||
135 | * <!-- begin-user-doc --> | ||
136 | * <!-- end-user-doc --> | ||
137 | * @generated | ||
138 | */ | ||
139 | public void setDivergent(Segment newDivergent) { | ||
140 | Segment oldDivergent = divergent; | ||
141 | divergent = newDivergent; | ||
142 | if (eNotificationRequired()) | ||
143 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TURNOUT__DIVERGENT, oldDivergent, divergent)); | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * <!-- begin-user-doc --> | ||
148 | * <!-- end-user-doc --> | ||
149 | * @generated | ||
150 | */ | ||
151 | @Override | ||
152 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
153 | switch (featureID) { | ||
154 | case Modes3Package.TURNOUT__STRAIGHT: | ||
155 | if (resolve) return getStraight(); | ||
156 | return basicGetStraight(); | ||
157 | case Modes3Package.TURNOUT__DIVERGENT: | ||
158 | if (resolve) return getDivergent(); | ||
159 | return basicGetDivergent(); | ||
160 | } | ||
161 | return super.eGet(featureID, resolve, coreType); | ||
162 | } | ||
163 | |||
164 | /** | ||
165 | * <!-- begin-user-doc --> | ||
166 | * <!-- end-user-doc --> | ||
167 | * @generated | ||
168 | */ | ||
169 | @Override | ||
170 | public void eSet(int featureID, Object newValue) { | ||
171 | switch (featureID) { | ||
172 | case Modes3Package.TURNOUT__STRAIGHT: | ||
173 | setStraight((Segment)newValue); | ||
174 | return; | ||
175 | case Modes3Package.TURNOUT__DIVERGENT: | ||
176 | setDivergent((Segment)newValue); | ||
177 | return; | ||
178 | } | ||
179 | super.eSet(featureID, newValue); | ||
180 | } | ||
181 | |||
182 | /** | ||
183 | * <!-- begin-user-doc --> | ||
184 | * <!-- end-user-doc --> | ||
185 | * @generated | ||
186 | */ | ||
187 | @Override | ||
188 | public void eUnset(int featureID) { | ||
189 | switch (featureID) { | ||
190 | case Modes3Package.TURNOUT__STRAIGHT: | ||
191 | setStraight((Segment)null); | ||
192 | return; | ||
193 | case Modes3Package.TURNOUT__DIVERGENT: | ||
194 | setDivergent((Segment)null); | ||
195 | return; | ||
196 | } | ||
197 | super.eUnset(featureID); | ||
198 | } | ||
199 | |||
200 | /** | ||
201 | * <!-- begin-user-doc --> | ||
202 | * <!-- end-user-doc --> | ||
203 | * @generated | ||
204 | */ | ||
205 | @Override | ||
206 | public boolean eIsSet(int featureID) { | ||
207 | switch (featureID) { | ||
208 | case Modes3Package.TURNOUT__STRAIGHT: | ||
209 | return straight != null; | ||
210 | case Modes3Package.TURNOUT__DIVERGENT: | ||
211 | return divergent != null; | ||
212 | } | ||
213 | return super.eIsSet(featureID); | ||
214 | } | ||
215 | |||
216 | } //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..9c5c8d2d --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3AdapterFactory.java | |||
@@ -0,0 +1,192 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.util; | ||
4 | |||
5 | import modes3.*; | ||
6 | |||
7 | import org.eclipse.emf.common.notify.Adapter; | ||
8 | import org.eclipse.emf.common.notify.Notifier; | ||
9 | |||
10 | import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; | ||
11 | |||
12 | import org.eclipse.emf.ecore.EObject; | ||
13 | |||
14 | /** | ||
15 | * <!-- begin-user-doc --> | ||
16 | * The <b>Adapter Factory</b> for the model. | ||
17 | * It provides an adapter <code>createXXX</code> method for each class of the model. | ||
18 | * <!-- end-user-doc --> | ||
19 | * @see modes3.Modes3Package | ||
20 | * @generated | ||
21 | */ | ||
22 | public class Modes3AdapterFactory extends AdapterFactoryImpl { | ||
23 | /** | ||
24 | * The cached model package. | ||
25 | * <!-- begin-user-doc --> | ||
26 | * <!-- end-user-doc --> | ||
27 | * @generated | ||
28 | */ | ||
29 | protected static Modes3Package modelPackage; | ||
30 | |||
31 | /** | ||
32 | * Creates an instance of the adapter factory. | ||
33 | * <!-- begin-user-doc --> | ||
34 | * <!-- end-user-doc --> | ||
35 | * @generated | ||
36 | */ | ||
37 | public Modes3AdapterFactory() { | ||
38 | if (modelPackage == null) { | ||
39 | modelPackage = Modes3Package.eINSTANCE; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | * Returns whether this factory is applicable for the type of the object. | ||
45 | * <!-- begin-user-doc --> | ||
46 | * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. | ||
47 | * <!-- end-user-doc --> | ||
48 | * @return whether this factory is applicable for the type of the object. | ||
49 | * @generated | ||
50 | */ | ||
51 | @Override | ||
52 | public boolean isFactoryForType(Object object) { | ||
53 | if (object == modelPackage) { | ||
54 | return true; | ||
55 | } | ||
56 | if (object instanceof EObject) { | ||
57 | return ((EObject)object).eClass().getEPackage() == modelPackage; | ||
58 | } | ||
59 | return false; | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * The switch that delegates to the <code>createXXX</code> methods. | ||
64 | * <!-- begin-user-doc --> | ||
65 | * <!-- end-user-doc --> | ||
66 | * @generated | ||
67 | */ | ||
68 | protected Modes3Switch<Adapter> modelSwitch = | ||
69 | new Modes3Switch<Adapter>() { | ||
70 | @Override | ||
71 | public Adapter caseSegment(Segment object) { | ||
72 | return createSegmentAdapter(); | ||
73 | } | ||
74 | @Override | ||
75 | public Adapter caseModes3ModelRoot(Modes3ModelRoot object) { | ||
76 | return createModes3ModelRootAdapter(); | ||
77 | } | ||
78 | @Override | ||
79 | public Adapter caseTurnout(Turnout object) { | ||
80 | return createTurnoutAdapter(); | ||
81 | } | ||
82 | @Override | ||
83 | public Adapter caseTrain(Train object) { | ||
84 | return createTrainAdapter(); | ||
85 | } | ||
86 | @Override | ||
87 | public Adapter caseSimpleSegment(SimpleSegment object) { | ||
88 | return createSimpleSegmentAdapter(); | ||
89 | } | ||
90 | @Override | ||
91 | public Adapter defaultCase(EObject object) { | ||
92 | return createEObjectAdapter(); | ||
93 | } | ||
94 | }; | ||
95 | |||
96 | /** | ||
97 | * Creates an adapter for the <code>target</code>. | ||
98 | * <!-- begin-user-doc --> | ||
99 | * <!-- end-user-doc --> | ||
100 | * @param target the object to adapt. | ||
101 | * @return the adapter for the <code>target</code>. | ||
102 | * @generated | ||
103 | */ | ||
104 | @Override | ||
105 | public Adapter createAdapter(Notifier target) { | ||
106 | return modelSwitch.doSwitch((EObject)target); | ||
107 | } | ||
108 | |||
109 | |||
110 | /** | ||
111 | * Creates a new adapter for an object of class '{@link modes3.Segment <em>Segment</em>}'. | ||
112 | * <!-- begin-user-doc --> | ||
113 | * This default implementation returns null so that we can easily ignore cases; | ||
114 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
115 | * <!-- end-user-doc --> | ||
116 | * @return the new adapter. | ||
117 | * @see modes3.Segment | ||
118 | * @generated | ||
119 | */ | ||
120 | public Adapter createSegmentAdapter() { | ||
121 | return null; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * Creates a new adapter for an object of class '{@link modes3.Modes3ModelRoot <em>Model Root</em>}'. | ||
126 | * <!-- begin-user-doc --> | ||
127 | * This default implementation returns null so that we can easily ignore cases; | ||
128 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
129 | * <!-- end-user-doc --> | ||
130 | * @return the new adapter. | ||
131 | * @see modes3.Modes3ModelRoot | ||
132 | * @generated | ||
133 | */ | ||
134 | public Adapter createModes3ModelRootAdapter() { | ||
135 | return null; | ||
136 | } | ||
137 | |||
138 | /** | ||
139 | * Creates a new adapter for an object of class '{@link modes3.Turnout <em>Turnout</em>}'. | ||
140 | * <!-- begin-user-doc --> | ||
141 | * This default implementation returns null so that we can easily ignore cases; | ||
142 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
143 | * <!-- end-user-doc --> | ||
144 | * @return the new adapter. | ||
145 | * @see modes3.Turnout | ||
146 | * @generated | ||
147 | */ | ||
148 | public Adapter createTurnoutAdapter() { | ||
149 | return null; | ||
150 | } | ||
151 | |||
152 | /** | ||
153 | * Creates a new adapter for an object of class '{@link modes3.Train <em>Train</em>}'. | ||
154 | * <!-- begin-user-doc --> | ||
155 | * This default implementation returns null so that we can easily ignore cases; | ||
156 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
157 | * <!-- end-user-doc --> | ||
158 | * @return the new adapter. | ||
159 | * @see modes3.Train | ||
160 | * @generated | ||
161 | */ | ||
162 | public Adapter createTrainAdapter() { | ||
163 | return null; | ||
164 | } | ||
165 | |||
166 | /** | ||
167 | * Creates a new adapter for an object of class '{@link modes3.SimpleSegment <em>Simple Segment</em>}'. | ||
168 | * <!-- begin-user-doc --> | ||
169 | * This default implementation returns null so that we can easily ignore cases; | ||
170 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
171 | * <!-- end-user-doc --> | ||
172 | * @return the new adapter. | ||
173 | * @see modes3.SimpleSegment | ||
174 | * @generated | ||
175 | */ | ||
176 | public Adapter createSimpleSegmentAdapter() { | ||
177 | return null; | ||
178 | } | ||
179 | |||
180 | /** | ||
181 | * Creates a new adapter for the default case. | ||
182 | * <!-- begin-user-doc --> | ||
183 | * This default implementation returns null. | ||
184 | * <!-- end-user-doc --> | ||
185 | * @return the new adapter. | ||
186 | * @generated | ||
187 | */ | ||
188 | public Adapter createEObjectAdapter() { | ||
189 | return null; | ||
190 | } | ||
191 | |||
192 | } //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..0c28861a --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3Switch.java | |||
@@ -0,0 +1,196 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.util; | ||
4 | |||
5 | import modes3.*; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | import org.eclipse.emf.ecore.EPackage; | ||
9 | |||
10 | import org.eclipse.emf.ecore.util.Switch; | ||
11 | |||
12 | /** | ||
13 | * <!-- begin-user-doc --> | ||
14 | * The <b>Switch</b> for the model's inheritance hierarchy. | ||
15 | * It supports the call {@link #doSwitch(EObject) doSwitch(object)} | ||
16 | * to invoke the <code>caseXXX</code> method for each class of the model, | ||
17 | * starting with the actual class of the object | ||
18 | * and proceeding up the inheritance hierarchy | ||
19 | * until a non-null result is returned, | ||
20 | * which is the result of the switch. | ||
21 | * <!-- end-user-doc --> | ||
22 | * @see modes3.Modes3Package | ||
23 | * @generated | ||
24 | */ | ||
25 | public class Modes3Switch<T> extends Switch<T> { | ||
26 | /** | ||
27 | * The cached model package | ||
28 | * <!-- begin-user-doc --> | ||
29 | * <!-- end-user-doc --> | ||
30 | * @generated | ||
31 | */ | ||
32 | protected static Modes3Package modelPackage; | ||
33 | |||
34 | /** | ||
35 | * Creates an instance of the switch. | ||
36 | * <!-- begin-user-doc --> | ||
37 | * <!-- end-user-doc --> | ||
38 | * @generated | ||
39 | */ | ||
40 | public Modes3Switch() { | ||
41 | if (modelPackage == null) { | ||
42 | modelPackage = Modes3Package.eINSTANCE; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | /** | ||
47 | * Checks whether this is a switch for the given package. | ||
48 | * <!-- begin-user-doc --> | ||
49 | * <!-- end-user-doc --> | ||
50 | * @param ePackage the package in question. | ||
51 | * @return whether this is a switch for the given package. | ||
52 | * @generated | ||
53 | */ | ||
54 | @Override | ||
55 | protected boolean isSwitchFor(EPackage ePackage) { | ||
56 | return ePackage == modelPackage; | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. | ||
61 | * <!-- begin-user-doc --> | ||
62 | * <!-- end-user-doc --> | ||
63 | * @return the first non-null result returned by a <code>caseXXX</code> call. | ||
64 | * @generated | ||
65 | */ | ||
66 | @Override | ||
67 | protected T doSwitch(int classifierID, EObject theEObject) { | ||
68 | switch (classifierID) { | ||
69 | case Modes3Package.SEGMENT: { | ||
70 | Segment segment = (Segment)theEObject; | ||
71 | T result = caseSegment(segment); | ||
72 | if (result == null) result = defaultCase(theEObject); | ||
73 | return result; | ||
74 | } | ||
75 | case Modes3Package.MODES3_MODEL_ROOT: { | ||
76 | Modes3ModelRoot modes3ModelRoot = (Modes3ModelRoot)theEObject; | ||
77 | T result = caseModes3ModelRoot(modes3ModelRoot); | ||
78 | if (result == null) result = defaultCase(theEObject); | ||
79 | return result; | ||
80 | } | ||
81 | case Modes3Package.TURNOUT: { | ||
82 | Turnout turnout = (Turnout)theEObject; | ||
83 | T result = caseTurnout(turnout); | ||
84 | if (result == null) result = caseSegment(turnout); | ||
85 | if (result == null) result = defaultCase(theEObject); | ||
86 | return result; | ||
87 | } | ||
88 | case Modes3Package.TRAIN: { | ||
89 | Train train = (Train)theEObject; | ||
90 | T result = caseTrain(train); | ||
91 | if (result == null) result = defaultCase(theEObject); | ||
92 | return result; | ||
93 | } | ||
94 | case Modes3Package.SIMPLE_SEGMENT: { | ||
95 | SimpleSegment simpleSegment = (SimpleSegment)theEObject; | ||
96 | T result = caseSimpleSegment(simpleSegment); | ||
97 | if (result == null) result = caseSegment(simpleSegment); | ||
98 | if (result == null) result = defaultCase(theEObject); | ||
99 | return result; | ||
100 | } | ||
101 | default: return defaultCase(theEObject); | ||
102 | } | ||
103 | } | ||
104 | |||
105 | /** | ||
106 | * Returns the result of interpreting the object as an instance of '<em>Segment</em>'. | ||
107 | * <!-- begin-user-doc --> | ||
108 | * This implementation returns null; | ||
109 | * returning a non-null result will terminate the switch. | ||
110 | * <!-- end-user-doc --> | ||
111 | * @param object the target of the switch. | ||
112 | * @return the result of interpreting the object as an instance of '<em>Segment</em>'. | ||
113 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
114 | * @generated | ||
115 | */ | ||
116 | public T caseSegment(Segment object) { | ||
117 | return null; | ||
118 | } | ||
119 | |||
120 | /** | ||
121 | * Returns the result of interpreting the object as an instance of '<em>Model Root</em>'. | ||
122 | * <!-- begin-user-doc --> | ||
123 | * This implementation returns null; | ||
124 | * returning a non-null result will terminate the switch. | ||
125 | * <!-- end-user-doc --> | ||
126 | * @param object the target of the switch. | ||
127 | * @return the result of interpreting the object as an instance of '<em>Model Root</em>'. | ||
128 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
129 | * @generated | ||
130 | */ | ||
131 | public T caseModes3ModelRoot(Modes3ModelRoot object) { | ||
132 | return null; | ||
133 | } | ||
134 | |||
135 | /** | ||
136 | * Returns the result of interpreting the object as an instance of '<em>Turnout</em>'. | ||
137 | * <!-- begin-user-doc --> | ||
138 | * This implementation returns null; | ||
139 | * returning a non-null result will terminate the switch. | ||
140 | * <!-- end-user-doc --> | ||
141 | * @param object the target of the switch. | ||
142 | * @return the result of interpreting the object as an instance of '<em>Turnout</em>'. | ||
143 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
144 | * @generated | ||
145 | */ | ||
146 | public T caseTurnout(Turnout object) { | ||
147 | return null; | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * Returns the result of interpreting the object as an instance of '<em>Train</em>'. | ||
152 | * <!-- begin-user-doc --> | ||
153 | * This implementation returns null; | ||
154 | * returning a non-null result will terminate the switch. | ||
155 | * <!-- end-user-doc --> | ||
156 | * @param object the target of the switch. | ||
157 | * @return the result of interpreting the object as an instance of '<em>Train</em>'. | ||
158 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
159 | * @generated | ||
160 | */ | ||
161 | public T caseTrain(Train object) { | ||
162 | return null; | ||
163 | } | ||
164 | |||
165 | /** | ||
166 | * Returns the result of interpreting the object as an instance of '<em>Simple Segment</em>'. | ||
167 | * <!-- begin-user-doc --> | ||
168 | * This implementation returns null; | ||
169 | * returning a non-null result will terminate the switch. | ||
170 | * <!-- end-user-doc --> | ||
171 | * @param object the target of the switch. | ||
172 | * @return the result of interpreting the object as an instance of '<em>Simple Segment</em>'. | ||
173 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
174 | * @generated | ||
175 | */ | ||
176 | public T caseSimpleSegment(SimpleSegment object) { | ||
177 | return null; | ||
178 | } | ||
179 | |||
180 | /** | ||
181 | * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. | ||
182 | * <!-- begin-user-doc --> | ||
183 | * This implementation returns null; | ||
184 | * returning a non-null result will terminate the switch, but this is the last case anyway. | ||
185 | * <!-- end-user-doc --> | ||
186 | * @param object the target of the switch. | ||
187 | * @return the result of interpreting the object as an instance of '<em>EObject</em>'. | ||
188 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) | ||
189 | * @generated | ||
190 | */ | ||
191 | @Override | ||
192 | public T defaultCase(EObject object) { | ||
193 | return null; | ||
194 | } | ||
195 | |||
196 | } //Modes3Switch | ||
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..f7cb28be --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.ecore | |||
@@ -0,0 +1,33 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="modes3" nsURI="http://www.ece.mcgill.ca/wcet/modes3" nsPrefix="modes3"> | ||
4 | <eClassifiers xsi:type="ecore:EClass" name="Segment"> | ||
5 | <eStructuralFeatures xsi:type="ecore:EReference" name="connectedTo" upperBound="2" | ||
6 | eType="#//Segment"/> | ||
7 | <eStructuralFeatures xsi:type="ecore:EReference" name="occupiedBy" eType="#//Train" | ||
8 | eOpposite="#//Train/location"/> | ||
9 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
10 | </eClassifiers> | ||
11 | <eClassifiers xsi:type="ecore:EClass" name="Modes3ModelRoot"> | ||
12 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
13 | <eStructuralFeatures xsi:type="ecore:EReference" name="trains" upperBound="-1" | ||
14 | eType="#//Train" containment="true"/> | ||
15 | <eStructuralFeatures xsi:type="ecore:EReference" name="segments" upperBound="-1" | ||
16 | eType="#//SimpleSegment" containment="true"/> | ||
17 | <eStructuralFeatures xsi:type="ecore:EReference" name="turnouts" upperBound="-1" | ||
18 | eType="#//Turnout" containment="true"/> | ||
19 | </eClassifiers> | ||
20 | <eClassifiers xsi:type="ecore:EClass" name="Turnout" eSuperTypes="#//Segment"> | ||
21 | <eStructuralFeatures xsi:type="ecore:EReference" name="straight" lowerBound="1" | ||
22 | eType="#//Segment"/> | ||
23 | <eStructuralFeatures xsi:type="ecore:EReference" name="divergent" lowerBound="1" | ||
24 | eType="#//Segment"/> | ||
25 | </eClassifiers> | ||
26 | <eClassifiers xsi:type="ecore:EClass" name="Train"> | ||
27 | <eStructuralFeatures xsi:type="ecore:EReference" name="location" lowerBound="1" | ||
28 | eType="#//Segment" eOpposite="#//Segment/occupiedBy"/> | ||
29 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
30 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="speed" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDouble"/> | ||
31 | </eClassifiers> | ||
32 | <eClassifiers xsi:type="ecore:EClass" name="SimpleSegment" eSuperTypes="#//Segment"/> | ||
33 | </ecore:EPackage> | ||
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..1cd4ac41 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.genmodel | |||
@@ -0,0 +1,31 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" | ||
3 | xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/ca.mcgill.rtgmrt.example.modes3/ecore-gen" modelPluginID="ca.mcgill.rtgmrt.example.modes3" | ||
4 | modelName="Modes3" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" | ||
5 | importerID="org.eclipse.emf.importer.ecore" complianceLevel="5.0" copyrightFields="false" | ||
6 | operationReflection="true" importOrganizing="true"> | ||
7 | <foreignModel>modes3.ecore</foreignModel> | ||
8 | <genPackages prefix="Modes3" disposableProviderFactory="true" ecorePackage="modes3.ecore#/"> | ||
9 | <genClasses ecoreClass="modes3.ecore#//Segment"> | ||
10 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference modes3.ecore#//Segment/connectedTo"/> | ||
11 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference modes3.ecore#//Segment/occupiedBy"/> | ||
12 | <genFeatures createChild="false" ecoreFeature="ecore:EAttribute modes3.ecore#//Segment/id"/> | ||
13 | </genClasses> | ||
14 | <genClasses ecoreClass="modes3.ecore#//Modes3ModelRoot"> | ||
15 | <genFeatures createChild="false" ecoreFeature="ecore:EAttribute modes3.ecore#//Modes3ModelRoot/id"/> | ||
16 | <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference modes3.ecore#//Modes3ModelRoot/trains"/> | ||
17 | <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference modes3.ecore#//Modes3ModelRoot/segments"/> | ||
18 | <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference modes3.ecore#//Modes3ModelRoot/turnouts"/> | ||
19 | </genClasses> | ||
20 | <genClasses ecoreClass="modes3.ecore#//Turnout"> | ||
21 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference modes3.ecore#//Turnout/straight"/> | ||
22 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference modes3.ecore#//Turnout/divergent"/> | ||
23 | </genClasses> | ||
24 | <genClasses ecoreClass="modes3.ecore#//Train"> | ||
25 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference modes3.ecore#//Train/location"/> | ||
26 | <genFeatures createChild="false" ecoreFeature="ecore:EAttribute modes3.ecore#//Train/id"/> | ||
27 | <genFeatures createChild="false" ecoreFeature="ecore:EAttribute modes3.ecore#//Train/speed"/> | ||
28 | </genClasses> | ||
29 | <genClasses ecoreClass="modes3.ecore#//SimpleSegment"/> | ||
30 | </genPackages> | ||
31 | </genmodel:GenModel> | ||
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 @@ | |||
1 | # | ||
2 | |||
3 | pluginName = ca.mcgill.rtgmrt.example.modes3 | ||
4 | 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..f7d32541 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/plugin.xml | |||
@@ -0,0 +1,44 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?><?eclipse version="3.0"?><!-- | ||
2 | --><plugin> | ||
3 | <extension point="org.eclipse.emf.ecore.generated_package"> | ||
4 | <!-- @generated modes3 --> | ||
5 | <package class="modes3.Modes3Package" genModel="model/modes3.genmodel" uri="http://www.ece.mcgill.ca/wcet/modes3"/> | ||
6 | </extension> | ||
7 | <extension id="modes3.queries.Modes3Queries" point="org.eclipse.viatra.query.runtime.queryspecification"> | ||
8 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:modes3.queries.Modes3Queries" id="modes3.queries.Modes3Queries"> | ||
9 | <query-specification fqn="modes3.queries.connectedTo"/> | ||
10 | <query-specification fqn="modes3.queries.connectedToNotSymmetric"/> | ||
11 | <query-specification fqn="modes3.queries.connectedToReflexive"/> | ||
12 | <query-specification fqn="modes3.queries.turnoutOutput"/> | ||
13 | <query-specification fqn="modes3.queries.outputReflexive"/> | ||
14 | <query-specification fqn="modes3.queries.turnoutOutputsAreSame"/> | ||
15 | <query-specification fqn="modes3.queries.output"/> | ||
16 | <query-specification fqn="modes3.queries.tooManyInputsOfSegment"/> | ||
17 | <query-specification fqn="modes3.queries.turnoutConnectedToBothOutputs"/> | ||
18 | <query-specification fqn="modes3.queries.adjacent"/> | ||
19 | <query-specification fqn="modes3.queries.tooManyInputsOfTurnout"/> | ||
20 | <query-specification fqn="modes3.queries.inputsOfTurnout"/> | ||
21 | <query-specification fqn="modes3.queries.tooFewInputsOfTurnout"/> | ||
22 | <query-specification fqn="modes3.queries.reachable"/> | ||
23 | <query-specification fqn="modes3.queries.unreachable"/> | ||
24 | <query-specification fqn="modes3.queries.closeTrains_step_2"/> | ||
25 | <query-specification fqn="modes3.queries.closeTrains_step_3"/> | ||
26 | <query-specification fqn="modes3.queries.closeTrains_step_4"/> | ||
27 | <query-specification fqn="modes3.queries.closeTrains_step_5"/> | ||
28 | <query-specification fqn="modes3.queries.closeTrains_step_6"/> | ||
29 | <query-specification fqn="modes3.queries.closeTrains_step_7"/> | ||
30 | <query-specification fqn="modes3.queries.trainLocations_step_2"/> | ||
31 | <query-specification fqn="modes3.queries.trainLocations_step_3"/> | ||
32 | <query-specification fqn="modes3.queries.misalignedTurnout_step_2"/> | ||
33 | <query-specification fqn="modes3.queries.misalignedTurnout_step_3"/> | ||
34 | <query-specification fqn="modes3.queries.misalignedTurnout_step_4"/> | ||
35 | <query-specification fqn="modes3.queries.misalignedTurnout_step_5"/> | ||
36 | <query-specification fqn="modes3.queries.connectedSegmentsDirected"/> | ||
37 | <query-specification fqn="modes3.queries.endOfSiding_step_2"/> | ||
38 | <query-specification fqn="modes3.queries.endOfSiding_step_3"/> | ||
39 | <query-specification fqn="modes3.queries.endOfSiding_step_4"/> | ||
40 | <query-specification fqn="modes3.queries.endOfSiding_step_5"/> | ||
41 | <query-specification fqn="modes3.queries.multipleConnectedTo"/> | ||
42 | </group> | ||
43 | </extension> | ||
44 | </plugin> | ||
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..d22bdd8b --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | |||
@@ -0,0 +1,295 @@ | |||
1 | package modes3.queries | ||
2 | |||
3 | import "http://www.ece.mcgill.ca/wcet/modes3" | ||
4 | |||
5 | pattern connectedTo(S1 : Segment, S2 : Segment) { | ||
6 | Segment.connectedTo(S1, S2); | ||
7 | } | ||
8 | |||
9 | @Constraint(message = "connectedToNotSymmetric", severity = "error", key = { S1, S2 }) | ||
10 | pattern connectedToNotSymmetric(S1 : Segment, S2 : Segment) { | ||
11 | Segment.connectedTo(S1, S2); | ||
12 | neg find connectedTo(S2, S1); | ||
13 | } | ||
14 | |||
15 | @Constraint(message = "connectedToReflexive", severity = "error", key = { S }) | ||
16 | pattern connectedToReflexive(S : Segment) { | ||
17 | Segment.connectedTo(S, S); | ||
18 | } | ||
19 | |||
20 | pattern turnoutOutput(T : Turnout, S : Segment) { | ||
21 | Turnout.straight(T, S); | ||
22 | } or { | ||
23 | Turnout.divergent(T, S); | ||
24 | } | ||
25 | |||
26 | @Constraint(message = "outputReflexive", severity = "error", key = { T }) | ||
27 | pattern outputReflexive(T : Turnout) { | ||
28 | find turnoutOutput(T, T); | ||
29 | } | ||
30 | |||
31 | @Constraint(message = "turnoutOutputsAreSame", severity = "error", key = { T }) | ||
32 | pattern turnoutOutputsAreSame(T : Turnout) { | ||
33 | Turnout.straight(T, S); | ||
34 | Turnout.divergent(T, S); | ||
35 | } | ||
36 | |||
37 | pattern output(S1 : Segment, S2 : Segment) { | ||
38 | Segment.connectedTo(S1, S2); | ||
39 | } or { | ||
40 | find turnoutOutput(S1, S2); | ||
41 | } | ||
42 | |||
43 | @Constraint(message = "tooManyInputsOfSegment", severity = "error", key = { S }) | ||
44 | pattern tooManyInputsOfSegment(S : SimpleSegment) { | ||
45 | find output(I1, S); | ||
46 | find output(I2, S); | ||
47 | find output(I3, S); | ||
48 | I1 != I2; | ||
49 | I1 != I3; | ||
50 | I2 != I3; | ||
51 | } | ||
52 | |||
53 | @Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) | ||
54 | pattern turnoutConnectedToBothOutputs(T : Turnout) { | ||
55 | Turnout.straight(T, Straight); | ||
56 | Turnout.divergent(T, Divergent); | ||
57 | Segment.connectedTo(T, Straight); | ||
58 | Segment.connectedTo(T, Divergent); | ||
59 | } | ||
60 | |||
61 | pattern adjacent(S1 : Segment, S2 : Segment) { | ||
62 | find output(S1, S2); | ||
63 | } or { | ||
64 | find turnoutOutput(S2, S1); | ||
65 | } | ||
66 | |||
67 | @Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) | ||
68 | pattern tooManyInputsOfTurnout(T : Turnout) { | ||
69 | find adjacent(I1, T); | ||
70 | find adjacent(I2, T); | ||
71 | find adjacent(I3, T); | ||
72 | find adjacent(I4, T); | ||
73 | I1 != I2; | ||
74 | I1 != I3; | ||
75 | I1 != I4; | ||
76 | I2 != I3; | ||
77 | I2 != I4; | ||
78 | I3 != I4; | ||
79 | } | ||
80 | |||
81 | pattern inputsOfTurnout(T : Turnout) { | ||
82 | find adjacent(I1, T); | ||
83 | find adjacent(I2, T); | ||
84 | find adjacent(I3, T); | ||
85 | I1 != I2; | ||
86 | I1 != I3; | ||
87 | I2 != I3; | ||
88 | } | ||
89 | |||
90 | @Constraint(message = "tooFewInputsOfTurnout", severity = "error", key = { T }) | ||
91 | pattern tooFewInputsOfTurnout(T : Turnout) { | ||
92 | neg find inputsOfTurnout(T); | ||
93 | } | ||
94 | |||
95 | pattern reachable(S1 : Segment, S2 : Segment) { | ||
96 | S1 == S2; | ||
97 | } or { | ||
98 | find adjacent+(S1, S2); | ||
99 | } | ||
100 | |||
101 | @Constraint(message = "unreachable", severity = "error", key = { S1, S2 }) | ||
102 | pattern unreachable(S1 : Segment, S2 : Segment) { | ||
103 | neg find reachable(S1, S2); | ||
104 | } | ||
105 | |||
106 | // | ||
107 | // closeTrains | ||
108 | // | ||
109 | |||
110 | pattern closeTrains_step_2(in train : Train) { | ||
111 | // frame->t1 = model->trains[i0]; | ||
112 | // frame->start = frame->t1->location; | ||
113 | // if(frame->start != 0){ | ||
114 | // ... | ||
115 | // } | ||
116 | // + OUTER FOR LOOP COUNTER INCREMENT | ||
117 | Train(train); | ||
118 | } | ||
119 | |||
120 | pattern closeTrains_step_3(in train : Train, in start : Segment) { | ||
121 | // int loop_bound1 = frame->start->connected_to_count; | ||
122 | // for (int i1 = 0; i1 < loop_bound1; i1++) { LOOP COUNTER INCREMENT IS NOT INCLUDED HERE | ||
123 | // ... | ||
124 | // } | ||
125 | Train.location(train, start); | ||
126 | } | ||
127 | |||
128 | pattern closeTrains_step_4(in train : Train, in start : Segment, in middle : Segment) { | ||
129 | // frame->middle = frame->start->connected_to[i1]; | ||
130 | // int loop_bound2 = frame->middle->connected_to_count; | ||
131 | |||
132 | // for (int i2 = 0; i2 < loop_bound2; i2++) { LOOP COUNTER INCREMENT IS NOT INCLUDED HERE | ||
133 | // ... | ||
134 | // } | ||
135 | // + OUTER FOR LOOP COUNTER INCREMENT | ||
136 | Train.location(train, start); | ||
137 | Segment.connectedTo(start, middle); | ||
138 | } | ||
139 | |||
140 | pattern closeTrains_step_5(in train : Train, in start : Segment, in middle : Segment, in end : Segment) { | ||
141 | // frame->end = frame->middle->connected_to[i2]; | ||
142 | // if (frame->start != frame->end) { | ||
143 | // ... | ||
144 | // } | ||
145 | // + OUTER FOR LOOP COUNTER INCREMENT | ||
146 | Train.location(train, start); | ||
147 | Segment.connectedTo(start, middle); | ||
148 | Segment.connectedTo(middle, end); | ||
149 | } | ||
150 | |||
151 | pattern closeTrains_step_6(in train : Train, in start : Segment, in middle : Segment, in end : Segment) { | ||
152 | // frame->t2 = frame->end->train; | ||
153 | // if (frame->t2 != 0) { | ||
154 | // ... | ||
155 | // } | ||
156 | Train.location(train, start); | ||
157 | Segment.connectedTo(start, middle); | ||
158 | Segment.connectedTo(middle, end); | ||
159 | start != end; | ||
160 | } | ||
161 | |||
162 | pattern closeTrains_step_7(in train : Train, in start : Segment, in middle : Segment, in end : Segment, in otherTrain : Train) { | ||
163 | // results->matches[match_cntr].start = frame->start; | ||
164 | // results->matches[match_cntr++].end = frame->end; | ||
165 | Train.location(train, start); | ||
166 | Segment.connectedTo(start, middle); | ||
167 | Segment.connectedTo(middle, end); | ||
168 | start != end; | ||
169 | Segment.occupiedBy(end, otherTrain); | ||
170 | } | ||
171 | |||
172 | // | ||
173 | // trainLocations | ||
174 | // | ||
175 | |||
176 | pattern trainLocations_step_2(in train : Train) { | ||
177 | // frame->train = model->trains[i0]; | ||
178 | // frame->location = frame->train->location; | ||
179 | // if (frame->location != NULL) { | ||
180 | // ... | ||
181 | // } | ||
182 | |||
183 | Train(train); | ||
184 | } | ||
185 | |||
186 | pattern trainLocations_step_3(in train : Train, in location : Segment) { | ||
187 | // results->matches[match_cntr].location = frame->location; | ||
188 | // results->matches[match_cntr++].train = frame->train; | ||
189 | Train(train); | ||
190 | Train.location(train, location); | ||
191 | } | ||
192 | |||
193 | // | ||
194 | // misalignedTurnout | ||
195 | // | ||
196 | |||
197 | pattern misalignedTurnout_step_2(in turnout : Turnout) { | ||
198 | // frame->turnout = model->turnouts[i0]; | ||
199 | // frame->location = frame->turnout->straight; | ||
200 | // if (frame->location != NULL) { | ||
201 | // ... | ||
202 | // } | ||
203 | Turnout(turnout); | ||
204 | } | ||
205 | |||
206 | pattern misalignedTurnout_step_3(in turnout : Turnout, in location : Segment) { | ||
207 | // Segment *disconnected = ((Segment *)frame->turnout); | ||
208 | // if (disconnected->connected_to[0] != frame->location && | ||
209 | // disconnected->connected_to[1] != frame->location) { | ||
210 | // ... | ||
211 | // } | ||
212 | Turnout(turnout); | ||
213 | Turnout.straight(turnout, location); | ||
214 | } | ||
215 | |||
216 | pattern misalignedTurnout_step_4(in turnout : Turnout, in location : Segment) { | ||
217 | // frame->train = frame->location->train; | ||
218 | // if (frame->train != NULL) { | ||
219 | // ... | ||
220 | // } | ||
221 | Turnout(turnout); | ||
222 | Turnout.straight(turnout, location); | ||
223 | neg find connectedSegmentsDirected(turnout, location); | ||
224 | } | ||
225 | |||
226 | pattern misalignedTurnout_step_5(in turnout : Turnout, in location : Segment, in train : Train) { | ||
227 | // results->matches[match_cntr].start = frame->start; | ||
228 | // results->matches[match_cntr++].end = frame->end; | ||
229 | Turnout(turnout); | ||
230 | Turnout.straight(turnout, location); | ||
231 | neg find connectedSegmentsDirected(turnout, location); | ||
232 | Segment.occupiedBy(location, train); | ||
233 | } | ||
234 | |||
235 | pattern connectedSegmentsDirected(s1 : Segment, s2 : Segment) { | ||
236 | Segment.connectedTo(s1, s2); | ||
237 | } | ||
238 | |||
239 | // | ||
240 | // endOfSiding | ||
241 | // | ||
242 | |||
243 | pattern endOfSiding_step_2(in train : Train) { | ||
244 | // frame->train = model->trains[i0]; | ||
245 | // frame->location = frame->train->location; | ||
246 | // if (frame->location != NULL) { | ||
247 | // ... | ||
248 | // } | ||
249 | |||
250 | Train(train); | ||
251 | } | ||
252 | |||
253 | pattern endOfSiding_step_3(in train : Train, in location : Segment) { | ||
254 | // int loop_bound1 = frame->location->connected_to_count; | ||
255 | // for (int i1 = 0; i1 < loop_bound1; i1++) { | ||
256 | // ... | ||
257 | // } | ||
258 | Train(train); | ||
259 | Train.location(train, location); | ||
260 | } | ||
261 | |||
262 | pattern endOfSiding_step_4(in train : Train, in location : Segment, in end : Segment) { | ||
263 | // frame->end = frame->location->connected_to[i1]; | ||
264 | // if (frame->end != NULL && | ||
265 | // frame->end->connected_to[1] == frame->location && | ||
266 | // frame->end->connected_to[0] == NULL) { | ||
267 | // ... | ||
268 | // } | ||
269 | // if (frame->end != NULL && | ||
270 | // frame->end->connected_to[0] == frame->location && | ||
271 | // frame->end->connected_to[1] == NULL) { | ||
272 | // ... | ||
273 | // } | ||
274 | Train(train); | ||
275 | Train.location(train, location); | ||
276 | Segment.connectedTo(location, end); | ||
277 | } | ||
278 | |||
279 | pattern endOfSiding_step_5(in train : Train, in location : Segment, in end : Segment) { | ||
280 | // results->matches[match_cntr].location = frame->location; | ||
281 | // results->matches[match_cntr++].train = frame->train; | ||
282 | // ...OR... | ||
283 | // results->matches[match_cntr].location = frame->location; | ||
284 | // results->matches[match_cntr++].train = frame->train; | ||
285 | Train(train); | ||
286 | Train.location(train, location); | ||
287 | Segment.connectedTo(location, end); | ||
288 | neg find multipleConnectedTo(end); | ||
289 | } | ||
290 | |||
291 | pattern multipleConnectedTo(s : Segment) { | ||
292 | Segment.connectedTo(s, n1); | ||
293 | Segment.connectedTo(s, n2); | ||
294 | n1 != n2; | ||
295 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/CloseTrainsObjectiveHint.xtend b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/CloseTrainsObjectiveHint.xtend new file mode 100644 index 00000000..519a228a --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/CloseTrainsObjectiveHint.xtend | |||
@@ -0,0 +1,201 @@ | |||
1 | package modes3.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint | ||
10 | import java.util.Collection | ||
11 | import java.util.Map | ||
12 | import modes3.Modes3Package | ||
13 | import modes3.queries.CloseTrains_step_2 | ||
14 | import modes3.queries.CloseTrains_step_3 | ||
15 | import modes3.queries.CloseTrains_step_4 | ||
16 | import modes3.queries.CloseTrains_step_5 | ||
17 | import modes3.queries.CloseTrains_step_6 | ||
18 | import modes3.queries.CloseTrains_step_7 | ||
19 | |||
20 | class CloseTrainsObjectiveHint extends CostObjectiveHint { | ||
21 | val Type segmentType | ||
22 | val Type trainType | ||
23 | |||
24 | new(extension Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { | ||
25 | extension val Modes3Package = Modes3Package.eINSTANCE | ||
26 | segmentType = ecore2LogicTrace.TypeofEClass(segment) | ||
27 | trainType = ecore2LogicTrace.TypeofEClass(train) | ||
28 | } | ||
29 | |||
30 | override isExact() { | ||
31 | true | ||
32 | } | ||
33 | |||
34 | override createPolyhedronExtensionOperator(Map<String, CostElementMatchers> costElementMatchers) { | ||
35 | val step2 = costElementMatchers.get(CloseTrains_step_2.instance.fullyQualifiedName) | ||
36 | val step3 = costElementMatchers.get(CloseTrains_step_3.instance.fullyQualifiedName) | ||
37 | val step4 = costElementMatchers.get(CloseTrains_step_4.instance.fullyQualifiedName) | ||
38 | val step5 = costElementMatchers.get(CloseTrains_step_5.instance.fullyQualifiedName) | ||
39 | val step6 = costElementMatchers.get(CloseTrains_step_6.instance.fullyQualifiedName) | ||
40 | val step7 = costElementMatchers.get(CloseTrains_step_7.instance.fullyQualifiedName); | ||
41 | |||
42 | [ | ||
43 | val objectiveBuilder = createBuilder | ||
44 | |||
45 | for (m : step2.matches) { | ||
46 | val dimension = getDimension(m.match) | ||
47 | objectiveBuilder.add(step2.weight, dimension) | ||
48 | dimension.tightenLowerBound(0) | ||
49 | if (m.multi) { | ||
50 | createBuilder.add(1, dimension).add(-1, trainType).build.assertEqualsTo(0) | ||
51 | } else { | ||
52 | dimension.tightenUpperBound(1) | ||
53 | if (m.must) { | ||
54 | dimension.tightenLowerBound(1) | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | |||
59 | val step3Matches = step3.matches | ||
60 | for (m : step3Matches) { | ||
61 | val dimension = getDimension(m.match) | ||
62 | objectiveBuilder.add(step3.weight, dimension) | ||
63 | dimension.tightenLowerBound(0) | ||
64 | if (!m.multi) { | ||
65 | dimension.tightenUpperBound(1) | ||
66 | if (m.must) { | ||
67 | dimension.tightenLowerBound(1) | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | for (pair : step3Matches.groupBy[step2.projectMayMatch(match, 2)].entrySet) { | ||
72 | val multiplicityBuilder = createBuilder | ||
73 | for (m : pair.value) { | ||
74 | multiplicityBuilder.add(1, m.match) | ||
75 | } | ||
76 | multiplicityBuilder.add(-1, pair.key) | ||
77 | multiplicityBuilder.build.assertEqualsTo(0) | ||
78 | } | ||
79 | boundLimit(step3Matches, 2, trainType, 1) | ||
80 | boundLimit(step3Matches, 3, segmentType, 1) | ||
81 | |||
82 | val step4Matches = step4.matches | ||
83 | for (m : step4Matches) { | ||
84 | val dimension = getDimension(m.match) | ||
85 | objectiveBuilder.add(step4.weight, dimension) | ||
86 | dimension.tightenLowerBound(0) | ||
87 | if (!m.multi) { | ||
88 | dimension.tightenUpperBound(1) | ||
89 | if (m.must) { | ||
90 | dimension.tightenLowerBound(1) | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | for (pair : step4Matches.groupBy[step3.projectMayMatch(match, 2, 3)].entrySet) { | ||
95 | val multiplicityBuilder = createBuilder | ||
96 | for (m : pair.value) { | ||
97 | multiplicityBuilder.add(1, m.match) | ||
98 | } | ||
99 | multiplicityBuilder.add(-2, pair.key) | ||
100 | multiplicityBuilder.build.tightenUpperBound(0) | ||
101 | } | ||
102 | boundLimit(step4Matches, 2, trainType, 2) | ||
103 | boundLimit(step4Matches, 3, segmentType, 2) | ||
104 | boundLimit(step4Matches, 4, segmentType, 2) | ||
105 | |||
106 | val step5Matches = step5.matches | ||
107 | for (m : step5Matches) { | ||
108 | val dimension = getDimension(m.match) | ||
109 | objectiveBuilder.add(step5.weight, dimension) | ||
110 | dimension.tightenLowerBound(0) | ||
111 | if (!m.multi) { | ||
112 | dimension.tightenUpperBound(1) | ||
113 | if (m.must) { | ||
114 | dimension.tightenLowerBound(1) | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | for (pair : step5Matches.groupBy[step4.projectMayMatch(match, 2, 3, 4)].entrySet) { | ||
119 | val multiplicityBuilder = createBuilder | ||
120 | for (m : pair.value) { | ||
121 | multiplicityBuilder.add(1, m.match) | ||
122 | } | ||
123 | multiplicityBuilder.add(-2, pair.key) | ||
124 | multiplicityBuilder.build.tightenUpperBound(0) | ||
125 | } | ||
126 | boundLimit(step5Matches, 2, trainType, 4) | ||
127 | boundLimit(step5Matches, 3, segmentType, 4) | ||
128 | boundLimit(step5Matches, 4, segmentType, 4) | ||
129 | boundLimit(step5Matches, 5, segmentType, 4) | ||
130 | |||
131 | val step6Matches = step6.matches | ||
132 | for (m : step6Matches) { | ||
133 | val dimension = getDimension(m.match) | ||
134 | objectiveBuilder.add(step6.weight, dimension) | ||
135 | dimension.tightenLowerBound(0) | ||
136 | if (m.multi) { | ||
137 | if (m.match.get(3) == m.match.get(5)) { | ||
138 | createBuilder.add(2, m.match).add(-1, step5.projectMayMatch(m.match, 2, 3, 4, 5)).build. | ||
139 | assertEqualsTo(0) | ||
140 | } else { | ||
141 | createBuilder.add(1, m.match).add(-1, step5.projectMayMatch(m.match, 2, 3, 4, 5)).build. | ||
142 | assertEqualsTo(0) | ||
143 | } | ||
144 | } else { | ||
145 | dimension.tightenUpperBound(1) | ||
146 | if (m.must) { | ||
147 | dimension.tightenLowerBound(1) | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | boundLimit(step6Matches, 2, trainType, 2) | ||
152 | boundLimit(step6Matches, 3, segmentType, 2) | ||
153 | boundLimit(step6Matches, 4, segmentType, 2) | ||
154 | boundLimit(step6Matches, 5, segmentType, 2) | ||
155 | |||
156 | val step7Matches = step7.matches | ||
157 | for (m : step7Matches) { | ||
158 | val dimension = getDimension(m.match) | ||
159 | objectiveBuilder.add(step7.weight, dimension) | ||
160 | dimension.tightenLowerBound(0) | ||
161 | if (!m.multi) { | ||
162 | dimension.tightenUpperBound(1) | ||
163 | if (m.must) { | ||
164 | dimension.tightenLowerBound(1) | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | for (pair : step7Matches.groupBy[step6.projectMayMatch(match, 2, 3, 4, 5)].entrySet) { | ||
169 | val multiplicityBuilder = createBuilder | ||
170 | for (m : pair.value) { | ||
171 | multiplicityBuilder.add(1, m.match) | ||
172 | } | ||
173 | multiplicityBuilder.add(-1, pair.key) | ||
174 | multiplicityBuilder.build.tightenUpperBound(0) | ||
175 | } | ||
176 | boundLimit(step7Matches, 2, trainType, 2) | ||
177 | boundLimit(step7Matches, 3, segmentType, 2) | ||
178 | boundLimit(step7Matches, 4, segmentType, 2) | ||
179 | boundLimit(step7Matches, 5, segmentType, 2) | ||
180 | boundLimit(step7Matches, 6, trainType, 2) | ||
181 | |||
182 | objectiveBuilder.buildWithBounds | ||
183 | ] | ||
184 | } | ||
185 | |||
186 | private static def boundLimit(extension ExtendedLinearExpressionBuilderFactory factory, | ||
187 | Collection<CostElementMatch> matches, int index, Type type, int count) { | ||
188 | for (pair : matches.groupBy[match.get(index)].entrySet) { | ||
189 | val multiplicityBuilder = createBuilder | ||
190 | for (m : pair.value) { | ||
191 | multiplicityBuilder.add(1, m.match) | ||
192 | } | ||
193 | if (CostElementMatchers.isMulti(pair.key)) { | ||
194 | multiplicityBuilder.add(-count, type) | ||
195 | multiplicityBuilder.build.tightenUpperBound(0) | ||
196 | } else { | ||
197 | multiplicityBuilder.build.tightenUpperBound(count) | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/EndOfSidingObjectiveHint.xtend b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/EndOfSidingObjectiveHint.xtend new file mode 100644 index 00000000..f7e23a57 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/EndOfSidingObjectiveHint.xtend | |||
@@ -0,0 +1,139 @@ | |||
1 | package modes3.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint | ||
10 | import java.util.Collection | ||
11 | import java.util.Map | ||
12 | import modes3.Modes3Package | ||
13 | import modes3.queries.EndOfSiding_step_2 | ||
14 | import modes3.queries.EndOfSiding_step_3 | ||
15 | import modes3.queries.EndOfSiding_step_4 | ||
16 | import modes3.queries.EndOfSiding_step_5 | ||
17 | |||
18 | class EndOfSidingObjectiveHint extends CostObjectiveHint { | ||
19 | val Type segmentType | ||
20 | val Type trainType | ||
21 | |||
22 | new(extension Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { | ||
23 | extension val Modes3Package = Modes3Package.eINSTANCE | ||
24 | segmentType = ecore2LogicTrace.TypeofEClass(segment) | ||
25 | trainType = ecore2LogicTrace.TypeofEClass(train) | ||
26 | } | ||
27 | |||
28 | override isExact() { | ||
29 | true | ||
30 | // false | ||
31 | } | ||
32 | |||
33 | override createPolyhedronExtensionOperator(Map<String, CostElementMatchers> costElementMatchers) { | ||
34 | val step2 = costElementMatchers.get(EndOfSiding_step_2.instance.fullyQualifiedName) | ||
35 | val step3 = costElementMatchers.get(EndOfSiding_step_3.instance.fullyQualifiedName) | ||
36 | val step4 = costElementMatchers.get(EndOfSiding_step_4.instance.fullyQualifiedName) | ||
37 | val step5 = costElementMatchers.get(EndOfSiding_step_5.instance.fullyQualifiedName); | ||
38 | |||
39 | [ | ||
40 | val objectiveBuilder = createBuilder | ||
41 | |||
42 | for (m : step2.matches) { | ||
43 | val dimension = getDimension(m.match) | ||
44 | objectiveBuilder.add(step2.weight, dimension) | ||
45 | dimension.tightenLowerBound(0) | ||
46 | if (m.multi) { | ||
47 | createBuilder.add(1, dimension).add(-1, trainType).build.assertEqualsTo(0) | ||
48 | } else { | ||
49 | dimension.tightenUpperBound(1) | ||
50 | if (m.must) { | ||
51 | dimension.tightenLowerBound(1) | ||
52 | } | ||
53 | } | ||
54 | } | ||
55 | |||
56 | val step3Matches = step3.matches | ||
57 | for (m : step3Matches) { | ||
58 | val dimension = getDimension(m.match) | ||
59 | objectiveBuilder.add(step3.weight, dimension) | ||
60 | dimension.tightenLowerBound(0) | ||
61 | if (!m.multi) { | ||
62 | dimension.tightenUpperBound(1) | ||
63 | if (m.must) { | ||
64 | dimension.tightenLowerBound(1) | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | for (pair : step3Matches.groupBy[step2.projectMayMatch(match, 2)].entrySet) { | ||
69 | val multiplicityBuilder = createBuilder | ||
70 | for (m : pair.value) { | ||
71 | multiplicityBuilder.add(1, m.match) | ||
72 | } | ||
73 | multiplicityBuilder.add(-1, pair.key) | ||
74 | multiplicityBuilder.build.assertEqualsTo(0) | ||
75 | } | ||
76 | boundLimit(step3Matches, 2, trainType, 1) | ||
77 | boundLimit(step3Matches, 3, segmentType, 1) | ||
78 | |||
79 | val step4Matches = step4.matches | ||
80 | for (m : step4Matches) { | ||
81 | val dimension = getDimension(m.match) | ||
82 | objectiveBuilder.add(step4.weight, dimension) | ||
83 | dimension.tightenLowerBound(0) | ||
84 | if (!m.multi) { | ||
85 | dimension.tightenUpperBound(1) | ||
86 | if (m.must) { | ||
87 | dimension.tightenLowerBound(1) | ||
88 | } | ||
89 | } | ||
90 | } | ||
91 | for (pair : step4Matches.groupBy[step3.projectMayMatch(match, 2, 3)].entrySet) { | ||
92 | val multiplicityBuilder = createBuilder | ||
93 | for (m : pair.value) { | ||
94 | multiplicityBuilder.add(1, m.match) | ||
95 | } | ||
96 | multiplicityBuilder.add(-2, pair.key) | ||
97 | multiplicityBuilder.build.tightenUpperBound(0) | ||
98 | } | ||
99 | boundLimit(step4Matches, 2, trainType, 2) | ||
100 | boundLimit(step4Matches, 3, segmentType, 2) | ||
101 | boundLimit(step4Matches, 4, segmentType, 2) | ||
102 | |||
103 | val step5Matches = step5.matches | ||
104 | for (m : step5Matches) { | ||
105 | val dimension = getDimension(m.match) | ||
106 | objectiveBuilder.add(step5.weight, dimension) | ||
107 | dimension.tightenLowerBound(0) | ||
108 | if (!m.multi) { | ||
109 | dimension.tightenUpperBound(1) | ||
110 | if (m.must) { | ||
111 | dimension.tightenLowerBound(1) | ||
112 | } | ||
113 | } | ||
114 | createBuilder.add(1, m.match).add(-1, step4.projectMayMatch(m.match, 2, 3, 4)).build.tightenUpperBound(0) | ||
115 | } | ||
116 | boundLimit(step5Matches, 2, trainType, 1) | ||
117 | boundLimit(step5Matches, 3, segmentType, 2) | ||
118 | boundLimit(step5Matches, 4, segmentType, 1) | ||
119 | |||
120 | objectiveBuilder.buildWithBounds | ||
121 | ] | ||
122 | } | ||
123 | |||
124 | private static def boundLimit(extension ExtendedLinearExpressionBuilderFactory factory, | ||
125 | Collection<CostElementMatch> matches, int index, Type type, int count) { | ||
126 | for (pair : matches.groupBy[match.get(index)].entrySet) { | ||
127 | val multiplicityBuilder = createBuilder | ||
128 | for (m : pair.value) { | ||
129 | multiplicityBuilder.add(1, m.match) | ||
130 | } | ||
131 | if (CostElementMatchers.isMulti(pair.key)) { | ||
132 | multiplicityBuilder.add(-count, type) | ||
133 | multiplicityBuilder.build.tightenUpperBound(0) | ||
134 | } else { | ||
135 | multiplicityBuilder.build.tightenUpperBound(count) | ||
136 | } | ||
137 | } | ||
138 | } | ||
139 | } \ No newline at end of file | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/MisalignedTurnoutObjectiveHint.xtend b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/MisalignedTurnoutObjectiveHint.xtend new file mode 100644 index 00000000..cb014dea --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/MisalignedTurnoutObjectiveHint.xtend | |||
@@ -0,0 +1,140 @@ | |||
1 | package modes3.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint | ||
10 | import java.util.Collection | ||
11 | import java.util.Map | ||
12 | import modes3.Modes3Package | ||
13 | import modes3.queries.MisalignedTurnout_step_2 | ||
14 | import modes3.queries.MisalignedTurnout_step_3 | ||
15 | import modes3.queries.MisalignedTurnout_step_4 | ||
16 | import modes3.queries.MisalignedTurnout_step_5 | ||
17 | |||
18 | class MisalignedTurnoutObjectiveHint extends CostObjectiveHint { | ||
19 | val Type segmentType | ||
20 | val Type turnoutType | ||
21 | val Type trainType | ||
22 | |||
23 | new(extension Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { | ||
24 | extension val Modes3Package = Modes3Package.eINSTANCE | ||
25 | segmentType = ecore2LogicTrace.TypeofEClass(segment) | ||
26 | turnoutType = ecore2LogicTrace.TypeofEClass(turnout) | ||
27 | trainType = ecore2LogicTrace.TypeofEClass(train) | ||
28 | } | ||
29 | |||
30 | override isExact() { | ||
31 | true | ||
32 | // false | ||
33 | } | ||
34 | |||
35 | override createPolyhedronExtensionOperator(Map<String, CostElementMatchers> costElementMatchers) { | ||
36 | val step2 = costElementMatchers.get(MisalignedTurnout_step_2.instance.fullyQualifiedName) | ||
37 | val step3 = costElementMatchers.get(MisalignedTurnout_step_3.instance.fullyQualifiedName) | ||
38 | val step4 = costElementMatchers.get(MisalignedTurnout_step_4.instance.fullyQualifiedName) | ||
39 | val step5 = costElementMatchers.get(MisalignedTurnout_step_5.instance.fullyQualifiedName); | ||
40 | |||
41 | [ | ||
42 | val objectiveBuilder = createBuilder | ||
43 | |||
44 | for (m : step2.matches) { | ||
45 | val dimension = getDimension(m.match) | ||
46 | objectiveBuilder.add(step2.weight, dimension) | ||
47 | dimension.tightenLowerBound(0) | ||
48 | if (m.multi) { | ||
49 | createBuilder.add(1, dimension).add(-1, turnoutType).build.assertEqualsTo(0) | ||
50 | } else { | ||
51 | dimension.tightenUpperBound(1) | ||
52 | if (m.must) { | ||
53 | dimension.tightenLowerBound(1) | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | |||
58 | val step3Matches = step3.matches | ||
59 | for (m : step3Matches) { | ||
60 | val dimension = getDimension(m.match) | ||
61 | objectiveBuilder.add(step3.weight, dimension) | ||
62 | dimension.tightenLowerBound(0) | ||
63 | if (!m.multi) { | ||
64 | dimension.tightenUpperBound(1) | ||
65 | if (m.must) { | ||
66 | dimension.tightenLowerBound(1) | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | for (pair : step3Matches.groupBy[step2.projectMayMatch(match, 2)].entrySet) { | ||
71 | val multiplicityBuilder = createBuilder | ||
72 | for (m : pair.value) { | ||
73 | multiplicityBuilder.add(1, m.match) | ||
74 | } | ||
75 | multiplicityBuilder.add(-1, pair.key) | ||
76 | multiplicityBuilder.build.tightenUpperBound(0) | ||
77 | } | ||
78 | boundLimit(step3Matches, 2, turnoutType, 1) | ||
79 | boundLimit(step3Matches, 3, segmentType, 2) | ||
80 | |||
81 | val step4Matches = step4.matches | ||
82 | for (m : step4Matches) { | ||
83 | val dimension = getDimension(m.match) | ||
84 | objectiveBuilder.add(step4.weight, dimension) | ||
85 | dimension.tightenLowerBound(0) | ||
86 | if (!m.multi) { | ||
87 | dimension.tightenUpperBound(1) | ||
88 | if (m.must) { | ||
89 | dimension.tightenLowerBound(1) | ||
90 | } | ||
91 | } | ||
92 | createBuilder.add(1, m.match).add(-1, step3.projectMayMatch(m.match, 2, 3)).build.tightenUpperBound(0) | ||
93 | } | ||
94 | boundLimit(step4Matches, 2, turnoutType, 1) | ||
95 | boundLimit(step4Matches, 3, segmentType, 2) | ||
96 | |||
97 | val step5Matches = step5.matches | ||
98 | for (m : step5Matches) { | ||
99 | val dimension = getDimension(m.match) | ||
100 | objectiveBuilder.add(step5.weight, dimension) | ||
101 | dimension.tightenLowerBound(0) | ||
102 | if (!m.multi) { | ||
103 | dimension.tightenUpperBound(1) | ||
104 | if (m.must) { | ||
105 | dimension.tightenLowerBound(1) | ||
106 | } | ||
107 | } | ||
108 | } | ||
109 | for (pair : step5Matches.groupBy[step4.projectMayMatch(match, 2, 3)].entrySet) { | ||
110 | val multiplicityBuilder = createBuilder | ||
111 | for (m : pair.value) { | ||
112 | multiplicityBuilder.add(1, m.match) | ||
113 | } | ||
114 | multiplicityBuilder.add(-1, pair.key) | ||
115 | multiplicityBuilder.build.tightenUpperBound(0) | ||
116 | } | ||
117 | boundLimit(step5Matches, 2, turnoutType, 1) | ||
118 | boundLimit(step5Matches, 3, segmentType, 2) | ||
119 | boundLimit(step5Matches, 4, trainType, 2) | ||
120 | |||
121 | objectiveBuilder.buildWithBounds | ||
122 | ] | ||
123 | } | ||
124 | |||
125 | private static def boundLimit(extension ExtendedLinearExpressionBuilderFactory factory, | ||
126 | Collection<CostElementMatch> matches, int index, Type type, int count) { | ||
127 | for (pair : matches.groupBy[match.get(index)].entrySet) { | ||
128 | val multiplicityBuilder = createBuilder | ||
129 | for (m : pair.value) { | ||
130 | multiplicityBuilder.add(1, m.match) | ||
131 | } | ||
132 | if (CostElementMatchers.isMulti(pair.key)) { | ||
133 | multiplicityBuilder.add(-count, type) | ||
134 | multiplicityBuilder.build.tightenUpperBound(0) | ||
135 | } else { | ||
136 | multiplicityBuilder.build.tightenUpperBound(count) | ||
137 | } | ||
138 | } | ||
139 | } | ||
140 | } | ||
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..613cb3e4 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3ModelGenerator.xtend | |||
@@ -0,0 +1,357 @@ | |||
1 | package modes3.run | ||
2 | |||
3 | import com.google.common.collect.ImmutableList | ||
4 | import com.google.common.collect.ImmutableSet | ||
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EReferenceMapper_RelationsOverTypes_Trace | ||
6 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration | ||
8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
9 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor | ||
10 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsFactory | ||
11 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsPackage | ||
12 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel | ||
13 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder | ||
14 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage | ||
15 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition | ||
16 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage | ||
17 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult | ||
18 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore | ||
19 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic | ||
20 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration | ||
21 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor | ||
22 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.Viatra2LogicAnnotationsPackage | ||
23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod | ||
24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorConstraints | ||
25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorSolver | ||
26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy | ||
27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic | ||
28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink | ||
29 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation | ||
30 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage | ||
31 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml | ||
32 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.CostObjectiveConfiguration | ||
33 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.CostObjectiveElementConfiguration | ||
34 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.StateCoderStrategy | ||
35 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner | ||
36 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration | ||
37 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.PartialModelAsLogicInterpretation | ||
38 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind | ||
39 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold | ||
40 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser | ||
41 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace | ||
42 | import java.util.List | ||
43 | import modes3.Modes3Factory | ||
44 | import modes3.Modes3Package | ||
45 | import modes3.queries.CloseTrains_step_2 | ||
46 | import modes3.queries.CloseTrains_step_3 | ||
47 | import modes3.queries.CloseTrains_step_4 | ||
48 | import modes3.queries.CloseTrains_step_5 | ||
49 | import modes3.queries.CloseTrains_step_6 | ||
50 | import modes3.queries.CloseTrains_step_7 | ||
51 | import modes3.queries.EndOfSiding_step_2 | ||
52 | import modes3.queries.EndOfSiding_step_3 | ||
53 | import modes3.queries.EndOfSiding_step_4 | ||
54 | import modes3.queries.EndOfSiding_step_5 | ||
55 | import modes3.queries.MisalignedTurnout_step_2 | ||
56 | import modes3.queries.MisalignedTurnout_step_3 | ||
57 | import modes3.queries.MisalignedTurnout_step_4 | ||
58 | import modes3.queries.MisalignedTurnout_step_5 | ||
59 | import modes3.queries.Modes3Queries | ||
60 | import modes3.queries.TrainLocations_step_2 | ||
61 | import modes3.queries.TrainLocations_step_3 | ||
62 | import org.eclipse.emf.ecore.EClass | ||
63 | import org.eclipse.emf.ecore.EObject | ||
64 | import org.eclipse.emf.ecore.resource.Resource | ||
65 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | ||
66 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup | ||
67 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions | ||
68 | import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchEMFBackendFactory | ||
69 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory | ||
70 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor | ||
71 | |||
72 | @FinalFieldsConstructor | ||
73 | class Modes3ModelGenerator { | ||
74 | val MonitoringQuery monitoringQuery | ||
75 | val int modelSize | ||
76 | |||
77 | val ecore2Logic = new Ecore2Logic | ||
78 | val instanceModel2Logic = new InstanceModel2Logic | ||
79 | val viatra2Logic = new Viatra2Logic(ecore2Logic) | ||
80 | val solver = new ViatraReasoner | ||
81 | extension val LogicProblemBuilder = new LogicProblemBuilder | ||
82 | |||
83 | def generate() { | ||
84 | val metamodel = createMetamodelDescriptor() | ||
85 | val metamodelLogic = ecore2Logic.transformMetamodel(metamodel, new Ecore2LogicConfiguration) | ||
86 | val segment = ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.segment) | ||
87 | val connectedTo = ecore2Logic.relationOfReference(metamodelLogic.trace, | ||
88 | Modes3Package.eINSTANCE.segment_ConnectedTo) | ||
89 | val connectedToIndicator = (metamodelLogic.trace. | ||
90 | referenceMapperTrace as EReferenceMapper_RelationsOverTypes_Trace).indicators.get( | ||
91 | Modes3Package.eINSTANCE.segment_ConnectedTo) | ||
92 | val inverseAssertion = Assertion( | ||
93 | '''oppositeReference «connectedTo.name» «connectedTo.name»''', | ||
94 | Forall[ | ||
95 | val src = addVar('''src''', segment) | ||
96 | val trg = addVar('''trg''', segment) | ||
97 | connectedToIndicator.call(src, trg) <=> connectedToIndicator.call(trg, src) | ||
98 | ] | ||
99 | ) | ||
100 | metamodelLogic.output.assertions += inverseAssertion | ||
101 | val inverseAnnotation = Ecore2logicannotationsFactory.eINSTANCE.createInverseRelationAssertion => [ | ||
102 | target = inverseAssertion | ||
103 | inverseA = connectedTo | ||
104 | inverseB = connectedTo | ||
105 | ] | ||
106 | metamodelLogic.output.annotations += inverseAnnotation | ||
107 | val initialModel = loadInitialModel() | ||
108 | val initialModelLogic = instanceModel2Logic.transform(metamodelLogic, initialModel) | ||
109 | val queries = loadQueries | ||
110 | val logic = viatra2Logic.transformQueries(queries, initialModelLogic, new Viatra2LogicConfiguration) | ||
111 | val config = new ViatraReasonerConfiguration => [ | ||
112 | runtimeLimit = 3600 | ||
113 | typeScopes => [ | ||
114 | minNewElements = modelSize | ||
115 | maxNewElements = modelSize | ||
116 | minNewElementsByType => [ | ||
117 | // put(ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.train), modelSize / 5) | ||
118 | // put(ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.turnout), modelSize / 5) | ||
119 | // put(ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.simpleSegment), 3 * modelSize / 5) | ||
120 | ] | ||
121 | maxNewElementsByType => [ | ||
122 | put(ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.train), modelSize / 5) | ||
123 | put(ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.turnout), modelSize / 5) | ||
124 | put(ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.simpleSegment), 3 * modelSize / 5) | ||
125 | ] | ||
126 | ] | ||
127 | solutionScope => [ | ||
128 | numberOfRequiredSolutions = 1 | ||
129 | ] | ||
130 | costObjectives += getObjective(ecore2Logic, metamodelLogic.trace) | ||
131 | scopeWeight = 6 | ||
132 | nameNewElements = false | ||
133 | typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis | ||
134 | stateCoderStrategy = StateCoderStrategy.PairwiseNeighbourhood | ||
135 | scopePropagatorStrategy = new ScopePropagatorStrategy.Polyhedral( | ||
136 | PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp) | ||
137 | hints += new Modes3TypeScopeHint(ecore2Logic, metamodelLogic.trace) | ||
138 | unitPropagationPatternGenerators += new Modes3UnitPropagationGenerator(ecore2Logic, metamodelLogic.trace) | ||
139 | debugConfiguration => [ | ||
140 | partialInterpretatioVisualiser = new GraphvizVisualiser | ||
141 | // partalInterpretationVisualisationFrequency = 50 | ||
142 | ] | ||
143 | documentationLevel = DocumentationLevel.NORMAL | ||
144 | ] | ||
145 | val workspace = new FileSystemWorkspace("output/", "") | ||
146 | workspace.writeModel(logic.output, "problem.logicproblem") | ||
147 | val solution = solver.solve(logic.output, config, workspace) | ||
148 | if (solution instanceof ModelResult) { | ||
149 | println("Saving generated solutions") | ||
150 | val logic2Ecore = new Logic2Ecore(ecore2Logic) | ||
151 | val interpretations = solver.getInterpretations(solution) | ||
152 | for (representationIndex : 0 ..< interpretations.size) { | ||
153 | val interpretation = interpretations.get(representationIndex) | ||
154 | val representationNumber = representationIndex + 1 | ||
155 | if (interpretation instanceof PartialModelAsLogicInterpretation) { | ||
156 | val representation = interpretation.partialInterpretation | ||
157 | workspace.writeModel(representation, '''solution«representationNumber».partialinterpretation''') | ||
158 | val partialInterpretation2GML = new PartialInterpretation2Gml | ||
159 | val gml = partialInterpretation2GML.transform(representation) | ||
160 | workspace.writeText('''solution«representationNumber».gml''', gml) | ||
161 | val model = logic2Ecore.transformInterpretation(interpretation, metamodelLogic.trace) | ||
162 | val iterator = model.eAllContents | ||
163 | var int id = 0 | ||
164 | while (iterator.hasNext) { | ||
165 | val obj = iterator.next | ||
166 | val idFeature = obj.eClass.EAllAttributes.findFirst[name == 'id'] | ||
167 | if (idFeature !== null) { | ||
168 | obj.eSet(idFeature, id) | ||
169 | id++ | ||
170 | } | ||
171 | } | ||
172 | workspace.writeModel(model, '''solution«representationNumber».modes3''') | ||
173 | if (representation.newElements.size < 160) { | ||
174 | val rootType = (representation.problem.types.findFirst [ | ||
175 | name == "Modes3ModelRoot class DefinedPart" | ||
176 | ] as TypeDefinition) | ||
177 | val rootIntepretation = representation.partialtypeinterpratation.filter( | ||
178 | PartialComplexTypeInterpretation).findFirst [ | ||
179 | interpretationOf.name == "Modes3ModelRoot class" | ||
180 | ] | ||
181 | rootIntepretation.elements.removeAll(rootType.elements) | ||
182 | representation.problem.elements.removeAll(rootType.elements) | ||
183 | for (relationInterpretation : representation.partialrelationinterpretation) { | ||
184 | relationInterpretation.relationlinks.removeIf [ link | | ||
185 | if (link instanceof BinaryElementRelationLink) { | ||
186 | rootType.elements.contains(link.param1) || | ||
187 | rootType.elements.contains(link.param2) | ||
188 | } else { | ||
189 | false | ||
190 | } | ||
191 | ] | ||
192 | } | ||
193 | rootType.elements.clear | ||
194 | val visualiser = new GraphvizVisualiser | ||
195 | val visualisation = visualiser.visualiseConcretization(representation) | ||
196 | visualisation.writeToFile(workspace, '''solution«representationNumber».png''') | ||
197 | } | ||
198 | } else { | ||
199 | workspace.writeText('''solution«representationNumber».txt''', interpretation.toString) | ||
200 | } | ||
201 | } | ||
202 | } else { | ||
203 | println("Failed to solve problem") | ||
204 | val partial = logic.output | ||
205 | workspace.writeModel(partial, "solution.partialinterpretation") | ||
206 | } | ||
207 | } | ||
208 | |||
209 | static def createMetamodelDescriptor() { | ||
210 | val eClasses = ImmutableList.copyOf(Modes3Package.eINSTANCE.EClassifiers.filter(EClass)) | ||
211 | new EcoreMetamodelDescriptor( | ||
212 | eClasses, | ||
213 | emptySet, | ||
214 | false, | ||
215 | emptyList, | ||
216 | emptyList, | ||
217 | ImmutableList.copyOf(eClasses.flatMap[EReferences]), | ||
218 | emptyList | ||
219 | ) | ||
220 | } | ||
221 | |||
222 | static def List<EObject> loadInitialModel() { | ||
223 | #[Modes3Factory.eINSTANCE.createModes3ModelRoot] | ||
224 | } | ||
225 | |||
226 | def loadQueries() { | ||
227 | val patternsBuilder = ImmutableList.builder | ||
228 | patternsBuilder.addAll(Modes3Queries.instance.specifications) | ||
229 | val patterns = patternsBuilder.build | ||
230 | val validationPatterns = ImmutableSet.copyOf(patterns.filter [ pattern | | ||
231 | pattern.allAnnotations.exists[name == "Constraint"] | ||
232 | ]) | ||
233 | new ViatraQuerySetDescriptor( | ||
234 | patterns, | ||
235 | validationPatterns, | ||
236 | emptyMap | ||
237 | ) | ||
238 | } | ||
239 | |||
240 | def getObjective(Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { | ||
241 | new CostObjectiveConfiguration => [ | ||
242 | switch (monitoringQuery) { | ||
243 | case closeTrains: { | ||
244 | elements += new CostObjectiveElementConfiguration => [ | ||
245 | patternQualifiedName = CloseTrains_step_2.instance.fullyQualifiedName | ||
246 | weight = 14 + 53 + 11 | ||
247 | ] | ||
248 | elements += new CostObjectiveElementConfiguration => [ | ||
249 | patternQualifiedName = CloseTrains_step_3.instance.fullyQualifiedName | ||
250 | weight = 21 + 14 | ||
251 | ] | ||
252 | elements += new CostObjectiveElementConfiguration => [ | ||
253 | patternQualifiedName = CloseTrains_step_4.instance.fullyQualifiedName | ||
254 | weight = 14 + 44 + 14 + 9 | ||
255 | ] | ||
256 | elements += new CostObjectiveElementConfiguration => [ | ||
257 | patternQualifiedName = CloseTrains_step_5.instance.fullyQualifiedName | ||
258 | weight = 14 + 41 + 11 | ||
259 | ] | ||
260 | elements += new CostObjectiveElementConfiguration => [ | ||
261 | patternQualifiedName = CloseTrains_step_6.instance.fullyQualifiedName | ||
262 | weight = 27 | ||
263 | ] | ||
264 | elements += new CostObjectiveElementConfiguration => [ | ||
265 | patternQualifiedName = CloseTrains_step_7.instance.fullyQualifiedName | ||
266 | weight = 48 | ||
267 | ] | ||
268 | hint = new CloseTrainsObjectiveHint(ecore2Logic, ecore2LogicTrace) | ||
269 | } | ||
270 | case trainLocations: { | ||
271 | elements += new CostObjectiveElementConfiguration => [ | ||
272 | patternQualifiedName = TrainLocations_step_2.instance.fullyQualifiedName | ||
273 | weight = 14 + 53 + 11 | ||
274 | ] | ||
275 | elements += new CostObjectiveElementConfiguration => [ | ||
276 | patternQualifiedName = TrainLocations_step_3.instance.fullyQualifiedName | ||
277 | weight = 48 | ||
278 | ] | ||
279 | hint = new TrainLocationsObjectiveHint(ecore2Logic, ecore2LogicTrace) | ||
280 | } | ||
281 | case misalignedTurnout: { | ||
282 | elements += new CostObjectiveElementConfiguration => [ | ||
283 | patternQualifiedName = MisalignedTurnout_step_2.instance.fullyQualifiedName | ||
284 | weight = 14 + 53 + 11 | ||
285 | ] | ||
286 | elements += new CostObjectiveElementConfiguration => [ | ||
287 | patternQualifiedName = MisalignedTurnout_step_3.instance.fullyQualifiedName | ||
288 | weight = 108 | ||
289 | ] | ||
290 | elements += new CostObjectiveElementConfiguration => [ | ||
291 | patternQualifiedName = MisalignedTurnout_step_4.instance.fullyQualifiedName | ||
292 | weight = 27 | ||
293 | ] | ||
294 | elements += new CostObjectiveElementConfiguration => [ | ||
295 | patternQualifiedName = MisalignedTurnout_step_5.instance.fullyQualifiedName | ||
296 | weight = 48 | ||
297 | ] | ||
298 | hint = new MisalignedTurnoutObjectiveHint(ecore2Logic, ecore2LogicTrace) | ||
299 | } | ||
300 | case endOfSiding: { | ||
301 | elements += new CostObjectiveElementConfiguration => [ | ||
302 | patternQualifiedName = EndOfSiding_step_2.instance.fullyQualifiedName | ||
303 | weight = 14 + 53 + 11 | ||
304 | ] | ||
305 | elements += new CostObjectiveElementConfiguration => [ | ||
306 | patternQualifiedName = EndOfSiding_step_3.instance.fullyQualifiedName | ||
307 | weight = 21 + 14 | ||
308 | ] | ||
309 | elements += new CostObjectiveElementConfiguration => [ | ||
310 | patternQualifiedName = EndOfSiding_step_4.instance.fullyQualifiedName | ||
311 | weight = 14 + 35 + 21 + 15 + 14 + 21 + 15 + 11 | ||
312 | ] | ||
313 | elements += new CostObjectiveElementConfiguration => [ | ||
314 | patternQualifiedName = EndOfSiding_step_5.instance.fullyQualifiedName | ||
315 | weight = 48 | ||
316 | ] | ||
317 | hint = new EndOfSidingObjectiveHint(ecore2Logic, ecore2LogicTrace) | ||
318 | } | ||
319 | default: | ||
320 | throw new IllegalArgumentException("Unknown monitoring query: " + monitoringQuery) | ||
321 | } | ||
322 | kind = ObjectiveKind.HIGHER_IS_BETTER | ||
323 | threshold = ObjectiveThreshold.NO_THRESHOLD | ||
324 | findExtremum = true | ||
325 | ] | ||
326 | } | ||
327 | |||
328 | def static init() { | ||
329 | EMFPatternLanguageStandaloneSetup.doSetup | ||
330 | ViatraQueryEngineOptions.setSystemDefaultBackends(ReteBackendFactory.INSTANCE, ReteBackendFactory.INSTANCE, | ||
331 | LocalSearchEMFBackendFactory.INSTANCE) | ||
332 | LogiclanguagePackage.eINSTANCE.class | ||
333 | LogicproblemPackage.eINSTANCE.class | ||
334 | PartialinterpretationPackage.eINSTANCE.class | ||
335 | Ecore2logicannotationsPackage.eINSTANCE.class | ||
336 | Viatra2LogicAnnotationsPackage.eINSTANCE.class | ||
337 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("*", new XMIResourceFactoryImpl) | ||
338 | } | ||
339 | |||
340 | def static void main(String[] args) { | ||
341 | if (args.length != 2) { | ||
342 | System.err.println("Usage: <query> <model size>") | ||
343 | } | ||
344 | val monitoringQuery = MonitoringQuery.valueOf(args.get(0)) | ||
345 | val modelSize = Integer.parseInt(args.get(1)) | ||
346 | init() | ||
347 | val generator = new Modes3ModelGenerator(monitoringQuery, modelSize) | ||
348 | generator.generate() | ||
349 | } | ||
350 | |||
351 | private static enum MonitoringQuery { | ||
352 | closeTrains, | ||
353 | trainLocations, | ||
354 | endOfSiding, | ||
355 | misalignedTurnout | ||
356 | } | ||
357 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3TypeScopeHint.xtend b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3TypeScopeHint.xtend new file mode 100644 index 00000000..94e5eb08 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3TypeScopeHint.xtend | |||
@@ -0,0 +1,79 @@ | |||
1 | package modes3.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator | ||
10 | import java.util.Map | ||
11 | import modes3.Modes3Package | ||
12 | import modes3.queries.Adjacent | ||
13 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | ||
14 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | ||
15 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | ||
16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
17 | |||
18 | class Modes3TypeScopeHint implements LinearTypeConstraintHint { | ||
19 | static val TURNOUT_NEIGHBOR_COUNT = "turnoutNeighborCount" | ||
20 | |||
21 | val Type segmentType | ||
22 | val Type turnoutType | ||
23 | |||
24 | new(extension Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { | ||
25 | extension val Modes3Package = Modes3Package.eINSTANCE | ||
26 | segmentType = ecore2LogicTrace.TypeofEClass(segment) | ||
27 | turnoutType = ecore2LogicTrace.TypeofEClass(turnout) | ||
28 | } | ||
29 | |||
30 | override getAdditionalPatterns(extension PatternGenerator patternGenerator, Map<String, PQuery> fqnToPQuery) { | ||
31 | ''' | ||
32 | pattern «TURNOUT_NEIGHBOR_COUNT»_helper(problem: LogicProblem, interpretation: PartialInterpretation, source: DefinedElement, target: DefinedElement) { | ||
33 | find interpretation(problem, interpretation); | ||
34 | find mustExist(problem, interpretation, source); | ||
35 | find mustExist(problem, interpretation, target); | ||
36 | «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "source")» | ||
37 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "target")» | ||
38 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["source", "target"], Modality.MUST, true, false)» | ||
39 | } | ||
40 | |||
41 | pattern «TURNOUT_NEIGHBOR_COUNT»(problem: LogicProblem, interpretation: PartialInterpretation, element: DefinedElement, N) { | ||
42 | find interpretation(problem, interpretation); | ||
43 | find mustExist(problem, interpretation, element); | ||
44 | «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "element")» | ||
45 | N == count find «TURNOUT_NEIGHBOR_COUNT»_helper(problem, interpretation, element, _); | ||
46 | } | ||
47 | ''' | ||
48 | } | ||
49 | |||
50 | override createConstraintUpdater(LinearTypeExpressionBuilderFactory builderFactory) { | ||
51 | val turnoutNeighborCountMatcher = builderFactory.createMatcher(TURNOUT_NEIGHBOR_COUNT) | ||
52 | val newNeighbors = builderFactory.createBuilder.add(1, segmentType).build | ||
53 | |||
54 | return [ partialInterpretation | | ||
55 | val requiredNeighbbors = turnoutNeighborCountMatcher.getRemainingCount(partialInterpretation, 3) | ||
56 | newNeighbors.tightenLowerBound(requiredNeighbbors) | ||
57 | ] | ||
58 | } | ||
59 | |||
60 | private static def <T extends IPatternMatch> getRemainingCount(ViatraQueryMatcher<T> matcher, | ||
61 | PartialInterpretation partialInterpretation, int capacity) { | ||
62 | val partialMatch = matcher.newEmptyMatch | ||
63 | partialMatch.set(0, partialInterpretation.problem) | ||
64 | partialMatch.set(1, partialInterpretation) | ||
65 | val iterator = matcher.streamAllMatches(partialMatch).iterator | ||
66 | var int max = 0 | ||
67 | while (iterator.hasNext) { | ||
68 | val match = iterator.next | ||
69 | val n = (match.get(3) as Integer).intValue | ||
70 | if (n < capacity) { | ||
71 | val required = capacity - n | ||
72 | if (max < required) { | ||
73 | max = required | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | max | ||
78 | } | ||
79 | } | ||
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..953a21d4 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3UnitPropagationGenerator.xtend | |||
@@ -0,0 +1,417 @@ | |||
1 | package modes3.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.UnitPropagationPatternGenerator | ||
10 | import java.util.Map | ||
11 | import modes3.Modes3Package | ||
12 | import modes3.queries.Adjacent | ||
13 | import modes3.queries.Output | ||
14 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | ||
15 | import org.eclipse.xtend2.lib.StringConcatenationClient | ||
16 | |||
17 | class Modes3UnitPropagationGenerator implements UnitPropagationPatternGenerator { | ||
18 | static val MUST_NOT_CONNECTED_TO = "mustNotConnectedTo" | ||
19 | static val MUST_NOT_STRAIGHT = "mustNotStraight" | ||
20 | static val MUST_NOT_DIVERGENT = "mustNotDivergent" | ||
21 | static val MUST_CONNECTED_TO = "mustConnectedTo" | ||
22 | static val MUST_STRAIGHT = "mustStraight" | ||
23 | static val MUST_DIVERGENT = "mustDivergent" | ||
24 | |||
25 | val Type segmentType | ||
26 | val Type simpleSegmentType | ||
27 | val Type turnoutType | ||
28 | val Relation connectedToRelation | ||
29 | val Relation straightRelation | ||
30 | val Relation divergentRelation | ||
31 | |||
32 | new(extension Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { | ||
33 | extension val Modes3Package = Modes3Package.eINSTANCE | ||
34 | segmentType = ecore2LogicTrace.TypeofEClass(segment) | ||
35 | simpleSegmentType = ecore2LogicTrace.TypeofEClass(simpleSegment) | ||
36 | turnoutType = ecore2LogicTrace.TypeofEClass(turnout) | ||
37 | connectedToRelation = ecore2LogicTrace.relationOfReference(segment_ConnectedTo) | ||
38 | straightRelation = ecore2LogicTrace.relationOfReference(turnout_Straight) | ||
39 | divergentRelation = ecore2LogicTrace.relationOfReference(turnout_Divergent) | ||
40 | } | ||
41 | |||
42 | override getMustPatterns() { | ||
43 | #{ | ||
44 | connectedToRelation -> MUST_CONNECTED_TO, | ||
45 | straightRelation -> MUST_STRAIGHT, | ||
46 | divergentRelation -> MUST_DIVERGENT | ||
47 | } | ||
48 | } | ||
49 | |||
50 | override getMustNotPatterns() { | ||
51 | #{ | ||
52 | connectedToRelation -> MUST_NOT_CONNECTED_TO, | ||
53 | straightRelation -> MUST_NOT_STRAIGHT, | ||
54 | divergentRelation -> MUST_NOT_DIVERGENT | ||
55 | } | ||
56 | } | ||
57 | |||
58 | override getAdditionalPatterns(extension PatternGenerator generator, Map<String, PQuery> fqnToPQuery) { | ||
59 | val StringConcatenationClient parameters = ''' | ||
60 | problem: LogicProblem, interpretation: PartialInterpretation, | ||
61 | source: DefinedElement, target: DefinedElement | ||
62 | ''' | ||
63 | |||
64 | val StringConcatenationClient commonMustParameterConstraints = ''' | ||
65 | find interpretation(problem, interpretation); | ||
66 | find mustExist(problem, interpretation, source); | ||
67 | find mustExist(problem, interpretation, target); | ||
68 | ''' | ||
69 | |||
70 | val StringConcatenationClient commonMayParameterConstraints = ''' | ||
71 | find interpretation(problem, interpretation); | ||
72 | find mayExist(problem, interpretation, source); | ||
73 | find mayExist(problem, interpretation, target); | ||
74 | ''' | ||
75 | |||
76 | ''' | ||
77 | pattern mayInput(«parameters») { | ||
78 | «commonMayParameterConstraints» | ||
79 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
80 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["target", "source"], Modality.MAY, true, false)» | ||
81 | neg «referRelation(straightRelation, "target", "source", Modality.MUST, fqnToPQuery)» | ||
82 | neg «referRelation(straightRelation, "target", "source", Modality.MUST, fqnToPQuery)» | ||
83 | } | ||
84 | |||
85 | pattern multipleMayInput(problem: LogicProblem, interpretation: PartialInterpretation, | ||
86 | target: DefinedElement) { | ||
87 | find interpretation(problem, interpretation); | ||
88 | find mustExist(problem, interpretation, target); | ||
89 | find mayInput(problem, interpretaton, source1, target); | ||
90 | find mayInput(problem, interpretaton, source2, target); | ||
91 | neg find mustEquivalent(problem, interpretation, source1, source2); | ||
92 | } | ||
93 | |||
94 | pattern multipleMayStraight(problem: LogicProblem, interpretation: PartialInterpretation, | ||
95 | source: DefinedElement) { | ||
96 | find interpretation(problem, interpretation); | ||
97 | find mustExist(problem, interpretation, source); | ||
98 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
99 | «referRelation(straightRelation, "source", "target1", Modality.MAY, fqnToPQuery)» | ||
100 | «referRelation(straightRelation, "source", "target2", Modality.MAY, fqnToPQuery)» | ||
101 | neg find mustEquivalent(problem, interpretation, target1, target2); | ||
102 | } | ||
103 | |||
104 | pattern multipleMayDivergent(problem: LogicProblem, interpretation: PartialInterpretation, | ||
105 | source: DefinedElement) { | ||
106 | find interpretation(problem, interpretation); | ||
107 | find mustExist(problem, interpretation, source); | ||
108 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
109 | «referRelation(divergentRelation, "source", "target1", Modality.MAY, fqnToPQuery)» | ||
110 | «referRelation(divergentRelation, "source", "target2", Modality.MAY, fqnToPQuery)» | ||
111 | neg find mustEquivalent(problem, interpretation, target1, target2); | ||
112 | } | ||
113 | |||
114 | pattern «MUST_CONNECTED_TO»(«parameters») { | ||
115 | «commonMustParameterConstraints» | ||
116 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
117 | find mayInput(problem, interpretaton, source, target); | ||
118 | neg find multipleMayInput(problem, interpretaton, target); | ||
119 | «referRelation(connectedToRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
120 | neg «referRelation(connectedToRelation, "source", "target", Modality.MUST, fqnToPQuery)» | ||
121 | neg «referRelation(straightRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
122 | neg «referRelation(divergentRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
123 | } | ||
124 | |||
125 | pattern «MUST_STRAIGHT»(«parameters») { | ||
126 | «commonMustParameterConstraints» | ||
127 | neg «referRelation(straightRelation, "source", "_", Modality.MUST, fqnToPQuery)» | ||
128 | neg find multipleMayStraight(problem, interpretation, source); | ||
129 | «referRelation(straightRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
130 | neg «referRelation(straightRelation, "source", "target", Modality.MUST, fqnToPQuery)» | ||
131 | } or { | ||
132 | «commonMustParameterConstraints» | ||
133 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
134 | find mayInput(problem, interpretaton, source, target); | ||
135 | neg find multipleMayInput(problem, interpretaton, target); | ||
136 | neg «referRelation(connectedToRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
137 | «referRelation(straightRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
138 | neg «referRelation(straightRelation, "source", "target", Modality.MUST, fqnToPQuery)» | ||
139 | neg «referRelation(divergentRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
140 | } | ||
141 | |||
142 | pattern «MUST_DIVERGENT»(«parameters») { | ||
143 | «commonMustParameterConstraints» | ||
144 | neg «referRelation(divergentRelation, "source", "_", Modality.MUST, fqnToPQuery)» | ||
145 | neg find multipleMayDivergent(problem, interpretation, source); | ||
146 | «referRelation(divergentRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
147 | neg «referRelation(divergentRelation, "source", "target", Modality.MUST, fqnToPQuery)» | ||
148 | } or { | ||
149 | «commonMustParameterConstraints» | ||
150 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
151 | find mayInput(problem, interpretaton, source, target); | ||
152 | neg find multipleMayInput(problem, interpretaton, target); | ||
153 | neg «referRelation(connectedToRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
154 | neg «referRelation(straightRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
155 | «referRelation(divergentRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
156 | neg «referRelation(divergentRelation, "source", "target", Modality.MUST, fqnToPQuery)» | ||
157 | } | ||
158 | |||
159 | pattern turnoutOutput_must_to_true_by_straight(«parameters», T : DefinedElement, S : DefinedElement) { | ||
160 | «commonMayParameterConstraints» | ||
161 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
162 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
163 | T == source; | ||
164 | S == target; | ||
165 | } | ||
166 | |||
167 | pattern turnoutOutput_must_to_true_by_divergent(«parameters», T : DefinedElement, S : DefinedElement) { | ||
168 | «commonMayParameterConstraints» | ||
169 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
170 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
171 | T == source; | ||
172 | S == target; | ||
173 | } | ||
174 | |||
175 | pattern output_must_to_true_by_connectedTo(«parameters», S1 : DefinedElement, S2 : DefinedElement) { | ||
176 | «commonMayParameterConstraints» | ||
177 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "source")» | ||
178 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
179 | S1 == source; | ||
180 | S2 == target; | ||
181 | } | ||
182 | |||
183 | pattern output_must_to_true_by_straight(«parameters», S1 : DefinedElement, S2 : DefinedElement) { | ||
184 | find turnoutOutput_must_to_true_by_straight(problem, interpretation, source, target, S1, S2); | ||
185 | } | ||
186 | |||
187 | pattern output_must_to_true_by_divergent(«parameters», S1 : DefinedElement, S2 : DefinedElement) { | ||
188 | find turnoutOutput_must_to_true_by_divergent(problem, interpretation, source, target, S1, S2); | ||
189 | } | ||
190 | |||
191 | pattern adjacent_must_to_true_by_connectedTo(«parameters», S1 : DefinedElement, S2 : DefinedElement) { | ||
192 | find output_must_to_true_by_connectedTo(problem, interpretation, source, target, S1, S2); | ||
193 | } | ||
194 | |||
195 | pattern adjacent_must_to_true_by_straight(«parameters», S1 : DefinedElement, S2 : DefinedElement) { | ||
196 | find output_must_to_true_by_straight(problem, interpretation, source, target, S1, S2); | ||
197 | } or { | ||
198 | find turnoutOutput_must_to_true_by_straight(problem, interpretation, source, target, S2, S1); | ||
199 | } | ||
200 | |||
201 | pattern adjacent_must_to_true_by_divergent(«parameters», S1 : DefinedElement, S2 : DefinedElement) { | ||
202 | find output_must_to_true_by_divergent(problem, interpretation, source, target, S1, S2); | ||
203 | } or { | ||
204 | find turnoutOutput_must_to_true_by_divergent(problem, interpretation, source, target, S2, S1); | ||
205 | } | ||
206 | |||
207 | pattern connectedToReflexive_must_to_true_by_connectedTo(«parameters», S : DefinedElement) { | ||
208 | find mustExist(problem, interpretation, source); | ||
209 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "source")» | ||
210 | S == source; | ||
211 | S == target; | ||
212 | } | ||
213 | |||
214 | pattern outputReflexive_must_to_true_by_straight(«parameters», T : DefinedElement) { | ||
215 | find turnoutOutput_must_to_true_by_straight(problem, interpretation, source, target, T, T); | ||
216 | } | ||
217 | |||
218 | pattern outputReflexive_must_to_true_by_divergent(«parameters», T : DefinedElement) { | ||
219 | find turnoutOutput_must_to_true_by_divergent(problem, interpretation, source, target, T, T); | ||
220 | } | ||
221 | |||
222 | pattern turnoutOutputsAreSame_must_to_true_by_straight(«parameters», T : DefinedElement) { | ||
223 | «commonMayParameterConstraints» | ||
224 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
225 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
226 | T == source; | ||
227 | S == target; | ||
228 | «referRelation(divergentRelation, "T", "S", Modality.MUST, fqnToPQuery)» | ||
229 | } | ||
230 | |||
231 | pattern turnoutOutputsAreSame_must_to_true_by_divergent(«parameters», T : DefinedElement) { | ||
232 | «commonMayParameterConstraints» | ||
233 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
234 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
235 | T == source; | ||
236 | S == target; | ||
237 | «referRelation(straightRelation, "T", "S", Modality.MUST, fqnToPQuery)» | ||
238 | } | ||
239 | |||
240 | pattern tooManyInputsOfSegment_must_to_true_by_connectedTo(«parameters», S : DefinedElement) { | ||
241 | find mustExist(problem, interpretation, S); | ||
242 | «typeIndexer.referInstanceOf(simpleSegmentType, Modality.MUST, "S")» | ||
243 | find output_must_to_true_by_connectedTo(problem, interpretation, source, target, I1, S); | ||
244 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["I2", "S"], Modality.MUST, true, false)» | ||
245 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["I3", "S"], Modality.MUST, true, false)» | ||
246 | I1 != I2; | ||
247 | I1 != I3; | ||
248 | I2 != I3; | ||
249 | } | ||
250 | |||
251 | pattern tooManyInputsOfSegment_must_to_true_by_straight(«parameters», S : DefinedElement) { | ||
252 | find mustExist(problem, interpretation, S); | ||
253 | «typeIndexer.referInstanceOf(simpleSegmentType, Modality.MUST, "S")» | ||
254 | find output_must_to_true_by_straight(problem, interpretation, source, target, I1, S); | ||
255 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["I2", "S"], Modality.MUST, true, false)» | ||
256 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["I3", "S"], Modality.MUST, true, false)» | ||
257 | I1 != I2; | ||
258 | I1 != I3; | ||
259 | I2 != I3; | ||
260 | } | ||
261 | |||
262 | pattern tooManyInputsOfSegment_must_to_true_by_divergent(«parameters», S : DefinedElement) { | ||
263 | find mustExist(problem, interpretation, S); | ||
264 | «typeIndexer.referInstanceOf(simpleSegmentType, Modality.MUST, "S")» | ||
265 | find output_must_to_true_by_divergent(problem, interpretation, source, target, I1, S); | ||
266 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["I2", "S"], Modality.MUST, true, false)» | ||
267 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["I3", "S"], Modality.MUST, true, false)» | ||
268 | I1 != I2; | ||
269 | I1 != I3; | ||
270 | I2 != I3; | ||
271 | } | ||
272 | |||
273 | pattern turnoutConnectedToBothOutputs_must_to_true_by_connectedTo(«parameters», T : DefinedElement) { | ||
274 | «commonMayParameterConstraints» | ||
275 | find mustExist(problem, interpretation, Straight); | ||
276 | find mustExist(problem, interpretation, Divergent); | ||
277 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
278 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
279 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Straight")» | ||
280 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Divergent")» | ||
281 | «referRelation(straightRelation, "T", "Straight", Modality.MUST, fqnToPQuery)» | ||
282 | «referRelation(divergentRelation, "T", "Divergent", Modality.MUST, fqnToPQuery)» | ||
283 | T == source; | ||
284 | Straight == target; | ||
285 | «referRelation(connectedToRelation, "T", "Divergent", Modality.MUST, fqnToPQuery)» | ||
286 | } or { | ||
287 | «commonMayParameterConstraints» | ||
288 | find mustExist(problem, interpretation, Straight); | ||
289 | find mustExist(problem, interpretation, Divergent); | ||
290 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
291 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
292 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Straight")» | ||
293 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Divergent")» | ||
294 | «referRelation(straightRelation, "T", "Straight", Modality.MUST, fqnToPQuery)» | ||
295 | «referRelation(divergentRelation, "T", "Divergent", Modality.MUST, fqnToPQuery)» | ||
296 | «referRelation(connectedToRelation, "T", "Straight", Modality.MUST, fqnToPQuery)» | ||
297 | T == source; | ||
298 | Straight == target; | ||
299 | } | ||
300 | |||
301 | pattern turnoutConnectedToBothOutputs_must_to_true_by_straight(«parameters», T : DefinedElement) { | ||
302 | «commonMayParameterConstraints» | ||
303 | find mustExist(problem, interpretation, Straight); | ||
304 | find mustExist(problem, interpretation, Divergent); | ||
305 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
306 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
307 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Straight")» | ||
308 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Divergent")» | ||
309 | T == source; | ||
310 | Straight == target; | ||
311 | «referRelation(divergentRelation, "T", "Divergent", Modality.MUST, fqnToPQuery)» | ||
312 | «referRelation(connectedToRelation, "T", "Straight", Modality.MUST, fqnToPQuery)» | ||
313 | «referRelation(connectedToRelation, "T", "Divergent", Modality.MUST, fqnToPQuery)» | ||
314 | } | ||
315 | |||
316 | pattern turnoutConnectedToBothOutputs_must_to_true_by_divergent(«parameters», T : DefinedElement) { | ||
317 | «commonMayParameterConstraints» | ||
318 | find mustExist(problem, interpretation, Straight); | ||
319 | find mustExist(problem, interpretation, Divergent); | ||
320 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
321 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
322 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Straight")» | ||
323 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Divergent")» | ||
324 | «referRelation(straightRelation, "T", "Straight", Modality.MUST, fqnToPQuery)» | ||
325 | T == source; | ||
326 | Divergent == target; | ||
327 | «referRelation(connectedToRelation, "T", "Straight", Modality.MUST, fqnToPQuery)» | ||
328 | «referRelation(connectedToRelation, "T", "Divergent", Modality.MUST, fqnToPQuery)» | ||
329 | } | ||
330 | |||
331 | pattern tooManyInputsOfTurnout_must_to_true_by_connectedTo(«parameters», T : DefinedElement) { | ||
332 | find mustExist(problem, interpretation, S); | ||
333 | «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "S")» | ||
334 | find adjacent_must_to_true_by_connectedTo(problem, interpretation, source, target, I1, S); | ||
335 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I2", "S"], Modality.MUST, true, false)» | ||
336 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I3", "S"], Modality.MUST, true, false)» | ||
337 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I4", "S"], Modality.MUST, true, false)» | ||
338 | I1 != I2; | ||
339 | I1 != I3; | ||
340 | I1 != I4; | ||
341 | I2 != I3; | ||
342 | I2 != I4; | ||
343 | I3 != I4; | ||
344 | } | ||
345 | |||
346 | pattern tooManyInputsOfTurnout_must_to_true_by_straight(«parameters», T : DefinedElement) { | ||
347 | find mustExist(problem, interpretation, S); | ||
348 | «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "S")» | ||
349 | find adjacent_must_to_true_by_straight(problem, interpretation, source, target, I1, S); | ||
350 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I2", "S"], Modality.MUST, true, false)» | ||
351 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I3", "S"], Modality.MUST, true, false)» | ||
352 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I4", "S"], Modality.MUST, true, false)» | ||
353 | I1 != I2; | ||
354 | I1 != I3; | ||
355 | I1 != I4; | ||
356 | I2 != I3; | ||
357 | I2 != I4; | ||
358 | I3 != I4; | ||
359 | } | ||
360 | |||
361 | pattern tooManyInputsOfTurnout_must_to_true_by_divergent(«parameters», T : DefinedElement) { | ||
362 | find mustExist(problem, interpretation, S); | ||
363 | «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "S")» | ||
364 | find adjacent_must_to_true_by_divergent(problem, interpretation, source, target, I1, S); | ||
365 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I2", "S"], Modality.MUST, true, false)» | ||
366 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I3", "S"], Modality.MUST, true, false)» | ||
367 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I4", "S"], Modality.MUST, true, false)» | ||
368 | I1 != I2; | ||
369 | I1 != I3; | ||
370 | I1 != I4; | ||
371 | I2 != I3; | ||
372 | I2 != I4; | ||
373 | I3 != I4; | ||
374 | } | ||
375 | |||
376 | pattern «MUST_NOT_CONNECTED_TO»_helper(«parameters») { | ||
377 | find connectedToReflexive_must_to_true_by_connectedTo(problem, interpretation, source, target, _); | ||
378 | } or { | ||
379 | find tooManyInputsOfSegment_must_to_true_by_connectedTo(problem, interpretation, source, target, _); | ||
380 | } or { | ||
381 | find turnoutConnectedToBothOutputs_must_to_true_by_connectedTo(problem, interpretation, source, target, _); | ||
382 | } or { | ||
383 | find tooManyInputsOfTurnout_must_to_true_by_connectedTo(problem, interpretation, source, target, _); | ||
384 | } | ||
385 | |||
386 | pattern «MUST_NOT_CONNECTED_TO»(«parameters») { | ||
387 | find «MUST_NOT_CONNECTED_TO»_helper(problem, interpretation, source, target); | ||
388 | } or { | ||
389 | find «MUST_NOT_CONNECTED_TO»_helper(problem, interpretation, target, source); | ||
390 | } | ||
391 | |||
392 | pattern «MUST_NOT_STRAIGHT»(«parameters») { | ||
393 | find outputReflexive_must_to_true_by_straight(problem, interpretation, source, target, _); | ||
394 | } or { | ||
395 | find turnoutOutputsAreSame_must_to_true_by_straight(problem, interpretation, source, target, _); | ||
396 | } or { | ||
397 | find tooManyInputsOfSegment_must_to_true_by_straight(problem, interpretation, source, target, _); | ||
398 | } or { | ||
399 | find turnoutConnectedToBothOutputs_must_to_true_by_straight(problem, interpretation, source, target, _); | ||
400 | } or { | ||
401 | find tooManyInputsOfTurnout_must_to_true_by_straight(problem, interpretation, source, target, _); | ||
402 | } | ||
403 | |||
404 | pattern «MUST_NOT_DIVERGENT»(«parameters») { | ||
405 | find outputReflexive_must_to_true_by_divergent(problem, interpretation, source, target, _); | ||
406 | } or { | ||
407 | find turnoutOutputsAreSame_must_to_true_by_divergent(problem, interpretation, source, target, _); | ||
408 | } or { | ||
409 | find tooManyInputsOfSegment_must_to_true_by_divergent(problem, interpretation, source, target, _); | ||
410 | } or { | ||
411 | find turnoutConnectedToBothOutputs_must_to_true_by_divergent(problem, interpretation, source, target, _); | ||
412 | } or { | ||
413 | find tooManyInputsOfTurnout_must_to_true_by_divergent(problem, interpretation, source, target, _); | ||
414 | } | ||
415 | ''' | ||
416 | } | ||
417 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/TrainLocationsObjectiveHint.xtend b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/TrainLocationsObjectiveHint.xtend new file mode 100644 index 00000000..cc2d7925 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/TrainLocationsObjectiveHint.xtend | |||
@@ -0,0 +1,85 @@ | |||
1 | package modes3.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint | ||
10 | import java.util.Collection | ||
11 | import java.util.Map | ||
12 | import modes3.Modes3Package | ||
13 | import modes3.queries.TrainLocations_step_2 | ||
14 | import modes3.queries.TrainLocations_step_3 | ||
15 | |||
16 | class TrainLocationsObjectiveHint extends CostObjectiveHint { | ||
17 | val Type segmentType | ||
18 | val Type trainType | ||
19 | |||
20 | new(extension Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { | ||
21 | extension val Modes3Package = Modes3Package.eINSTANCE | ||
22 | segmentType = ecore2LogicTrace.TypeofEClass(segment) | ||
23 | trainType = ecore2LogicTrace.TypeofEClass(train) | ||
24 | } | ||
25 | |||
26 | override isExact() { | ||
27 | true | ||
28 | } | ||
29 | |||
30 | override createPolyhedronExtensionOperator(Map<String, CostElementMatchers> costElementMatchers) { | ||
31 | val step2 = costElementMatchers.get(TrainLocations_step_2.instance.fullyQualifiedName) | ||
32 | val step3 = costElementMatchers.get(TrainLocations_step_3.instance.fullyQualifiedName); | ||
33 | |||
34 | [ | ||
35 | val objectiveBuilder = createBuilder | ||
36 | |||
37 | for (m : step2.matches) { | ||
38 | val dimension = getDimension(m.match) | ||
39 | objectiveBuilder.add(step2.weight, dimension) | ||
40 | dimension.tightenLowerBound(0) | ||
41 | if (m.multi) { | ||
42 | createBuilder.add(1, dimension).add(-1, trainType).build.assertEqualsTo(0) | ||
43 | } else { | ||
44 | dimension.tightenUpperBound(1) | ||
45 | if (m.must) { | ||
46 | dimension.tightenLowerBound(1) | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | |||
51 | val step3Matches = step3.matches | ||
52 | for (m : step3Matches) { | ||
53 | val dimension = getDimension(m.match) | ||
54 | objectiveBuilder.add(step3.weight, dimension) | ||
55 | dimension.tightenLowerBound(0) | ||
56 | if (!m.multi) { | ||
57 | dimension.tightenUpperBound(1) | ||
58 | if (m.must) { | ||
59 | dimension.tightenLowerBound(1) | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | boundLimit(step3Matches, 2, trainType, 1) | ||
64 | boundLimit(step3Matches, 3, segmentType, 1) | ||
65 | |||
66 | objectiveBuilder.buildWithBounds | ||
67 | ] | ||
68 | } | ||
69 | |||
70 | private static def boundLimit(extension ExtendedLinearExpressionBuilderFactory factory, | ||
71 | Collection<CostElementMatch> matches, int index, Type type, int count) { | ||
72 | for (pair : matches.groupBy[match.get(index)].entrySet) { | ||
73 | val multiplicityBuilder = createBuilder | ||
74 | for (m : pair.value) { | ||
75 | multiplicityBuilder.add(1, m.match) | ||
76 | } | ||
77 | if (CostElementMatchers.isMulti(pair.key)) { | ||
78 | multiplicityBuilder.add(-count, type) | ||
79 | multiplicityBuilder.build.tightenUpperBound(0) | ||
80 | } else { | ||
81 | multiplicityBuilder.build.tightenUpperBound(count) | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | } \ No newline at end of file | ||
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..a84c2906 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/.gitignore | |||
@@ -0,0 +1,78 @@ | |||
1 | /.ConnectedToReflexive.java._trace | ||
2 | /.Modes3Queries.java._trace | ||
3 | /.StraightReflexive.java._trace | ||
4 | /.DivergentReflexive.java._trace | ||
5 | /.TurnoutOutputsAreSame.java._trace | ||
6 | /.Adjacent.java._trace | ||
7 | /.Output.java._trace | ||
8 | /.OutputReflexive.java._trace | ||
9 | /.TooManyAdjacentSegmentsOfSegment.java._trace | ||
10 | /.Turnout.java._trace | ||
11 | /.ConnectedTo.java._trace | ||
12 | /.TurnoutNotConnectedToOutput.java._trace | ||
13 | /.DisjointNetwork.java._trace | ||
14 | /.Reachable.java._trace | ||
15 | /.Unreachable.java._trace | ||
16 | /.TurnoutInSegments.java._trace | ||
17 | /.ConnectedToNotSymmetric.java._trace | ||
18 | /.TurnoutConnectedToBothOutputs.java._trace | ||
19 | /.TooManyAdjacentTurnouts.java._trace | ||
20 | /.NoAdjacentSegmentOfSegment.java._trace | ||
21 | /.TurnoutOutput.java._trace | ||
22 | /.NoInputOfSegment.java._trace | ||
23 | /.TooManyInputsOfSegment.java._trace | ||
24 | /.ExtraInputOfTurnout.java._trace | ||
25 | /.NoExtraInputOfTurnout.java._trace | ||
26 | /.TooManyExtraInputsOfTurnout.java._trace | ||
27 | /.TooManyInputsOfTurnout.java._trace | ||
28 | /.NonDivergentInputOfTurnout.java._trace | ||
29 | /.NonStraightInputOfTurnout.java._trace | ||
30 | /.TooManyNonDivergentInputsOfTurnout.java._trace | ||
31 | /.TooManyNonStraightInputsOfTurnout.java._trace | ||
32 | /.InputsOfTurnout.java._trace | ||
33 | /.TooFewInputsOfTurnout.java._trace | ||
34 | /.CloseTrains_step_2.java._trace | ||
35 | /.CloseTrains_step_3.java._trace | ||
36 | /.CloseTrains_step_4.java._trace | ||
37 | /.CloseTrains_step_5.java._trace | ||
38 | /.CloseTrains_step_6.java._trace | ||
39 | /.CloseTrains_step_7.java._trace | ||
40 | /.MisalignedTurnout_step_2.java._trace | ||
41 | /.MisalignedTurnout_step_3.java._trace | ||
42 | /.MisalignedTurnout_step_4.java._trace | ||
43 | /.MisalignedTurnout_step_5.java._trace | ||
44 | /.ConnectedSegmentsDirected.java._trace | ||
45 | /Adjacent.java | ||
46 | /CloseTrains_step_2.java | ||
47 | /CloseTrains_step_3.java | ||
48 | /CloseTrains_step_4.java | ||
49 | /CloseTrains_step_5.java | ||
50 | /CloseTrains_step_6.java | ||
51 | /CloseTrains_step_7.java | ||
52 | /ConnectedSegmentsDirected.java | ||
53 | /ConnectedTo.java | ||
54 | /ConnectedToNotSymmetric.java | ||
55 | /ConnectedToReflexive.java | ||
56 | /InputsOfTurnout.java | ||
57 | /MisalignedTurnout_step_2.java | ||
58 | /MisalignedTurnout_step_3.java | ||
59 | /MisalignedTurnout_step_4.java | ||
60 | /MisalignedTurnout_step_5.java | ||
61 | /Modes3Queries.java | ||
62 | /Output.java | ||
63 | /OutputReflexive.java | ||
64 | /Reachable.java | ||
65 | /TooFewInputsOfTurnout.java | ||
66 | /TooManyInputsOfSegment.java | ||
67 | /TooManyInputsOfTurnout.java | ||
68 | /TurnoutConnectedToBothOutputs.java | ||
69 | /TurnoutOutput.java | ||
70 | /TurnoutOutputsAreSame.java | ||
71 | /Unreachable.java | ||
72 | /.TrainLocations_step_2.java._trace | ||
73 | /.TrainLocations_step_3.java._trace | ||
74 | /.EndOfSiding_step_2.java._trace | ||
75 | /.EndOfSiding_step_3.java._trace | ||
76 | /.EndOfSiding_step_4.java._trace | ||
77 | /.EndOfSiding_step_5.java._trace | ||
78 | /.MultipleConnectedTo.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 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.queries.Output; | ||
18 | import modes3.queries.TurnoutOutput; | ||
19 | import org.apache.log4j.Logger; | ||
20 | import org.eclipse.emf.ecore.EClass; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern adjacent(S1 : Segment, S2 : Segment) { | ||
48 | * find output(S1, S2); | ||
49 | * } or { | ||
50 | * find turnoutOutput(S2, S1); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class Adjacent extends BaseGeneratedEMFQuerySpecification<Adjacent.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.adjacent pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Segment fS1; | ||
74 | |||
75 | private Segment fS2; | ||
76 | |||
77 | private static List<String> parameterNames = makeImmutableList("S1", "S2"); | ||
78 | |||
79 | private Match(final Segment pS1, final Segment pS2) { | ||
80 | this.fS1 = pS1; | ||
81 | this.fS2 = pS2; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | switch(parameterName) { | ||
87 | case "S1": return this.fS1; | ||
88 | case "S2": return this.fS2; | ||
89 | default: return null; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | @Override | ||
94 | public Object get(final int index) { | ||
95 | switch(index) { | ||
96 | case 0: return this.fS1; | ||
97 | case 1: return this.fS2; | ||
98 | default: return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public Segment getS1() { | ||
103 | return this.fS1; | ||
104 | } | ||
105 | |||
106 | public Segment getS2() { | ||
107 | return this.fS2; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public boolean set(final String parameterName, final Object newValue) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | if ("S1".equals(parameterName) ) { | ||
114 | this.fS1 = (Segment) newValue; | ||
115 | return true; | ||
116 | } | ||
117 | if ("S2".equals(parameterName) ) { | ||
118 | this.fS2 = (Segment) newValue; | ||
119 | return true; | ||
120 | } | ||
121 | return false; | ||
122 | } | ||
123 | |||
124 | public void setS1(final Segment pS1) { | ||
125 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
126 | this.fS1 = pS1; | ||
127 | } | ||
128 | |||
129 | public void setS2(final Segment pS2) { | ||
130 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
131 | this.fS2 = pS2; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public String patternName() { | ||
136 | return "modes3.queries.adjacent"; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public List<String> parameterNames() { | ||
141 | return Adjacent.Match.parameterNames; | ||
142 | } | ||
143 | |||
144 | @Override | ||
145 | public Object[] toArray() { | ||
146 | return new Object[]{fS1, fS2}; | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public Adjacent.Match toImmutable() { | ||
151 | return isMutable() ? newMatch(fS1, fS2) : this; | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public String prettyPrint() { | ||
156 | StringBuilder result = new StringBuilder(); | ||
157 | result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); | ||
158 | result.append("\"S2\"=" + prettyPrintValue(fS2)); | ||
159 | return result.toString(); | ||
160 | } | ||
161 | |||
162 | @Override | ||
163 | public int hashCode() { | ||
164 | return Objects.hash(fS1, fS2); | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public boolean equals(final Object obj) { | ||
169 | if (this == obj) | ||
170 | return true; | ||
171 | if (obj == null) { | ||
172 | return false; | ||
173 | } | ||
174 | if ((obj instanceof Adjacent.Match)) { | ||
175 | Adjacent.Match other = (Adjacent.Match) obj; | ||
176 | return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); | ||
177 | } else { | ||
178 | // this should be infrequent | ||
179 | if (!(obj instanceof IPatternMatch)) { | ||
180 | return false; | ||
181 | } | ||
182 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
183 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | @Override | ||
188 | public Adjacent specification() { | ||
189 | return Adjacent.instance(); | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * Returns an empty, mutable match. | ||
194 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
195 | * | ||
196 | * @return the empty match. | ||
197 | * | ||
198 | */ | ||
199 | public static Adjacent.Match newEmptyMatch() { | ||
200 | return new Mutable(null, null); | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * Returns a mutable (partial) match. | ||
205 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
206 | * | ||
207 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
208 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
209 | * @return the new, mutable (partial) match object. | ||
210 | * | ||
211 | */ | ||
212 | public static Adjacent.Match newMutableMatch(final Segment pS1, final Segment pS2) { | ||
213 | return new Mutable(pS1, pS2); | ||
214 | } | ||
215 | |||
216 | /** | ||
217 | * Returns a new (partial) match. | ||
218 | * This can be used e.g. to call the matcher with a partial match. | ||
219 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
220 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
221 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
222 | * @return the (partial) match object. | ||
223 | * | ||
224 | */ | ||
225 | public static Adjacent.Match newMatch(final Segment pS1, final Segment pS2) { | ||
226 | return new Immutable(pS1, pS2); | ||
227 | } | ||
228 | |||
229 | private static final class Mutable extends Adjacent.Match { | ||
230 | Mutable(final Segment pS1, final Segment pS2) { | ||
231 | super(pS1, pS2); | ||
232 | } | ||
233 | |||
234 | @Override | ||
235 | public boolean isMutable() { | ||
236 | return true; | ||
237 | } | ||
238 | } | ||
239 | |||
240 | private static final class Immutable extends Adjacent.Match { | ||
241 | Immutable(final Segment pS1, final Segment pS2) { | ||
242 | super(pS1, pS2); | ||
243 | } | ||
244 | |||
245 | @Override | ||
246 | public boolean isMutable() { | ||
247 | return false; | ||
248 | } | ||
249 | } | ||
250 | } | ||
251 | |||
252 | /** | ||
253 | * Generated pattern matcher API of the modes3.queries.adjacent pattern, | ||
254 | * providing pattern-specific query methods. | ||
255 | * | ||
256 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
257 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
258 | * | ||
259 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
260 | * | ||
261 | * <p>Original source: | ||
262 | * <code><pre> | ||
263 | * pattern adjacent(S1 : Segment, S2 : Segment) { | ||
264 | * find output(S1, S2); | ||
265 | * } or { | ||
266 | * find turnoutOutput(S2, S1); | ||
267 | * } | ||
268 | * </pre></code> | ||
269 | * | ||
270 | * @see Match | ||
271 | * @see Adjacent | ||
272 | * | ||
273 | */ | ||
274 | public static class Matcher extends BaseMatcher<Adjacent.Match> { | ||
275 | /** | ||
276 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
277 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
278 | * | ||
279 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
280 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
281 | * | ||
282 | */ | ||
283 | public static Adjacent.Matcher on(final ViatraQueryEngine engine) { | ||
284 | // check if matcher already exists | ||
285 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
286 | if (matcher == null) { | ||
287 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
288 | } | ||
289 | return matcher; | ||
290 | } | ||
291 | |||
292 | /** | ||
293 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
294 | * @return an initialized matcher | ||
295 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
296 | * | ||
297 | */ | ||
298 | public static Adjacent.Matcher create() { | ||
299 | return new Matcher(); | ||
300 | } | ||
301 | |||
302 | private static final int POSITION_S1 = 0; | ||
303 | |||
304 | private static final int POSITION_S2 = 1; | ||
305 | |||
306 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Adjacent.Matcher.class); | ||
307 | |||
308 | /** | ||
309 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
310 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
311 | * | ||
312 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
313 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
314 | * | ||
315 | */ | ||
316 | private Matcher() { | ||
317 | super(querySpecification()); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
322 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
323 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
324 | * @return matches represented as a Match object. | ||
325 | * | ||
326 | */ | ||
327 | public Collection<Adjacent.Match> getAllMatches(final Segment pS1, final Segment pS2) { | ||
328 | return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
333 | * </p> | ||
334 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
335 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
336 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
337 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
338 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
339 | * @return a stream of matches represented as a Match object. | ||
340 | * | ||
341 | */ | ||
342 | public Stream<Adjacent.Match> streamAllMatches(final Segment pS1, final Segment pS2) { | ||
343 | return rawStreamAllMatches(new Object[]{pS1, pS2}); | ||
344 | } | ||
345 | |||
346 | /** | ||
347 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
348 | * Neither determinism nor randomness of selection is guaranteed. | ||
349 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
350 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
351 | * @return a match represented as a Match object, or null if no match is found. | ||
352 | * | ||
353 | */ | ||
354 | public Optional<Adjacent.Match> getOneArbitraryMatch(final Segment pS1, final Segment pS2) { | ||
355 | return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
360 | * under any possible substitution of the unspecified parameters (if any). | ||
361 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
362 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
363 | * @return true if the input is a valid (partial) match of the pattern. | ||
364 | * | ||
365 | */ | ||
366 | public boolean hasMatch(final Segment pS1, final Segment pS2) { | ||
367 | return rawHasMatch(new Object[]{pS1, pS2}); | ||
368 | } | ||
369 | |||
370 | /** | ||
371 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
372 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
373 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
374 | * @return the number of pattern matches found. | ||
375 | * | ||
376 | */ | ||
377 | public int countMatches(final Segment pS1, final Segment pS2) { | ||
378 | return rawCountMatches(new Object[]{pS1, pS2}); | ||
379 | } | ||
380 | |||
381 | /** | ||
382 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
383 | * Neither determinism nor randomness of selection is guaranteed. | ||
384 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
385 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
386 | * @param processor the action that will process the selected match. | ||
387 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
388 | * | ||
389 | */ | ||
390 | public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer<? super Adjacent.Match> processor) { | ||
391 | return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Returns a new (partial) match. | ||
396 | * This can be used e.g. to call the matcher with a partial match. | ||
397 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
398 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
399 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
400 | * @return the (partial) match object. | ||
401 | * | ||
402 | */ | ||
403 | public Adjacent.Match newMatch(final Segment pS1, final Segment pS2) { | ||
404 | return Adjacent.Match.newMatch(pS1, pS2); | ||
405 | } | ||
406 | |||
407 | /** | ||
408 | * Retrieve the set of values that occur in matches for S1. | ||
409 | * @return the Set of all values or empty set if there are no matches | ||
410 | * | ||
411 | */ | ||
412 | protected Stream<Segment> rawStreamAllValuesOfS1(final Object[] parameters) { | ||
413 | return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); | ||
414 | } | ||
415 | |||
416 | /** | ||
417 | * Retrieve the set of values that occur in matches for S1. | ||
418 | * @return the Set of all values or empty set if there are no matches | ||
419 | * | ||
420 | */ | ||
421 | public Set<Segment> getAllValuesOfS1() { | ||
422 | return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); | ||
423 | } | ||
424 | |||
425 | /** | ||
426 | * Retrieve the set of values that occur in matches for S1. | ||
427 | * @return the Set of all values or empty set if there are no matches | ||
428 | * | ||
429 | */ | ||
430 | public Stream<Segment> streamAllValuesOfS1() { | ||
431 | return rawStreamAllValuesOfS1(emptyArray()); | ||
432 | } | ||
433 | |||
434 | /** | ||
435 | * Retrieve the set of values that occur in matches for S1. | ||
436 | * </p> | ||
437 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
438 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
439 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
440 | * | ||
441 | * @return the Stream of all values or empty set if there are no matches | ||
442 | * | ||
443 | */ | ||
444 | public Stream<Segment> streamAllValuesOfS1(final Adjacent.Match partialMatch) { | ||
445 | return rawStreamAllValuesOfS1(partialMatch.toArray()); | ||
446 | } | ||
447 | |||
448 | /** | ||
449 | * Retrieve the set of values that occur in matches for S1. | ||
450 | * </p> | ||
451 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
452 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
453 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
454 | * | ||
455 | * @return the Stream of all values or empty set if there are no matches | ||
456 | * | ||
457 | */ | ||
458 | public Stream<Segment> streamAllValuesOfS1(final Segment pS2) { | ||
459 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}); | ||
460 | } | ||
461 | |||
462 | /** | ||
463 | * Retrieve the set of values that occur in matches for S1. | ||
464 | * @return the Set of all values or empty set if there are no matches | ||
465 | * | ||
466 | */ | ||
467 | public Set<Segment> getAllValuesOfS1(final Adjacent.Match partialMatch) { | ||
468 | return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); | ||
469 | } | ||
470 | |||
471 | /** | ||
472 | * Retrieve the set of values that occur in matches for S1. | ||
473 | * @return the Set of all values or empty set if there are no matches | ||
474 | * | ||
475 | */ | ||
476 | public Set<Segment> getAllValuesOfS1(final Segment pS2) { | ||
477 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Retrieve the set of values that occur in matches for S2. | ||
482 | * @return the Set of all values or empty set if there are no matches | ||
483 | * | ||
484 | */ | ||
485 | protected Stream<Segment> rawStreamAllValuesOfS2(final Object[] parameters) { | ||
486 | return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); | ||
487 | } | ||
488 | |||
489 | /** | ||
490 | * Retrieve the set of values that occur in matches for S2. | ||
491 | * @return the Set of all values or empty set if there are no matches | ||
492 | * | ||
493 | */ | ||
494 | public Set<Segment> getAllValuesOfS2() { | ||
495 | return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); | ||
496 | } | ||
497 | |||
498 | /** | ||
499 | * Retrieve the set of values that occur in matches for S2. | ||
500 | * @return the Set of all values or empty set if there are no matches | ||
501 | * | ||
502 | */ | ||
503 | public Stream<Segment> streamAllValuesOfS2() { | ||
504 | return rawStreamAllValuesOfS2(emptyArray()); | ||
505 | } | ||
506 | |||
507 | /** | ||
508 | * Retrieve the set of values that occur in matches for S2. | ||
509 | * </p> | ||
510 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
511 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
512 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
513 | * | ||
514 | * @return the Stream of all values or empty set if there are no matches | ||
515 | * | ||
516 | */ | ||
517 | public Stream<Segment> streamAllValuesOfS2(final Adjacent.Match partialMatch) { | ||
518 | return rawStreamAllValuesOfS2(partialMatch.toArray()); | ||
519 | } | ||
520 | |||
521 | /** | ||
522 | * Retrieve the set of values that occur in matches for S2. | ||
523 | * </p> | ||
524 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
525 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
526 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
527 | * | ||
528 | * @return the Stream of all values or empty set if there are no matches | ||
529 | * | ||
530 | */ | ||
531 | public Stream<Segment> streamAllValuesOfS2(final Segment pS1) { | ||
532 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}); | ||
533 | } | ||
534 | |||
535 | /** | ||
536 | * Retrieve the set of values that occur in matches for S2. | ||
537 | * @return the Set of all values or empty set if there are no matches | ||
538 | * | ||
539 | */ | ||
540 | public Set<Segment> getAllValuesOfS2(final Adjacent.Match partialMatch) { | ||
541 | return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); | ||
542 | } | ||
543 | |||
544 | /** | ||
545 | * Retrieve the set of values that occur in matches for S2. | ||
546 | * @return the Set of all values or empty set if there are no matches | ||
547 | * | ||
548 | */ | ||
549 | public Set<Segment> getAllValuesOfS2(final Segment pS1) { | ||
550 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); | ||
551 | } | ||
552 | |||
553 | @Override | ||
554 | protected Adjacent.Match tupleToMatch(final Tuple t) { | ||
555 | try { | ||
556 | return Adjacent.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); | ||
557 | } catch(ClassCastException e) { | ||
558 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
559 | return null; | ||
560 | } | ||
561 | } | ||
562 | |||
563 | @Override | ||
564 | protected Adjacent.Match arrayToMatch(final Object[] match) { | ||
565 | try { | ||
566 | return Adjacent.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
567 | } catch(ClassCastException e) { | ||
568 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
569 | return null; | ||
570 | } | ||
571 | } | ||
572 | |||
573 | @Override | ||
574 | protected Adjacent.Match arrayToMatchMutable(final Object[] match) { | ||
575 | try { | ||
576 | return Adjacent.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
577 | } catch(ClassCastException e) { | ||
578 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
579 | return null; | ||
580 | } | ||
581 | } | ||
582 | |||
583 | /** | ||
584 | * @return the singleton instance of the query specification of this pattern | ||
585 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
586 | * | ||
587 | */ | ||
588 | public static IQuerySpecification<Adjacent.Matcher> querySpecification() { | ||
589 | return Adjacent.instance(); | ||
590 | } | ||
591 | } | ||
592 | |||
593 | private Adjacent() { | ||
594 | super(GeneratedPQuery.INSTANCE); | ||
595 | } | ||
596 | |||
597 | /** | ||
598 | * @return the singleton instance of the query specification | ||
599 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
600 | * | ||
601 | */ | ||
602 | public static Adjacent instance() { | ||
603 | try{ | ||
604 | return LazyHolder.INSTANCE; | ||
605 | } catch (ExceptionInInitializerError err) { | ||
606 | throw processInitializerError(err); | ||
607 | } | ||
608 | } | ||
609 | |||
610 | @Override | ||
611 | protected Adjacent.Matcher instantiate(final ViatraQueryEngine engine) { | ||
612 | return Adjacent.Matcher.on(engine); | ||
613 | } | ||
614 | |||
615 | @Override | ||
616 | public Adjacent.Matcher instantiate() { | ||
617 | return Adjacent.Matcher.create(); | ||
618 | } | ||
619 | |||
620 | @Override | ||
621 | public Adjacent.Match newEmptyMatch() { | ||
622 | return Adjacent.Match.newEmptyMatch(); | ||
623 | } | ||
624 | |||
625 | @Override | ||
626 | public Adjacent.Match newMatch(final Object... parameters) { | ||
627 | return Adjacent.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); | ||
628 | } | ||
629 | |||
630 | /** | ||
631 | * Inner class allowing the singleton instance of {@link Adjacent} to be created | ||
632 | * <b>not</b> at the class load time of the outer class, | ||
633 | * but rather at the first call to {@link Adjacent#instance()}. | ||
634 | * | ||
635 | * <p> This workaround is required e.g. to support recursion. | ||
636 | * | ||
637 | */ | ||
638 | private static class LazyHolder { | ||
639 | private static final Adjacent INSTANCE = new Adjacent(); | ||
640 | |||
641 | /** | ||
642 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
643 | * This initialization order is required to support indirect recursion. | ||
644 | * | ||
645 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
646 | * | ||
647 | */ | ||
648 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
649 | |||
650 | public static Object ensureInitialized() { | ||
651 | INSTANCE.ensureInitializedInternal(); | ||
652 | return null; | ||
653 | } | ||
654 | } | ||
655 | |||
656 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
657 | private static final Adjacent.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
658 | |||
659 | private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
660 | |||
661 | private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
662 | |||
663 | private final List<PParameter> parameters = Arrays.asList(parameter_S1, parameter_S2); | ||
664 | |||
665 | private GeneratedPQuery() { | ||
666 | super(PVisibility.PUBLIC); | ||
667 | } | ||
668 | |||
669 | @Override | ||
670 | public String getFullyQualifiedName() { | ||
671 | return "modes3.queries.adjacent"; | ||
672 | } | ||
673 | |||
674 | @Override | ||
675 | public List<String> getParameterNames() { | ||
676 | return Arrays.asList("S1","S2"); | ||
677 | } | ||
678 | |||
679 | @Override | ||
680 | public List<PParameter> getParameters() { | ||
681 | return parameters; | ||
682 | } | ||
683 | |||
684 | @Override | ||
685 | public Set<PBody> doGetContainedBodies() { | ||
686 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
687 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
688 | { | ||
689 | PBody body = new PBody(this); | ||
690 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
691 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
692 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
693 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
694 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
695 | new ExportedParameter(body, var_S1, parameter_S1), | ||
696 | new ExportedParameter(body, var_S2, parameter_S2) | ||
697 | )); | ||
698 | // find output(S1, S2) | ||
699 | new PositivePatternCall(body, Tuples.flatTupleOf(var_S1, var_S2), Output.instance().getInternalQueryRepresentation()); | ||
700 | bodies.add(body); | ||
701 | } | ||
702 | { | ||
703 | PBody body = new PBody(this); | ||
704 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
705 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
706 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
707 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
708 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
709 | new ExportedParameter(body, var_S1, parameter_S1), | ||
710 | new ExportedParameter(body, var_S2, parameter_S2) | ||
711 | )); | ||
712 | // find turnoutOutput(S2, S1) | ||
713 | new PositivePatternCall(body, Tuples.flatTupleOf(var_S2, var_S1), TurnoutOutput.instance().getInternalQueryRepresentation()); | ||
714 | bodies.add(body); | ||
715 | } | ||
716 | return bodies; | ||
717 | } | ||
718 | } | ||
719 | } | ||
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 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
40 | |||
41 | /** | ||
42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
43 | * | ||
44 | * <p>Original source: | ||
45 | * <code><pre> | ||
46 | * pattern connectedTo(S1 : Segment, S2 : Segment) { | ||
47 | * Segment.connectedTo(S1, S2); | ||
48 | * } | ||
49 | * </pre></code> | ||
50 | * | ||
51 | * @see Matcher | ||
52 | * @see Match | ||
53 | * | ||
54 | */ | ||
55 | @SuppressWarnings("all") | ||
56 | public final class ConnectedTo extends BaseGeneratedEMFQuerySpecification<ConnectedTo.Matcher> { | ||
57 | /** | ||
58 | * Pattern-specific match representation of the modes3.queries.connectedTo pattern, | ||
59 | * to be used in conjunction with {@link Matcher}. | ||
60 | * | ||
61 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
62 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
63 | * usable to represent a match of the pattern in the result of a query, | ||
64 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
65 | * | ||
66 | * @see Matcher | ||
67 | * | ||
68 | */ | ||
69 | public static abstract class Match extends BasePatternMatch { | ||
70 | private Segment fS1; | ||
71 | |||
72 | private Segment fS2; | ||
73 | |||
74 | private static List<String> parameterNames = makeImmutableList("S1", "S2"); | ||
75 | |||
76 | private Match(final Segment pS1, final Segment pS2) { | ||
77 | this.fS1 = pS1; | ||
78 | this.fS2 = pS2; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "S1": return this.fS1; | ||
85 | case "S2": return this.fS2; | ||
86 | default: return null; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | @Override | ||
91 | public Object get(final int index) { | ||
92 | switch(index) { | ||
93 | case 0: return this.fS1; | ||
94 | case 1: return this.fS2; | ||
95 | default: return null; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | public Segment getS1() { | ||
100 | return this.fS1; | ||
101 | } | ||
102 | |||
103 | public Segment getS2() { | ||
104 | return this.fS2; | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public boolean set(final String parameterName, final Object newValue) { | ||
109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
110 | if ("S1".equals(parameterName) ) { | ||
111 | this.fS1 = (Segment) newValue; | ||
112 | return true; | ||
113 | } | ||
114 | if ("S2".equals(parameterName) ) { | ||
115 | this.fS2 = (Segment) newValue; | ||
116 | return true; | ||
117 | } | ||
118 | return false; | ||
119 | } | ||
120 | |||
121 | public void setS1(final Segment pS1) { | ||
122 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
123 | this.fS1 = pS1; | ||
124 | } | ||
125 | |||
126 | public void setS2(final Segment pS2) { | ||
127 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
128 | this.fS2 = pS2; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public String patternName() { | ||
133 | return "modes3.queries.connectedTo"; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public List<String> parameterNames() { | ||
138 | return ConnectedTo.Match.parameterNames; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public Object[] toArray() { | ||
143 | return new Object[]{fS1, fS2}; | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public ConnectedTo.Match toImmutable() { | ||
148 | return isMutable() ? newMatch(fS1, fS2) : this; | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public String prettyPrint() { | ||
153 | StringBuilder result = new StringBuilder(); | ||
154 | result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); | ||
155 | result.append("\"S2\"=" + prettyPrintValue(fS2)); | ||
156 | return result.toString(); | ||
157 | } | ||
158 | |||
159 | @Override | ||
160 | public int hashCode() { | ||
161 | return Objects.hash(fS1, fS2); | ||
162 | } | ||
163 | |||
164 | @Override | ||
165 | public boolean equals(final Object obj) { | ||
166 | if (this == obj) | ||
167 | return true; | ||
168 | if (obj == null) { | ||
169 | return false; | ||
170 | } | ||
171 | if ((obj instanceof ConnectedTo.Match)) { | ||
172 | ConnectedTo.Match other = (ConnectedTo.Match) obj; | ||
173 | return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); | ||
174 | } else { | ||
175 | // this should be infrequent | ||
176 | if (!(obj instanceof IPatternMatch)) { | ||
177 | return false; | ||
178 | } | ||
179 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
180 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | @Override | ||
185 | public ConnectedTo specification() { | ||
186 | return ConnectedTo.instance(); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * Returns an empty, mutable match. | ||
191 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
192 | * | ||
193 | * @return the empty match. | ||
194 | * | ||
195 | */ | ||
196 | public static ConnectedTo.Match newEmptyMatch() { | ||
197 | return new Mutable(null, null); | ||
198 | } | ||
199 | |||
200 | /** | ||
201 | * Returns a mutable (partial) match. | ||
202 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
203 | * | ||
204 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
205 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
206 | * @return the new, mutable (partial) match object. | ||
207 | * | ||
208 | */ | ||
209 | public static ConnectedTo.Match newMutableMatch(final Segment pS1, final Segment pS2) { | ||
210 | return new Mutable(pS1, pS2); | ||
211 | } | ||
212 | |||
213 | /** | ||
214 | * Returns a new (partial) match. | ||
215 | * This can be used e.g. to call the matcher with a partial match. | ||
216 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
217 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
218 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
219 | * @return the (partial) match object. | ||
220 | * | ||
221 | */ | ||
222 | public static ConnectedTo.Match newMatch(final Segment pS1, final Segment pS2) { | ||
223 | return new Immutable(pS1, pS2); | ||
224 | } | ||
225 | |||
226 | private static final class Mutable extends ConnectedTo.Match { | ||
227 | Mutable(final Segment pS1, final Segment pS2) { | ||
228 | super(pS1, pS2); | ||
229 | } | ||
230 | |||
231 | @Override | ||
232 | public boolean isMutable() { | ||
233 | return true; | ||
234 | } | ||
235 | } | ||
236 | |||
237 | private static final class Immutable extends ConnectedTo.Match { | ||
238 | Immutable(final Segment pS1, final Segment pS2) { | ||
239 | super(pS1, pS2); | ||
240 | } | ||
241 | |||
242 | @Override | ||
243 | public boolean isMutable() { | ||
244 | return false; | ||
245 | } | ||
246 | } | ||
247 | } | ||
248 | |||
249 | /** | ||
250 | * Generated pattern matcher API of the modes3.queries.connectedTo pattern, | ||
251 | * providing pattern-specific query methods. | ||
252 | * | ||
253 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
254 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
255 | * | ||
256 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
257 | * | ||
258 | * <p>Original source: | ||
259 | * <code><pre> | ||
260 | * pattern connectedTo(S1 : Segment, S2 : Segment) { | ||
261 | * Segment.connectedTo(S1, S2); | ||
262 | * } | ||
263 | * </pre></code> | ||
264 | * | ||
265 | * @see Match | ||
266 | * @see ConnectedTo | ||
267 | * | ||
268 | */ | ||
269 | public static class Matcher extends BaseMatcher<ConnectedTo.Match> { | ||
270 | /** | ||
271 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
272 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
273 | * | ||
274 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
275 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
276 | * | ||
277 | */ | ||
278 | public static ConnectedTo.Matcher on(final ViatraQueryEngine engine) { | ||
279 | // check if matcher already exists | ||
280 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
281 | if (matcher == null) { | ||
282 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
283 | } | ||
284 | return matcher; | ||
285 | } | ||
286 | |||
287 | /** | ||
288 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
289 | * @return an initialized matcher | ||
290 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
291 | * | ||
292 | */ | ||
293 | public static ConnectedTo.Matcher create() { | ||
294 | return new Matcher(); | ||
295 | } | ||
296 | |||
297 | private static final int POSITION_S1 = 0; | ||
298 | |||
299 | private static final int POSITION_S2 = 1; | ||
300 | |||
301 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ConnectedTo.Matcher.class); | ||
302 | |||
303 | /** | ||
304 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
305 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
306 | * | ||
307 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
308 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
309 | * | ||
310 | */ | ||
311 | private Matcher() { | ||
312 | super(querySpecification()); | ||
313 | } | ||
314 | |||
315 | /** | ||
316 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
317 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
318 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
319 | * @return matches represented as a Match object. | ||
320 | * | ||
321 | */ | ||
322 | public Collection<ConnectedTo.Match> getAllMatches(final Segment pS1, final Segment pS2) { | ||
323 | return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
328 | * </p> | ||
329 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
330 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
331 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
332 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
333 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
334 | * @return a stream of matches represented as a Match object. | ||
335 | * | ||
336 | */ | ||
337 | public Stream<ConnectedTo.Match> streamAllMatches(final Segment pS1, final Segment pS2) { | ||
338 | return rawStreamAllMatches(new Object[]{pS1, pS2}); | ||
339 | } | ||
340 | |||
341 | /** | ||
342 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
343 | * Neither determinism nor randomness of selection is guaranteed. | ||
344 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
345 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
346 | * @return a match represented as a Match object, or null if no match is found. | ||
347 | * | ||
348 | */ | ||
349 | public Optional<ConnectedTo.Match> getOneArbitraryMatch(final Segment pS1, final Segment pS2) { | ||
350 | return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
355 | * under any possible substitution of the unspecified parameters (if any). | ||
356 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
357 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
358 | * @return true if the input is a valid (partial) match of the pattern. | ||
359 | * | ||
360 | */ | ||
361 | public boolean hasMatch(final Segment pS1, final Segment pS2) { | ||
362 | return rawHasMatch(new Object[]{pS1, pS2}); | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
367 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
368 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
369 | * @return the number of pattern matches found. | ||
370 | * | ||
371 | */ | ||
372 | public int countMatches(final Segment pS1, final Segment pS2) { | ||
373 | return rawCountMatches(new Object[]{pS1, pS2}); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
378 | * Neither determinism nor randomness of selection is guaranteed. | ||
379 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
380 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
381 | * @param processor the action that will process the selected match. | ||
382 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
383 | * | ||
384 | */ | ||
385 | public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer<? super ConnectedTo.Match> processor) { | ||
386 | return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); | ||
387 | } | ||
388 | |||
389 | /** | ||
390 | * Returns a new (partial) match. | ||
391 | * This can be used e.g. to call the matcher with a partial match. | ||
392 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
393 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
394 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
395 | * @return the (partial) match object. | ||
396 | * | ||
397 | */ | ||
398 | public ConnectedTo.Match newMatch(final Segment pS1, final Segment pS2) { | ||
399 | return ConnectedTo.Match.newMatch(pS1, pS2); | ||
400 | } | ||
401 | |||
402 | /** | ||
403 | * Retrieve the set of values that occur in matches for S1. | ||
404 | * @return the Set of all values or empty set if there are no matches | ||
405 | * | ||
406 | */ | ||
407 | protected Stream<Segment> rawStreamAllValuesOfS1(final Object[] parameters) { | ||
408 | return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); | ||
409 | } | ||
410 | |||
411 | /** | ||
412 | * Retrieve the set of values that occur in matches for S1. | ||
413 | * @return the Set of all values or empty set if there are no matches | ||
414 | * | ||
415 | */ | ||
416 | public Set<Segment> getAllValuesOfS1() { | ||
417 | return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); | ||
418 | } | ||
419 | |||
420 | /** | ||
421 | * Retrieve the set of values that occur in matches for S1. | ||
422 | * @return the Set of all values or empty set if there are no matches | ||
423 | * | ||
424 | */ | ||
425 | public Stream<Segment> streamAllValuesOfS1() { | ||
426 | return rawStreamAllValuesOfS1(emptyArray()); | ||
427 | } | ||
428 | |||
429 | /** | ||
430 | * Retrieve the set of values that occur in matches for S1. | ||
431 | * </p> | ||
432 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
433 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
434 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
435 | * | ||
436 | * @return the Stream of all values or empty set if there are no matches | ||
437 | * | ||
438 | */ | ||
439 | public Stream<Segment> streamAllValuesOfS1(final ConnectedTo.Match partialMatch) { | ||
440 | return rawStreamAllValuesOfS1(partialMatch.toArray()); | ||
441 | } | ||
442 | |||
443 | /** | ||
444 | * Retrieve the set of values that occur in matches for S1. | ||
445 | * </p> | ||
446 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
447 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
448 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
449 | * | ||
450 | * @return the Stream of all values or empty set if there are no matches | ||
451 | * | ||
452 | */ | ||
453 | public Stream<Segment> streamAllValuesOfS1(final Segment pS2) { | ||
454 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}); | ||
455 | } | ||
456 | |||
457 | /** | ||
458 | * Retrieve the set of values that occur in matches for S1. | ||
459 | * @return the Set of all values or empty set if there are no matches | ||
460 | * | ||
461 | */ | ||
462 | public Set<Segment> getAllValuesOfS1(final ConnectedTo.Match partialMatch) { | ||
463 | return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); | ||
464 | } | ||
465 | |||
466 | /** | ||
467 | * Retrieve the set of values that occur in matches for S1. | ||
468 | * @return the Set of all values or empty set if there are no matches | ||
469 | * | ||
470 | */ | ||
471 | public Set<Segment> getAllValuesOfS1(final Segment pS2) { | ||
472 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); | ||
473 | } | ||
474 | |||
475 | /** | ||
476 | * Retrieve the set of values that occur in matches for S2. | ||
477 | * @return the Set of all values or empty set if there are no matches | ||
478 | * | ||
479 | */ | ||
480 | protected Stream<Segment> rawStreamAllValuesOfS2(final Object[] parameters) { | ||
481 | return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); | ||
482 | } | ||
483 | |||
484 | /** | ||
485 | * Retrieve the set of values that occur in matches for S2. | ||
486 | * @return the Set of all values or empty set if there are no matches | ||
487 | * | ||
488 | */ | ||
489 | public Set<Segment> getAllValuesOfS2() { | ||
490 | return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); | ||
491 | } | ||
492 | |||
493 | /** | ||
494 | * Retrieve the set of values that occur in matches for S2. | ||
495 | * @return the Set of all values or empty set if there are no matches | ||
496 | * | ||
497 | */ | ||
498 | public Stream<Segment> streamAllValuesOfS2() { | ||
499 | return rawStreamAllValuesOfS2(emptyArray()); | ||
500 | } | ||
501 | |||
502 | /** | ||
503 | * Retrieve the set of values that occur in matches for S2. | ||
504 | * </p> | ||
505 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
506 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
507 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
508 | * | ||
509 | * @return the Stream of all values or empty set if there are no matches | ||
510 | * | ||
511 | */ | ||
512 | public Stream<Segment> streamAllValuesOfS2(final ConnectedTo.Match partialMatch) { | ||
513 | return rawStreamAllValuesOfS2(partialMatch.toArray()); | ||
514 | } | ||
515 | |||
516 | /** | ||
517 | * Retrieve the set of values that occur in matches for S2. | ||
518 | * </p> | ||
519 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
520 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
521 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
522 | * | ||
523 | * @return the Stream of all values or empty set if there are no matches | ||
524 | * | ||
525 | */ | ||
526 | public Stream<Segment> streamAllValuesOfS2(final Segment pS1) { | ||
527 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}); | ||
528 | } | ||
529 | |||
530 | /** | ||
531 | * Retrieve the set of values that occur in matches for S2. | ||
532 | * @return the Set of all values or empty set if there are no matches | ||
533 | * | ||
534 | */ | ||
535 | public Set<Segment> getAllValuesOfS2(final ConnectedTo.Match partialMatch) { | ||
536 | return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); | ||
537 | } | ||
538 | |||
539 | /** | ||
540 | * Retrieve the set of values that occur in matches for S2. | ||
541 | * @return the Set of all values or empty set if there are no matches | ||
542 | * | ||
543 | */ | ||
544 | public Set<Segment> getAllValuesOfS2(final Segment pS1) { | ||
545 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); | ||
546 | } | ||
547 | |||
548 | @Override | ||
549 | protected ConnectedTo.Match tupleToMatch(final Tuple t) { | ||
550 | try { | ||
551 | return ConnectedTo.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); | ||
552 | } catch(ClassCastException e) { | ||
553 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
554 | return null; | ||
555 | } | ||
556 | } | ||
557 | |||
558 | @Override | ||
559 | protected ConnectedTo.Match arrayToMatch(final Object[] match) { | ||
560 | try { | ||
561 | return ConnectedTo.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
562 | } catch(ClassCastException e) { | ||
563 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
564 | return null; | ||
565 | } | ||
566 | } | ||
567 | |||
568 | @Override | ||
569 | protected ConnectedTo.Match arrayToMatchMutable(final Object[] match) { | ||
570 | try { | ||
571 | return ConnectedTo.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
572 | } catch(ClassCastException e) { | ||
573 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
574 | return null; | ||
575 | } | ||
576 | } | ||
577 | |||
578 | /** | ||
579 | * @return the singleton instance of the query specification of this pattern | ||
580 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
581 | * | ||
582 | */ | ||
583 | public static IQuerySpecification<ConnectedTo.Matcher> querySpecification() { | ||
584 | return ConnectedTo.instance(); | ||
585 | } | ||
586 | } | ||
587 | |||
588 | private ConnectedTo() { | ||
589 | super(GeneratedPQuery.INSTANCE); | ||
590 | } | ||
591 | |||
592 | /** | ||
593 | * @return the singleton instance of the query specification | ||
594 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
595 | * | ||
596 | */ | ||
597 | public static ConnectedTo instance() { | ||
598 | try{ | ||
599 | return LazyHolder.INSTANCE; | ||
600 | } catch (ExceptionInInitializerError err) { | ||
601 | throw processInitializerError(err); | ||
602 | } | ||
603 | } | ||
604 | |||
605 | @Override | ||
606 | protected ConnectedTo.Matcher instantiate(final ViatraQueryEngine engine) { | ||
607 | return ConnectedTo.Matcher.on(engine); | ||
608 | } | ||
609 | |||
610 | @Override | ||
611 | public ConnectedTo.Matcher instantiate() { | ||
612 | return ConnectedTo.Matcher.create(); | ||
613 | } | ||
614 | |||
615 | @Override | ||
616 | public ConnectedTo.Match newEmptyMatch() { | ||
617 | return ConnectedTo.Match.newEmptyMatch(); | ||
618 | } | ||
619 | |||
620 | @Override | ||
621 | public ConnectedTo.Match newMatch(final Object... parameters) { | ||
622 | return ConnectedTo.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); | ||
623 | } | ||
624 | |||
625 | /** | ||
626 | * Inner class allowing the singleton instance of {@link ConnectedTo} to be created | ||
627 | * <b>not</b> at the class load time of the outer class, | ||
628 | * but rather at the first call to {@link ConnectedTo#instance()}. | ||
629 | * | ||
630 | * <p> This workaround is required e.g. to support recursion. | ||
631 | * | ||
632 | */ | ||
633 | private static class LazyHolder { | ||
634 | private static final ConnectedTo INSTANCE = new ConnectedTo(); | ||
635 | |||
636 | /** | ||
637 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
638 | * This initialization order is required to support indirect recursion. | ||
639 | * | ||
640 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
641 | * | ||
642 | */ | ||
643 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
644 | |||
645 | public static Object ensureInitialized() { | ||
646 | INSTANCE.ensureInitializedInternal(); | ||
647 | return null; | ||
648 | } | ||
649 | } | ||
650 | |||
651 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
652 | private static final ConnectedTo.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
653 | |||
654 | private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
655 | |||
656 | private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
657 | |||
658 | private final List<PParameter> parameters = Arrays.asList(parameter_S1, parameter_S2); | ||
659 | |||
660 | private GeneratedPQuery() { | ||
661 | super(PVisibility.PUBLIC); | ||
662 | } | ||
663 | |||
664 | @Override | ||
665 | public String getFullyQualifiedName() { | ||
666 | return "modes3.queries.connectedTo"; | ||
667 | } | ||
668 | |||
669 | @Override | ||
670 | public List<String> getParameterNames() { | ||
671 | return Arrays.asList("S1","S2"); | ||
672 | } | ||
673 | |||
674 | @Override | ||
675 | public List<PParameter> getParameters() { | ||
676 | return parameters; | ||
677 | } | ||
678 | |||
679 | @Override | ||
680 | public Set<PBody> doGetContainedBodies() { | ||
681 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
682 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
683 | { | ||
684 | PBody body = new PBody(this); | ||
685 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
686 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
687 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
688 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
689 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
690 | new ExportedParameter(body, var_S1, parameter_S1), | ||
691 | new ExportedParameter(body, var_S2, parameter_S2) | ||
692 | )); | ||
693 | // Segment.connectedTo(S1, S2) | ||
694 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
695 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
696 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
697 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
698 | new Equality(body, var__virtual_0_, var_S2); | ||
699 | bodies.add(body); | ||
700 | } | ||
701 | return bodies; | ||
702 | } | ||
703 | } | ||
704 | } | ||
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 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.queries.ConnectedTo; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
43 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
44 | |||
45 | /** | ||
46 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
47 | * | ||
48 | * <p>Original source: | ||
49 | * <code><pre> | ||
50 | * {@literal @}Constraint(message = "connectedToNotSymmetric", severity = "error", key = { S1, S2 }) | ||
51 | * pattern connectedToNotSymmetric(S1 : Segment, S2 : Segment) { | ||
52 | * Segment.connectedTo(S1, S2); | ||
53 | * neg find connectedTo(S2, S1); | ||
54 | * } | ||
55 | * </pre></code> | ||
56 | * | ||
57 | * @see Matcher | ||
58 | * @see Match | ||
59 | * | ||
60 | */ | ||
61 | @SuppressWarnings("all") | ||
62 | public final class ConnectedToNotSymmetric extends BaseGeneratedEMFQuerySpecification<ConnectedToNotSymmetric.Matcher> { | ||
63 | /** | ||
64 | * Pattern-specific match representation of the modes3.queries.connectedToNotSymmetric pattern, | ||
65 | * to be used in conjunction with {@link Matcher}. | ||
66 | * | ||
67 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
68 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
69 | * usable to represent a match of the pattern in the result of a query, | ||
70 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
71 | * | ||
72 | * @see Matcher | ||
73 | * | ||
74 | */ | ||
75 | public static abstract class Match extends BasePatternMatch { | ||
76 | private Segment fS1; | ||
77 | |||
78 | private Segment fS2; | ||
79 | |||
80 | private static List<String> parameterNames = makeImmutableList("S1", "S2"); | ||
81 | |||
82 | private Match(final Segment pS1, final Segment pS2) { | ||
83 | this.fS1 = pS1; | ||
84 | this.fS2 = pS2; | ||
85 | } | ||
86 | |||
87 | @Override | ||
88 | public Object get(final String parameterName) { | ||
89 | switch(parameterName) { | ||
90 | case "S1": return this.fS1; | ||
91 | case "S2": return this.fS2; | ||
92 | default: return null; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | @Override | ||
97 | public Object get(final int index) { | ||
98 | switch(index) { | ||
99 | case 0: return this.fS1; | ||
100 | case 1: return this.fS2; | ||
101 | default: return null; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | public Segment getS1() { | ||
106 | return this.fS1; | ||
107 | } | ||
108 | |||
109 | public Segment getS2() { | ||
110 | return this.fS2; | ||
111 | } | ||
112 | |||
113 | @Override | ||
114 | public boolean set(final String parameterName, final Object newValue) { | ||
115 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
116 | if ("S1".equals(parameterName) ) { | ||
117 | this.fS1 = (Segment) newValue; | ||
118 | return true; | ||
119 | } | ||
120 | if ("S2".equals(parameterName) ) { | ||
121 | this.fS2 = (Segment) newValue; | ||
122 | return true; | ||
123 | } | ||
124 | return false; | ||
125 | } | ||
126 | |||
127 | public void setS1(final Segment pS1) { | ||
128 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
129 | this.fS1 = pS1; | ||
130 | } | ||
131 | |||
132 | public void setS2(final Segment pS2) { | ||
133 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
134 | this.fS2 = pS2; | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public String patternName() { | ||
139 | return "modes3.queries.connectedToNotSymmetric"; | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public List<String> parameterNames() { | ||
144 | return ConnectedToNotSymmetric.Match.parameterNames; | ||
145 | } | ||
146 | |||
147 | @Override | ||
148 | public Object[] toArray() { | ||
149 | return new Object[]{fS1, fS2}; | ||
150 | } | ||
151 | |||
152 | @Override | ||
153 | public ConnectedToNotSymmetric.Match toImmutable() { | ||
154 | return isMutable() ? newMatch(fS1, fS2) : this; | ||
155 | } | ||
156 | |||
157 | @Override | ||
158 | public String prettyPrint() { | ||
159 | StringBuilder result = new StringBuilder(); | ||
160 | result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); | ||
161 | result.append("\"S2\"=" + prettyPrintValue(fS2)); | ||
162 | return result.toString(); | ||
163 | } | ||
164 | |||
165 | @Override | ||
166 | public int hashCode() { | ||
167 | return Objects.hash(fS1, fS2); | ||
168 | } | ||
169 | |||
170 | @Override | ||
171 | public boolean equals(final Object obj) { | ||
172 | if (this == obj) | ||
173 | return true; | ||
174 | if (obj == null) { | ||
175 | return false; | ||
176 | } | ||
177 | if ((obj instanceof ConnectedToNotSymmetric.Match)) { | ||
178 | ConnectedToNotSymmetric.Match other = (ConnectedToNotSymmetric.Match) obj; | ||
179 | return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); | ||
180 | } else { | ||
181 | // this should be infrequent | ||
182 | if (!(obj instanceof IPatternMatch)) { | ||
183 | return false; | ||
184 | } | ||
185 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
186 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
187 | } | ||
188 | } | ||
189 | |||
190 | @Override | ||
191 | public ConnectedToNotSymmetric specification() { | ||
192 | return ConnectedToNotSymmetric.instance(); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * Returns an empty, mutable match. | ||
197 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
198 | * | ||
199 | * @return the empty match. | ||
200 | * | ||
201 | */ | ||
202 | public static ConnectedToNotSymmetric.Match newEmptyMatch() { | ||
203 | return new Mutable(null, null); | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * Returns a mutable (partial) match. | ||
208 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
209 | * | ||
210 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
211 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
212 | * @return the new, mutable (partial) match object. | ||
213 | * | ||
214 | */ | ||
215 | public static ConnectedToNotSymmetric.Match newMutableMatch(final Segment pS1, final Segment pS2) { | ||
216 | return new Mutable(pS1, pS2); | ||
217 | } | ||
218 | |||
219 | /** | ||
220 | * Returns a new (partial) match. | ||
221 | * This can be used e.g. to call the matcher with a partial match. | ||
222 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
223 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
224 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
225 | * @return the (partial) match object. | ||
226 | * | ||
227 | */ | ||
228 | public static ConnectedToNotSymmetric.Match newMatch(final Segment pS1, final Segment pS2) { | ||
229 | return new Immutable(pS1, pS2); | ||
230 | } | ||
231 | |||
232 | private static final class Mutable extends ConnectedToNotSymmetric.Match { | ||
233 | Mutable(final Segment pS1, final Segment pS2) { | ||
234 | super(pS1, pS2); | ||
235 | } | ||
236 | |||
237 | @Override | ||
238 | public boolean isMutable() { | ||
239 | return true; | ||
240 | } | ||
241 | } | ||
242 | |||
243 | private static final class Immutable extends ConnectedToNotSymmetric.Match { | ||
244 | Immutable(final Segment pS1, final Segment pS2) { | ||
245 | super(pS1, pS2); | ||
246 | } | ||
247 | |||
248 | @Override | ||
249 | public boolean isMutable() { | ||
250 | return false; | ||
251 | } | ||
252 | } | ||
253 | } | ||
254 | |||
255 | /** | ||
256 | * Generated pattern matcher API of the modes3.queries.connectedToNotSymmetric pattern, | ||
257 | * providing pattern-specific query methods. | ||
258 | * | ||
259 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
260 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
261 | * | ||
262 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
263 | * | ||
264 | * <p>Original source: | ||
265 | * <code><pre> | ||
266 | * {@literal @}Constraint(message = "connectedToNotSymmetric", severity = "error", key = { S1, S2 }) | ||
267 | * pattern connectedToNotSymmetric(S1 : Segment, S2 : Segment) { | ||
268 | * Segment.connectedTo(S1, S2); | ||
269 | * neg find connectedTo(S2, S1); | ||
270 | * } | ||
271 | * </pre></code> | ||
272 | * | ||
273 | * @see Match | ||
274 | * @see ConnectedToNotSymmetric | ||
275 | * | ||
276 | */ | ||
277 | public static class Matcher extends BaseMatcher<ConnectedToNotSymmetric.Match> { | ||
278 | /** | ||
279 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
280 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
281 | * | ||
282 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
283 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
284 | * | ||
285 | */ | ||
286 | public static ConnectedToNotSymmetric.Matcher on(final ViatraQueryEngine engine) { | ||
287 | // check if matcher already exists | ||
288 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
289 | if (matcher == null) { | ||
290 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
291 | } | ||
292 | return matcher; | ||
293 | } | ||
294 | |||
295 | /** | ||
296 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
297 | * @return an initialized matcher | ||
298 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
299 | * | ||
300 | */ | ||
301 | public static ConnectedToNotSymmetric.Matcher create() { | ||
302 | return new Matcher(); | ||
303 | } | ||
304 | |||
305 | private static final int POSITION_S1 = 0; | ||
306 | |||
307 | private static final int POSITION_S2 = 1; | ||
308 | |||
309 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ConnectedToNotSymmetric.Matcher.class); | ||
310 | |||
311 | /** | ||
312 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
313 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
314 | * | ||
315 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
316 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
317 | * | ||
318 | */ | ||
319 | private Matcher() { | ||
320 | super(querySpecification()); | ||
321 | } | ||
322 | |||
323 | /** | ||
324 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
325 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
326 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
327 | * @return matches represented as a Match object. | ||
328 | * | ||
329 | */ | ||
330 | public Collection<ConnectedToNotSymmetric.Match> getAllMatches(final Segment pS1, final Segment pS2) { | ||
331 | return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); | ||
332 | } | ||
333 | |||
334 | /** | ||
335 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
336 | * </p> | ||
337 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
338 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
339 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
340 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
341 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
342 | * @return a stream of matches represented as a Match object. | ||
343 | * | ||
344 | */ | ||
345 | public Stream<ConnectedToNotSymmetric.Match> streamAllMatches(final Segment pS1, final Segment pS2) { | ||
346 | return rawStreamAllMatches(new Object[]{pS1, pS2}); | ||
347 | } | ||
348 | |||
349 | /** | ||
350 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
351 | * Neither determinism nor randomness of selection is guaranteed. | ||
352 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
353 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
354 | * @return a match represented as a Match object, or null if no match is found. | ||
355 | * | ||
356 | */ | ||
357 | public Optional<ConnectedToNotSymmetric.Match> getOneArbitraryMatch(final Segment pS1, final Segment pS2) { | ||
358 | return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); | ||
359 | } | ||
360 | |||
361 | /** | ||
362 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
363 | * under any possible substitution of the unspecified parameters (if any). | ||
364 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
365 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
366 | * @return true if the input is a valid (partial) match of the pattern. | ||
367 | * | ||
368 | */ | ||
369 | public boolean hasMatch(final Segment pS1, final Segment pS2) { | ||
370 | return rawHasMatch(new Object[]{pS1, pS2}); | ||
371 | } | ||
372 | |||
373 | /** | ||
374 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
375 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
376 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
377 | * @return the number of pattern matches found. | ||
378 | * | ||
379 | */ | ||
380 | public int countMatches(final Segment pS1, final Segment pS2) { | ||
381 | return rawCountMatches(new Object[]{pS1, pS2}); | ||
382 | } | ||
383 | |||
384 | /** | ||
385 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
386 | * Neither determinism nor randomness of selection is guaranteed. | ||
387 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
388 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
389 | * @param processor the action that will process the selected match. | ||
390 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
391 | * | ||
392 | */ | ||
393 | public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer<? super ConnectedToNotSymmetric.Match> processor) { | ||
394 | return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); | ||
395 | } | ||
396 | |||
397 | /** | ||
398 | * Returns a new (partial) match. | ||
399 | * This can be used e.g. to call the matcher with a partial match. | ||
400 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
401 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
402 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
403 | * @return the (partial) match object. | ||
404 | * | ||
405 | */ | ||
406 | public ConnectedToNotSymmetric.Match newMatch(final Segment pS1, final Segment pS2) { | ||
407 | return ConnectedToNotSymmetric.Match.newMatch(pS1, pS2); | ||
408 | } | ||
409 | |||
410 | /** | ||
411 | * Retrieve the set of values that occur in matches for S1. | ||
412 | * @return the Set of all values or empty set if there are no matches | ||
413 | * | ||
414 | */ | ||
415 | protected Stream<Segment> rawStreamAllValuesOfS1(final Object[] parameters) { | ||
416 | return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); | ||
417 | } | ||
418 | |||
419 | /** | ||
420 | * Retrieve the set of values that occur in matches for S1. | ||
421 | * @return the Set of all values or empty set if there are no matches | ||
422 | * | ||
423 | */ | ||
424 | public Set<Segment> getAllValuesOfS1() { | ||
425 | return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); | ||
426 | } | ||
427 | |||
428 | /** | ||
429 | * Retrieve the set of values that occur in matches for S1. | ||
430 | * @return the Set of all values or empty set if there are no matches | ||
431 | * | ||
432 | */ | ||
433 | public Stream<Segment> streamAllValuesOfS1() { | ||
434 | return rawStreamAllValuesOfS1(emptyArray()); | ||
435 | } | ||
436 | |||
437 | /** | ||
438 | * Retrieve the set of values that occur in matches for S1. | ||
439 | * </p> | ||
440 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
441 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
442 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
443 | * | ||
444 | * @return the Stream of all values or empty set if there are no matches | ||
445 | * | ||
446 | */ | ||
447 | public Stream<Segment> streamAllValuesOfS1(final ConnectedToNotSymmetric.Match partialMatch) { | ||
448 | return rawStreamAllValuesOfS1(partialMatch.toArray()); | ||
449 | } | ||
450 | |||
451 | /** | ||
452 | * Retrieve the set of values that occur in matches for S1. | ||
453 | * </p> | ||
454 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
455 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
456 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
457 | * | ||
458 | * @return the Stream of all values or empty set if there are no matches | ||
459 | * | ||
460 | */ | ||
461 | public Stream<Segment> streamAllValuesOfS1(final Segment pS2) { | ||
462 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}); | ||
463 | } | ||
464 | |||
465 | /** | ||
466 | * Retrieve the set of values that occur in matches for S1. | ||
467 | * @return the Set of all values or empty set if there are no matches | ||
468 | * | ||
469 | */ | ||
470 | public Set<Segment> getAllValuesOfS1(final ConnectedToNotSymmetric.Match partialMatch) { | ||
471 | return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); | ||
472 | } | ||
473 | |||
474 | /** | ||
475 | * Retrieve the set of values that occur in matches for S1. | ||
476 | * @return the Set of all values or empty set if there are no matches | ||
477 | * | ||
478 | */ | ||
479 | public Set<Segment> getAllValuesOfS1(final Segment pS2) { | ||
480 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); | ||
481 | } | ||
482 | |||
483 | /** | ||
484 | * Retrieve the set of values that occur in matches for S2. | ||
485 | * @return the Set of all values or empty set if there are no matches | ||
486 | * | ||
487 | */ | ||
488 | protected Stream<Segment> rawStreamAllValuesOfS2(final Object[] parameters) { | ||
489 | return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); | ||
490 | } | ||
491 | |||
492 | /** | ||
493 | * Retrieve the set of values that occur in matches for S2. | ||
494 | * @return the Set of all values or empty set if there are no matches | ||
495 | * | ||
496 | */ | ||
497 | public Set<Segment> getAllValuesOfS2() { | ||
498 | return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); | ||
499 | } | ||
500 | |||
501 | /** | ||
502 | * Retrieve the set of values that occur in matches for S2. | ||
503 | * @return the Set of all values or empty set if there are no matches | ||
504 | * | ||
505 | */ | ||
506 | public Stream<Segment> streamAllValuesOfS2() { | ||
507 | return rawStreamAllValuesOfS2(emptyArray()); | ||
508 | } | ||
509 | |||
510 | /** | ||
511 | * Retrieve the set of values that occur in matches for S2. | ||
512 | * </p> | ||
513 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
514 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
515 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
516 | * | ||
517 | * @return the Stream of all values or empty set if there are no matches | ||
518 | * | ||
519 | */ | ||
520 | public Stream<Segment> streamAllValuesOfS2(final ConnectedToNotSymmetric.Match partialMatch) { | ||
521 | return rawStreamAllValuesOfS2(partialMatch.toArray()); | ||
522 | } | ||
523 | |||
524 | /** | ||
525 | * Retrieve the set of values that occur in matches for S2. | ||
526 | * </p> | ||
527 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
528 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
529 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
530 | * | ||
531 | * @return the Stream of all values or empty set if there are no matches | ||
532 | * | ||
533 | */ | ||
534 | public Stream<Segment> streamAllValuesOfS2(final Segment pS1) { | ||
535 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}); | ||
536 | } | ||
537 | |||
538 | /** | ||
539 | * Retrieve the set of values that occur in matches for S2. | ||
540 | * @return the Set of all values or empty set if there are no matches | ||
541 | * | ||
542 | */ | ||
543 | public Set<Segment> getAllValuesOfS2(final ConnectedToNotSymmetric.Match partialMatch) { | ||
544 | return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); | ||
545 | } | ||
546 | |||
547 | /** | ||
548 | * Retrieve the set of values that occur in matches for S2. | ||
549 | * @return the Set of all values or empty set if there are no matches | ||
550 | * | ||
551 | */ | ||
552 | public Set<Segment> getAllValuesOfS2(final Segment pS1) { | ||
553 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); | ||
554 | } | ||
555 | |||
556 | @Override | ||
557 | protected ConnectedToNotSymmetric.Match tupleToMatch(final Tuple t) { | ||
558 | try { | ||
559 | return ConnectedToNotSymmetric.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); | ||
560 | } catch(ClassCastException e) { | ||
561 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
562 | return null; | ||
563 | } | ||
564 | } | ||
565 | |||
566 | @Override | ||
567 | protected ConnectedToNotSymmetric.Match arrayToMatch(final Object[] match) { | ||
568 | try { | ||
569 | return ConnectedToNotSymmetric.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
570 | } catch(ClassCastException e) { | ||
571 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
572 | return null; | ||
573 | } | ||
574 | } | ||
575 | |||
576 | @Override | ||
577 | protected ConnectedToNotSymmetric.Match arrayToMatchMutable(final Object[] match) { | ||
578 | try { | ||
579 | return ConnectedToNotSymmetric.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
580 | } catch(ClassCastException e) { | ||
581 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
582 | return null; | ||
583 | } | ||
584 | } | ||
585 | |||
586 | /** | ||
587 | * @return the singleton instance of the query specification of this pattern | ||
588 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
589 | * | ||
590 | */ | ||
591 | public static IQuerySpecification<ConnectedToNotSymmetric.Matcher> querySpecification() { | ||
592 | return ConnectedToNotSymmetric.instance(); | ||
593 | } | ||
594 | } | ||
595 | |||
596 | private ConnectedToNotSymmetric() { | ||
597 | super(GeneratedPQuery.INSTANCE); | ||
598 | } | ||
599 | |||
600 | /** | ||
601 | * @return the singleton instance of the query specification | ||
602 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
603 | * | ||
604 | */ | ||
605 | public static ConnectedToNotSymmetric instance() { | ||
606 | try{ | ||
607 | return LazyHolder.INSTANCE; | ||
608 | } catch (ExceptionInInitializerError err) { | ||
609 | throw processInitializerError(err); | ||
610 | } | ||
611 | } | ||
612 | |||
613 | @Override | ||
614 | protected ConnectedToNotSymmetric.Matcher instantiate(final ViatraQueryEngine engine) { | ||
615 | return ConnectedToNotSymmetric.Matcher.on(engine); | ||
616 | } | ||
617 | |||
618 | @Override | ||
619 | public ConnectedToNotSymmetric.Matcher instantiate() { | ||
620 | return ConnectedToNotSymmetric.Matcher.create(); | ||
621 | } | ||
622 | |||
623 | @Override | ||
624 | public ConnectedToNotSymmetric.Match newEmptyMatch() { | ||
625 | return ConnectedToNotSymmetric.Match.newEmptyMatch(); | ||
626 | } | ||
627 | |||
628 | @Override | ||
629 | public ConnectedToNotSymmetric.Match newMatch(final Object... parameters) { | ||
630 | return ConnectedToNotSymmetric.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); | ||
631 | } | ||
632 | |||
633 | /** | ||
634 | * Inner class allowing the singleton instance of {@link ConnectedToNotSymmetric} to be created | ||
635 | * <b>not</b> at the class load time of the outer class, | ||
636 | * but rather at the first call to {@link ConnectedToNotSymmetric#instance()}. | ||
637 | * | ||
638 | * <p> This workaround is required e.g. to support recursion. | ||
639 | * | ||
640 | */ | ||
641 | private static class LazyHolder { | ||
642 | private static final ConnectedToNotSymmetric INSTANCE = new ConnectedToNotSymmetric(); | ||
643 | |||
644 | /** | ||
645 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
646 | * This initialization order is required to support indirect recursion. | ||
647 | * | ||
648 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
649 | * | ||
650 | */ | ||
651 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
652 | |||
653 | public static Object ensureInitialized() { | ||
654 | INSTANCE.ensureInitializedInternal(); | ||
655 | return null; | ||
656 | } | ||
657 | } | ||
658 | |||
659 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
660 | private static final ConnectedToNotSymmetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
661 | |||
662 | private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
663 | |||
664 | private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
665 | |||
666 | private final List<PParameter> parameters = Arrays.asList(parameter_S1, parameter_S2); | ||
667 | |||
668 | private GeneratedPQuery() { | ||
669 | super(PVisibility.PUBLIC); | ||
670 | } | ||
671 | |||
672 | @Override | ||
673 | public String getFullyQualifiedName() { | ||
674 | return "modes3.queries.connectedToNotSymmetric"; | ||
675 | } | ||
676 | |||
677 | @Override | ||
678 | public List<String> getParameterNames() { | ||
679 | return Arrays.asList("S1","S2"); | ||
680 | } | ||
681 | |||
682 | @Override | ||
683 | public List<PParameter> getParameters() { | ||
684 | return parameters; | ||
685 | } | ||
686 | |||
687 | @Override | ||
688 | public Set<PBody> doGetContainedBodies() { | ||
689 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
690 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
691 | { | ||
692 | PBody body = new PBody(this); | ||
693 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
694 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
695 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
696 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
697 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
698 | new ExportedParameter(body, var_S1, parameter_S1), | ||
699 | new ExportedParameter(body, var_S2, parameter_S2) | ||
700 | )); | ||
701 | // Segment.connectedTo(S1, S2) | ||
702 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
703 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
704 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
705 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
706 | new Equality(body, var__virtual_0_, var_S2); | ||
707 | // neg find connectedTo(S2, S1) | ||
708 | new NegativePatternCall(body, Tuples.flatTupleOf(var_S2, var_S1), ConnectedTo.instance().getInternalQueryRepresentation()); | ||
709 | bodies.add(body); | ||
710 | } | ||
711 | { | ||
712 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
713 | annotation.addAttribute("message", "connectedToNotSymmetric"); | ||
714 | annotation.addAttribute("severity", "error"); | ||
715 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
716 | new ParameterReference("S1"), | ||
717 | new ParameterReference("S2") | ||
718 | })); | ||
719 | addAnnotation(annotation); | ||
720 | } | ||
721 | return bodies; | ||
722 | } | ||
723 | } | ||
724 | } | ||
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 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * {@literal @}Constraint(message = "connectedToReflexive", severity = "error", key = { S }) | ||
49 | * pattern connectedToReflexive(S : Segment) { | ||
50 | * Segment.connectedTo(S, S); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class ConnectedToReflexive extends BaseGeneratedEMFQuerySpecification<ConnectedToReflexive.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.connectedToReflexive pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Segment fS; | ||
74 | |||
75 | private static List<String> parameterNames = makeImmutableList("S"); | ||
76 | |||
77 | private Match(final Segment pS) { | ||
78 | this.fS = pS; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "S": return this.fS; | ||
85 | default: return null; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final int index) { | ||
91 | switch(index) { | ||
92 | case 0: return this.fS; | ||
93 | default: return null; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | public Segment getS() { | ||
98 | return this.fS; | ||
99 | } | ||
100 | |||
101 | @Override | ||
102 | public boolean set(final String parameterName, final Object newValue) { | ||
103 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
104 | if ("S".equals(parameterName) ) { | ||
105 | this.fS = (Segment) newValue; | ||
106 | return true; | ||
107 | } | ||
108 | return false; | ||
109 | } | ||
110 | |||
111 | public void setS(final Segment pS) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | this.fS = pS; | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public String patternName() { | ||
118 | return "modes3.queries.connectedToReflexive"; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public List<String> parameterNames() { | ||
123 | return ConnectedToReflexive.Match.parameterNames; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public Object[] toArray() { | ||
128 | return new Object[]{fS}; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public ConnectedToReflexive.Match toImmutable() { | ||
133 | return isMutable() ? newMatch(fS) : this; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public String prettyPrint() { | ||
138 | StringBuilder result = new StringBuilder(); | ||
139 | result.append("\"S\"=" + prettyPrintValue(fS)); | ||
140 | return result.toString(); | ||
141 | } | ||
142 | |||
143 | @Override | ||
144 | public int hashCode() { | ||
145 | return Objects.hash(fS); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public boolean equals(final Object obj) { | ||
150 | if (this == obj) | ||
151 | return true; | ||
152 | if (obj == null) { | ||
153 | return false; | ||
154 | } | ||
155 | if ((obj instanceof ConnectedToReflexive.Match)) { | ||
156 | ConnectedToReflexive.Match other = (ConnectedToReflexive.Match) obj; | ||
157 | return Objects.equals(fS, other.fS); | ||
158 | } else { | ||
159 | // this should be infrequent | ||
160 | if (!(obj instanceof IPatternMatch)) { | ||
161 | return false; | ||
162 | } | ||
163 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
164 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public ConnectedToReflexive specification() { | ||
170 | return ConnectedToReflexive.instance(); | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * Returns an empty, mutable match. | ||
175 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
176 | * | ||
177 | * @return the empty match. | ||
178 | * | ||
179 | */ | ||
180 | public static ConnectedToReflexive.Match newEmptyMatch() { | ||
181 | return new Mutable(null); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Returns a mutable (partial) match. | ||
186 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
187 | * | ||
188 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
189 | * @return the new, mutable (partial) match object. | ||
190 | * | ||
191 | */ | ||
192 | public static ConnectedToReflexive.Match newMutableMatch(final Segment pS) { | ||
193 | return new Mutable(pS); | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * Returns a new (partial) match. | ||
198 | * This can be used e.g. to call the matcher with a partial match. | ||
199 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
200 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
201 | * @return the (partial) match object. | ||
202 | * | ||
203 | */ | ||
204 | public static ConnectedToReflexive.Match newMatch(final Segment pS) { | ||
205 | return new Immutable(pS); | ||
206 | } | ||
207 | |||
208 | private static final class Mutable extends ConnectedToReflexive.Match { | ||
209 | Mutable(final Segment pS) { | ||
210 | super(pS); | ||
211 | } | ||
212 | |||
213 | @Override | ||
214 | public boolean isMutable() { | ||
215 | return true; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | private static final class Immutable extends ConnectedToReflexive.Match { | ||
220 | Immutable(final Segment pS) { | ||
221 | super(pS); | ||
222 | } | ||
223 | |||
224 | @Override | ||
225 | public boolean isMutable() { | ||
226 | return false; | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * Generated pattern matcher API of the modes3.queries.connectedToReflexive pattern, | ||
233 | * providing pattern-specific query methods. | ||
234 | * | ||
235 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
236 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
237 | * | ||
238 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
239 | * | ||
240 | * <p>Original source: | ||
241 | * <code><pre> | ||
242 | * {@literal @}Constraint(message = "connectedToReflexive", severity = "error", key = { S }) | ||
243 | * pattern connectedToReflexive(S : Segment) { | ||
244 | * Segment.connectedTo(S, S); | ||
245 | * } | ||
246 | * </pre></code> | ||
247 | * | ||
248 | * @see Match | ||
249 | * @see ConnectedToReflexive | ||
250 | * | ||
251 | */ | ||
252 | public static class Matcher extends BaseMatcher<ConnectedToReflexive.Match> { | ||
253 | /** | ||
254 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
255 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
256 | * | ||
257 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
258 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
259 | * | ||
260 | */ | ||
261 | public static ConnectedToReflexive.Matcher on(final ViatraQueryEngine engine) { | ||
262 | // check if matcher already exists | ||
263 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
264 | if (matcher == null) { | ||
265 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
266 | } | ||
267 | return matcher; | ||
268 | } | ||
269 | |||
270 | /** | ||
271 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
272 | * @return an initialized matcher | ||
273 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
274 | * | ||
275 | */ | ||
276 | public static ConnectedToReflexive.Matcher create() { | ||
277 | return new Matcher(); | ||
278 | } | ||
279 | |||
280 | private static final int POSITION_S = 0; | ||
281 | |||
282 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ConnectedToReflexive.Matcher.class); | ||
283 | |||
284 | /** | ||
285 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
286 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
287 | * | ||
288 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
289 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
290 | * | ||
291 | */ | ||
292 | private Matcher() { | ||
293 | super(querySpecification()); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
298 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
299 | * @return matches represented as a Match object. | ||
300 | * | ||
301 | */ | ||
302 | public Collection<ConnectedToReflexive.Match> getAllMatches(final Segment pS) { | ||
303 | return rawStreamAllMatches(new Object[]{pS}).collect(Collectors.toSet()); | ||
304 | } | ||
305 | |||
306 | /** | ||
307 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
308 | * </p> | ||
309 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
310 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
311 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
312 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
313 | * @return a stream of matches represented as a Match object. | ||
314 | * | ||
315 | */ | ||
316 | public Stream<ConnectedToReflexive.Match> streamAllMatches(final Segment pS) { | ||
317 | return rawStreamAllMatches(new Object[]{pS}); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
322 | * Neither determinism nor randomness of selection is guaranteed. | ||
323 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
324 | * @return a match represented as a Match object, or null if no match is found. | ||
325 | * | ||
326 | */ | ||
327 | public Optional<ConnectedToReflexive.Match> getOneArbitraryMatch(final Segment pS) { | ||
328 | return rawGetOneArbitraryMatch(new Object[]{pS}); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
333 | * under any possible substitution of the unspecified parameters (if any). | ||
334 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
335 | * @return true if the input is a valid (partial) match of the pattern. | ||
336 | * | ||
337 | */ | ||
338 | public boolean hasMatch(final Segment pS) { | ||
339 | return rawHasMatch(new Object[]{pS}); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
344 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
345 | * @return the number of pattern matches found. | ||
346 | * | ||
347 | */ | ||
348 | public int countMatches(final Segment pS) { | ||
349 | return rawCountMatches(new Object[]{pS}); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
354 | * Neither determinism nor randomness of selection is guaranteed. | ||
355 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
356 | * @param processor the action that will process the selected match. | ||
357 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
358 | * | ||
359 | */ | ||
360 | public boolean forOneArbitraryMatch(final Segment pS, final Consumer<? super ConnectedToReflexive.Match> processor) { | ||
361 | return rawForOneArbitraryMatch(new Object[]{pS}, processor); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Returns a new (partial) match. | ||
366 | * This can be used e.g. to call the matcher with a partial match. | ||
367 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
368 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
369 | * @return the (partial) match object. | ||
370 | * | ||
371 | */ | ||
372 | public ConnectedToReflexive.Match newMatch(final Segment pS) { | ||
373 | return ConnectedToReflexive.Match.newMatch(pS); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Retrieve the set of values that occur in matches for S. | ||
378 | * @return the Set of all values or empty set if there are no matches | ||
379 | * | ||
380 | */ | ||
381 | protected Stream<Segment> rawStreamAllValuesOfS(final Object[] parameters) { | ||
382 | return rawStreamAllValues(POSITION_S, parameters).map(Segment.class::cast); | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * Retrieve the set of values that occur in matches for S. | ||
387 | * @return the Set of all values or empty set if there are no matches | ||
388 | * | ||
389 | */ | ||
390 | public Set<Segment> getAllValuesOfS() { | ||
391 | return rawStreamAllValuesOfS(emptyArray()).collect(Collectors.toSet()); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Retrieve the set of values that occur in matches for S. | ||
396 | * @return the Set of all values or empty set if there are no matches | ||
397 | * | ||
398 | */ | ||
399 | public Stream<Segment> streamAllValuesOfS() { | ||
400 | return rawStreamAllValuesOfS(emptyArray()); | ||
401 | } | ||
402 | |||
403 | @Override | ||
404 | protected ConnectedToReflexive.Match tupleToMatch(final Tuple t) { | ||
405 | try { | ||
406 | return ConnectedToReflexive.Match.newMatch((Segment) t.get(POSITION_S)); | ||
407 | } catch(ClassCastException e) { | ||
408 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
409 | return null; | ||
410 | } | ||
411 | } | ||
412 | |||
413 | @Override | ||
414 | protected ConnectedToReflexive.Match arrayToMatch(final Object[] match) { | ||
415 | try { | ||
416 | return ConnectedToReflexive.Match.newMatch((Segment) match[POSITION_S]); | ||
417 | } catch(ClassCastException e) { | ||
418 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
419 | return null; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | @Override | ||
424 | protected ConnectedToReflexive.Match arrayToMatchMutable(final Object[] match) { | ||
425 | try { | ||
426 | return ConnectedToReflexive.Match.newMutableMatch((Segment) match[POSITION_S]); | ||
427 | } catch(ClassCastException e) { | ||
428 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
429 | return null; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * @return the singleton instance of the query specification of this pattern | ||
435 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
436 | * | ||
437 | */ | ||
438 | public static IQuerySpecification<ConnectedToReflexive.Matcher> querySpecification() { | ||
439 | return ConnectedToReflexive.instance(); | ||
440 | } | ||
441 | } | ||
442 | |||
443 | private ConnectedToReflexive() { | ||
444 | super(GeneratedPQuery.INSTANCE); | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @return the singleton instance of the query specification | ||
449 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
450 | * | ||
451 | */ | ||
452 | public static ConnectedToReflexive instance() { | ||
453 | try{ | ||
454 | return LazyHolder.INSTANCE; | ||
455 | } catch (ExceptionInInitializerError err) { | ||
456 | throw processInitializerError(err); | ||
457 | } | ||
458 | } | ||
459 | |||
460 | @Override | ||
461 | protected ConnectedToReflexive.Matcher instantiate(final ViatraQueryEngine engine) { | ||
462 | return ConnectedToReflexive.Matcher.on(engine); | ||
463 | } | ||
464 | |||
465 | @Override | ||
466 | public ConnectedToReflexive.Matcher instantiate() { | ||
467 | return ConnectedToReflexive.Matcher.create(); | ||
468 | } | ||
469 | |||
470 | @Override | ||
471 | public ConnectedToReflexive.Match newEmptyMatch() { | ||
472 | return ConnectedToReflexive.Match.newEmptyMatch(); | ||
473 | } | ||
474 | |||
475 | @Override | ||
476 | public ConnectedToReflexive.Match newMatch(final Object... parameters) { | ||
477 | return ConnectedToReflexive.Match.newMatch((modes3.Segment) parameters[0]); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Inner class allowing the singleton instance of {@link ConnectedToReflexive} to be created | ||
482 | * <b>not</b> at the class load time of the outer class, | ||
483 | * but rather at the first call to {@link ConnectedToReflexive#instance()}. | ||
484 | * | ||
485 | * <p> This workaround is required e.g. to support recursion. | ||
486 | * | ||
487 | */ | ||
488 | private static class LazyHolder { | ||
489 | private static final ConnectedToReflexive INSTANCE = new ConnectedToReflexive(); | ||
490 | |||
491 | /** | ||
492 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
493 | * This initialization order is required to support indirect recursion. | ||
494 | * | ||
495 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
496 | * | ||
497 | */ | ||
498 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
499 | |||
500 | public static Object ensureInitialized() { | ||
501 | INSTANCE.ensureInitializedInternal(); | ||
502 | return null; | ||
503 | } | ||
504 | } | ||
505 | |||
506 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
507 | private static final ConnectedToReflexive.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
508 | |||
509 | private final PParameter parameter_S = new PParameter("S", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
510 | |||
511 | private final List<PParameter> parameters = Arrays.asList(parameter_S); | ||
512 | |||
513 | private GeneratedPQuery() { | ||
514 | super(PVisibility.PUBLIC); | ||
515 | } | ||
516 | |||
517 | @Override | ||
518 | public String getFullyQualifiedName() { | ||
519 | return "modes3.queries.connectedToReflexive"; | ||
520 | } | ||
521 | |||
522 | @Override | ||
523 | public List<String> getParameterNames() { | ||
524 | return Arrays.asList("S"); | ||
525 | } | ||
526 | |||
527 | @Override | ||
528 | public List<PParameter> getParameters() { | ||
529 | return parameters; | ||
530 | } | ||
531 | |||
532 | @Override | ||
533 | public Set<PBody> doGetContainedBodies() { | ||
534 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
535 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
536 | { | ||
537 | PBody body = new PBody(this); | ||
538 | PVariable var_S = body.getOrCreateVariableByName("S"); | ||
539 | new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
540 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
541 | new ExportedParameter(body, var_S, parameter_S) | ||
542 | )); | ||
543 | // Segment.connectedTo(S, S) | ||
544 | new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
545 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
546 | new TypeConstraint(body, Tuples.flatTupleOf(var_S, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
547 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
548 | new Equality(body, var__virtual_0_, var_S); | ||
549 | bodies.add(body); | ||
550 | } | ||
551 | { | ||
552 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
553 | annotation.addAttribute("message", "connectedToReflexive"); | ||
554 | annotation.addAttribute("severity", "error"); | ||
555 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
556 | new ParameterReference("S") | ||
557 | })); | ||
558 | addAnnotation(annotation); | ||
559 | } | ||
560 | return bodies; | ||
561 | } | ||
562 | } | ||
563 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_2.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_2.java new file mode 100644 index 00000000..a8f68dca --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_2.java | |||
@@ -0,0 +1,564 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Train; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
37 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
38 | |||
39 | /** | ||
40 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
41 | * | ||
42 | * <p>Original source: | ||
43 | * <code><pre> | ||
44 | * // | ||
45 | * // endOfSiding | ||
46 | * // | ||
47 | * | ||
48 | * pattern endOfSiding_step_2(in train : Train) { | ||
49 | * // frame-{@literal >}train = model-{@literal >}trains[i0]; | ||
50 | * // frame-{@literal >}location = frame-{@literal >}train-{@literal >}location; | ||
51 | * // if (frame-{@literal >}location != NULL) { | ||
52 | * // ... | ||
53 | * // } | ||
54 | * | ||
55 | * Train(train); | ||
56 | * } | ||
57 | * </pre></code> | ||
58 | * | ||
59 | * @see Matcher | ||
60 | * @see Match | ||
61 | * | ||
62 | */ | ||
63 | @SuppressWarnings("all") | ||
64 | public final class EndOfSiding_step_2 extends BaseGeneratedEMFQuerySpecification<EndOfSiding_step_2.Matcher> { | ||
65 | /** | ||
66 | * Pattern-specific match representation of the modes3.queries.endOfSiding_step_2 pattern, | ||
67 | * to be used in conjunction with {@link Matcher}. | ||
68 | * | ||
69 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
70 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
71 | * usable to represent a match of the pattern in the result of a query, | ||
72 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
73 | * | ||
74 | * @see Matcher | ||
75 | * | ||
76 | */ | ||
77 | public static abstract class Match extends BasePatternMatch { | ||
78 | private Train fTrain; | ||
79 | |||
80 | private static List<String> parameterNames = makeImmutableList("train"); | ||
81 | |||
82 | private Match(final Train pTrain) { | ||
83 | this.fTrain = pTrain; | ||
84 | } | ||
85 | |||
86 | @Override | ||
87 | public Object get(final String parameterName) { | ||
88 | switch(parameterName) { | ||
89 | case "train": return this.fTrain; | ||
90 | default: return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | @Override | ||
95 | public Object get(final int index) { | ||
96 | switch(index) { | ||
97 | case 0: return this.fTrain; | ||
98 | default: return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public Train getTrain() { | ||
103 | return this.fTrain; | ||
104 | } | ||
105 | |||
106 | @Override | ||
107 | public boolean set(final String parameterName, final Object newValue) { | ||
108 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
109 | if ("train".equals(parameterName) ) { | ||
110 | this.fTrain = (Train) newValue; | ||
111 | return true; | ||
112 | } | ||
113 | return false; | ||
114 | } | ||
115 | |||
116 | public void setTrain(final Train pTrain) { | ||
117 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
118 | this.fTrain = pTrain; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public String patternName() { | ||
123 | return "modes3.queries.endOfSiding_step_2"; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public List<String> parameterNames() { | ||
128 | return EndOfSiding_step_2.Match.parameterNames; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public Object[] toArray() { | ||
133 | return new Object[]{fTrain}; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public EndOfSiding_step_2.Match toImmutable() { | ||
138 | return isMutable() ? newMatch(fTrain) : this; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public String prettyPrint() { | ||
143 | StringBuilder result = new StringBuilder(); | ||
144 | result.append("\"train\"=" + prettyPrintValue(fTrain)); | ||
145 | return result.toString(); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public int hashCode() { | ||
150 | return Objects.hash(fTrain); | ||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public boolean equals(final Object obj) { | ||
155 | if (this == obj) | ||
156 | return true; | ||
157 | if (obj == null) { | ||
158 | return false; | ||
159 | } | ||
160 | if ((obj instanceof EndOfSiding_step_2.Match)) { | ||
161 | EndOfSiding_step_2.Match other = (EndOfSiding_step_2.Match) obj; | ||
162 | return Objects.equals(fTrain, other.fTrain); | ||
163 | } else { | ||
164 | // this should be infrequent | ||
165 | if (!(obj instanceof IPatternMatch)) { | ||
166 | return false; | ||
167 | } | ||
168 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
169 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | @Override | ||
174 | public EndOfSiding_step_2 specification() { | ||
175 | return EndOfSiding_step_2.instance(); | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * Returns an empty, mutable match. | ||
180 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
181 | * | ||
182 | * @return the empty match. | ||
183 | * | ||
184 | */ | ||
185 | public static EndOfSiding_step_2.Match newEmptyMatch() { | ||
186 | return new Mutable(null); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * Returns a mutable (partial) match. | ||
191 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
192 | * | ||
193 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
194 | * @return the new, mutable (partial) match object. | ||
195 | * | ||
196 | */ | ||
197 | public static EndOfSiding_step_2.Match newMutableMatch(final Train pTrain) { | ||
198 | return new Mutable(pTrain); | ||
199 | } | ||
200 | |||
201 | /** | ||
202 | * Returns a new (partial) match. | ||
203 | * This can be used e.g. to call the matcher with a partial match. | ||
204 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
205 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
206 | * @return the (partial) match object. | ||
207 | * | ||
208 | */ | ||
209 | public static EndOfSiding_step_2.Match newMatch(final Train pTrain) { | ||
210 | return new Immutable(pTrain); | ||
211 | } | ||
212 | |||
213 | private static final class Mutable extends EndOfSiding_step_2.Match { | ||
214 | Mutable(final Train pTrain) { | ||
215 | super(pTrain); | ||
216 | } | ||
217 | |||
218 | @Override | ||
219 | public boolean isMutable() { | ||
220 | return true; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | private static final class Immutable extends EndOfSiding_step_2.Match { | ||
225 | Immutable(final Train pTrain) { | ||
226 | super(pTrain); | ||
227 | } | ||
228 | |||
229 | @Override | ||
230 | public boolean isMutable() { | ||
231 | return false; | ||
232 | } | ||
233 | } | ||
234 | } | ||
235 | |||
236 | /** | ||
237 | * Generated pattern matcher API of the modes3.queries.endOfSiding_step_2 pattern, | ||
238 | * providing pattern-specific query methods. | ||
239 | * | ||
240 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
241 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
242 | * | ||
243 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
244 | * | ||
245 | * <p>Original source: | ||
246 | * <code><pre> | ||
247 | * // | ||
248 | * // endOfSiding | ||
249 | * // | ||
250 | * | ||
251 | * pattern endOfSiding_step_2(in train : Train) { | ||
252 | * // frame-{@literal >}train = model-{@literal >}trains[i0]; | ||
253 | * // frame-{@literal >}location = frame-{@literal >}train-{@literal >}location; | ||
254 | * // if (frame-{@literal >}location != NULL) { | ||
255 | * // ... | ||
256 | * // } | ||
257 | * | ||
258 | * Train(train); | ||
259 | * } | ||
260 | * </pre></code> | ||
261 | * | ||
262 | * @see Match | ||
263 | * @see EndOfSiding_step_2 | ||
264 | * | ||
265 | */ | ||
266 | public static class Matcher extends BaseMatcher<EndOfSiding_step_2.Match> { | ||
267 | /** | ||
268 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
269 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
270 | * | ||
271 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
272 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
273 | * | ||
274 | */ | ||
275 | public static EndOfSiding_step_2.Matcher on(final ViatraQueryEngine engine) { | ||
276 | // check if matcher already exists | ||
277 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
278 | if (matcher == null) { | ||
279 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
280 | } | ||
281 | return matcher; | ||
282 | } | ||
283 | |||
284 | /** | ||
285 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
286 | * @return an initialized matcher | ||
287 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
288 | * | ||
289 | */ | ||
290 | public static EndOfSiding_step_2.Matcher create() { | ||
291 | return new Matcher(); | ||
292 | } | ||
293 | |||
294 | private static final int POSITION_TRAIN = 0; | ||
295 | |||
296 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EndOfSiding_step_2.Matcher.class); | ||
297 | |||
298 | /** | ||
299 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
300 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
301 | * | ||
302 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
303 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
304 | * | ||
305 | */ | ||
306 | private Matcher() { | ||
307 | super(querySpecification()); | ||
308 | } | ||
309 | |||
310 | /** | ||
311 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
312 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
313 | * @return matches represented as a Match object. | ||
314 | * | ||
315 | */ | ||
316 | public Collection<EndOfSiding_step_2.Match> getAllMatches(final Train pTrain) { | ||
317 | return rawStreamAllMatches(new Object[]{pTrain}).collect(Collectors.toSet()); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
322 | * </p> | ||
323 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
324 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
325 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
326 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
327 | * @return a stream of matches represented as a Match object. | ||
328 | * | ||
329 | */ | ||
330 | public Stream<EndOfSiding_step_2.Match> streamAllMatches(final Train pTrain) { | ||
331 | return rawStreamAllMatches(new Object[]{pTrain}); | ||
332 | } | ||
333 | |||
334 | /** | ||
335 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
336 | * Neither determinism nor randomness of selection is guaranteed. | ||
337 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
338 | * @return a match represented as a Match object, or null if no match is found. | ||
339 | * | ||
340 | */ | ||
341 | public Optional<EndOfSiding_step_2.Match> getOneArbitraryMatch(final Train pTrain) { | ||
342 | return rawGetOneArbitraryMatch(new Object[]{pTrain}); | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
347 | * under any possible substitution of the unspecified parameters (if any). | ||
348 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
349 | * @return true if the input is a valid (partial) match of the pattern. | ||
350 | * | ||
351 | */ | ||
352 | public boolean hasMatch(final Train pTrain) { | ||
353 | return rawHasMatch(new Object[]{pTrain}); | ||
354 | } | ||
355 | |||
356 | /** | ||
357 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
358 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
359 | * @return the number of pattern matches found. | ||
360 | * | ||
361 | */ | ||
362 | public int countMatches(final Train pTrain) { | ||
363 | return rawCountMatches(new Object[]{pTrain}); | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
368 | * Neither determinism nor randomness of selection is guaranteed. | ||
369 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
370 | * @param processor the action that will process the selected match. | ||
371 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
372 | * | ||
373 | */ | ||
374 | public boolean forOneArbitraryMatch(final Train pTrain, final Consumer<? super EndOfSiding_step_2.Match> processor) { | ||
375 | return rawForOneArbitraryMatch(new Object[]{pTrain}, processor); | ||
376 | } | ||
377 | |||
378 | /** | ||
379 | * Returns a new (partial) match. | ||
380 | * This can be used e.g. to call the matcher with a partial match. | ||
381 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
382 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
383 | * @return the (partial) match object. | ||
384 | * | ||
385 | */ | ||
386 | public EndOfSiding_step_2.Match newMatch(final Train pTrain) { | ||
387 | return EndOfSiding_step_2.Match.newMatch(pTrain); | ||
388 | } | ||
389 | |||
390 | /** | ||
391 | * Retrieve the set of values that occur in matches for train. | ||
392 | * @return the Set of all values or empty set if there are no matches | ||
393 | * | ||
394 | */ | ||
395 | protected Stream<Train> rawStreamAllValuesOftrain(final Object[] parameters) { | ||
396 | return rawStreamAllValues(POSITION_TRAIN, parameters).map(Train.class::cast); | ||
397 | } | ||
398 | |||
399 | /** | ||
400 | * Retrieve the set of values that occur in matches for train. | ||
401 | * @return the Set of all values or empty set if there are no matches | ||
402 | * | ||
403 | */ | ||
404 | public Set<Train> getAllValuesOftrain() { | ||
405 | return rawStreamAllValuesOftrain(emptyArray()).collect(Collectors.toSet()); | ||
406 | } | ||
407 | |||
408 | /** | ||
409 | * Retrieve the set of values that occur in matches for train. | ||
410 | * @return the Set of all values or empty set if there are no matches | ||
411 | * | ||
412 | */ | ||
413 | public Stream<Train> streamAllValuesOftrain() { | ||
414 | return rawStreamAllValuesOftrain(emptyArray()); | ||
415 | } | ||
416 | |||
417 | @Override | ||
418 | protected EndOfSiding_step_2.Match tupleToMatch(final Tuple t) { | ||
419 | try { | ||
420 | return EndOfSiding_step_2.Match.newMatch((Train) t.get(POSITION_TRAIN)); | ||
421 | } catch(ClassCastException e) { | ||
422 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
423 | return null; | ||
424 | } | ||
425 | } | ||
426 | |||
427 | @Override | ||
428 | protected EndOfSiding_step_2.Match arrayToMatch(final Object[] match) { | ||
429 | try { | ||
430 | return EndOfSiding_step_2.Match.newMatch((Train) match[POSITION_TRAIN]); | ||
431 | } catch(ClassCastException e) { | ||
432 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
433 | return null; | ||
434 | } | ||
435 | } | ||
436 | |||
437 | @Override | ||
438 | protected EndOfSiding_step_2.Match arrayToMatchMutable(final Object[] match) { | ||
439 | try { | ||
440 | return EndOfSiding_step_2.Match.newMutableMatch((Train) match[POSITION_TRAIN]); | ||
441 | } catch(ClassCastException e) { | ||
442 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
443 | return null; | ||
444 | } | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @return the singleton instance of the query specification of this pattern | ||
449 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
450 | * | ||
451 | */ | ||
452 | public static IQuerySpecification<EndOfSiding_step_2.Matcher> querySpecification() { | ||
453 | return EndOfSiding_step_2.instance(); | ||
454 | } | ||
455 | } | ||
456 | |||
457 | private EndOfSiding_step_2() { | ||
458 | super(GeneratedPQuery.INSTANCE); | ||
459 | } | ||
460 | |||
461 | /** | ||
462 | * @return the singleton instance of the query specification | ||
463 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
464 | * | ||
465 | */ | ||
466 | public static EndOfSiding_step_2 instance() { | ||
467 | try{ | ||
468 | return LazyHolder.INSTANCE; | ||
469 | } catch (ExceptionInInitializerError err) { | ||
470 | throw processInitializerError(err); | ||
471 | } | ||
472 | } | ||
473 | |||
474 | @Override | ||
475 | protected EndOfSiding_step_2.Matcher instantiate(final ViatraQueryEngine engine) { | ||
476 | return EndOfSiding_step_2.Matcher.on(engine); | ||
477 | } | ||
478 | |||
479 | @Override | ||
480 | public EndOfSiding_step_2.Matcher instantiate() { | ||
481 | return EndOfSiding_step_2.Matcher.create(); | ||
482 | } | ||
483 | |||
484 | @Override | ||
485 | public EndOfSiding_step_2.Match newEmptyMatch() { | ||
486 | return EndOfSiding_step_2.Match.newEmptyMatch(); | ||
487 | } | ||
488 | |||
489 | @Override | ||
490 | public EndOfSiding_step_2.Match newMatch(final Object... parameters) { | ||
491 | return EndOfSiding_step_2.Match.newMatch((modes3.Train) parameters[0]); | ||
492 | } | ||
493 | |||
494 | /** | ||
495 | * Inner class allowing the singleton instance of {@link EndOfSiding_step_2} to be created | ||
496 | * <b>not</b> at the class load time of the outer class, | ||
497 | * but rather at the first call to {@link EndOfSiding_step_2#instance()}. | ||
498 | * | ||
499 | * <p> This workaround is required e.g. to support recursion. | ||
500 | * | ||
501 | */ | ||
502 | private static class LazyHolder { | ||
503 | private static final EndOfSiding_step_2 INSTANCE = new EndOfSiding_step_2(); | ||
504 | |||
505 | /** | ||
506 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
507 | * This initialization order is required to support indirect recursion. | ||
508 | * | ||
509 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
510 | * | ||
511 | */ | ||
512 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
513 | |||
514 | public static Object ensureInitialized() { | ||
515 | INSTANCE.ensureInitializedInternal(); | ||
516 | return null; | ||
517 | } | ||
518 | } | ||
519 | |||
520 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
521 | private static final EndOfSiding_step_2.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
522 | |||
523 | private final PParameter parameter_train = new PParameter("train", "modes3.Train", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Train")), PParameterDirection.INOUT); | ||
524 | |||
525 | private final List<PParameter> parameters = Arrays.asList(parameter_train); | ||
526 | |||
527 | private GeneratedPQuery() { | ||
528 | super(PVisibility.PUBLIC); | ||
529 | } | ||
530 | |||
531 | @Override | ||
532 | public String getFullyQualifiedName() { | ||
533 | return "modes3.queries.endOfSiding_step_2"; | ||
534 | } | ||
535 | |||
536 | @Override | ||
537 | public List<String> getParameterNames() { | ||
538 | return Arrays.asList("train"); | ||
539 | } | ||
540 | |||
541 | @Override | ||
542 | public List<PParameter> getParameters() { | ||
543 | return parameters; | ||
544 | } | ||
545 | |||
546 | @Override | ||
547 | public Set<PBody> doGetContainedBodies() { | ||
548 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
549 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
550 | { | ||
551 | PBody body = new PBody(this); | ||
552 | PVariable var_train = body.getOrCreateVariableByName("train"); | ||
553 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
554 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
555 | new ExportedParameter(body, var_train, parameter_train) | ||
556 | )); | ||
557 | // // frame->train = model->trains[i0];// frame->location = frame->train->location;// if (frame->location != NULL) {// ...// } Train(train) | ||
558 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
559 | bodies.add(body); | ||
560 | } | ||
561 | return bodies; | ||
562 | } | ||
563 | } | ||
564 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_3.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_3.java new file mode 100644 index 00000000..16b28a9f --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_3.java | |||
@@ -0,0 +1,717 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.Train; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern endOfSiding_step_3(in train : Train, in location : Segment) { | ||
48 | * // int loop_bound1 = frame-{@literal >}location-{@literal >}connected_to_count; | ||
49 | * // for (int i1 = 0; i1 {@literal <} loop_bound1; i1++) { | ||
50 | * // ... | ||
51 | * // } | ||
52 | * Train(train); | ||
53 | * Train.location(train, location); | ||
54 | * } | ||
55 | * </pre></code> | ||
56 | * | ||
57 | * @see Matcher | ||
58 | * @see Match | ||
59 | * | ||
60 | */ | ||
61 | @SuppressWarnings("all") | ||
62 | public final class EndOfSiding_step_3 extends BaseGeneratedEMFQuerySpecification<EndOfSiding_step_3.Matcher> { | ||
63 | /** | ||
64 | * Pattern-specific match representation of the modes3.queries.endOfSiding_step_3 pattern, | ||
65 | * to be used in conjunction with {@link Matcher}. | ||
66 | * | ||
67 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
68 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
69 | * usable to represent a match of the pattern in the result of a query, | ||
70 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
71 | * | ||
72 | * @see Matcher | ||
73 | * | ||
74 | */ | ||
75 | public static abstract class Match extends BasePatternMatch { | ||
76 | private Train fTrain; | ||
77 | |||
78 | private Segment fLocation; | ||
79 | |||
80 | private static List<String> parameterNames = makeImmutableList("train", "location"); | ||
81 | |||
82 | private Match(final Train pTrain, final Segment pLocation) { | ||
83 | this.fTrain = pTrain; | ||
84 | this.fLocation = pLocation; | ||
85 | } | ||
86 | |||
87 | @Override | ||
88 | public Object get(final String parameterName) { | ||
89 | switch(parameterName) { | ||
90 | case "train": return this.fTrain; | ||
91 | case "location": return this.fLocation; | ||
92 | default: return null; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | @Override | ||
97 | public Object get(final int index) { | ||
98 | switch(index) { | ||
99 | case 0: return this.fTrain; | ||
100 | case 1: return this.fLocation; | ||
101 | default: return null; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | public Train getTrain() { | ||
106 | return this.fTrain; | ||
107 | } | ||
108 | |||
109 | public Segment getLocation() { | ||
110 | return this.fLocation; | ||
111 | } | ||
112 | |||
113 | @Override | ||
114 | public boolean set(final String parameterName, final Object newValue) { | ||
115 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
116 | if ("train".equals(parameterName) ) { | ||
117 | this.fTrain = (Train) newValue; | ||
118 | return true; | ||
119 | } | ||
120 | if ("location".equals(parameterName) ) { | ||
121 | this.fLocation = (Segment) newValue; | ||
122 | return true; | ||
123 | } | ||
124 | return false; | ||
125 | } | ||
126 | |||
127 | public void setTrain(final Train pTrain) { | ||
128 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
129 | this.fTrain = pTrain; | ||
130 | } | ||
131 | |||
132 | public void setLocation(final Segment pLocation) { | ||
133 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
134 | this.fLocation = pLocation; | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public String patternName() { | ||
139 | return "modes3.queries.endOfSiding_step_3"; | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public List<String> parameterNames() { | ||
144 | return EndOfSiding_step_3.Match.parameterNames; | ||
145 | } | ||
146 | |||
147 | @Override | ||
148 | public Object[] toArray() { | ||
149 | return new Object[]{fTrain, fLocation}; | ||
150 | } | ||
151 | |||
152 | @Override | ||
153 | public EndOfSiding_step_3.Match toImmutable() { | ||
154 | return isMutable() ? newMatch(fTrain, fLocation) : this; | ||
155 | } | ||
156 | |||
157 | @Override | ||
158 | public String prettyPrint() { | ||
159 | StringBuilder result = new StringBuilder(); | ||
160 | result.append("\"train\"=" + prettyPrintValue(fTrain) + ", "); | ||
161 | result.append("\"location\"=" + prettyPrintValue(fLocation)); | ||
162 | return result.toString(); | ||
163 | } | ||
164 | |||
165 | @Override | ||
166 | public int hashCode() { | ||
167 | return Objects.hash(fTrain, fLocation); | ||
168 | } | ||
169 | |||
170 | @Override | ||
171 | public boolean equals(final Object obj) { | ||
172 | if (this == obj) | ||
173 | return true; | ||
174 | if (obj == null) { | ||
175 | return false; | ||
176 | } | ||
177 | if ((obj instanceof EndOfSiding_step_3.Match)) { | ||
178 | EndOfSiding_step_3.Match other = (EndOfSiding_step_3.Match) obj; | ||
179 | return Objects.equals(fTrain, other.fTrain) && Objects.equals(fLocation, other.fLocation); | ||
180 | } else { | ||
181 | // this should be infrequent | ||
182 | if (!(obj instanceof IPatternMatch)) { | ||
183 | return false; | ||
184 | } | ||
185 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
186 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
187 | } | ||
188 | } | ||
189 | |||
190 | @Override | ||
191 | public EndOfSiding_step_3 specification() { | ||
192 | return EndOfSiding_step_3.instance(); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * Returns an empty, mutable match. | ||
197 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
198 | * | ||
199 | * @return the empty match. | ||
200 | * | ||
201 | */ | ||
202 | public static EndOfSiding_step_3.Match newEmptyMatch() { | ||
203 | return new Mutable(null, null); | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * Returns a mutable (partial) match. | ||
208 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
209 | * | ||
210 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
211 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
212 | * @return the new, mutable (partial) match object. | ||
213 | * | ||
214 | */ | ||
215 | public static EndOfSiding_step_3.Match newMutableMatch(final Train pTrain, final Segment pLocation) { | ||
216 | return new Mutable(pTrain, pLocation); | ||
217 | } | ||
218 | |||
219 | /** | ||
220 | * Returns a new (partial) match. | ||
221 | * This can be used e.g. to call the matcher with a partial match. | ||
222 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
223 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
224 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
225 | * @return the (partial) match object. | ||
226 | * | ||
227 | */ | ||
228 | public static EndOfSiding_step_3.Match newMatch(final Train pTrain, final Segment pLocation) { | ||
229 | return new Immutable(pTrain, pLocation); | ||
230 | } | ||
231 | |||
232 | private static final class Mutable extends EndOfSiding_step_3.Match { | ||
233 | Mutable(final Train pTrain, final Segment pLocation) { | ||
234 | super(pTrain, pLocation); | ||
235 | } | ||
236 | |||
237 | @Override | ||
238 | public boolean isMutable() { | ||
239 | return true; | ||
240 | } | ||
241 | } | ||
242 | |||
243 | private static final class Immutable extends EndOfSiding_step_3.Match { | ||
244 | Immutable(final Train pTrain, final Segment pLocation) { | ||
245 | super(pTrain, pLocation); | ||
246 | } | ||
247 | |||
248 | @Override | ||
249 | public boolean isMutable() { | ||
250 | return false; | ||
251 | } | ||
252 | } | ||
253 | } | ||
254 | |||
255 | /** | ||
256 | * Generated pattern matcher API of the modes3.queries.endOfSiding_step_3 pattern, | ||
257 | * providing pattern-specific query methods. | ||
258 | * | ||
259 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
260 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
261 | * | ||
262 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
263 | * | ||
264 | * <p>Original source: | ||
265 | * <code><pre> | ||
266 | * pattern endOfSiding_step_3(in train : Train, in location : Segment) { | ||
267 | * // int loop_bound1 = frame-{@literal >}location-{@literal >}connected_to_count; | ||
268 | * // for (int i1 = 0; i1 {@literal <} loop_bound1; i1++) { | ||
269 | * // ... | ||
270 | * // } | ||
271 | * Train(train); | ||
272 | * Train.location(train, location); | ||
273 | * } | ||
274 | * </pre></code> | ||
275 | * | ||
276 | * @see Match | ||
277 | * @see EndOfSiding_step_3 | ||
278 | * | ||
279 | */ | ||
280 | public static class Matcher extends BaseMatcher<EndOfSiding_step_3.Match> { | ||
281 | /** | ||
282 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
283 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
284 | * | ||
285 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
286 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
287 | * | ||
288 | */ | ||
289 | public static EndOfSiding_step_3.Matcher on(final ViatraQueryEngine engine) { | ||
290 | // check if matcher already exists | ||
291 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
292 | if (matcher == null) { | ||
293 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
294 | } | ||
295 | return matcher; | ||
296 | } | ||
297 | |||
298 | /** | ||
299 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
300 | * @return an initialized matcher | ||
301 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
302 | * | ||
303 | */ | ||
304 | public static EndOfSiding_step_3.Matcher create() { | ||
305 | return new Matcher(); | ||
306 | } | ||
307 | |||
308 | private static final int POSITION_TRAIN = 0; | ||
309 | |||
310 | private static final int POSITION_LOCATION = 1; | ||
311 | |||
312 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EndOfSiding_step_3.Matcher.class); | ||
313 | |||
314 | /** | ||
315 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
316 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
317 | * | ||
318 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
319 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
320 | * | ||
321 | */ | ||
322 | private Matcher() { | ||
323 | super(querySpecification()); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
328 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
329 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
330 | * @return matches represented as a Match object. | ||
331 | * | ||
332 | */ | ||
333 | public Collection<EndOfSiding_step_3.Match> getAllMatches(final Train pTrain, final Segment pLocation) { | ||
334 | return rawStreamAllMatches(new Object[]{pTrain, pLocation}).collect(Collectors.toSet()); | ||
335 | } | ||
336 | |||
337 | /** | ||
338 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
339 | * </p> | ||
340 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
341 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
342 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
343 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
344 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
345 | * @return a stream of matches represented as a Match object. | ||
346 | * | ||
347 | */ | ||
348 | public Stream<EndOfSiding_step_3.Match> streamAllMatches(final Train pTrain, final Segment pLocation) { | ||
349 | return rawStreamAllMatches(new Object[]{pTrain, pLocation}); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
354 | * Neither determinism nor randomness of selection is guaranteed. | ||
355 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
356 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
357 | * @return a match represented as a Match object, or null if no match is found. | ||
358 | * | ||
359 | */ | ||
360 | public Optional<EndOfSiding_step_3.Match> getOneArbitraryMatch(final Train pTrain, final Segment pLocation) { | ||
361 | return rawGetOneArbitraryMatch(new Object[]{pTrain, pLocation}); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
366 | * under any possible substitution of the unspecified parameters (if any). | ||
367 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
368 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
369 | * @return true if the input is a valid (partial) match of the pattern. | ||
370 | * | ||
371 | */ | ||
372 | public boolean hasMatch(final Train pTrain, final Segment pLocation) { | ||
373 | return rawHasMatch(new Object[]{pTrain, pLocation}); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
378 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
379 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
380 | * @return the number of pattern matches found. | ||
381 | * | ||
382 | */ | ||
383 | public int countMatches(final Train pTrain, final Segment pLocation) { | ||
384 | return rawCountMatches(new Object[]{pTrain, pLocation}); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
389 | * Neither determinism nor randomness of selection is guaranteed. | ||
390 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
391 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
392 | * @param processor the action that will process the selected match. | ||
393 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
394 | * | ||
395 | */ | ||
396 | public boolean forOneArbitraryMatch(final Train pTrain, final Segment pLocation, final Consumer<? super EndOfSiding_step_3.Match> processor) { | ||
397 | return rawForOneArbitraryMatch(new Object[]{pTrain, pLocation}, processor); | ||
398 | } | ||
399 | |||
400 | /** | ||
401 | * Returns a new (partial) match. | ||
402 | * This can be used e.g. to call the matcher with a partial match. | ||
403 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
404 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
405 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
406 | * @return the (partial) match object. | ||
407 | * | ||
408 | */ | ||
409 | public EndOfSiding_step_3.Match newMatch(final Train pTrain, final Segment pLocation) { | ||
410 | return EndOfSiding_step_3.Match.newMatch(pTrain, pLocation); | ||
411 | } | ||
412 | |||
413 | /** | ||
414 | * Retrieve the set of values that occur in matches for train. | ||
415 | * @return the Set of all values or empty set if there are no matches | ||
416 | * | ||
417 | */ | ||
418 | protected Stream<Train> rawStreamAllValuesOftrain(final Object[] parameters) { | ||
419 | return rawStreamAllValues(POSITION_TRAIN, parameters).map(Train.class::cast); | ||
420 | } | ||
421 | |||
422 | /** | ||
423 | * Retrieve the set of values that occur in matches for train. | ||
424 | * @return the Set of all values or empty set if there are no matches | ||
425 | * | ||
426 | */ | ||
427 | public Set<Train> getAllValuesOftrain() { | ||
428 | return rawStreamAllValuesOftrain(emptyArray()).collect(Collectors.toSet()); | ||
429 | } | ||
430 | |||
431 | /** | ||
432 | * Retrieve the set of values that occur in matches for train. | ||
433 | * @return the Set of all values or empty set if there are no matches | ||
434 | * | ||
435 | */ | ||
436 | public Stream<Train> streamAllValuesOftrain() { | ||
437 | return rawStreamAllValuesOftrain(emptyArray()); | ||
438 | } | ||
439 | |||
440 | /** | ||
441 | * Retrieve the set of values that occur in matches for train. | ||
442 | * </p> | ||
443 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
444 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
445 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
446 | * | ||
447 | * @return the Stream of all values or empty set if there are no matches | ||
448 | * | ||
449 | */ | ||
450 | public Stream<Train> streamAllValuesOftrain(final EndOfSiding_step_3.Match partialMatch) { | ||
451 | return rawStreamAllValuesOftrain(partialMatch.toArray()); | ||
452 | } | ||
453 | |||
454 | /** | ||
455 | * Retrieve the set of values that occur in matches for train. | ||
456 | * </p> | ||
457 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
458 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
459 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
460 | * | ||
461 | * @return the Stream of all values or empty set if there are no matches | ||
462 | * | ||
463 | */ | ||
464 | public Stream<Train> streamAllValuesOftrain(final Segment pLocation) { | ||
465 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation}); | ||
466 | } | ||
467 | |||
468 | /** | ||
469 | * Retrieve the set of values that occur in matches for train. | ||
470 | * @return the Set of all values or empty set if there are no matches | ||
471 | * | ||
472 | */ | ||
473 | public Set<Train> getAllValuesOftrain(final EndOfSiding_step_3.Match partialMatch) { | ||
474 | return rawStreamAllValuesOftrain(partialMatch.toArray()).collect(Collectors.toSet()); | ||
475 | } | ||
476 | |||
477 | /** | ||
478 | * Retrieve the set of values that occur in matches for train. | ||
479 | * @return the Set of all values or empty set if there are no matches | ||
480 | * | ||
481 | */ | ||
482 | public Set<Train> getAllValuesOftrain(final Segment pLocation) { | ||
483 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation}).collect(Collectors.toSet()); | ||
484 | } | ||
485 | |||
486 | /** | ||
487 | * Retrieve the set of values that occur in matches for location. | ||
488 | * @return the Set of all values or empty set if there are no matches | ||
489 | * | ||
490 | */ | ||
491 | protected Stream<Segment> rawStreamAllValuesOflocation(final Object[] parameters) { | ||
492 | return rawStreamAllValues(POSITION_LOCATION, parameters).map(Segment.class::cast); | ||
493 | } | ||
494 | |||
495 | /** | ||
496 | * Retrieve the set of values that occur in matches for location. | ||
497 | * @return the Set of all values or empty set if there are no matches | ||
498 | * | ||
499 | */ | ||
500 | public Set<Segment> getAllValuesOflocation() { | ||
501 | return rawStreamAllValuesOflocation(emptyArray()).collect(Collectors.toSet()); | ||
502 | } | ||
503 | |||
504 | /** | ||
505 | * Retrieve the set of values that occur in matches for location. | ||
506 | * @return the Set of all values or empty set if there are no matches | ||
507 | * | ||
508 | */ | ||
509 | public Stream<Segment> streamAllValuesOflocation() { | ||
510 | return rawStreamAllValuesOflocation(emptyArray()); | ||
511 | } | ||
512 | |||
513 | /** | ||
514 | * Retrieve the set of values that occur in matches for location. | ||
515 | * </p> | ||
516 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
517 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
518 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
519 | * | ||
520 | * @return the Stream of all values or empty set if there are no matches | ||
521 | * | ||
522 | */ | ||
523 | public Stream<Segment> streamAllValuesOflocation(final EndOfSiding_step_3.Match partialMatch) { | ||
524 | return rawStreamAllValuesOflocation(partialMatch.toArray()); | ||
525 | } | ||
526 | |||
527 | /** | ||
528 | * Retrieve the set of values that occur in matches for location. | ||
529 | * </p> | ||
530 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
531 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
532 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
533 | * | ||
534 | * @return the Stream of all values or empty set if there are no matches | ||
535 | * | ||
536 | */ | ||
537 | public Stream<Segment> streamAllValuesOflocation(final Train pTrain) { | ||
538 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null}); | ||
539 | } | ||
540 | |||
541 | /** | ||
542 | * Retrieve the set of values that occur in matches for location. | ||
543 | * @return the Set of all values or empty set if there are no matches | ||
544 | * | ||
545 | */ | ||
546 | public Set<Segment> getAllValuesOflocation(final EndOfSiding_step_3.Match partialMatch) { | ||
547 | return rawStreamAllValuesOflocation(partialMatch.toArray()).collect(Collectors.toSet()); | ||
548 | } | ||
549 | |||
550 | /** | ||
551 | * Retrieve the set of values that occur in matches for location. | ||
552 | * @return the Set of all values or empty set if there are no matches | ||
553 | * | ||
554 | */ | ||
555 | public Set<Segment> getAllValuesOflocation(final Train pTrain) { | ||
556 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null}).collect(Collectors.toSet()); | ||
557 | } | ||
558 | |||
559 | @Override | ||
560 | protected EndOfSiding_step_3.Match tupleToMatch(final Tuple t) { | ||
561 | try { | ||
562 | return EndOfSiding_step_3.Match.newMatch((Train) t.get(POSITION_TRAIN), (Segment) t.get(POSITION_LOCATION)); | ||
563 | } catch(ClassCastException e) { | ||
564 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
565 | return null; | ||
566 | } | ||
567 | } | ||
568 | |||
569 | @Override | ||
570 | protected EndOfSiding_step_3.Match arrayToMatch(final Object[] match) { | ||
571 | try { | ||
572 | return EndOfSiding_step_3.Match.newMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION]); | ||
573 | } catch(ClassCastException e) { | ||
574 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
575 | return null; | ||
576 | } | ||
577 | } | ||
578 | |||
579 | @Override | ||
580 | protected EndOfSiding_step_3.Match arrayToMatchMutable(final Object[] match) { | ||
581 | try { | ||
582 | return EndOfSiding_step_3.Match.newMutableMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION]); | ||
583 | } catch(ClassCastException e) { | ||
584 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
585 | return null; | ||
586 | } | ||
587 | } | ||
588 | |||
589 | /** | ||
590 | * @return the singleton instance of the query specification of this pattern | ||
591 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
592 | * | ||
593 | */ | ||
594 | public static IQuerySpecification<EndOfSiding_step_3.Matcher> querySpecification() { | ||
595 | return EndOfSiding_step_3.instance(); | ||
596 | } | ||
597 | } | ||
598 | |||
599 | private EndOfSiding_step_3() { | ||
600 | super(GeneratedPQuery.INSTANCE); | ||
601 | } | ||
602 | |||
603 | /** | ||
604 | * @return the singleton instance of the query specification | ||
605 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
606 | * | ||
607 | */ | ||
608 | public static EndOfSiding_step_3 instance() { | ||
609 | try{ | ||
610 | return LazyHolder.INSTANCE; | ||
611 | } catch (ExceptionInInitializerError err) { | ||
612 | throw processInitializerError(err); | ||
613 | } | ||
614 | } | ||
615 | |||
616 | @Override | ||
617 | protected EndOfSiding_step_3.Matcher instantiate(final ViatraQueryEngine engine) { | ||
618 | return EndOfSiding_step_3.Matcher.on(engine); | ||
619 | } | ||
620 | |||
621 | @Override | ||
622 | public EndOfSiding_step_3.Matcher instantiate() { | ||
623 | return EndOfSiding_step_3.Matcher.create(); | ||
624 | } | ||
625 | |||
626 | @Override | ||
627 | public EndOfSiding_step_3.Match newEmptyMatch() { | ||
628 | return EndOfSiding_step_3.Match.newEmptyMatch(); | ||
629 | } | ||
630 | |||
631 | @Override | ||
632 | public EndOfSiding_step_3.Match newMatch(final Object... parameters) { | ||
633 | return EndOfSiding_step_3.Match.newMatch((modes3.Train) parameters[0], (modes3.Segment) parameters[1]); | ||
634 | } | ||
635 | |||
636 | /** | ||
637 | * Inner class allowing the singleton instance of {@link EndOfSiding_step_3} to be created | ||
638 | * <b>not</b> at the class load time of the outer class, | ||
639 | * but rather at the first call to {@link EndOfSiding_step_3#instance()}. | ||
640 | * | ||
641 | * <p> This workaround is required e.g. to support recursion. | ||
642 | * | ||
643 | */ | ||
644 | private static class LazyHolder { | ||
645 | private static final EndOfSiding_step_3 INSTANCE = new EndOfSiding_step_3(); | ||
646 | |||
647 | /** | ||
648 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
649 | * This initialization order is required to support indirect recursion. | ||
650 | * | ||
651 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
652 | * | ||
653 | */ | ||
654 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
655 | |||
656 | public static Object ensureInitialized() { | ||
657 | INSTANCE.ensureInitializedInternal(); | ||
658 | return null; | ||
659 | } | ||
660 | } | ||
661 | |||
662 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
663 | private static final EndOfSiding_step_3.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
664 | |||
665 | private final PParameter parameter_train = new PParameter("train", "modes3.Train", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Train")), PParameterDirection.INOUT); | ||
666 | |||
667 | private final PParameter parameter_location = new PParameter("location", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
668 | |||
669 | private final List<PParameter> parameters = Arrays.asList(parameter_train, parameter_location); | ||
670 | |||
671 | private GeneratedPQuery() { | ||
672 | super(PVisibility.PUBLIC); | ||
673 | } | ||
674 | |||
675 | @Override | ||
676 | public String getFullyQualifiedName() { | ||
677 | return "modes3.queries.endOfSiding_step_3"; | ||
678 | } | ||
679 | |||
680 | @Override | ||
681 | public List<String> getParameterNames() { | ||
682 | return Arrays.asList("train","location"); | ||
683 | } | ||
684 | |||
685 | @Override | ||
686 | public List<PParameter> getParameters() { | ||
687 | return parameters; | ||
688 | } | ||
689 | |||
690 | @Override | ||
691 | public Set<PBody> doGetContainedBodies() { | ||
692 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
693 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
694 | { | ||
695 | PBody body = new PBody(this); | ||
696 | PVariable var_train = body.getOrCreateVariableByName("train"); | ||
697 | PVariable var_location = body.getOrCreateVariableByName("location"); | ||
698 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
699 | new TypeConstraint(body, Tuples.flatTupleOf(var_location), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
700 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
701 | new ExportedParameter(body, var_train, parameter_train), | ||
702 | new ExportedParameter(body, var_location, parameter_location) | ||
703 | )); | ||
704 | // // int loop_bound1 = frame->location->connected_to_count;// for (int i1 = 0; i1 < loop_bound1; i1++) {// ...// } Train(train) | ||
705 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
706 | // Train.location(train, location) | ||
707 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
708 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
709 | new TypeConstraint(body, Tuples.flatTupleOf(var_train, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train", "location"))); | ||
710 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
711 | new Equality(body, var__virtual_0_, var_location); | ||
712 | bodies.add(body); | ||
713 | } | ||
714 | return bodies; | ||
715 | } | ||
716 | } | ||
717 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_4.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_4.java new file mode 100644 index 00000000..73df8514 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_4.java | |||
@@ -0,0 +1,847 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.Train; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern endOfSiding_step_4(in train : Train, in location : Segment, in end : Segment) { | ||
48 | * // frame-{@literal >}end = frame-{@literal >}location-{@literal >}connected_to[i1]; | ||
49 | * // if (frame-{@literal >}end != NULL && | ||
50 | * // frame-{@literal >}end-{@literal >}connected_to[1] == frame-{@literal >}location && | ||
51 | * // frame-{@literal >}end-{@literal >}connected_to[0] == NULL) { | ||
52 | * // ... | ||
53 | * // } | ||
54 | * // if (frame-{@literal >}end != NULL && | ||
55 | * // frame-{@literal >}end-{@literal >}connected_to[0] == frame-{@literal >}location && | ||
56 | * // frame-{@literal >}end-{@literal >}connected_to[1] == NULL) { | ||
57 | * // ... | ||
58 | * // } | ||
59 | * Train(train); | ||
60 | * Train.location(train, location); | ||
61 | * Segment.connectedTo(location, end); | ||
62 | * } | ||
63 | * </pre></code> | ||
64 | * | ||
65 | * @see Matcher | ||
66 | * @see Match | ||
67 | * | ||
68 | */ | ||
69 | @SuppressWarnings("all") | ||
70 | public final class EndOfSiding_step_4 extends BaseGeneratedEMFQuerySpecification<EndOfSiding_step_4.Matcher> { | ||
71 | /** | ||
72 | * Pattern-specific match representation of the modes3.queries.endOfSiding_step_4 pattern, | ||
73 | * to be used in conjunction with {@link Matcher}. | ||
74 | * | ||
75 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
76 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
77 | * usable to represent a match of the pattern in the result of a query, | ||
78 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
79 | * | ||
80 | * @see Matcher | ||
81 | * | ||
82 | */ | ||
83 | public static abstract class Match extends BasePatternMatch { | ||
84 | private Train fTrain; | ||
85 | |||
86 | private Segment fLocation; | ||
87 | |||
88 | private Segment fEnd; | ||
89 | |||
90 | private static List<String> parameterNames = makeImmutableList("train", "location", "end"); | ||
91 | |||
92 | private Match(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
93 | this.fTrain = pTrain; | ||
94 | this.fLocation = pLocation; | ||
95 | this.fEnd = pEnd; | ||
96 | } | ||
97 | |||
98 | @Override | ||
99 | public Object get(final String parameterName) { | ||
100 | switch(parameterName) { | ||
101 | case "train": return this.fTrain; | ||
102 | case "location": return this.fLocation; | ||
103 | case "end": return this.fEnd; | ||
104 | default: return null; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | @Override | ||
109 | public Object get(final int index) { | ||
110 | switch(index) { | ||
111 | case 0: return this.fTrain; | ||
112 | case 1: return this.fLocation; | ||
113 | case 2: return this.fEnd; | ||
114 | default: return null; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | public Train getTrain() { | ||
119 | return this.fTrain; | ||
120 | } | ||
121 | |||
122 | public Segment getLocation() { | ||
123 | return this.fLocation; | ||
124 | } | ||
125 | |||
126 | public Segment getEnd() { | ||
127 | return this.fEnd; | ||
128 | } | ||
129 | |||
130 | @Override | ||
131 | public boolean set(final String parameterName, final Object newValue) { | ||
132 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
133 | if ("train".equals(parameterName) ) { | ||
134 | this.fTrain = (Train) newValue; | ||
135 | return true; | ||
136 | } | ||
137 | if ("location".equals(parameterName) ) { | ||
138 | this.fLocation = (Segment) newValue; | ||
139 | return true; | ||
140 | } | ||
141 | if ("end".equals(parameterName) ) { | ||
142 | this.fEnd = (Segment) newValue; | ||
143 | return true; | ||
144 | } | ||
145 | return false; | ||
146 | } | ||
147 | |||
148 | public void setTrain(final Train pTrain) { | ||
149 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
150 | this.fTrain = pTrain; | ||
151 | } | ||
152 | |||
153 | public void setLocation(final Segment pLocation) { | ||
154 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
155 | this.fLocation = pLocation; | ||
156 | } | ||
157 | |||
158 | public void setEnd(final Segment pEnd) { | ||
159 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
160 | this.fEnd = pEnd; | ||
161 | } | ||
162 | |||
163 | @Override | ||
164 | public String patternName() { | ||
165 | return "modes3.queries.endOfSiding_step_4"; | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public List<String> parameterNames() { | ||
170 | return EndOfSiding_step_4.Match.parameterNames; | ||
171 | } | ||
172 | |||
173 | @Override | ||
174 | public Object[] toArray() { | ||
175 | return new Object[]{fTrain, fLocation, fEnd}; | ||
176 | } | ||
177 | |||
178 | @Override | ||
179 | public EndOfSiding_step_4.Match toImmutable() { | ||
180 | return isMutable() ? newMatch(fTrain, fLocation, fEnd) : this; | ||
181 | } | ||
182 | |||
183 | @Override | ||
184 | public String prettyPrint() { | ||
185 | StringBuilder result = new StringBuilder(); | ||
186 | result.append("\"train\"=" + prettyPrintValue(fTrain) + ", "); | ||
187 | result.append("\"location\"=" + prettyPrintValue(fLocation) + ", "); | ||
188 | result.append("\"end\"=" + prettyPrintValue(fEnd)); | ||
189 | return result.toString(); | ||
190 | } | ||
191 | |||
192 | @Override | ||
193 | public int hashCode() { | ||
194 | return Objects.hash(fTrain, fLocation, fEnd); | ||
195 | } | ||
196 | |||
197 | @Override | ||
198 | public boolean equals(final Object obj) { | ||
199 | if (this == obj) | ||
200 | return true; | ||
201 | if (obj == null) { | ||
202 | return false; | ||
203 | } | ||
204 | if ((obj instanceof EndOfSiding_step_4.Match)) { | ||
205 | EndOfSiding_step_4.Match other = (EndOfSiding_step_4.Match) obj; | ||
206 | return Objects.equals(fTrain, other.fTrain) && Objects.equals(fLocation, other.fLocation) && Objects.equals(fEnd, other.fEnd); | ||
207 | } else { | ||
208 | // this should be infrequent | ||
209 | if (!(obj instanceof IPatternMatch)) { | ||
210 | return false; | ||
211 | } | ||
212 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
213 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | @Override | ||
218 | public EndOfSiding_step_4 specification() { | ||
219 | return EndOfSiding_step_4.instance(); | ||
220 | } | ||
221 | |||
222 | /** | ||
223 | * Returns an empty, mutable match. | ||
224 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
225 | * | ||
226 | * @return the empty match. | ||
227 | * | ||
228 | */ | ||
229 | public static EndOfSiding_step_4.Match newEmptyMatch() { | ||
230 | return new Mutable(null, null, null); | ||
231 | } | ||
232 | |||
233 | /** | ||
234 | * Returns a mutable (partial) match. | ||
235 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
236 | * | ||
237 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
238 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
239 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
240 | * @return the new, mutable (partial) match object. | ||
241 | * | ||
242 | */ | ||
243 | public static EndOfSiding_step_4.Match newMutableMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
244 | return new Mutable(pTrain, pLocation, pEnd); | ||
245 | } | ||
246 | |||
247 | /** | ||
248 | * Returns a new (partial) match. | ||
249 | * This can be used e.g. to call the matcher with a partial match. | ||
250 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
251 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
252 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
253 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
254 | * @return the (partial) match object. | ||
255 | * | ||
256 | */ | ||
257 | public static EndOfSiding_step_4.Match newMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
258 | return new Immutable(pTrain, pLocation, pEnd); | ||
259 | } | ||
260 | |||
261 | private static final class Mutable extends EndOfSiding_step_4.Match { | ||
262 | Mutable(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
263 | super(pTrain, pLocation, pEnd); | ||
264 | } | ||
265 | |||
266 | @Override | ||
267 | public boolean isMutable() { | ||
268 | return true; | ||
269 | } | ||
270 | } | ||
271 | |||
272 | private static final class Immutable extends EndOfSiding_step_4.Match { | ||
273 | Immutable(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
274 | super(pTrain, pLocation, pEnd); | ||
275 | } | ||
276 | |||
277 | @Override | ||
278 | public boolean isMutable() { | ||
279 | return false; | ||
280 | } | ||
281 | } | ||
282 | } | ||
283 | |||
284 | /** | ||
285 | * Generated pattern matcher API of the modes3.queries.endOfSiding_step_4 pattern, | ||
286 | * providing pattern-specific query methods. | ||
287 | * | ||
288 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
289 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
290 | * | ||
291 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
292 | * | ||
293 | * <p>Original source: | ||
294 | * <code><pre> | ||
295 | * pattern endOfSiding_step_4(in train : Train, in location : Segment, in end : Segment) { | ||
296 | * // frame-{@literal >}end = frame-{@literal >}location-{@literal >}connected_to[i1]; | ||
297 | * // if (frame-{@literal >}end != NULL && | ||
298 | * // frame-{@literal >}end-{@literal >}connected_to[1] == frame-{@literal >}location && | ||
299 | * // frame-{@literal >}end-{@literal >}connected_to[0] == NULL) { | ||
300 | * // ... | ||
301 | * // } | ||
302 | * // if (frame-{@literal >}end != NULL && | ||
303 | * // frame-{@literal >}end-{@literal >}connected_to[0] == frame-{@literal >}location && | ||
304 | * // frame-{@literal >}end-{@literal >}connected_to[1] == NULL) { | ||
305 | * // ... | ||
306 | * // } | ||
307 | * Train(train); | ||
308 | * Train.location(train, location); | ||
309 | * Segment.connectedTo(location, end); | ||
310 | * } | ||
311 | * </pre></code> | ||
312 | * | ||
313 | * @see Match | ||
314 | * @see EndOfSiding_step_4 | ||
315 | * | ||
316 | */ | ||
317 | public static class Matcher extends BaseMatcher<EndOfSiding_step_4.Match> { | ||
318 | /** | ||
319 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
320 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
321 | * | ||
322 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
323 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
324 | * | ||
325 | */ | ||
326 | public static EndOfSiding_step_4.Matcher on(final ViatraQueryEngine engine) { | ||
327 | // check if matcher already exists | ||
328 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
329 | if (matcher == null) { | ||
330 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
331 | } | ||
332 | return matcher; | ||
333 | } | ||
334 | |||
335 | /** | ||
336 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
337 | * @return an initialized matcher | ||
338 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
339 | * | ||
340 | */ | ||
341 | public static EndOfSiding_step_4.Matcher create() { | ||
342 | return new Matcher(); | ||
343 | } | ||
344 | |||
345 | private static final int POSITION_TRAIN = 0; | ||
346 | |||
347 | private static final int POSITION_LOCATION = 1; | ||
348 | |||
349 | private static final int POSITION_END = 2; | ||
350 | |||
351 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EndOfSiding_step_4.Matcher.class); | ||
352 | |||
353 | /** | ||
354 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
355 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
356 | * | ||
357 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
358 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
359 | * | ||
360 | */ | ||
361 | private Matcher() { | ||
362 | super(querySpecification()); | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
367 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
368 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
369 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
370 | * @return matches represented as a Match object. | ||
371 | * | ||
372 | */ | ||
373 | public Collection<EndOfSiding_step_4.Match> getAllMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
374 | return rawStreamAllMatches(new Object[]{pTrain, pLocation, pEnd}).collect(Collectors.toSet()); | ||
375 | } | ||
376 | |||
377 | /** | ||
378 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
379 | * </p> | ||
380 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
381 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
382 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
383 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
384 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
385 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
386 | * @return a stream of matches represented as a Match object. | ||
387 | * | ||
388 | */ | ||
389 | public Stream<EndOfSiding_step_4.Match> streamAllMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
390 | return rawStreamAllMatches(new Object[]{pTrain, pLocation, pEnd}); | ||
391 | } | ||
392 | |||
393 | /** | ||
394 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
395 | * Neither determinism nor randomness of selection is guaranteed. | ||
396 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
397 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
398 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
399 | * @return a match represented as a Match object, or null if no match is found. | ||
400 | * | ||
401 | */ | ||
402 | public Optional<EndOfSiding_step_4.Match> getOneArbitraryMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
403 | return rawGetOneArbitraryMatch(new Object[]{pTrain, pLocation, pEnd}); | ||
404 | } | ||
405 | |||
406 | /** | ||
407 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
408 | * under any possible substitution of the unspecified parameters (if any). | ||
409 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
410 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
411 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
412 | * @return true if the input is a valid (partial) match of the pattern. | ||
413 | * | ||
414 | */ | ||
415 | public boolean hasMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
416 | return rawHasMatch(new Object[]{pTrain, pLocation, pEnd}); | ||
417 | } | ||
418 | |||
419 | /** | ||
420 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
421 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
422 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
423 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
424 | * @return the number of pattern matches found. | ||
425 | * | ||
426 | */ | ||
427 | public int countMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
428 | return rawCountMatches(new Object[]{pTrain, pLocation, pEnd}); | ||
429 | } | ||
430 | |||
431 | /** | ||
432 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
433 | * Neither determinism nor randomness of selection is guaranteed. | ||
434 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
435 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
436 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
437 | * @param processor the action that will process the selected match. | ||
438 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
439 | * | ||
440 | */ | ||
441 | public boolean forOneArbitraryMatch(final Train pTrain, final Segment pLocation, final Segment pEnd, final Consumer<? super EndOfSiding_step_4.Match> processor) { | ||
442 | return rawForOneArbitraryMatch(new Object[]{pTrain, pLocation, pEnd}, processor); | ||
443 | } | ||
444 | |||
445 | /** | ||
446 | * Returns a new (partial) match. | ||
447 | * This can be used e.g. to call the matcher with a partial match. | ||
448 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
449 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
450 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
451 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
452 | * @return the (partial) match object. | ||
453 | * | ||
454 | */ | ||
455 | public EndOfSiding_step_4.Match newMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
456 | return EndOfSiding_step_4.Match.newMatch(pTrain, pLocation, pEnd); | ||
457 | } | ||
458 | |||
459 | /** | ||
460 | * Retrieve the set of values that occur in matches for train. | ||
461 | * @return the Set of all values or empty set if there are no matches | ||
462 | * | ||
463 | */ | ||
464 | protected Stream<Train> rawStreamAllValuesOftrain(final Object[] parameters) { | ||
465 | return rawStreamAllValues(POSITION_TRAIN, parameters).map(Train.class::cast); | ||
466 | } | ||
467 | |||
468 | /** | ||
469 | * Retrieve the set of values that occur in matches for train. | ||
470 | * @return the Set of all values or empty set if there are no matches | ||
471 | * | ||
472 | */ | ||
473 | public Set<Train> getAllValuesOftrain() { | ||
474 | return rawStreamAllValuesOftrain(emptyArray()).collect(Collectors.toSet()); | ||
475 | } | ||
476 | |||
477 | /** | ||
478 | * Retrieve the set of values that occur in matches for train. | ||
479 | * @return the Set of all values or empty set if there are no matches | ||
480 | * | ||
481 | */ | ||
482 | public Stream<Train> streamAllValuesOftrain() { | ||
483 | return rawStreamAllValuesOftrain(emptyArray()); | ||
484 | } | ||
485 | |||
486 | /** | ||
487 | * Retrieve the set of values that occur in matches for train. | ||
488 | * </p> | ||
489 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
490 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
491 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
492 | * | ||
493 | * @return the Stream of all values or empty set if there are no matches | ||
494 | * | ||
495 | */ | ||
496 | public Stream<Train> streamAllValuesOftrain(final EndOfSiding_step_4.Match partialMatch) { | ||
497 | return rawStreamAllValuesOftrain(partialMatch.toArray()); | ||
498 | } | ||
499 | |||
500 | /** | ||
501 | * Retrieve the set of values that occur in matches for train. | ||
502 | * </p> | ||
503 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
504 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
505 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
506 | * | ||
507 | * @return the Stream of all values or empty set if there are no matches | ||
508 | * | ||
509 | */ | ||
510 | public Stream<Train> streamAllValuesOftrain(final Segment pLocation, final Segment pEnd) { | ||
511 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation, pEnd}); | ||
512 | } | ||
513 | |||
514 | /** | ||
515 | * Retrieve the set of values that occur in matches for train. | ||
516 | * @return the Set of all values or empty set if there are no matches | ||
517 | * | ||
518 | */ | ||
519 | public Set<Train> getAllValuesOftrain(final EndOfSiding_step_4.Match partialMatch) { | ||
520 | return rawStreamAllValuesOftrain(partialMatch.toArray()).collect(Collectors.toSet()); | ||
521 | } | ||
522 | |||
523 | /** | ||
524 | * Retrieve the set of values that occur in matches for train. | ||
525 | * @return the Set of all values or empty set if there are no matches | ||
526 | * | ||
527 | */ | ||
528 | public Set<Train> getAllValuesOftrain(final Segment pLocation, final Segment pEnd) { | ||
529 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation, pEnd}).collect(Collectors.toSet()); | ||
530 | } | ||
531 | |||
532 | /** | ||
533 | * Retrieve the set of values that occur in matches for location. | ||
534 | * @return the Set of all values or empty set if there are no matches | ||
535 | * | ||
536 | */ | ||
537 | protected Stream<Segment> rawStreamAllValuesOflocation(final Object[] parameters) { | ||
538 | return rawStreamAllValues(POSITION_LOCATION, parameters).map(Segment.class::cast); | ||
539 | } | ||
540 | |||
541 | /** | ||
542 | * Retrieve the set of values that occur in matches for location. | ||
543 | * @return the Set of all values or empty set if there are no matches | ||
544 | * | ||
545 | */ | ||
546 | public Set<Segment> getAllValuesOflocation() { | ||
547 | return rawStreamAllValuesOflocation(emptyArray()).collect(Collectors.toSet()); | ||
548 | } | ||
549 | |||
550 | /** | ||
551 | * Retrieve the set of values that occur in matches for location. | ||
552 | * @return the Set of all values or empty set if there are no matches | ||
553 | * | ||
554 | */ | ||
555 | public Stream<Segment> streamAllValuesOflocation() { | ||
556 | return rawStreamAllValuesOflocation(emptyArray()); | ||
557 | } | ||
558 | |||
559 | /** | ||
560 | * Retrieve the set of values that occur in matches for location. | ||
561 | * </p> | ||
562 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
563 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
564 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
565 | * | ||
566 | * @return the Stream of all values or empty set if there are no matches | ||
567 | * | ||
568 | */ | ||
569 | public Stream<Segment> streamAllValuesOflocation(final EndOfSiding_step_4.Match partialMatch) { | ||
570 | return rawStreamAllValuesOflocation(partialMatch.toArray()); | ||
571 | } | ||
572 | |||
573 | /** | ||
574 | * Retrieve the set of values that occur in matches for location. | ||
575 | * </p> | ||
576 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
577 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
578 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
579 | * | ||
580 | * @return the Stream of all values or empty set if there are no matches | ||
581 | * | ||
582 | */ | ||
583 | public Stream<Segment> streamAllValuesOflocation(final Train pTrain, final Segment pEnd) { | ||
584 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null, pEnd}); | ||
585 | } | ||
586 | |||
587 | /** | ||
588 | * Retrieve the set of values that occur in matches for location. | ||
589 | * @return the Set of all values or empty set if there are no matches | ||
590 | * | ||
591 | */ | ||
592 | public Set<Segment> getAllValuesOflocation(final EndOfSiding_step_4.Match partialMatch) { | ||
593 | return rawStreamAllValuesOflocation(partialMatch.toArray()).collect(Collectors.toSet()); | ||
594 | } | ||
595 | |||
596 | /** | ||
597 | * Retrieve the set of values that occur in matches for location. | ||
598 | * @return the Set of all values or empty set if there are no matches | ||
599 | * | ||
600 | */ | ||
601 | public Set<Segment> getAllValuesOflocation(final Train pTrain, final Segment pEnd) { | ||
602 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null, pEnd}).collect(Collectors.toSet()); | ||
603 | } | ||
604 | |||
605 | /** | ||
606 | * Retrieve the set of values that occur in matches for end. | ||
607 | * @return the Set of all values or empty set if there are no matches | ||
608 | * | ||
609 | */ | ||
610 | protected Stream<Segment> rawStreamAllValuesOfend(final Object[] parameters) { | ||
611 | return rawStreamAllValues(POSITION_END, parameters).map(Segment.class::cast); | ||
612 | } | ||
613 | |||
614 | /** | ||
615 | * Retrieve the set of values that occur in matches for end. | ||
616 | * @return the Set of all values or empty set if there are no matches | ||
617 | * | ||
618 | */ | ||
619 | public Set<Segment> getAllValuesOfend() { | ||
620 | return rawStreamAllValuesOfend(emptyArray()).collect(Collectors.toSet()); | ||
621 | } | ||
622 | |||
623 | /** | ||
624 | * Retrieve the set of values that occur in matches for end. | ||
625 | * @return the Set of all values or empty set if there are no matches | ||
626 | * | ||
627 | */ | ||
628 | public Stream<Segment> streamAllValuesOfend() { | ||
629 | return rawStreamAllValuesOfend(emptyArray()); | ||
630 | } | ||
631 | |||
632 | /** | ||
633 | * Retrieve the set of values that occur in matches for end. | ||
634 | * </p> | ||
635 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
636 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
637 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
638 | * | ||
639 | * @return the Stream of all values or empty set if there are no matches | ||
640 | * | ||
641 | */ | ||
642 | public Stream<Segment> streamAllValuesOfend(final EndOfSiding_step_4.Match partialMatch) { | ||
643 | return rawStreamAllValuesOfend(partialMatch.toArray()); | ||
644 | } | ||
645 | |||
646 | /** | ||
647 | * Retrieve the set of values that occur in matches for end. | ||
648 | * </p> | ||
649 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
650 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
651 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
652 | * | ||
653 | * @return the Stream of all values or empty set if there are no matches | ||
654 | * | ||
655 | */ | ||
656 | public Stream<Segment> streamAllValuesOfend(final Train pTrain, final Segment pLocation) { | ||
657 | return rawStreamAllValuesOfend(new Object[]{pTrain, pLocation, null}); | ||
658 | } | ||
659 | |||
660 | /** | ||
661 | * Retrieve the set of values that occur in matches for end. | ||
662 | * @return the Set of all values or empty set if there are no matches | ||
663 | * | ||
664 | */ | ||
665 | public Set<Segment> getAllValuesOfend(final EndOfSiding_step_4.Match partialMatch) { | ||
666 | return rawStreamAllValuesOfend(partialMatch.toArray()).collect(Collectors.toSet()); | ||
667 | } | ||
668 | |||
669 | /** | ||
670 | * Retrieve the set of values that occur in matches for end. | ||
671 | * @return the Set of all values or empty set if there are no matches | ||
672 | * | ||
673 | */ | ||
674 | public Set<Segment> getAllValuesOfend(final Train pTrain, final Segment pLocation) { | ||
675 | return rawStreamAllValuesOfend(new Object[]{pTrain, pLocation, null}).collect(Collectors.toSet()); | ||
676 | } | ||
677 | |||
678 | @Override | ||
679 | protected EndOfSiding_step_4.Match tupleToMatch(final Tuple t) { | ||
680 | try { | ||
681 | return EndOfSiding_step_4.Match.newMatch((Train) t.get(POSITION_TRAIN), (Segment) t.get(POSITION_LOCATION), (Segment) t.get(POSITION_END)); | ||
682 | } catch(ClassCastException e) { | ||
683 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
684 | return null; | ||
685 | } | ||
686 | } | ||
687 | |||
688 | @Override | ||
689 | protected EndOfSiding_step_4.Match arrayToMatch(final Object[] match) { | ||
690 | try { | ||
691 | return EndOfSiding_step_4.Match.newMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION], (Segment) match[POSITION_END]); | ||
692 | } catch(ClassCastException e) { | ||
693 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
694 | return null; | ||
695 | } | ||
696 | } | ||
697 | |||
698 | @Override | ||
699 | protected EndOfSiding_step_4.Match arrayToMatchMutable(final Object[] match) { | ||
700 | try { | ||
701 | return EndOfSiding_step_4.Match.newMutableMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION], (Segment) match[POSITION_END]); | ||
702 | } catch(ClassCastException e) { | ||
703 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
704 | return null; | ||
705 | } | ||
706 | } | ||
707 | |||
708 | /** | ||
709 | * @return the singleton instance of the query specification of this pattern | ||
710 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
711 | * | ||
712 | */ | ||
713 | public static IQuerySpecification<EndOfSiding_step_4.Matcher> querySpecification() { | ||
714 | return EndOfSiding_step_4.instance(); | ||
715 | } | ||
716 | } | ||
717 | |||
718 | private EndOfSiding_step_4() { | ||
719 | super(GeneratedPQuery.INSTANCE); | ||
720 | } | ||
721 | |||
722 | /** | ||
723 | * @return the singleton instance of the query specification | ||
724 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
725 | * | ||
726 | */ | ||
727 | public static EndOfSiding_step_4 instance() { | ||
728 | try{ | ||
729 | return LazyHolder.INSTANCE; | ||
730 | } catch (ExceptionInInitializerError err) { | ||
731 | throw processInitializerError(err); | ||
732 | } | ||
733 | } | ||
734 | |||
735 | @Override | ||
736 | protected EndOfSiding_step_4.Matcher instantiate(final ViatraQueryEngine engine) { | ||
737 | return EndOfSiding_step_4.Matcher.on(engine); | ||
738 | } | ||
739 | |||
740 | @Override | ||
741 | public EndOfSiding_step_4.Matcher instantiate() { | ||
742 | return EndOfSiding_step_4.Matcher.create(); | ||
743 | } | ||
744 | |||
745 | @Override | ||
746 | public EndOfSiding_step_4.Match newEmptyMatch() { | ||
747 | return EndOfSiding_step_4.Match.newEmptyMatch(); | ||
748 | } | ||
749 | |||
750 | @Override | ||
751 | public EndOfSiding_step_4.Match newMatch(final Object... parameters) { | ||
752 | return EndOfSiding_step_4.Match.newMatch((modes3.Train) parameters[0], (modes3.Segment) parameters[1], (modes3.Segment) parameters[2]); | ||
753 | } | ||
754 | |||
755 | /** | ||
756 | * Inner class allowing the singleton instance of {@link EndOfSiding_step_4} to be created | ||
757 | * <b>not</b> at the class load time of the outer class, | ||
758 | * but rather at the first call to {@link EndOfSiding_step_4#instance()}. | ||
759 | * | ||
760 | * <p> This workaround is required e.g. to support recursion. | ||
761 | * | ||
762 | */ | ||
763 | private static class LazyHolder { | ||
764 | private static final EndOfSiding_step_4 INSTANCE = new EndOfSiding_step_4(); | ||
765 | |||
766 | /** | ||
767 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
768 | * This initialization order is required to support indirect recursion. | ||
769 | * | ||
770 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
771 | * | ||
772 | */ | ||
773 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
774 | |||
775 | public static Object ensureInitialized() { | ||
776 | INSTANCE.ensureInitializedInternal(); | ||
777 | return null; | ||
778 | } | ||
779 | } | ||
780 | |||
781 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
782 | private static final EndOfSiding_step_4.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
783 | |||
784 | private final PParameter parameter_train = new PParameter("train", "modes3.Train", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Train")), PParameterDirection.INOUT); | ||
785 | |||
786 | private final PParameter parameter_location = new PParameter("location", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
787 | |||
788 | private final PParameter parameter_end = new PParameter("end", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
789 | |||
790 | private final List<PParameter> parameters = Arrays.asList(parameter_train, parameter_location, parameter_end); | ||
791 | |||
792 | private GeneratedPQuery() { | ||
793 | super(PVisibility.PUBLIC); | ||
794 | } | ||
795 | |||
796 | @Override | ||
797 | public String getFullyQualifiedName() { | ||
798 | return "modes3.queries.endOfSiding_step_4"; | ||
799 | } | ||
800 | |||
801 | @Override | ||
802 | public List<String> getParameterNames() { | ||
803 | return Arrays.asList("train","location","end"); | ||
804 | } | ||
805 | |||
806 | @Override | ||
807 | public List<PParameter> getParameters() { | ||
808 | return parameters; | ||
809 | } | ||
810 | |||
811 | @Override | ||
812 | public Set<PBody> doGetContainedBodies() { | ||
813 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
814 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
815 | { | ||
816 | PBody body = new PBody(this); | ||
817 | PVariable var_train = body.getOrCreateVariableByName("train"); | ||
818 | PVariable var_location = body.getOrCreateVariableByName("location"); | ||
819 | PVariable var_end = body.getOrCreateVariableByName("end"); | ||
820 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
821 | new TypeConstraint(body, Tuples.flatTupleOf(var_location), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
822 | new TypeConstraint(body, Tuples.flatTupleOf(var_end), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
823 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
824 | new ExportedParameter(body, var_train, parameter_train), | ||
825 | new ExportedParameter(body, var_location, parameter_location), | ||
826 | new ExportedParameter(body, var_end, parameter_end) | ||
827 | )); | ||
828 | // // frame->end = frame->location->connected_to[i1];// if (frame->end != NULL &&// frame->end->connected_to[1] == frame->location &&// frame->end->connected_to[0] == NULL) {// ...// } // if (frame->end != NULL &&// frame->end->connected_to[0] == frame->location &&// frame->end->connected_to[1] == NULL) {// ...// } Train(train) | ||
829 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
830 | // Train.location(train, location) | ||
831 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
832 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
833 | new TypeConstraint(body, Tuples.flatTupleOf(var_train, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train", "location"))); | ||
834 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
835 | new Equality(body, var__virtual_0_, var_location); | ||
836 | // Segment.connectedTo(location, end) | ||
837 | new TypeConstraint(body, Tuples.flatTupleOf(var_location), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
838 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
839 | new TypeConstraint(body, Tuples.flatTupleOf(var_location, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
840 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
841 | new Equality(body, var__virtual_1_, var_end); | ||
842 | bodies.add(body); | ||
843 | } | ||
844 | return bodies; | ||
845 | } | ||
846 | } | ||
847 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_5.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_5.java new file mode 100644 index 00000000..48a2697d --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_5.java | |||
@@ -0,0 +1,841 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.Train; | ||
18 | import modes3.queries.MultipleConnectedTo; | ||
19 | import org.apache.log4j.Logger; | ||
20 | import org.eclipse.emf.ecore.EClass; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
42 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
43 | |||
44 | /** | ||
45 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
46 | * | ||
47 | * <p>Original source: | ||
48 | * <code><pre> | ||
49 | * pattern endOfSiding_step_5(in train : Train, in location : Segment, in end : Segment) { | ||
50 | * // results-{@literal >}matches[match_cntr].location = frame-{@literal >}location; | ||
51 | * // results-{@literal >}matches[match_cntr++].train = frame-{@literal >}train; | ||
52 | * // ...OR... | ||
53 | * // results-{@literal >}matches[match_cntr].location = frame-{@literal >}location; | ||
54 | * // results-{@literal >}matches[match_cntr++].train = frame-{@literal >}train; | ||
55 | * Train(train); | ||
56 | * Train.location(train, location); | ||
57 | * Segment.connectedTo(location, end); | ||
58 | * neg find multipleConnectedTo(end); | ||
59 | * } | ||
60 | * </pre></code> | ||
61 | * | ||
62 | * @see Matcher | ||
63 | * @see Match | ||
64 | * | ||
65 | */ | ||
66 | @SuppressWarnings("all") | ||
67 | public final class EndOfSiding_step_5 extends BaseGeneratedEMFQuerySpecification<EndOfSiding_step_5.Matcher> { | ||
68 | /** | ||
69 | * Pattern-specific match representation of the modes3.queries.endOfSiding_step_5 pattern, | ||
70 | * to be used in conjunction with {@link Matcher}. | ||
71 | * | ||
72 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
73 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
74 | * usable to represent a match of the pattern in the result of a query, | ||
75 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
76 | * | ||
77 | * @see Matcher | ||
78 | * | ||
79 | */ | ||
80 | public static abstract class Match extends BasePatternMatch { | ||
81 | private Train fTrain; | ||
82 | |||
83 | private Segment fLocation; | ||
84 | |||
85 | private Segment fEnd; | ||
86 | |||
87 | private static List<String> parameterNames = makeImmutableList("train", "location", "end"); | ||
88 | |||
89 | private Match(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
90 | this.fTrain = pTrain; | ||
91 | this.fLocation = pLocation; | ||
92 | this.fEnd = pEnd; | ||
93 | } | ||
94 | |||
95 | @Override | ||
96 | public Object get(final String parameterName) { | ||
97 | switch(parameterName) { | ||
98 | case "train": return this.fTrain; | ||
99 | case "location": return this.fLocation; | ||
100 | case "end": return this.fEnd; | ||
101 | default: return null; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public Object get(final int index) { | ||
107 | switch(index) { | ||
108 | case 0: return this.fTrain; | ||
109 | case 1: return this.fLocation; | ||
110 | case 2: return this.fEnd; | ||
111 | default: return null; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | public Train getTrain() { | ||
116 | return this.fTrain; | ||
117 | } | ||
118 | |||
119 | public Segment getLocation() { | ||
120 | return this.fLocation; | ||
121 | } | ||
122 | |||
123 | public Segment getEnd() { | ||
124 | return this.fEnd; | ||
125 | } | ||
126 | |||
127 | @Override | ||
128 | public boolean set(final String parameterName, final Object newValue) { | ||
129 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
130 | if ("train".equals(parameterName) ) { | ||
131 | this.fTrain = (Train) newValue; | ||
132 | return true; | ||
133 | } | ||
134 | if ("location".equals(parameterName) ) { | ||
135 | this.fLocation = (Segment) newValue; | ||
136 | return true; | ||
137 | } | ||
138 | if ("end".equals(parameterName) ) { | ||
139 | this.fEnd = (Segment) newValue; | ||
140 | return true; | ||
141 | } | ||
142 | return false; | ||
143 | } | ||
144 | |||
145 | public void setTrain(final Train pTrain) { | ||
146 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
147 | this.fTrain = pTrain; | ||
148 | } | ||
149 | |||
150 | public void setLocation(final Segment pLocation) { | ||
151 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
152 | this.fLocation = pLocation; | ||
153 | } | ||
154 | |||
155 | public void setEnd(final Segment pEnd) { | ||
156 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
157 | this.fEnd = pEnd; | ||
158 | } | ||
159 | |||
160 | @Override | ||
161 | public String patternName() { | ||
162 | return "modes3.queries.endOfSiding_step_5"; | ||
163 | } | ||
164 | |||
165 | @Override | ||
166 | public List<String> parameterNames() { | ||
167 | return EndOfSiding_step_5.Match.parameterNames; | ||
168 | } | ||
169 | |||
170 | @Override | ||
171 | public Object[] toArray() { | ||
172 | return new Object[]{fTrain, fLocation, fEnd}; | ||
173 | } | ||
174 | |||
175 | @Override | ||
176 | public EndOfSiding_step_5.Match toImmutable() { | ||
177 | return isMutable() ? newMatch(fTrain, fLocation, fEnd) : this; | ||
178 | } | ||
179 | |||
180 | @Override | ||
181 | public String prettyPrint() { | ||
182 | StringBuilder result = new StringBuilder(); | ||
183 | result.append("\"train\"=" + prettyPrintValue(fTrain) + ", "); | ||
184 | result.append("\"location\"=" + prettyPrintValue(fLocation) + ", "); | ||
185 | result.append("\"end\"=" + prettyPrintValue(fEnd)); | ||
186 | return result.toString(); | ||
187 | } | ||
188 | |||
189 | @Override | ||
190 | public int hashCode() { | ||
191 | return Objects.hash(fTrain, fLocation, fEnd); | ||
192 | } | ||
193 | |||
194 | @Override | ||
195 | public boolean equals(final Object obj) { | ||
196 | if (this == obj) | ||
197 | return true; | ||
198 | if (obj == null) { | ||
199 | return false; | ||
200 | } | ||
201 | if ((obj instanceof EndOfSiding_step_5.Match)) { | ||
202 | EndOfSiding_step_5.Match other = (EndOfSiding_step_5.Match) obj; | ||
203 | return Objects.equals(fTrain, other.fTrain) && Objects.equals(fLocation, other.fLocation) && Objects.equals(fEnd, other.fEnd); | ||
204 | } else { | ||
205 | // this should be infrequent | ||
206 | if (!(obj instanceof IPatternMatch)) { | ||
207 | return false; | ||
208 | } | ||
209 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
210 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
211 | } | ||
212 | } | ||
213 | |||
214 | @Override | ||
215 | public EndOfSiding_step_5 specification() { | ||
216 | return EndOfSiding_step_5.instance(); | ||
217 | } | ||
218 | |||
219 | /** | ||
220 | * Returns an empty, mutable match. | ||
221 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
222 | * | ||
223 | * @return the empty match. | ||
224 | * | ||
225 | */ | ||
226 | public static EndOfSiding_step_5.Match newEmptyMatch() { | ||
227 | return new Mutable(null, null, null); | ||
228 | } | ||
229 | |||
230 | /** | ||
231 | * Returns a mutable (partial) match. | ||
232 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
233 | * | ||
234 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
235 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
236 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
237 | * @return the new, mutable (partial) match object. | ||
238 | * | ||
239 | */ | ||
240 | public static EndOfSiding_step_5.Match newMutableMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
241 | return new Mutable(pTrain, pLocation, pEnd); | ||
242 | } | ||
243 | |||
244 | /** | ||
245 | * Returns a new (partial) match. | ||
246 | * This can be used e.g. to call the matcher with a partial match. | ||
247 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
248 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
249 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
250 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
251 | * @return the (partial) match object. | ||
252 | * | ||
253 | */ | ||
254 | public static EndOfSiding_step_5.Match newMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
255 | return new Immutable(pTrain, pLocation, pEnd); | ||
256 | } | ||
257 | |||
258 | private static final class Mutable extends EndOfSiding_step_5.Match { | ||
259 | Mutable(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
260 | super(pTrain, pLocation, pEnd); | ||
261 | } | ||
262 | |||
263 | @Override | ||
264 | public boolean isMutable() { | ||
265 | return true; | ||
266 | } | ||
267 | } | ||
268 | |||
269 | private static final class Immutable extends EndOfSiding_step_5.Match { | ||
270 | Immutable(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
271 | super(pTrain, pLocation, pEnd); | ||
272 | } | ||
273 | |||
274 | @Override | ||
275 | public boolean isMutable() { | ||
276 | return false; | ||
277 | } | ||
278 | } | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * Generated pattern matcher API of the modes3.queries.endOfSiding_step_5 pattern, | ||
283 | * providing pattern-specific query methods. | ||
284 | * | ||
285 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
286 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
287 | * | ||
288 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
289 | * | ||
290 | * <p>Original source: | ||
291 | * <code><pre> | ||
292 | * pattern endOfSiding_step_5(in train : Train, in location : Segment, in end : Segment) { | ||
293 | * // results-{@literal >}matches[match_cntr].location = frame-{@literal >}location; | ||
294 | * // results-{@literal >}matches[match_cntr++].train = frame-{@literal >}train; | ||
295 | * // ...OR... | ||
296 | * // results-{@literal >}matches[match_cntr].location = frame-{@literal >}location; | ||
297 | * // results-{@literal >}matches[match_cntr++].train = frame-{@literal >}train; | ||
298 | * Train(train); | ||
299 | * Train.location(train, location); | ||
300 | * Segment.connectedTo(location, end); | ||
301 | * neg find multipleConnectedTo(end); | ||
302 | * } | ||
303 | * </pre></code> | ||
304 | * | ||
305 | * @see Match | ||
306 | * @see EndOfSiding_step_5 | ||
307 | * | ||
308 | */ | ||
309 | public static class Matcher extends BaseMatcher<EndOfSiding_step_5.Match> { | ||
310 | /** | ||
311 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
312 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
313 | * | ||
314 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
315 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
316 | * | ||
317 | */ | ||
318 | public static EndOfSiding_step_5.Matcher on(final ViatraQueryEngine engine) { | ||
319 | // check if matcher already exists | ||
320 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
321 | if (matcher == null) { | ||
322 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
323 | } | ||
324 | return matcher; | ||
325 | } | ||
326 | |||
327 | /** | ||
328 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
329 | * @return an initialized matcher | ||
330 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
331 | * | ||
332 | */ | ||
333 | public static EndOfSiding_step_5.Matcher create() { | ||
334 | return new Matcher(); | ||
335 | } | ||
336 | |||
337 | private static final int POSITION_TRAIN = 0; | ||
338 | |||
339 | private static final int POSITION_LOCATION = 1; | ||
340 | |||
341 | private static final int POSITION_END = 2; | ||
342 | |||
343 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EndOfSiding_step_5.Matcher.class); | ||
344 | |||
345 | /** | ||
346 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
347 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
348 | * | ||
349 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
350 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
351 | * | ||
352 | */ | ||
353 | private Matcher() { | ||
354 | super(querySpecification()); | ||
355 | } | ||
356 | |||
357 | /** | ||
358 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
359 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
360 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
361 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
362 | * @return matches represented as a Match object. | ||
363 | * | ||
364 | */ | ||
365 | public Collection<EndOfSiding_step_5.Match> getAllMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
366 | return rawStreamAllMatches(new Object[]{pTrain, pLocation, pEnd}).collect(Collectors.toSet()); | ||
367 | } | ||
368 | |||
369 | /** | ||
370 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
371 | * </p> | ||
372 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
373 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
374 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
375 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
376 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
377 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
378 | * @return a stream of matches represented as a Match object. | ||
379 | * | ||
380 | */ | ||
381 | public Stream<EndOfSiding_step_5.Match> streamAllMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
382 | return rawStreamAllMatches(new Object[]{pTrain, pLocation, pEnd}); | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
387 | * Neither determinism nor randomness of selection is guaranteed. | ||
388 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
389 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
390 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
391 | * @return a match represented as a Match object, or null if no match is found. | ||
392 | * | ||
393 | */ | ||
394 | public Optional<EndOfSiding_step_5.Match> getOneArbitraryMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
395 | return rawGetOneArbitraryMatch(new Object[]{pTrain, pLocation, pEnd}); | ||
396 | } | ||
397 | |||
398 | /** | ||
399 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
400 | * under any possible substitution of the unspecified parameters (if any). | ||
401 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
402 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
403 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
404 | * @return true if the input is a valid (partial) match of the pattern. | ||
405 | * | ||
406 | */ | ||
407 | public boolean hasMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
408 | return rawHasMatch(new Object[]{pTrain, pLocation, pEnd}); | ||
409 | } | ||
410 | |||
411 | /** | ||
412 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
413 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
414 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
415 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
416 | * @return the number of pattern matches found. | ||
417 | * | ||
418 | */ | ||
419 | public int countMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
420 | return rawCountMatches(new Object[]{pTrain, pLocation, pEnd}); | ||
421 | } | ||
422 | |||
423 | /** | ||
424 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
425 | * Neither determinism nor randomness of selection is guaranteed. | ||
426 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
427 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
428 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
429 | * @param processor the action that will process the selected match. | ||
430 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
431 | * | ||
432 | */ | ||
433 | public boolean forOneArbitraryMatch(final Train pTrain, final Segment pLocation, final Segment pEnd, final Consumer<? super EndOfSiding_step_5.Match> processor) { | ||
434 | return rawForOneArbitraryMatch(new Object[]{pTrain, pLocation, pEnd}, processor); | ||
435 | } | ||
436 | |||
437 | /** | ||
438 | * Returns a new (partial) match. | ||
439 | * This can be used e.g. to call the matcher with a partial match. | ||
440 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
441 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
442 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
443 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
444 | * @return the (partial) match object. | ||
445 | * | ||
446 | */ | ||
447 | public EndOfSiding_step_5.Match newMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
448 | return EndOfSiding_step_5.Match.newMatch(pTrain, pLocation, pEnd); | ||
449 | } | ||
450 | |||
451 | /** | ||
452 | * Retrieve the set of values that occur in matches for train. | ||
453 | * @return the Set of all values or empty set if there are no matches | ||
454 | * | ||
455 | */ | ||
456 | protected Stream<Train> rawStreamAllValuesOftrain(final Object[] parameters) { | ||
457 | return rawStreamAllValues(POSITION_TRAIN, parameters).map(Train.class::cast); | ||
458 | } | ||
459 | |||
460 | /** | ||
461 | * Retrieve the set of values that occur in matches for train. | ||
462 | * @return the Set of all values or empty set if there are no matches | ||
463 | * | ||
464 | */ | ||
465 | public Set<Train> getAllValuesOftrain() { | ||
466 | return rawStreamAllValuesOftrain(emptyArray()).collect(Collectors.toSet()); | ||
467 | } | ||
468 | |||
469 | /** | ||
470 | * Retrieve the set of values that occur in matches for train. | ||
471 | * @return the Set of all values or empty set if there are no matches | ||
472 | * | ||
473 | */ | ||
474 | public Stream<Train> streamAllValuesOftrain() { | ||
475 | return rawStreamAllValuesOftrain(emptyArray()); | ||
476 | } | ||
477 | |||
478 | /** | ||
479 | * Retrieve the set of values that occur in matches for train. | ||
480 | * </p> | ||
481 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
482 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
483 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
484 | * | ||
485 | * @return the Stream of all values or empty set if there are no matches | ||
486 | * | ||
487 | */ | ||
488 | public Stream<Train> streamAllValuesOftrain(final EndOfSiding_step_5.Match partialMatch) { | ||
489 | return rawStreamAllValuesOftrain(partialMatch.toArray()); | ||
490 | } | ||
491 | |||
492 | /** | ||
493 | * Retrieve the set of values that occur in matches for train. | ||
494 | * </p> | ||
495 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
496 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
497 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
498 | * | ||
499 | * @return the Stream of all values or empty set if there are no matches | ||
500 | * | ||
501 | */ | ||
502 | public Stream<Train> streamAllValuesOftrain(final Segment pLocation, final Segment pEnd) { | ||
503 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation, pEnd}); | ||
504 | } | ||
505 | |||
506 | /** | ||
507 | * Retrieve the set of values that occur in matches for train. | ||
508 | * @return the Set of all values or empty set if there are no matches | ||
509 | * | ||
510 | */ | ||
511 | public Set<Train> getAllValuesOftrain(final EndOfSiding_step_5.Match partialMatch) { | ||
512 | return rawStreamAllValuesOftrain(partialMatch.toArray()).collect(Collectors.toSet()); | ||
513 | } | ||
514 | |||
515 | /** | ||
516 | * Retrieve the set of values that occur in matches for train. | ||
517 | * @return the Set of all values or empty set if there are no matches | ||
518 | * | ||
519 | */ | ||
520 | public Set<Train> getAllValuesOftrain(final Segment pLocation, final Segment pEnd) { | ||
521 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation, pEnd}).collect(Collectors.toSet()); | ||
522 | } | ||
523 | |||
524 | /** | ||
525 | * Retrieve the set of values that occur in matches for location. | ||
526 | * @return the Set of all values or empty set if there are no matches | ||
527 | * | ||
528 | */ | ||
529 | protected Stream<Segment> rawStreamAllValuesOflocation(final Object[] parameters) { | ||
530 | return rawStreamAllValues(POSITION_LOCATION, parameters).map(Segment.class::cast); | ||
531 | } | ||
532 | |||
533 | /** | ||
534 | * Retrieve the set of values that occur in matches for location. | ||
535 | * @return the Set of all values or empty set if there are no matches | ||
536 | * | ||
537 | */ | ||
538 | public Set<Segment> getAllValuesOflocation() { | ||
539 | return rawStreamAllValuesOflocation(emptyArray()).collect(Collectors.toSet()); | ||
540 | } | ||
541 | |||
542 | /** | ||
543 | * Retrieve the set of values that occur in matches for location. | ||
544 | * @return the Set of all values or empty set if there are no matches | ||
545 | * | ||
546 | */ | ||
547 | public Stream<Segment> streamAllValuesOflocation() { | ||
548 | return rawStreamAllValuesOflocation(emptyArray()); | ||
549 | } | ||
550 | |||
551 | /** | ||
552 | * Retrieve the set of values that occur in matches for location. | ||
553 | * </p> | ||
554 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
555 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
556 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
557 | * | ||
558 | * @return the Stream of all values or empty set if there are no matches | ||
559 | * | ||
560 | */ | ||
561 | public Stream<Segment> streamAllValuesOflocation(final EndOfSiding_step_5.Match partialMatch) { | ||
562 | return rawStreamAllValuesOflocation(partialMatch.toArray()); | ||
563 | } | ||
564 | |||
565 | /** | ||
566 | * Retrieve the set of values that occur in matches for location. | ||
567 | * </p> | ||
568 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
569 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
570 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
571 | * | ||
572 | * @return the Stream of all values or empty set if there are no matches | ||
573 | * | ||
574 | */ | ||
575 | public Stream<Segment> streamAllValuesOflocation(final Train pTrain, final Segment pEnd) { | ||
576 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null, pEnd}); | ||
577 | } | ||
578 | |||
579 | /** | ||
580 | * Retrieve the set of values that occur in matches for location. | ||
581 | * @return the Set of all values or empty set if there are no matches | ||
582 | * | ||
583 | */ | ||
584 | public Set<Segment> getAllValuesOflocation(final EndOfSiding_step_5.Match partialMatch) { | ||
585 | return rawStreamAllValuesOflocation(partialMatch.toArray()).collect(Collectors.toSet()); | ||
586 | } | ||
587 | |||
588 | /** | ||
589 | * Retrieve the set of values that occur in matches for location. | ||
590 | * @return the Set of all values or empty set if there are no matches | ||
591 | * | ||
592 | */ | ||
593 | public Set<Segment> getAllValuesOflocation(final Train pTrain, final Segment pEnd) { | ||
594 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null, pEnd}).collect(Collectors.toSet()); | ||
595 | } | ||
596 | |||
597 | /** | ||
598 | * Retrieve the set of values that occur in matches for end. | ||
599 | * @return the Set of all values or empty set if there are no matches | ||
600 | * | ||
601 | */ | ||
602 | protected Stream<Segment> rawStreamAllValuesOfend(final Object[] parameters) { | ||
603 | return rawStreamAllValues(POSITION_END, parameters).map(Segment.class::cast); | ||
604 | } | ||
605 | |||
606 | /** | ||
607 | * Retrieve the set of values that occur in matches for end. | ||
608 | * @return the Set of all values or empty set if there are no matches | ||
609 | * | ||
610 | */ | ||
611 | public Set<Segment> getAllValuesOfend() { | ||
612 | return rawStreamAllValuesOfend(emptyArray()).collect(Collectors.toSet()); | ||
613 | } | ||
614 | |||
615 | /** | ||
616 | * Retrieve the set of values that occur in matches for end. | ||
617 | * @return the Set of all values or empty set if there are no matches | ||
618 | * | ||
619 | */ | ||
620 | public Stream<Segment> streamAllValuesOfend() { | ||
621 | return rawStreamAllValuesOfend(emptyArray()); | ||
622 | } | ||
623 | |||
624 | /** | ||
625 | * Retrieve the set of values that occur in matches for end. | ||
626 | * </p> | ||
627 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
628 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
629 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
630 | * | ||
631 | * @return the Stream of all values or empty set if there are no matches | ||
632 | * | ||
633 | */ | ||
634 | public Stream<Segment> streamAllValuesOfend(final EndOfSiding_step_5.Match partialMatch) { | ||
635 | return rawStreamAllValuesOfend(partialMatch.toArray()); | ||
636 | } | ||
637 | |||
638 | /** | ||
639 | * Retrieve the set of values that occur in matches for end. | ||
640 | * </p> | ||
641 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
642 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
643 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
644 | * | ||
645 | * @return the Stream of all values or empty set if there are no matches | ||
646 | * | ||
647 | */ | ||
648 | public Stream<Segment> streamAllValuesOfend(final Train pTrain, final Segment pLocation) { | ||
649 | return rawStreamAllValuesOfend(new Object[]{pTrain, pLocation, null}); | ||
650 | } | ||
651 | |||
652 | /** | ||
653 | * Retrieve the set of values that occur in matches for end. | ||
654 | * @return the Set of all values or empty set if there are no matches | ||
655 | * | ||
656 | */ | ||
657 | public Set<Segment> getAllValuesOfend(final EndOfSiding_step_5.Match partialMatch) { | ||
658 | return rawStreamAllValuesOfend(partialMatch.toArray()).collect(Collectors.toSet()); | ||
659 | } | ||
660 | |||
661 | /** | ||
662 | * Retrieve the set of values that occur in matches for end. | ||
663 | * @return the Set of all values or empty set if there are no matches | ||
664 | * | ||
665 | */ | ||
666 | public Set<Segment> getAllValuesOfend(final Train pTrain, final Segment pLocation) { | ||
667 | return rawStreamAllValuesOfend(new Object[]{pTrain, pLocation, null}).collect(Collectors.toSet()); | ||
668 | } | ||
669 | |||
670 | @Override | ||
671 | protected EndOfSiding_step_5.Match tupleToMatch(final Tuple t) { | ||
672 | try { | ||
673 | return EndOfSiding_step_5.Match.newMatch((Train) t.get(POSITION_TRAIN), (Segment) t.get(POSITION_LOCATION), (Segment) t.get(POSITION_END)); | ||
674 | } catch(ClassCastException e) { | ||
675 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
676 | return null; | ||
677 | } | ||
678 | } | ||
679 | |||
680 | @Override | ||
681 | protected EndOfSiding_step_5.Match arrayToMatch(final Object[] match) { | ||
682 | try { | ||
683 | return EndOfSiding_step_5.Match.newMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION], (Segment) match[POSITION_END]); | ||
684 | } catch(ClassCastException e) { | ||
685 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
686 | return null; | ||
687 | } | ||
688 | } | ||
689 | |||
690 | @Override | ||
691 | protected EndOfSiding_step_5.Match arrayToMatchMutable(final Object[] match) { | ||
692 | try { | ||
693 | return EndOfSiding_step_5.Match.newMutableMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION], (Segment) match[POSITION_END]); | ||
694 | } catch(ClassCastException e) { | ||
695 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
696 | return null; | ||
697 | } | ||
698 | } | ||
699 | |||
700 | /** | ||
701 | * @return the singleton instance of the query specification of this pattern | ||
702 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
703 | * | ||
704 | */ | ||
705 | public static IQuerySpecification<EndOfSiding_step_5.Matcher> querySpecification() { | ||
706 | return EndOfSiding_step_5.instance(); | ||
707 | } | ||
708 | } | ||
709 | |||
710 | private EndOfSiding_step_5() { | ||
711 | super(GeneratedPQuery.INSTANCE); | ||
712 | } | ||
713 | |||
714 | /** | ||
715 | * @return the singleton instance of the query specification | ||
716 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
717 | * | ||
718 | */ | ||
719 | public static EndOfSiding_step_5 instance() { | ||
720 | try{ | ||
721 | return LazyHolder.INSTANCE; | ||
722 | } catch (ExceptionInInitializerError err) { | ||
723 | throw processInitializerError(err); | ||
724 | } | ||
725 | } | ||
726 | |||
727 | @Override | ||
728 | protected EndOfSiding_step_5.Matcher instantiate(final ViatraQueryEngine engine) { | ||
729 | return EndOfSiding_step_5.Matcher.on(engine); | ||
730 | } | ||
731 | |||
732 | @Override | ||
733 | public EndOfSiding_step_5.Matcher instantiate() { | ||
734 | return EndOfSiding_step_5.Matcher.create(); | ||
735 | } | ||
736 | |||
737 | @Override | ||
738 | public EndOfSiding_step_5.Match newEmptyMatch() { | ||
739 | return EndOfSiding_step_5.Match.newEmptyMatch(); | ||
740 | } | ||
741 | |||
742 | @Override | ||
743 | public EndOfSiding_step_5.Match newMatch(final Object... parameters) { | ||
744 | return EndOfSiding_step_5.Match.newMatch((modes3.Train) parameters[0], (modes3.Segment) parameters[1], (modes3.Segment) parameters[2]); | ||
745 | } | ||
746 | |||
747 | /** | ||
748 | * Inner class allowing the singleton instance of {@link EndOfSiding_step_5} to be created | ||
749 | * <b>not</b> at the class load time of the outer class, | ||
750 | * but rather at the first call to {@link EndOfSiding_step_5#instance()}. | ||
751 | * | ||
752 | * <p> This workaround is required e.g. to support recursion. | ||
753 | * | ||
754 | */ | ||
755 | private static class LazyHolder { | ||
756 | private static final EndOfSiding_step_5 INSTANCE = new EndOfSiding_step_5(); | ||
757 | |||
758 | /** | ||
759 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
760 | * This initialization order is required to support indirect recursion. | ||
761 | * | ||
762 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
763 | * | ||
764 | */ | ||
765 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
766 | |||
767 | public static Object ensureInitialized() { | ||
768 | INSTANCE.ensureInitializedInternal(); | ||
769 | return null; | ||
770 | } | ||
771 | } | ||
772 | |||
773 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
774 | private static final EndOfSiding_step_5.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
775 | |||
776 | private final PParameter parameter_train = new PParameter("train", "modes3.Train", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Train")), PParameterDirection.INOUT); | ||
777 | |||
778 | private final PParameter parameter_location = new PParameter("location", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
779 | |||
780 | private final PParameter parameter_end = new PParameter("end", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
781 | |||
782 | private final List<PParameter> parameters = Arrays.asList(parameter_train, parameter_location, parameter_end); | ||
783 | |||
784 | private GeneratedPQuery() { | ||
785 | super(PVisibility.PUBLIC); | ||
786 | } | ||
787 | |||
788 | @Override | ||
789 | public String getFullyQualifiedName() { | ||
790 | return "modes3.queries.endOfSiding_step_5"; | ||
791 | } | ||
792 | |||
793 | @Override | ||
794 | public List<String> getParameterNames() { | ||
795 | return Arrays.asList("train","location","end"); | ||
796 | } | ||
797 | |||
798 | @Override | ||
799 | public List<PParameter> getParameters() { | ||
800 | return parameters; | ||
801 | } | ||
802 | |||
803 | @Override | ||
804 | public Set<PBody> doGetContainedBodies() { | ||
805 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
806 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
807 | { | ||
808 | PBody body = new PBody(this); | ||
809 | PVariable var_train = body.getOrCreateVariableByName("train"); | ||
810 | PVariable var_location = body.getOrCreateVariableByName("location"); | ||
811 | PVariable var_end = body.getOrCreateVariableByName("end"); | ||
812 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
813 | new TypeConstraint(body, Tuples.flatTupleOf(var_location), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
814 | new TypeConstraint(body, Tuples.flatTupleOf(var_end), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
815 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
816 | new ExportedParameter(body, var_train, parameter_train), | ||
817 | new ExportedParameter(body, var_location, parameter_location), | ||
818 | new ExportedParameter(body, var_end, parameter_end) | ||
819 | )); | ||
820 | // // results->matches[match_cntr].location = frame->location;// results->matches[match_cntr++].train = frame->train;// ...OR...// results->matches[match_cntr].location = frame->location;// results->matches[match_cntr++].train = frame->train; Train(train) | ||
821 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
822 | // Train.location(train, location) | ||
823 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
824 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
825 | new TypeConstraint(body, Tuples.flatTupleOf(var_train, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train", "location"))); | ||
826 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
827 | new Equality(body, var__virtual_0_, var_location); | ||
828 | // Segment.connectedTo(location, end) | ||
829 | new TypeConstraint(body, Tuples.flatTupleOf(var_location), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
830 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
831 | new TypeConstraint(body, Tuples.flatTupleOf(var_location, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
832 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
833 | new Equality(body, var__virtual_1_, var_end); | ||
834 | // neg find multipleConnectedTo(end) | ||
835 | new NegativePatternCall(body, Tuples.flatTupleOf(var_end), MultipleConnectedTo.instance().getInternalQueryRepresentation()); | ||
836 | bodies.add(body); | ||
837 | } | ||
838 | return bodies; | ||
839 | } | ||
840 | } | ||
841 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/InputsOfTurnout.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/InputsOfTurnout.java new file mode 100644 index 00000000..2f2eea11 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/InputsOfTurnout.java | |||
@@ -0,0 +1,570 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Turnout; | ||
17 | import modes3.queries.Adjacent; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern inputsOfTurnout(T : Turnout) { | ||
48 | * find adjacent(I1, T); | ||
49 | * find adjacent(I2, T); | ||
50 | * find adjacent(I3, T); | ||
51 | * I1 != I2; | ||
52 | * I1 != I3; | ||
53 | * I2 != I3; | ||
54 | * } | ||
55 | * </pre></code> | ||
56 | * | ||
57 | * @see Matcher | ||
58 | * @see Match | ||
59 | * | ||
60 | */ | ||
61 | @SuppressWarnings("all") | ||
62 | public final class InputsOfTurnout extends BaseGeneratedEMFQuerySpecification<InputsOfTurnout.Matcher> { | ||
63 | /** | ||
64 | * Pattern-specific match representation of the modes3.queries.inputsOfTurnout pattern, | ||
65 | * to be used in conjunction with {@link Matcher}. | ||
66 | * | ||
67 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
68 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
69 | * usable to represent a match of the pattern in the result of a query, | ||
70 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
71 | * | ||
72 | * @see Matcher | ||
73 | * | ||
74 | */ | ||
75 | public static abstract class Match extends BasePatternMatch { | ||
76 | private Turnout fT; | ||
77 | |||
78 | private static List<String> parameterNames = makeImmutableList("T"); | ||
79 | |||
80 | private Match(final Turnout pT) { | ||
81 | this.fT = pT; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | switch(parameterName) { | ||
87 | case "T": return this.fT; | ||
88 | default: return null; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | @Override | ||
93 | public Object get(final int index) { | ||
94 | switch(index) { | ||
95 | case 0: return this.fT; | ||
96 | default: return null; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | public Turnout getT() { | ||
101 | return this.fT; | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public boolean set(final String parameterName, final Object newValue) { | ||
106 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
107 | if ("T".equals(parameterName) ) { | ||
108 | this.fT = (Turnout) newValue; | ||
109 | return true; | ||
110 | } | ||
111 | return false; | ||
112 | } | ||
113 | |||
114 | public void setT(final Turnout pT) { | ||
115 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
116 | this.fT = pT; | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public String patternName() { | ||
121 | return "modes3.queries.inputsOfTurnout"; | ||
122 | } | ||
123 | |||
124 | @Override | ||
125 | public List<String> parameterNames() { | ||
126 | return InputsOfTurnout.Match.parameterNames; | ||
127 | } | ||
128 | |||
129 | @Override | ||
130 | public Object[] toArray() { | ||
131 | return new Object[]{fT}; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public InputsOfTurnout.Match toImmutable() { | ||
136 | return isMutable() ? newMatch(fT) : this; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public String prettyPrint() { | ||
141 | StringBuilder result = new StringBuilder(); | ||
142 | result.append("\"T\"=" + prettyPrintValue(fT)); | ||
143 | return result.toString(); | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public int hashCode() { | ||
148 | return Objects.hash(fT); | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public boolean equals(final Object obj) { | ||
153 | if (this == obj) | ||
154 | return true; | ||
155 | if (obj == null) { | ||
156 | return false; | ||
157 | } | ||
158 | if ((obj instanceof InputsOfTurnout.Match)) { | ||
159 | InputsOfTurnout.Match other = (InputsOfTurnout.Match) obj; | ||
160 | return Objects.equals(fT, other.fT); | ||
161 | } else { | ||
162 | // this should be infrequent | ||
163 | if (!(obj instanceof IPatternMatch)) { | ||
164 | return false; | ||
165 | } | ||
166 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
167 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
168 | } | ||
169 | } | ||
170 | |||
171 | @Override | ||
172 | public InputsOfTurnout specification() { | ||
173 | return InputsOfTurnout.instance(); | ||
174 | } | ||
175 | |||
176 | /** | ||
177 | * Returns an empty, mutable match. | ||
178 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
179 | * | ||
180 | * @return the empty match. | ||
181 | * | ||
182 | */ | ||
183 | public static InputsOfTurnout.Match newEmptyMatch() { | ||
184 | return new Mutable(null); | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * Returns a mutable (partial) match. | ||
189 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
190 | * | ||
191 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
192 | * @return the new, mutable (partial) match object. | ||
193 | * | ||
194 | */ | ||
195 | public static InputsOfTurnout.Match newMutableMatch(final Turnout pT) { | ||
196 | return new Mutable(pT); | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * Returns a new (partial) match. | ||
201 | * This can be used e.g. to call the matcher with a partial match. | ||
202 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
203 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
204 | * @return the (partial) match object. | ||
205 | * | ||
206 | */ | ||
207 | public static InputsOfTurnout.Match newMatch(final Turnout pT) { | ||
208 | return new Immutable(pT); | ||
209 | } | ||
210 | |||
211 | private static final class Mutable extends InputsOfTurnout.Match { | ||
212 | Mutable(final Turnout pT) { | ||
213 | super(pT); | ||
214 | } | ||
215 | |||
216 | @Override | ||
217 | public boolean isMutable() { | ||
218 | return true; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | private static final class Immutable extends InputsOfTurnout.Match { | ||
223 | Immutable(final Turnout pT) { | ||
224 | super(pT); | ||
225 | } | ||
226 | |||
227 | @Override | ||
228 | public boolean isMutable() { | ||
229 | return false; | ||
230 | } | ||
231 | } | ||
232 | } | ||
233 | |||
234 | /** | ||
235 | * Generated pattern matcher API of the modes3.queries.inputsOfTurnout pattern, | ||
236 | * providing pattern-specific query methods. | ||
237 | * | ||
238 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
239 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
240 | * | ||
241 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
242 | * | ||
243 | * <p>Original source: | ||
244 | * <code><pre> | ||
245 | * pattern inputsOfTurnout(T : Turnout) { | ||
246 | * find adjacent(I1, T); | ||
247 | * find adjacent(I2, T); | ||
248 | * find adjacent(I3, T); | ||
249 | * I1 != I2; | ||
250 | * I1 != I3; | ||
251 | * I2 != I3; | ||
252 | * } | ||
253 | * </pre></code> | ||
254 | * | ||
255 | * @see Match | ||
256 | * @see InputsOfTurnout | ||
257 | * | ||
258 | */ | ||
259 | public static class Matcher extends BaseMatcher<InputsOfTurnout.Match> { | ||
260 | /** | ||
261 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
262 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
263 | * | ||
264 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
265 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
266 | * | ||
267 | */ | ||
268 | public static InputsOfTurnout.Matcher on(final ViatraQueryEngine engine) { | ||
269 | // check if matcher already exists | ||
270 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
271 | if (matcher == null) { | ||
272 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
273 | } | ||
274 | return matcher; | ||
275 | } | ||
276 | |||
277 | /** | ||
278 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
279 | * @return an initialized matcher | ||
280 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
281 | * | ||
282 | */ | ||
283 | public static InputsOfTurnout.Matcher create() { | ||
284 | return new Matcher(); | ||
285 | } | ||
286 | |||
287 | private static final int POSITION_T = 0; | ||
288 | |||
289 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(InputsOfTurnout.Matcher.class); | ||
290 | |||
291 | /** | ||
292 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
293 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
294 | * | ||
295 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
296 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
297 | * | ||
298 | */ | ||
299 | private Matcher() { | ||
300 | super(querySpecification()); | ||
301 | } | ||
302 | |||
303 | /** | ||
304 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
305 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
306 | * @return matches represented as a Match object. | ||
307 | * | ||
308 | */ | ||
309 | public Collection<InputsOfTurnout.Match> getAllMatches(final Turnout pT) { | ||
310 | return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); | ||
311 | } | ||
312 | |||
313 | /** | ||
314 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
315 | * </p> | ||
316 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
317 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
318 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
319 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
320 | * @return a stream of matches represented as a Match object. | ||
321 | * | ||
322 | */ | ||
323 | public Stream<InputsOfTurnout.Match> streamAllMatches(final Turnout pT) { | ||
324 | return rawStreamAllMatches(new Object[]{pT}); | ||
325 | } | ||
326 | |||
327 | /** | ||
328 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
329 | * Neither determinism nor randomness of selection is guaranteed. | ||
330 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
331 | * @return a match represented as a Match object, or null if no match is found. | ||
332 | * | ||
333 | */ | ||
334 | public Optional<InputsOfTurnout.Match> getOneArbitraryMatch(final Turnout pT) { | ||
335 | return rawGetOneArbitraryMatch(new Object[]{pT}); | ||
336 | } | ||
337 | |||
338 | /** | ||
339 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
340 | * under any possible substitution of the unspecified parameters (if any). | ||
341 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
342 | * @return true if the input is a valid (partial) match of the pattern. | ||
343 | * | ||
344 | */ | ||
345 | public boolean hasMatch(final Turnout pT) { | ||
346 | return rawHasMatch(new Object[]{pT}); | ||
347 | } | ||
348 | |||
349 | /** | ||
350 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
351 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
352 | * @return the number of pattern matches found. | ||
353 | * | ||
354 | */ | ||
355 | public int countMatches(final Turnout pT) { | ||
356 | return rawCountMatches(new Object[]{pT}); | ||
357 | } | ||
358 | |||
359 | /** | ||
360 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
361 | * Neither determinism nor randomness of selection is guaranteed. | ||
362 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
363 | * @param processor the action that will process the selected match. | ||
364 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
365 | * | ||
366 | */ | ||
367 | public boolean forOneArbitraryMatch(final Turnout pT, final Consumer<? super InputsOfTurnout.Match> processor) { | ||
368 | return rawForOneArbitraryMatch(new Object[]{pT}, processor); | ||
369 | } | ||
370 | |||
371 | /** | ||
372 | * Returns a new (partial) match. | ||
373 | * This can be used e.g. to call the matcher with a partial match. | ||
374 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
375 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
376 | * @return the (partial) match object. | ||
377 | * | ||
378 | */ | ||
379 | public InputsOfTurnout.Match newMatch(final Turnout pT) { | ||
380 | return InputsOfTurnout.Match.newMatch(pT); | ||
381 | } | ||
382 | |||
383 | /** | ||
384 | * Retrieve the set of values that occur in matches for T. | ||
385 | * @return the Set of all values or empty set if there are no matches | ||
386 | * | ||
387 | */ | ||
388 | protected Stream<Turnout> rawStreamAllValuesOfT(final Object[] parameters) { | ||
389 | return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); | ||
390 | } | ||
391 | |||
392 | /** | ||
393 | * Retrieve the set of values that occur in matches for T. | ||
394 | * @return the Set of all values or empty set if there are no matches | ||
395 | * | ||
396 | */ | ||
397 | public Set<Turnout> getAllValuesOfT() { | ||
398 | return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); | ||
399 | } | ||
400 | |||
401 | /** | ||
402 | * Retrieve the set of values that occur in matches for T. | ||
403 | * @return the Set of all values or empty set if there are no matches | ||
404 | * | ||
405 | */ | ||
406 | public Stream<Turnout> streamAllValuesOfT() { | ||
407 | return rawStreamAllValuesOfT(emptyArray()); | ||
408 | } | ||
409 | |||
410 | @Override | ||
411 | protected InputsOfTurnout.Match tupleToMatch(final Tuple t) { | ||
412 | try { | ||
413 | return InputsOfTurnout.Match.newMatch((Turnout) t.get(POSITION_T)); | ||
414 | } catch(ClassCastException e) { | ||
415 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
416 | return null; | ||
417 | } | ||
418 | } | ||
419 | |||
420 | @Override | ||
421 | protected InputsOfTurnout.Match arrayToMatch(final Object[] match) { | ||
422 | try { | ||
423 | return InputsOfTurnout.Match.newMatch((Turnout) match[POSITION_T]); | ||
424 | } catch(ClassCastException e) { | ||
425 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
426 | return null; | ||
427 | } | ||
428 | } | ||
429 | |||
430 | @Override | ||
431 | protected InputsOfTurnout.Match arrayToMatchMutable(final Object[] match) { | ||
432 | try { | ||
433 | return InputsOfTurnout.Match.newMutableMatch((Turnout) match[POSITION_T]); | ||
434 | } catch(ClassCastException e) { | ||
435 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
436 | return null; | ||
437 | } | ||
438 | } | ||
439 | |||
440 | /** | ||
441 | * @return the singleton instance of the query specification of this pattern | ||
442 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
443 | * | ||
444 | */ | ||
445 | public static IQuerySpecification<InputsOfTurnout.Matcher> querySpecification() { | ||
446 | return InputsOfTurnout.instance(); | ||
447 | } | ||
448 | } | ||
449 | |||
450 | private InputsOfTurnout() { | ||
451 | super(GeneratedPQuery.INSTANCE); | ||
452 | } | ||
453 | |||
454 | /** | ||
455 | * @return the singleton instance of the query specification | ||
456 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
457 | * | ||
458 | */ | ||
459 | public static InputsOfTurnout instance() { | ||
460 | try{ | ||
461 | return LazyHolder.INSTANCE; | ||
462 | } catch (ExceptionInInitializerError err) { | ||
463 | throw processInitializerError(err); | ||
464 | } | ||
465 | } | ||
466 | |||
467 | @Override | ||
468 | protected InputsOfTurnout.Matcher instantiate(final ViatraQueryEngine engine) { | ||
469 | return InputsOfTurnout.Matcher.on(engine); | ||
470 | } | ||
471 | |||
472 | @Override | ||
473 | public InputsOfTurnout.Matcher instantiate() { | ||
474 | return InputsOfTurnout.Matcher.create(); | ||
475 | } | ||
476 | |||
477 | @Override | ||
478 | public InputsOfTurnout.Match newEmptyMatch() { | ||
479 | return InputsOfTurnout.Match.newEmptyMatch(); | ||
480 | } | ||
481 | |||
482 | @Override | ||
483 | public InputsOfTurnout.Match newMatch(final Object... parameters) { | ||
484 | return InputsOfTurnout.Match.newMatch((modes3.Turnout) parameters[0]); | ||
485 | } | ||
486 | |||
487 | /** | ||
488 | * Inner class allowing the singleton instance of {@link InputsOfTurnout} to be created | ||
489 | * <b>not</b> at the class load time of the outer class, | ||
490 | * but rather at the first call to {@link InputsOfTurnout#instance()}. | ||
491 | * | ||
492 | * <p> This workaround is required e.g. to support recursion. | ||
493 | * | ||
494 | */ | ||
495 | private static class LazyHolder { | ||
496 | private static final InputsOfTurnout INSTANCE = new InputsOfTurnout(); | ||
497 | |||
498 | /** | ||
499 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
500 | * This initialization order is required to support indirect recursion. | ||
501 | * | ||
502 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
503 | * | ||
504 | */ | ||
505 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
506 | |||
507 | public static Object ensureInitialized() { | ||
508 | INSTANCE.ensureInitializedInternal(); | ||
509 | return null; | ||
510 | } | ||
511 | } | ||
512 | |||
513 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
514 | private static final InputsOfTurnout.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
515 | |||
516 | private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); | ||
517 | |||
518 | private final List<PParameter> parameters = Arrays.asList(parameter_T); | ||
519 | |||
520 | private GeneratedPQuery() { | ||
521 | super(PVisibility.PUBLIC); | ||
522 | } | ||
523 | |||
524 | @Override | ||
525 | public String getFullyQualifiedName() { | ||
526 | return "modes3.queries.inputsOfTurnout"; | ||
527 | } | ||
528 | |||
529 | @Override | ||
530 | public List<String> getParameterNames() { | ||
531 | return Arrays.asList("T"); | ||
532 | } | ||
533 | |||
534 | @Override | ||
535 | public List<PParameter> getParameters() { | ||
536 | return parameters; | ||
537 | } | ||
538 | |||
539 | @Override | ||
540 | public Set<PBody> doGetContainedBodies() { | ||
541 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
542 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
543 | { | ||
544 | PBody body = new PBody(this); | ||
545 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
546 | PVariable var_I1 = body.getOrCreateVariableByName("I1"); | ||
547 | PVariable var_I2 = body.getOrCreateVariableByName("I2"); | ||
548 | PVariable var_I3 = body.getOrCreateVariableByName("I3"); | ||
549 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
550 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
551 | new ExportedParameter(body, var_T, parameter_T) | ||
552 | )); | ||
553 | // find adjacent(I1, T) | ||
554 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I1, var_T), Adjacent.instance().getInternalQueryRepresentation()); | ||
555 | // find adjacent(I2, T) | ||
556 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I2, var_T), Adjacent.instance().getInternalQueryRepresentation()); | ||
557 | // find adjacent(I3, T) | ||
558 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I3, var_T), Adjacent.instance().getInternalQueryRepresentation()); | ||
559 | // I1 != I2 | ||
560 | new Inequality(body, var_I1, var_I2); | ||
561 | // I1 != I3 | ||
562 | new Inequality(body, var_I1, var_I3); | ||
563 | // I2 != I3 | ||
564 | new Inequality(body, var_I2, var_I3); | ||
565 | bodies.add(body); | ||
566 | } | ||
567 | return bodies; | ||
568 | } | ||
569 | } | ||
570 | } | ||
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..d1238d61 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Modes3Queries.java | |||
@@ -0,0 +1,405 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import modes3.queries.Adjacent; | ||
7 | import modes3.queries.CloseTrains_step_2; | ||
8 | import modes3.queries.CloseTrains_step_3; | ||
9 | import modes3.queries.CloseTrains_step_4; | ||
10 | import modes3.queries.CloseTrains_step_5; | ||
11 | import modes3.queries.CloseTrains_step_6; | ||
12 | import modes3.queries.CloseTrains_step_7; | ||
13 | import modes3.queries.ConnectedSegmentsDirected; | ||
14 | import modes3.queries.ConnectedTo; | ||
15 | import modes3.queries.ConnectedToNotSymmetric; | ||
16 | import modes3.queries.ConnectedToReflexive; | ||
17 | import modes3.queries.EndOfSiding_step_2; | ||
18 | import modes3.queries.EndOfSiding_step_3; | ||
19 | import modes3.queries.EndOfSiding_step_4; | ||
20 | import modes3.queries.EndOfSiding_step_5; | ||
21 | import modes3.queries.InputsOfTurnout; | ||
22 | import modes3.queries.MisalignedTurnout_step_2; | ||
23 | import modes3.queries.MisalignedTurnout_step_3; | ||
24 | import modes3.queries.MisalignedTurnout_step_4; | ||
25 | import modes3.queries.MisalignedTurnout_step_5; | ||
26 | import modes3.queries.MultipleConnectedTo; | ||
27 | import modes3.queries.Output; | ||
28 | import modes3.queries.OutputReflexive; | ||
29 | import modes3.queries.Reachable; | ||
30 | import modes3.queries.TooFewInputsOfTurnout; | ||
31 | import modes3.queries.TooManyInputsOfSegment; | ||
32 | import modes3.queries.TooManyInputsOfTurnout; | ||
33 | import modes3.queries.TrainLocations_step_2; | ||
34 | import modes3.queries.TrainLocations_step_3; | ||
35 | import modes3.queries.TurnoutConnectedToBothOutputs; | ||
36 | import modes3.queries.TurnoutOutput; | ||
37 | import modes3.queries.TurnoutOutputsAreSame; | ||
38 | import modes3.queries.Unreachable; | ||
39 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
40 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; | ||
41 | |||
42 | /** | ||
43 | * A pattern group formed of all public patterns defined in Modes3Queries.vql. | ||
44 | * | ||
45 | * <p>Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare | ||
46 | * a VIATRA Query engine for matching all patterns originally defined in file Modes3Queries.vql, | ||
47 | * in order to achieve better performance than one-by-one on-demand matcher initialization. | ||
48 | * | ||
49 | * <p> From package modes3.queries, the group contains the definition of the following patterns: <ul> | ||
50 | * <li>connectedTo</li> | ||
51 | * <li>connectedToNotSymmetric</li> | ||
52 | * <li>connectedToReflexive</li> | ||
53 | * <li>turnoutOutput</li> | ||
54 | * <li>outputReflexive</li> | ||
55 | * <li>turnoutOutputsAreSame</li> | ||
56 | * <li>output</li> | ||
57 | * <li>tooManyInputsOfSegment</li> | ||
58 | * <li>turnoutConnectedToBothOutputs</li> | ||
59 | * <li>adjacent</li> | ||
60 | * <li>tooManyInputsOfTurnout</li> | ||
61 | * <li>inputsOfTurnout</li> | ||
62 | * <li>tooFewInputsOfTurnout</li> | ||
63 | * <li>reachable</li> | ||
64 | * <li>unreachable</li> | ||
65 | * <li>closeTrains_step_2</li> | ||
66 | * <li>closeTrains_step_3</li> | ||
67 | * <li>closeTrains_step_4</li> | ||
68 | * <li>closeTrains_step_5</li> | ||
69 | * <li>closeTrains_step_6</li> | ||
70 | * <li>closeTrains_step_7</li> | ||
71 | * <li>trainLocations_step_2</li> | ||
72 | * <li>trainLocations_step_3</li> | ||
73 | * <li>misalignedTurnout_step_2</li> | ||
74 | * <li>misalignedTurnout_step_3</li> | ||
75 | * <li>misalignedTurnout_step_4</li> | ||
76 | * <li>misalignedTurnout_step_5</li> | ||
77 | * <li>connectedSegmentsDirected</li> | ||
78 | * <li>endOfSiding_step_2</li> | ||
79 | * <li>endOfSiding_step_3</li> | ||
80 | * <li>endOfSiding_step_4</li> | ||
81 | * <li>endOfSiding_step_5</li> | ||
82 | * <li>multipleConnectedTo</li> | ||
83 | * </ul> | ||
84 | * | ||
85 | * @see IQueryGroup | ||
86 | * | ||
87 | */ | ||
88 | @SuppressWarnings("all") | ||
89 | public final class Modes3Queries extends BaseGeneratedPatternGroup { | ||
90 | /** | ||
91 | * Access the pattern group. | ||
92 | * | ||
93 | * @return the singleton instance of the group | ||
94 | * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications | ||
95 | * | ||
96 | */ | ||
97 | public static Modes3Queries instance() { | ||
98 | if (INSTANCE == null) { | ||
99 | INSTANCE = new Modes3Queries(); | ||
100 | } | ||
101 | return INSTANCE; | ||
102 | } | ||
103 | |||
104 | private static Modes3Queries INSTANCE; | ||
105 | |||
106 | private Modes3Queries() { | ||
107 | querySpecifications.add(ConnectedTo.instance()); | ||
108 | querySpecifications.add(ConnectedToNotSymmetric.instance()); | ||
109 | querySpecifications.add(ConnectedToReflexive.instance()); | ||
110 | querySpecifications.add(TurnoutOutput.instance()); | ||
111 | querySpecifications.add(OutputReflexive.instance()); | ||
112 | querySpecifications.add(TurnoutOutputsAreSame.instance()); | ||
113 | querySpecifications.add(Output.instance()); | ||
114 | querySpecifications.add(TooManyInputsOfSegment.instance()); | ||
115 | querySpecifications.add(TurnoutConnectedToBothOutputs.instance()); | ||
116 | querySpecifications.add(Adjacent.instance()); | ||
117 | querySpecifications.add(TooManyInputsOfTurnout.instance()); | ||
118 | querySpecifications.add(InputsOfTurnout.instance()); | ||
119 | querySpecifications.add(TooFewInputsOfTurnout.instance()); | ||
120 | querySpecifications.add(Reachable.instance()); | ||
121 | querySpecifications.add(Unreachable.instance()); | ||
122 | querySpecifications.add(CloseTrains_step_2.instance()); | ||
123 | querySpecifications.add(CloseTrains_step_3.instance()); | ||
124 | querySpecifications.add(CloseTrains_step_4.instance()); | ||
125 | querySpecifications.add(CloseTrains_step_5.instance()); | ||
126 | querySpecifications.add(CloseTrains_step_6.instance()); | ||
127 | querySpecifications.add(CloseTrains_step_7.instance()); | ||
128 | querySpecifications.add(TrainLocations_step_2.instance()); | ||
129 | querySpecifications.add(TrainLocations_step_3.instance()); | ||
130 | querySpecifications.add(MisalignedTurnout_step_2.instance()); | ||
131 | querySpecifications.add(MisalignedTurnout_step_3.instance()); | ||
132 | querySpecifications.add(MisalignedTurnout_step_4.instance()); | ||
133 | querySpecifications.add(MisalignedTurnout_step_5.instance()); | ||
134 | querySpecifications.add(ConnectedSegmentsDirected.instance()); | ||
135 | querySpecifications.add(EndOfSiding_step_2.instance()); | ||
136 | querySpecifications.add(EndOfSiding_step_3.instance()); | ||
137 | querySpecifications.add(EndOfSiding_step_4.instance()); | ||
138 | querySpecifications.add(EndOfSiding_step_5.instance()); | ||
139 | querySpecifications.add(MultipleConnectedTo.instance()); | ||
140 | } | ||
141 | |||
142 | public ConnectedTo getConnectedTo() { | ||
143 | return ConnectedTo.instance(); | ||
144 | } | ||
145 | |||
146 | public ConnectedTo.Matcher getConnectedTo(final ViatraQueryEngine engine) { | ||
147 | return ConnectedTo.Matcher.on(engine); | ||
148 | } | ||
149 | |||
150 | public ConnectedToNotSymmetric getConnectedToNotSymmetric() { | ||
151 | return ConnectedToNotSymmetric.instance(); | ||
152 | } | ||
153 | |||
154 | public ConnectedToNotSymmetric.Matcher getConnectedToNotSymmetric(final ViatraQueryEngine engine) { | ||
155 | return ConnectedToNotSymmetric.Matcher.on(engine); | ||
156 | } | ||
157 | |||
158 | public ConnectedToReflexive getConnectedToReflexive() { | ||
159 | return ConnectedToReflexive.instance(); | ||
160 | } | ||
161 | |||
162 | public ConnectedToReflexive.Matcher getConnectedToReflexive(final ViatraQueryEngine engine) { | ||
163 | return ConnectedToReflexive.Matcher.on(engine); | ||
164 | } | ||
165 | |||
166 | public TurnoutOutput getTurnoutOutput() { | ||
167 | return TurnoutOutput.instance(); | ||
168 | } | ||
169 | |||
170 | public TurnoutOutput.Matcher getTurnoutOutput(final ViatraQueryEngine engine) { | ||
171 | return TurnoutOutput.Matcher.on(engine); | ||
172 | } | ||
173 | |||
174 | public OutputReflexive getOutputReflexive() { | ||
175 | return OutputReflexive.instance(); | ||
176 | } | ||
177 | |||
178 | public OutputReflexive.Matcher getOutputReflexive(final ViatraQueryEngine engine) { | ||
179 | return OutputReflexive.Matcher.on(engine); | ||
180 | } | ||
181 | |||
182 | public TurnoutOutputsAreSame getTurnoutOutputsAreSame() { | ||
183 | return TurnoutOutputsAreSame.instance(); | ||
184 | } | ||
185 | |||
186 | public TurnoutOutputsAreSame.Matcher getTurnoutOutputsAreSame(final ViatraQueryEngine engine) { | ||
187 | return TurnoutOutputsAreSame.Matcher.on(engine); | ||
188 | } | ||
189 | |||
190 | public Output getOutput() { | ||
191 | return Output.instance(); | ||
192 | } | ||
193 | |||
194 | public Output.Matcher getOutput(final ViatraQueryEngine engine) { | ||
195 | return Output.Matcher.on(engine); | ||
196 | } | ||
197 | |||
198 | public TooManyInputsOfSegment getTooManyInputsOfSegment() { | ||
199 | return TooManyInputsOfSegment.instance(); | ||
200 | } | ||
201 | |||
202 | public TooManyInputsOfSegment.Matcher getTooManyInputsOfSegment(final ViatraQueryEngine engine) { | ||
203 | return TooManyInputsOfSegment.Matcher.on(engine); | ||
204 | } | ||
205 | |||
206 | public TurnoutConnectedToBothOutputs getTurnoutConnectedToBothOutputs() { | ||
207 | return TurnoutConnectedToBothOutputs.instance(); | ||
208 | } | ||
209 | |||
210 | public TurnoutConnectedToBothOutputs.Matcher getTurnoutConnectedToBothOutputs(final ViatraQueryEngine engine) { | ||
211 | return TurnoutConnectedToBothOutputs.Matcher.on(engine); | ||
212 | } | ||
213 | |||
214 | public Adjacent getAdjacent() { | ||
215 | return Adjacent.instance(); | ||
216 | } | ||
217 | |||
218 | public Adjacent.Matcher getAdjacent(final ViatraQueryEngine engine) { | ||
219 | return Adjacent.Matcher.on(engine); | ||
220 | } | ||
221 | |||
222 | public TooManyInputsOfTurnout getTooManyInputsOfTurnout() { | ||
223 | return TooManyInputsOfTurnout.instance(); | ||
224 | } | ||
225 | |||
226 | public TooManyInputsOfTurnout.Matcher getTooManyInputsOfTurnout(final ViatraQueryEngine engine) { | ||
227 | return TooManyInputsOfTurnout.Matcher.on(engine); | ||
228 | } | ||
229 | |||
230 | public InputsOfTurnout getInputsOfTurnout() { | ||
231 | return InputsOfTurnout.instance(); | ||
232 | } | ||
233 | |||
234 | public InputsOfTurnout.Matcher getInputsOfTurnout(final ViatraQueryEngine engine) { | ||
235 | return InputsOfTurnout.Matcher.on(engine); | ||
236 | } | ||
237 | |||
238 | public TooFewInputsOfTurnout getTooFewInputsOfTurnout() { | ||
239 | return TooFewInputsOfTurnout.instance(); | ||
240 | } | ||
241 | |||
242 | public TooFewInputsOfTurnout.Matcher getTooFewInputsOfTurnout(final ViatraQueryEngine engine) { | ||
243 | return TooFewInputsOfTurnout.Matcher.on(engine); | ||
244 | } | ||
245 | |||
246 | public Reachable getReachable() { | ||
247 | return Reachable.instance(); | ||
248 | } | ||
249 | |||
250 | public Reachable.Matcher getReachable(final ViatraQueryEngine engine) { | ||
251 | return Reachable.Matcher.on(engine); | ||
252 | } | ||
253 | |||
254 | public Unreachable getUnreachable() { | ||
255 | return Unreachable.instance(); | ||
256 | } | ||
257 | |||
258 | public Unreachable.Matcher getUnreachable(final ViatraQueryEngine engine) { | ||
259 | return Unreachable.Matcher.on(engine); | ||
260 | } | ||
261 | |||
262 | public CloseTrains_step_2 getCloseTrains_step_2() { | ||
263 | return CloseTrains_step_2.instance(); | ||
264 | } | ||
265 | |||
266 | public CloseTrains_step_2.Matcher getCloseTrains_step_2(final ViatraQueryEngine engine) { | ||
267 | return CloseTrains_step_2.Matcher.on(engine); | ||
268 | } | ||
269 | |||
270 | public CloseTrains_step_3 getCloseTrains_step_3() { | ||
271 | return CloseTrains_step_3.instance(); | ||
272 | } | ||
273 | |||
274 | public CloseTrains_step_3.Matcher getCloseTrains_step_3(final ViatraQueryEngine engine) { | ||
275 | return CloseTrains_step_3.Matcher.on(engine); | ||
276 | } | ||
277 | |||
278 | public CloseTrains_step_4 getCloseTrains_step_4() { | ||
279 | return CloseTrains_step_4.instance(); | ||
280 | } | ||
281 | |||
282 | public CloseTrains_step_4.Matcher getCloseTrains_step_4(final ViatraQueryEngine engine) { | ||
283 | return CloseTrains_step_4.Matcher.on(engine); | ||
284 | } | ||
285 | |||
286 | public CloseTrains_step_5 getCloseTrains_step_5() { | ||
287 | return CloseTrains_step_5.instance(); | ||
288 | } | ||
289 | |||
290 | public CloseTrains_step_5.Matcher getCloseTrains_step_5(final ViatraQueryEngine engine) { | ||
291 | return CloseTrains_step_5.Matcher.on(engine); | ||
292 | } | ||
293 | |||
294 | public CloseTrains_step_6 getCloseTrains_step_6() { | ||
295 | return CloseTrains_step_6.instance(); | ||
296 | } | ||
297 | |||
298 | public CloseTrains_step_6.Matcher getCloseTrains_step_6(final ViatraQueryEngine engine) { | ||
299 | return CloseTrains_step_6.Matcher.on(engine); | ||
300 | } | ||
301 | |||
302 | public CloseTrains_step_7 getCloseTrains_step_7() { | ||
303 | return CloseTrains_step_7.instance(); | ||
304 | } | ||
305 | |||
306 | public CloseTrains_step_7.Matcher getCloseTrains_step_7(final ViatraQueryEngine engine) { | ||
307 | return CloseTrains_step_7.Matcher.on(engine); | ||
308 | } | ||
309 | |||
310 | public TrainLocations_step_2 getTrainLocations_step_2() { | ||
311 | return TrainLocations_step_2.instance(); | ||
312 | } | ||
313 | |||
314 | public TrainLocations_step_2.Matcher getTrainLocations_step_2(final ViatraQueryEngine engine) { | ||
315 | return TrainLocations_step_2.Matcher.on(engine); | ||
316 | } | ||
317 | |||
318 | public TrainLocations_step_3 getTrainLocations_step_3() { | ||
319 | return TrainLocations_step_3.instance(); | ||
320 | } | ||
321 | |||
322 | public TrainLocations_step_3.Matcher getTrainLocations_step_3(final ViatraQueryEngine engine) { | ||
323 | return TrainLocations_step_3.Matcher.on(engine); | ||
324 | } | ||
325 | |||
326 | public MisalignedTurnout_step_2 getMisalignedTurnout_step_2() { | ||
327 | return MisalignedTurnout_step_2.instance(); | ||
328 | } | ||
329 | |||
330 | public MisalignedTurnout_step_2.Matcher getMisalignedTurnout_step_2(final ViatraQueryEngine engine) { | ||
331 | return MisalignedTurnout_step_2.Matcher.on(engine); | ||
332 | } | ||
333 | |||
334 | public MisalignedTurnout_step_3 getMisalignedTurnout_step_3() { | ||
335 | return MisalignedTurnout_step_3.instance(); | ||
336 | } | ||
337 | |||
338 | public MisalignedTurnout_step_3.Matcher getMisalignedTurnout_step_3(final ViatraQueryEngine engine) { | ||
339 | return MisalignedTurnout_step_3.Matcher.on(engine); | ||
340 | } | ||
341 | |||
342 | public MisalignedTurnout_step_4 getMisalignedTurnout_step_4() { | ||
343 | return MisalignedTurnout_step_4.instance(); | ||
344 | } | ||
345 | |||
346 | public MisalignedTurnout_step_4.Matcher getMisalignedTurnout_step_4(final ViatraQueryEngine engine) { | ||
347 | return MisalignedTurnout_step_4.Matcher.on(engine); | ||
348 | } | ||
349 | |||
350 | public MisalignedTurnout_step_5 getMisalignedTurnout_step_5() { | ||
351 | return MisalignedTurnout_step_5.instance(); | ||
352 | } | ||
353 | |||
354 | public MisalignedTurnout_step_5.Matcher getMisalignedTurnout_step_5(final ViatraQueryEngine engine) { | ||
355 | return MisalignedTurnout_step_5.Matcher.on(engine); | ||
356 | } | ||
357 | |||
358 | public ConnectedSegmentsDirected getConnectedSegmentsDirected() { | ||
359 | return ConnectedSegmentsDirected.instance(); | ||
360 | } | ||
361 | |||
362 | public ConnectedSegmentsDirected.Matcher getConnectedSegmentsDirected(final ViatraQueryEngine engine) { | ||
363 | return ConnectedSegmentsDirected.Matcher.on(engine); | ||
364 | } | ||
365 | |||
366 | public EndOfSiding_step_2 getEndOfSiding_step_2() { | ||
367 | return EndOfSiding_step_2.instance(); | ||
368 | } | ||
369 | |||
370 | public EndOfSiding_step_2.Matcher getEndOfSiding_step_2(final ViatraQueryEngine engine) { | ||
371 | return EndOfSiding_step_2.Matcher.on(engine); | ||
372 | } | ||
373 | |||
374 | public EndOfSiding_step_3 getEndOfSiding_step_3() { | ||
375 | return EndOfSiding_step_3.instance(); | ||
376 | } | ||
377 | |||
378 | public EndOfSiding_step_3.Matcher getEndOfSiding_step_3(final ViatraQueryEngine engine) { | ||
379 | return EndOfSiding_step_3.Matcher.on(engine); | ||
380 | } | ||
381 | |||
382 | public EndOfSiding_step_4 getEndOfSiding_step_4() { | ||
383 | return EndOfSiding_step_4.instance(); | ||
384 | } | ||
385 | |||
386 | public EndOfSiding_step_4.Matcher getEndOfSiding_step_4(final ViatraQueryEngine engine) { | ||
387 | return EndOfSiding_step_4.Matcher.on(engine); | ||
388 | } | ||
389 | |||
390 | public EndOfSiding_step_5 getEndOfSiding_step_5() { | ||
391 | return EndOfSiding_step_5.instance(); | ||
392 | } | ||
393 | |||
394 | public EndOfSiding_step_5.Matcher getEndOfSiding_step_5(final ViatraQueryEngine engine) { | ||
395 | return EndOfSiding_step_5.Matcher.on(engine); | ||
396 | } | ||
397 | |||
398 | public MultipleConnectedTo getMultipleConnectedTo() { | ||
399 | return MultipleConnectedTo.instance(); | ||
400 | } | ||
401 | |||
402 | public MultipleConnectedTo.Matcher getMultipleConnectedTo(final ViatraQueryEngine engine) { | ||
403 | return MultipleConnectedTo.Matcher.on(engine); | ||
404 | } | ||
405 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/MultipleConnectedTo.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/MultipleConnectedTo.java new file mode 100644 index 00000000..277006c9 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/MultipleConnectedTo.java | |||
@@ -0,0 +1,565 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern multipleConnectedTo(s : Segment) { | ||
48 | * Segment.connectedTo(s, n1); | ||
49 | * Segment.connectedTo(s, n2); | ||
50 | * n1 != n2; | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class MultipleConnectedTo extends BaseGeneratedEMFQuerySpecification<MultipleConnectedTo.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.multipleConnectedTo pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Segment fS; | ||
74 | |||
75 | private static List<String> parameterNames = makeImmutableList("s"); | ||
76 | |||
77 | private Match(final Segment pS) { | ||
78 | this.fS = pS; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "s": return this.fS; | ||
85 | default: return null; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final int index) { | ||
91 | switch(index) { | ||
92 | case 0: return this.fS; | ||
93 | default: return null; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | public Segment getS() { | ||
98 | return this.fS; | ||
99 | } | ||
100 | |||
101 | @Override | ||
102 | public boolean set(final String parameterName, final Object newValue) { | ||
103 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
104 | if ("s".equals(parameterName) ) { | ||
105 | this.fS = (Segment) newValue; | ||
106 | return true; | ||
107 | } | ||
108 | return false; | ||
109 | } | ||
110 | |||
111 | public void setS(final Segment pS) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | this.fS = pS; | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public String patternName() { | ||
118 | return "modes3.queries.multipleConnectedTo"; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public List<String> parameterNames() { | ||
123 | return MultipleConnectedTo.Match.parameterNames; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public Object[] toArray() { | ||
128 | return new Object[]{fS}; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public MultipleConnectedTo.Match toImmutable() { | ||
133 | return isMutable() ? newMatch(fS) : this; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public String prettyPrint() { | ||
138 | StringBuilder result = new StringBuilder(); | ||
139 | result.append("\"s\"=" + prettyPrintValue(fS)); | ||
140 | return result.toString(); | ||
141 | } | ||
142 | |||
143 | @Override | ||
144 | public int hashCode() { | ||
145 | return Objects.hash(fS); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public boolean equals(final Object obj) { | ||
150 | if (this == obj) | ||
151 | return true; | ||
152 | if (obj == null) { | ||
153 | return false; | ||
154 | } | ||
155 | if ((obj instanceof MultipleConnectedTo.Match)) { | ||
156 | MultipleConnectedTo.Match other = (MultipleConnectedTo.Match) obj; | ||
157 | return Objects.equals(fS, other.fS); | ||
158 | } else { | ||
159 | // this should be infrequent | ||
160 | if (!(obj instanceof IPatternMatch)) { | ||
161 | return false; | ||
162 | } | ||
163 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
164 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public MultipleConnectedTo specification() { | ||
170 | return MultipleConnectedTo.instance(); | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * Returns an empty, mutable match. | ||
175 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
176 | * | ||
177 | * @return the empty match. | ||
178 | * | ||
179 | */ | ||
180 | public static MultipleConnectedTo.Match newEmptyMatch() { | ||
181 | return new Mutable(null); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Returns a mutable (partial) match. | ||
186 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
187 | * | ||
188 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
189 | * @return the new, mutable (partial) match object. | ||
190 | * | ||
191 | */ | ||
192 | public static MultipleConnectedTo.Match newMutableMatch(final Segment pS) { | ||
193 | return new Mutable(pS); | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * Returns a new (partial) match. | ||
198 | * This can be used e.g. to call the matcher with a partial match. | ||
199 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
200 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
201 | * @return the (partial) match object. | ||
202 | * | ||
203 | */ | ||
204 | public static MultipleConnectedTo.Match newMatch(final Segment pS) { | ||
205 | return new Immutable(pS); | ||
206 | } | ||
207 | |||
208 | private static final class Mutable extends MultipleConnectedTo.Match { | ||
209 | Mutable(final Segment pS) { | ||
210 | super(pS); | ||
211 | } | ||
212 | |||
213 | @Override | ||
214 | public boolean isMutable() { | ||
215 | return true; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | private static final class Immutable extends MultipleConnectedTo.Match { | ||
220 | Immutable(final Segment pS) { | ||
221 | super(pS); | ||
222 | } | ||
223 | |||
224 | @Override | ||
225 | public boolean isMutable() { | ||
226 | return false; | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * Generated pattern matcher API of the modes3.queries.multipleConnectedTo pattern, | ||
233 | * providing pattern-specific query methods. | ||
234 | * | ||
235 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
236 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
237 | * | ||
238 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
239 | * | ||
240 | * <p>Original source: | ||
241 | * <code><pre> | ||
242 | * pattern multipleConnectedTo(s : Segment) { | ||
243 | * Segment.connectedTo(s, n1); | ||
244 | * Segment.connectedTo(s, n2); | ||
245 | * n1 != n2; | ||
246 | * } | ||
247 | * </pre></code> | ||
248 | * | ||
249 | * @see Match | ||
250 | * @see MultipleConnectedTo | ||
251 | * | ||
252 | */ | ||
253 | public static class Matcher extends BaseMatcher<MultipleConnectedTo.Match> { | ||
254 | /** | ||
255 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
256 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
257 | * | ||
258 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
259 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
260 | * | ||
261 | */ | ||
262 | public static MultipleConnectedTo.Matcher on(final ViatraQueryEngine engine) { | ||
263 | // check if matcher already exists | ||
264 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
265 | if (matcher == null) { | ||
266 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
267 | } | ||
268 | return matcher; | ||
269 | } | ||
270 | |||
271 | /** | ||
272 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
273 | * @return an initialized matcher | ||
274 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
275 | * | ||
276 | */ | ||
277 | public static MultipleConnectedTo.Matcher create() { | ||
278 | return new Matcher(); | ||
279 | } | ||
280 | |||
281 | private static final int POSITION_S = 0; | ||
282 | |||
283 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(MultipleConnectedTo.Matcher.class); | ||
284 | |||
285 | /** | ||
286 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
287 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
288 | * | ||
289 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
290 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
291 | * | ||
292 | */ | ||
293 | private Matcher() { | ||
294 | super(querySpecification()); | ||
295 | } | ||
296 | |||
297 | /** | ||
298 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
299 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
300 | * @return matches represented as a Match object. | ||
301 | * | ||
302 | */ | ||
303 | public Collection<MultipleConnectedTo.Match> getAllMatches(final Segment pS) { | ||
304 | return rawStreamAllMatches(new Object[]{pS}).collect(Collectors.toSet()); | ||
305 | } | ||
306 | |||
307 | /** | ||
308 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
309 | * </p> | ||
310 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
311 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
312 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
313 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
314 | * @return a stream of matches represented as a Match object. | ||
315 | * | ||
316 | */ | ||
317 | public Stream<MultipleConnectedTo.Match> streamAllMatches(final Segment pS) { | ||
318 | return rawStreamAllMatches(new Object[]{pS}); | ||
319 | } | ||
320 | |||
321 | /** | ||
322 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
323 | * Neither determinism nor randomness of selection is guaranteed. | ||
324 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
325 | * @return a match represented as a Match object, or null if no match is found. | ||
326 | * | ||
327 | */ | ||
328 | public Optional<MultipleConnectedTo.Match> getOneArbitraryMatch(final Segment pS) { | ||
329 | return rawGetOneArbitraryMatch(new Object[]{pS}); | ||
330 | } | ||
331 | |||
332 | /** | ||
333 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
334 | * under any possible substitution of the unspecified parameters (if any). | ||
335 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
336 | * @return true if the input is a valid (partial) match of the pattern. | ||
337 | * | ||
338 | */ | ||
339 | public boolean hasMatch(final Segment pS) { | ||
340 | return rawHasMatch(new Object[]{pS}); | ||
341 | } | ||
342 | |||
343 | /** | ||
344 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
345 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
346 | * @return the number of pattern matches found. | ||
347 | * | ||
348 | */ | ||
349 | public int countMatches(final Segment pS) { | ||
350 | return rawCountMatches(new Object[]{pS}); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
355 | * Neither determinism nor randomness of selection is guaranteed. | ||
356 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
357 | * @param processor the action that will process the selected match. | ||
358 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
359 | * | ||
360 | */ | ||
361 | public boolean forOneArbitraryMatch(final Segment pS, final Consumer<? super MultipleConnectedTo.Match> processor) { | ||
362 | return rawForOneArbitraryMatch(new Object[]{pS}, processor); | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * Returns a new (partial) match. | ||
367 | * This can be used e.g. to call the matcher with a partial match. | ||
368 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
369 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
370 | * @return the (partial) match object. | ||
371 | * | ||
372 | */ | ||
373 | public MultipleConnectedTo.Match newMatch(final Segment pS) { | ||
374 | return MultipleConnectedTo.Match.newMatch(pS); | ||
375 | } | ||
376 | |||
377 | /** | ||
378 | * Retrieve the set of values that occur in matches for s. | ||
379 | * @return the Set of all values or empty set if there are no matches | ||
380 | * | ||
381 | */ | ||
382 | protected Stream<Segment> rawStreamAllValuesOfs(final Object[] parameters) { | ||
383 | return rawStreamAllValues(POSITION_S, parameters).map(Segment.class::cast); | ||
384 | } | ||
385 | |||
386 | /** | ||
387 | * Retrieve the set of values that occur in matches for s. | ||
388 | * @return the Set of all values or empty set if there are no matches | ||
389 | * | ||
390 | */ | ||
391 | public Set<Segment> getAllValuesOfs() { | ||
392 | return rawStreamAllValuesOfs(emptyArray()).collect(Collectors.toSet()); | ||
393 | } | ||
394 | |||
395 | /** | ||
396 | * Retrieve the set of values that occur in matches for s. | ||
397 | * @return the Set of all values or empty set if there are no matches | ||
398 | * | ||
399 | */ | ||
400 | public Stream<Segment> streamAllValuesOfs() { | ||
401 | return rawStreamAllValuesOfs(emptyArray()); | ||
402 | } | ||
403 | |||
404 | @Override | ||
405 | protected MultipleConnectedTo.Match tupleToMatch(final Tuple t) { | ||
406 | try { | ||
407 | return MultipleConnectedTo.Match.newMatch((Segment) t.get(POSITION_S)); | ||
408 | } catch(ClassCastException e) { | ||
409 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
410 | return null; | ||
411 | } | ||
412 | } | ||
413 | |||
414 | @Override | ||
415 | protected MultipleConnectedTo.Match arrayToMatch(final Object[] match) { | ||
416 | try { | ||
417 | return MultipleConnectedTo.Match.newMatch((Segment) match[POSITION_S]); | ||
418 | } catch(ClassCastException e) { | ||
419 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
420 | return null; | ||
421 | } | ||
422 | } | ||
423 | |||
424 | @Override | ||
425 | protected MultipleConnectedTo.Match arrayToMatchMutable(final Object[] match) { | ||
426 | try { | ||
427 | return MultipleConnectedTo.Match.newMutableMatch((Segment) match[POSITION_S]); | ||
428 | } catch(ClassCastException e) { | ||
429 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
430 | return null; | ||
431 | } | ||
432 | } | ||
433 | |||
434 | /** | ||
435 | * @return the singleton instance of the query specification of this pattern | ||
436 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
437 | * | ||
438 | */ | ||
439 | public static IQuerySpecification<MultipleConnectedTo.Matcher> querySpecification() { | ||
440 | return MultipleConnectedTo.instance(); | ||
441 | } | ||
442 | } | ||
443 | |||
444 | private MultipleConnectedTo() { | ||
445 | super(GeneratedPQuery.INSTANCE); | ||
446 | } | ||
447 | |||
448 | /** | ||
449 | * @return the singleton instance of the query specification | ||
450 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
451 | * | ||
452 | */ | ||
453 | public static MultipleConnectedTo instance() { | ||
454 | try{ | ||
455 | return LazyHolder.INSTANCE; | ||
456 | } catch (ExceptionInInitializerError err) { | ||
457 | throw processInitializerError(err); | ||
458 | } | ||
459 | } | ||
460 | |||
461 | @Override | ||
462 | protected MultipleConnectedTo.Matcher instantiate(final ViatraQueryEngine engine) { | ||
463 | return MultipleConnectedTo.Matcher.on(engine); | ||
464 | } | ||
465 | |||
466 | @Override | ||
467 | public MultipleConnectedTo.Matcher instantiate() { | ||
468 | return MultipleConnectedTo.Matcher.create(); | ||
469 | } | ||
470 | |||
471 | @Override | ||
472 | public MultipleConnectedTo.Match newEmptyMatch() { | ||
473 | return MultipleConnectedTo.Match.newEmptyMatch(); | ||
474 | } | ||
475 | |||
476 | @Override | ||
477 | public MultipleConnectedTo.Match newMatch(final Object... parameters) { | ||
478 | return MultipleConnectedTo.Match.newMatch((modes3.Segment) parameters[0]); | ||
479 | } | ||
480 | |||
481 | /** | ||
482 | * Inner class allowing the singleton instance of {@link MultipleConnectedTo} to be created | ||
483 | * <b>not</b> at the class load time of the outer class, | ||
484 | * but rather at the first call to {@link MultipleConnectedTo#instance()}. | ||
485 | * | ||
486 | * <p> This workaround is required e.g. to support recursion. | ||
487 | * | ||
488 | */ | ||
489 | private static class LazyHolder { | ||
490 | private static final MultipleConnectedTo INSTANCE = new MultipleConnectedTo(); | ||
491 | |||
492 | /** | ||
493 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
494 | * This initialization order is required to support indirect recursion. | ||
495 | * | ||
496 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
497 | * | ||
498 | */ | ||
499 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
500 | |||
501 | public static Object ensureInitialized() { | ||
502 | INSTANCE.ensureInitializedInternal(); | ||
503 | return null; | ||
504 | } | ||
505 | } | ||
506 | |||
507 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
508 | private static final MultipleConnectedTo.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
509 | |||
510 | private final PParameter parameter_s = new PParameter("s", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
511 | |||
512 | private final List<PParameter> parameters = Arrays.asList(parameter_s); | ||
513 | |||
514 | private GeneratedPQuery() { | ||
515 | super(PVisibility.PUBLIC); | ||
516 | } | ||
517 | |||
518 | @Override | ||
519 | public String getFullyQualifiedName() { | ||
520 | return "modes3.queries.multipleConnectedTo"; | ||
521 | } | ||
522 | |||
523 | @Override | ||
524 | public List<String> getParameterNames() { | ||
525 | return Arrays.asList("s"); | ||
526 | } | ||
527 | |||
528 | @Override | ||
529 | public List<PParameter> getParameters() { | ||
530 | return parameters; | ||
531 | } | ||
532 | |||
533 | @Override | ||
534 | public Set<PBody> doGetContainedBodies() { | ||
535 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
536 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
537 | { | ||
538 | PBody body = new PBody(this); | ||
539 | PVariable var_s = body.getOrCreateVariableByName("s"); | ||
540 | PVariable var_n1 = body.getOrCreateVariableByName("n1"); | ||
541 | PVariable var_n2 = body.getOrCreateVariableByName("n2"); | ||
542 | new TypeConstraint(body, Tuples.flatTupleOf(var_s), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
543 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
544 | new ExportedParameter(body, var_s, parameter_s) | ||
545 | )); | ||
546 | // Segment.connectedTo(s, n1) | ||
547 | new TypeConstraint(body, Tuples.flatTupleOf(var_s), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
548 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
549 | new TypeConstraint(body, Tuples.flatTupleOf(var_s, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
550 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
551 | new Equality(body, var__virtual_0_, var_n1); | ||
552 | // Segment.connectedTo(s, n2) | ||
553 | new TypeConstraint(body, Tuples.flatTupleOf(var_s), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
554 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
555 | new TypeConstraint(body, Tuples.flatTupleOf(var_s, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
556 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
557 | new Equality(body, var__virtual_1_, var_n2); | ||
558 | // n1 != n2 | ||
559 | new Inequality(body, var_n1, var_n2); | ||
560 | bodies.add(body); | ||
561 | } | ||
562 | return bodies; | ||
563 | } | ||
564 | } | ||
565 | } | ||
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 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.queries.TurnoutOutput; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * pattern output(S1 : Segment, S2 : Segment) { | ||
49 | * Segment.connectedTo(S1, S2); | ||
50 | * } or { | ||
51 | * find turnoutOutput(S1, S2); | ||
52 | * } | ||
53 | * </pre></code> | ||
54 | * | ||
55 | * @see Matcher | ||
56 | * @see Match | ||
57 | * | ||
58 | */ | ||
59 | @SuppressWarnings("all") | ||
60 | public final class Output extends BaseGeneratedEMFQuerySpecification<Output.Matcher> { | ||
61 | /** | ||
62 | * Pattern-specific match representation of the modes3.queries.output pattern, | ||
63 | * to be used in conjunction with {@link Matcher}. | ||
64 | * | ||
65 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
66 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
67 | * usable to represent a match of the pattern in the result of a query, | ||
68 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
69 | * | ||
70 | * @see Matcher | ||
71 | * | ||
72 | */ | ||
73 | public static abstract class Match extends BasePatternMatch { | ||
74 | private Segment fS1; | ||
75 | |||
76 | private Segment fS2; | ||
77 | |||
78 | private static List<String> parameterNames = makeImmutableList("S1", "S2"); | ||
79 | |||
80 | private Match(final Segment pS1, final Segment pS2) { | ||
81 | this.fS1 = pS1; | ||
82 | this.fS2 = pS2; | ||
83 | } | ||
84 | |||
85 | @Override | ||
86 | public Object get(final String parameterName) { | ||
87 | switch(parameterName) { | ||
88 | case "S1": return this.fS1; | ||
89 | case "S2": return this.fS2; | ||
90 | default: return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | @Override | ||
95 | public Object get(final int index) { | ||
96 | switch(index) { | ||
97 | case 0: return this.fS1; | ||
98 | case 1: return this.fS2; | ||
99 | default: return null; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | public Segment getS1() { | ||
104 | return this.fS1; | ||
105 | } | ||
106 | |||
107 | public Segment getS2() { | ||
108 | return this.fS2; | ||
109 | } | ||
110 | |||
111 | @Override | ||
112 | public boolean set(final String parameterName, final Object newValue) { | ||
113 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
114 | if ("S1".equals(parameterName) ) { | ||
115 | this.fS1 = (Segment) newValue; | ||
116 | return true; | ||
117 | } | ||
118 | if ("S2".equals(parameterName) ) { | ||
119 | this.fS2 = (Segment) newValue; | ||
120 | return true; | ||
121 | } | ||
122 | return false; | ||
123 | } | ||
124 | |||
125 | public void setS1(final Segment pS1) { | ||
126 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
127 | this.fS1 = pS1; | ||
128 | } | ||
129 | |||
130 | public void setS2(final Segment pS2) { | ||
131 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
132 | this.fS2 = pS2; | ||
133 | } | ||
134 | |||
135 | @Override | ||
136 | public String patternName() { | ||
137 | return "modes3.queries.output"; | ||
138 | } | ||
139 | |||
140 | @Override | ||
141 | public List<String> parameterNames() { | ||
142 | return Output.Match.parameterNames; | ||
143 | } | ||
144 | |||
145 | @Override | ||
146 | public Object[] toArray() { | ||
147 | return new Object[]{fS1, fS2}; | ||
148 | } | ||
149 | |||
150 | @Override | ||
151 | public Output.Match toImmutable() { | ||
152 | return isMutable() ? newMatch(fS1, fS2) : this; | ||
153 | } | ||
154 | |||
155 | @Override | ||
156 | public String prettyPrint() { | ||
157 | StringBuilder result = new StringBuilder(); | ||
158 | result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); | ||
159 | result.append("\"S2\"=" + prettyPrintValue(fS2)); | ||
160 | return result.toString(); | ||
161 | } | ||
162 | |||
163 | @Override | ||
164 | public int hashCode() { | ||
165 | return Objects.hash(fS1, fS2); | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public boolean equals(final Object obj) { | ||
170 | if (this == obj) | ||
171 | return true; | ||
172 | if (obj == null) { | ||
173 | return false; | ||
174 | } | ||
175 | if ((obj instanceof Output.Match)) { | ||
176 | Output.Match other = (Output.Match) obj; | ||
177 | return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); | ||
178 | } else { | ||
179 | // this should be infrequent | ||
180 | if (!(obj instanceof IPatternMatch)) { | ||
181 | return false; | ||
182 | } | ||
183 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
184 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
185 | } | ||
186 | } | ||
187 | |||
188 | @Override | ||
189 | public Output specification() { | ||
190 | return Output.instance(); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * Returns an empty, mutable match. | ||
195 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
196 | * | ||
197 | * @return the empty match. | ||
198 | * | ||
199 | */ | ||
200 | public static Output.Match newEmptyMatch() { | ||
201 | return new Mutable(null, null); | ||
202 | } | ||
203 | |||
204 | /** | ||
205 | * Returns a mutable (partial) match. | ||
206 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
207 | * | ||
208 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
209 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
210 | * @return the new, mutable (partial) match object. | ||
211 | * | ||
212 | */ | ||
213 | public static Output.Match newMutableMatch(final Segment pS1, final Segment pS2) { | ||
214 | return new Mutable(pS1, pS2); | ||
215 | } | ||
216 | |||
217 | /** | ||
218 | * Returns a new (partial) match. | ||
219 | * This can be used e.g. to call the matcher with a partial match. | ||
220 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
221 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
222 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
223 | * @return the (partial) match object. | ||
224 | * | ||
225 | */ | ||
226 | public static Output.Match newMatch(final Segment pS1, final Segment pS2) { | ||
227 | return new Immutable(pS1, pS2); | ||
228 | } | ||
229 | |||
230 | private static final class Mutable extends Output.Match { | ||
231 | Mutable(final Segment pS1, final Segment pS2) { | ||
232 | super(pS1, pS2); | ||
233 | } | ||
234 | |||
235 | @Override | ||
236 | public boolean isMutable() { | ||
237 | return true; | ||
238 | } | ||
239 | } | ||
240 | |||
241 | private static final class Immutable extends Output.Match { | ||
242 | Immutable(final Segment pS1, final Segment pS2) { | ||
243 | super(pS1, pS2); | ||
244 | } | ||
245 | |||
246 | @Override | ||
247 | public boolean isMutable() { | ||
248 | return false; | ||
249 | } | ||
250 | } | ||
251 | } | ||
252 | |||
253 | /** | ||
254 | * Generated pattern matcher API of the modes3.queries.output pattern, | ||
255 | * providing pattern-specific query methods. | ||
256 | * | ||
257 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
258 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
259 | * | ||
260 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
261 | * | ||
262 | * <p>Original source: | ||
263 | * <code><pre> | ||
264 | * pattern output(S1 : Segment, S2 : Segment) { | ||
265 | * Segment.connectedTo(S1, S2); | ||
266 | * } or { | ||
267 | * find turnoutOutput(S1, S2); | ||
268 | * } | ||
269 | * </pre></code> | ||
270 | * | ||
271 | * @see Match | ||
272 | * @see Output | ||
273 | * | ||
274 | */ | ||
275 | public static class Matcher extends BaseMatcher<Output.Match> { | ||
276 | /** | ||
277 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
278 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
279 | * | ||
280 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
281 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
282 | * | ||
283 | */ | ||
284 | public static Output.Matcher on(final ViatraQueryEngine engine) { | ||
285 | // check if matcher already exists | ||
286 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
287 | if (matcher == null) { | ||
288 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
289 | } | ||
290 | return matcher; | ||
291 | } | ||
292 | |||
293 | /** | ||
294 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
295 | * @return an initialized matcher | ||
296 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
297 | * | ||
298 | */ | ||
299 | public static Output.Matcher create() { | ||
300 | return new Matcher(); | ||
301 | } | ||
302 | |||
303 | private static final int POSITION_S1 = 0; | ||
304 | |||
305 | private static final int POSITION_S2 = 1; | ||
306 | |||
307 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Output.Matcher.class); | ||
308 | |||
309 | /** | ||
310 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
311 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
312 | * | ||
313 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
314 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
315 | * | ||
316 | */ | ||
317 | private Matcher() { | ||
318 | super(querySpecification()); | ||
319 | } | ||
320 | |||
321 | /** | ||
322 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
323 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
324 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
325 | * @return matches represented as a Match object. | ||
326 | * | ||
327 | */ | ||
328 | public Collection<Output.Match> getAllMatches(final Segment pS1, final Segment pS2) { | ||
329 | return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); | ||
330 | } | ||
331 | |||
332 | /** | ||
333 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
334 | * </p> | ||
335 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
336 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
337 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
338 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
339 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
340 | * @return a stream of matches represented as a Match object. | ||
341 | * | ||
342 | */ | ||
343 | public Stream<Output.Match> streamAllMatches(final Segment pS1, final Segment pS2) { | ||
344 | return rawStreamAllMatches(new Object[]{pS1, pS2}); | ||
345 | } | ||
346 | |||
347 | /** | ||
348 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
349 | * Neither determinism nor randomness of selection is guaranteed. | ||
350 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
351 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
352 | * @return a match represented as a Match object, or null if no match is found. | ||
353 | * | ||
354 | */ | ||
355 | public Optional<Output.Match> getOneArbitraryMatch(final Segment pS1, final Segment pS2) { | ||
356 | return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); | ||
357 | } | ||
358 | |||
359 | /** | ||
360 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
361 | * under any possible substitution of the unspecified parameters (if any). | ||
362 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
363 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
364 | * @return true if the input is a valid (partial) match of the pattern. | ||
365 | * | ||
366 | */ | ||
367 | public boolean hasMatch(final Segment pS1, final Segment pS2) { | ||
368 | return rawHasMatch(new Object[]{pS1, pS2}); | ||
369 | } | ||
370 | |||
371 | /** | ||
372 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
373 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
374 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
375 | * @return the number of pattern matches found. | ||
376 | * | ||
377 | */ | ||
378 | public int countMatches(final Segment pS1, final Segment pS2) { | ||
379 | return rawCountMatches(new Object[]{pS1, pS2}); | ||
380 | } | ||
381 | |||
382 | /** | ||
383 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
384 | * Neither determinism nor randomness of selection is guaranteed. | ||
385 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
386 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
387 | * @param processor the action that will process the selected match. | ||
388 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
389 | * | ||
390 | */ | ||
391 | public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer<? super Output.Match> processor) { | ||
392 | return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); | ||
393 | } | ||
394 | |||
395 | /** | ||
396 | * Returns a new (partial) match. | ||
397 | * This can be used e.g. to call the matcher with a partial match. | ||
398 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
399 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
400 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
401 | * @return the (partial) match object. | ||
402 | * | ||
403 | */ | ||
404 | public Output.Match newMatch(final Segment pS1, final Segment pS2) { | ||
405 | return Output.Match.newMatch(pS1, pS2); | ||
406 | } | ||
407 | |||
408 | /** | ||
409 | * Retrieve the set of values that occur in matches for S1. | ||
410 | * @return the Set of all values or empty set if there are no matches | ||
411 | * | ||
412 | */ | ||
413 | protected Stream<Segment> rawStreamAllValuesOfS1(final Object[] parameters) { | ||
414 | return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); | ||
415 | } | ||
416 | |||
417 | /** | ||
418 | * Retrieve the set of values that occur in matches for S1. | ||
419 | * @return the Set of all values or empty set if there are no matches | ||
420 | * | ||
421 | */ | ||
422 | public Set<Segment> getAllValuesOfS1() { | ||
423 | return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); | ||
424 | } | ||
425 | |||
426 | /** | ||
427 | * Retrieve the set of values that occur in matches for S1. | ||
428 | * @return the Set of all values or empty set if there are no matches | ||
429 | * | ||
430 | */ | ||
431 | public Stream<Segment> streamAllValuesOfS1() { | ||
432 | return rawStreamAllValuesOfS1(emptyArray()); | ||
433 | } | ||
434 | |||
435 | /** | ||
436 | * Retrieve the set of values that occur in matches for S1. | ||
437 | * </p> | ||
438 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
439 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
440 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
441 | * | ||
442 | * @return the Stream of all values or empty set if there are no matches | ||
443 | * | ||
444 | */ | ||
445 | public Stream<Segment> streamAllValuesOfS1(final Output.Match partialMatch) { | ||
446 | return rawStreamAllValuesOfS1(partialMatch.toArray()); | ||
447 | } | ||
448 | |||
449 | /** | ||
450 | * Retrieve the set of values that occur in matches for S1. | ||
451 | * </p> | ||
452 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
453 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
454 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
455 | * | ||
456 | * @return the Stream of all values or empty set if there are no matches | ||
457 | * | ||
458 | */ | ||
459 | public Stream<Segment> streamAllValuesOfS1(final Segment pS2) { | ||
460 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}); | ||
461 | } | ||
462 | |||
463 | /** | ||
464 | * Retrieve the set of values that occur in matches for S1. | ||
465 | * @return the Set of all values or empty set if there are no matches | ||
466 | * | ||
467 | */ | ||
468 | public Set<Segment> getAllValuesOfS1(final Output.Match partialMatch) { | ||
469 | return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); | ||
470 | } | ||
471 | |||
472 | /** | ||
473 | * Retrieve the set of values that occur in matches for S1. | ||
474 | * @return the Set of all values or empty set if there are no matches | ||
475 | * | ||
476 | */ | ||
477 | public Set<Segment> getAllValuesOfS1(final Segment pS2) { | ||
478 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); | ||
479 | } | ||
480 | |||
481 | /** | ||
482 | * Retrieve the set of values that occur in matches for S2. | ||
483 | * @return the Set of all values or empty set if there are no matches | ||
484 | * | ||
485 | */ | ||
486 | protected Stream<Segment> rawStreamAllValuesOfS2(final Object[] parameters) { | ||
487 | return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); | ||
488 | } | ||
489 | |||
490 | /** | ||
491 | * Retrieve the set of values that occur in matches for S2. | ||
492 | * @return the Set of all values or empty set if there are no matches | ||
493 | * | ||
494 | */ | ||
495 | public Set<Segment> getAllValuesOfS2() { | ||
496 | return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); | ||
497 | } | ||
498 | |||
499 | /** | ||
500 | * Retrieve the set of values that occur in matches for S2. | ||
501 | * @return the Set of all values or empty set if there are no matches | ||
502 | * | ||
503 | */ | ||
504 | public Stream<Segment> streamAllValuesOfS2() { | ||
505 | return rawStreamAllValuesOfS2(emptyArray()); | ||
506 | } | ||
507 | |||
508 | /** | ||
509 | * Retrieve the set of values that occur in matches for S2. | ||
510 | * </p> | ||
511 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
512 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
513 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
514 | * | ||
515 | * @return the Stream of all values or empty set if there are no matches | ||
516 | * | ||
517 | */ | ||
518 | public Stream<Segment> streamAllValuesOfS2(final Output.Match partialMatch) { | ||
519 | return rawStreamAllValuesOfS2(partialMatch.toArray()); | ||
520 | } | ||
521 | |||
522 | /** | ||
523 | * Retrieve the set of values that occur in matches for S2. | ||
524 | * </p> | ||
525 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
526 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
527 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
528 | * | ||
529 | * @return the Stream of all values or empty set if there are no matches | ||
530 | * | ||
531 | */ | ||
532 | public Stream<Segment> streamAllValuesOfS2(final Segment pS1) { | ||
533 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}); | ||
534 | } | ||
535 | |||
536 | /** | ||
537 | * Retrieve the set of values that occur in matches for S2. | ||
538 | * @return the Set of all values or empty set if there are no matches | ||
539 | * | ||
540 | */ | ||
541 | public Set<Segment> getAllValuesOfS2(final Output.Match partialMatch) { | ||
542 | return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); | ||
543 | } | ||
544 | |||
545 | /** | ||
546 | * Retrieve the set of values that occur in matches for S2. | ||
547 | * @return the Set of all values or empty set if there are no matches | ||
548 | * | ||
549 | */ | ||
550 | public Set<Segment> getAllValuesOfS2(final Segment pS1) { | ||
551 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); | ||
552 | } | ||
553 | |||
554 | @Override | ||
555 | protected Output.Match tupleToMatch(final Tuple t) { | ||
556 | try { | ||
557 | return Output.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); | ||
558 | } catch(ClassCastException e) { | ||
559 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
560 | return null; | ||
561 | } | ||
562 | } | ||
563 | |||
564 | @Override | ||
565 | protected Output.Match arrayToMatch(final Object[] match) { | ||
566 | try { | ||
567 | return Output.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
568 | } catch(ClassCastException e) { | ||
569 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
570 | return null; | ||
571 | } | ||
572 | } | ||
573 | |||
574 | @Override | ||
575 | protected Output.Match arrayToMatchMutable(final Object[] match) { | ||
576 | try { | ||
577 | return Output.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
578 | } catch(ClassCastException e) { | ||
579 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
580 | return null; | ||
581 | } | ||
582 | } | ||
583 | |||
584 | /** | ||
585 | * @return the singleton instance of the query specification of this pattern | ||
586 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
587 | * | ||
588 | */ | ||
589 | public static IQuerySpecification<Output.Matcher> querySpecification() { | ||
590 | return Output.instance(); | ||
591 | } | ||
592 | } | ||
593 | |||
594 | private Output() { | ||
595 | super(GeneratedPQuery.INSTANCE); | ||
596 | } | ||
597 | |||
598 | /** | ||
599 | * @return the singleton instance of the query specification | ||
600 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
601 | * | ||
602 | */ | ||
603 | public static Output instance() { | ||
604 | try{ | ||
605 | return LazyHolder.INSTANCE; | ||
606 | } catch (ExceptionInInitializerError err) { | ||
607 | throw processInitializerError(err); | ||
608 | } | ||
609 | } | ||
610 | |||
611 | @Override | ||
612 | protected Output.Matcher instantiate(final ViatraQueryEngine engine) { | ||
613 | return Output.Matcher.on(engine); | ||
614 | } | ||
615 | |||
616 | @Override | ||
617 | public Output.Matcher instantiate() { | ||
618 | return Output.Matcher.create(); | ||
619 | } | ||
620 | |||
621 | @Override | ||
622 | public Output.Match newEmptyMatch() { | ||
623 | return Output.Match.newEmptyMatch(); | ||
624 | } | ||
625 | |||
626 | @Override | ||
627 | public Output.Match newMatch(final Object... parameters) { | ||
628 | return Output.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); | ||
629 | } | ||
630 | |||
631 | /** | ||
632 | * Inner class allowing the singleton instance of {@link Output} to be created | ||
633 | * <b>not</b> at the class load time of the outer class, | ||
634 | * but rather at the first call to {@link Output#instance()}. | ||
635 | * | ||
636 | * <p> This workaround is required e.g. to support recursion. | ||
637 | * | ||
638 | */ | ||
639 | private static class LazyHolder { | ||
640 | private static final Output INSTANCE = new Output(); | ||
641 | |||
642 | /** | ||
643 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
644 | * This initialization order is required to support indirect recursion. | ||
645 | * | ||
646 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
647 | * | ||
648 | */ | ||
649 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
650 | |||
651 | public static Object ensureInitialized() { | ||
652 | INSTANCE.ensureInitializedInternal(); | ||
653 | return null; | ||
654 | } | ||
655 | } | ||
656 | |||
657 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
658 | private static final Output.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
659 | |||
660 | private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
661 | |||
662 | private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
663 | |||
664 | private final List<PParameter> parameters = Arrays.asList(parameter_S1, parameter_S2); | ||
665 | |||
666 | private GeneratedPQuery() { | ||
667 | super(PVisibility.PUBLIC); | ||
668 | } | ||
669 | |||
670 | @Override | ||
671 | public String getFullyQualifiedName() { | ||
672 | return "modes3.queries.output"; | ||
673 | } | ||
674 | |||
675 | @Override | ||
676 | public List<String> getParameterNames() { | ||
677 | return Arrays.asList("S1","S2"); | ||
678 | } | ||
679 | |||
680 | @Override | ||
681 | public List<PParameter> getParameters() { | ||
682 | return parameters; | ||
683 | } | ||
684 | |||
685 | @Override | ||
686 | public Set<PBody> doGetContainedBodies() { | ||
687 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
688 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
689 | { | ||
690 | PBody body = new PBody(this); | ||
691 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
692 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
693 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
694 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
695 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
696 | new ExportedParameter(body, var_S1, parameter_S1), | ||
697 | new ExportedParameter(body, var_S2, parameter_S2) | ||
698 | )); | ||
699 | // Segment.connectedTo(S1, S2) | ||
700 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
701 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
702 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
703 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
704 | new Equality(body, var__virtual_0_, var_S2); | ||
705 | bodies.add(body); | ||
706 | } | ||
707 | { | ||
708 | PBody body = new PBody(this); | ||
709 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
710 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
711 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
712 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
713 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
714 | new ExportedParameter(body, var_S1, parameter_S1), | ||
715 | new ExportedParameter(body, var_S2, parameter_S2) | ||
716 | )); | ||
717 | // find turnoutOutput(S1, S2) | ||
718 | new PositivePatternCall(body, Tuples.flatTupleOf(var_S1, var_S2), TurnoutOutput.instance().getInternalQueryRepresentation()); | ||
719 | bodies.add(body); | ||
720 | } | ||
721 | return bodies; | ||
722 | } | ||
723 | } | ||
724 | } | ||
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 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Turnout; | ||
17 | import modes3.queries.TurnoutOutput; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * {@literal @}Constraint(message = "outputReflexive", severity = "error", key = { T }) | ||
49 | * pattern outputReflexive(T : Turnout) { | ||
50 | * find turnoutOutput(T, T); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class OutputReflexive extends BaseGeneratedEMFQuerySpecification<OutputReflexive.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.outputReflexive pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Turnout fT; | ||
74 | |||
75 | private static List<String> parameterNames = makeImmutableList("T"); | ||
76 | |||
77 | private Match(final Turnout pT) { | ||
78 | this.fT = pT; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "T": return this.fT; | ||
85 | default: return null; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final int index) { | ||
91 | switch(index) { | ||
92 | case 0: return this.fT; | ||
93 | default: return null; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | public Turnout getT() { | ||
98 | return this.fT; | ||
99 | } | ||
100 | |||
101 | @Override | ||
102 | public boolean set(final String parameterName, final Object newValue) { | ||
103 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
104 | if ("T".equals(parameterName) ) { | ||
105 | this.fT = (Turnout) newValue; | ||
106 | return true; | ||
107 | } | ||
108 | return false; | ||
109 | } | ||
110 | |||
111 | public void setT(final Turnout pT) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | this.fT = pT; | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public String patternName() { | ||
118 | return "modes3.queries.outputReflexive"; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public List<String> parameterNames() { | ||
123 | return OutputReflexive.Match.parameterNames; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public Object[] toArray() { | ||
128 | return new Object[]{fT}; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public OutputReflexive.Match toImmutable() { | ||
133 | return isMutable() ? newMatch(fT) : this; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public String prettyPrint() { | ||
138 | StringBuilder result = new StringBuilder(); | ||
139 | result.append("\"T\"=" + prettyPrintValue(fT)); | ||
140 | return result.toString(); | ||
141 | } | ||
142 | |||
143 | @Override | ||
144 | public int hashCode() { | ||
145 | return Objects.hash(fT); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public boolean equals(final Object obj) { | ||
150 | if (this == obj) | ||
151 | return true; | ||
152 | if (obj == null) { | ||
153 | return false; | ||
154 | } | ||
155 | if ((obj instanceof OutputReflexive.Match)) { | ||
156 | OutputReflexive.Match other = (OutputReflexive.Match) obj; | ||
157 | return Objects.equals(fT, other.fT); | ||
158 | } else { | ||
159 | // this should be infrequent | ||
160 | if (!(obj instanceof IPatternMatch)) { | ||
161 | return false; | ||
162 | } | ||
163 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
164 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public OutputReflexive specification() { | ||
170 | return OutputReflexive.instance(); | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * Returns an empty, mutable match. | ||
175 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
176 | * | ||
177 | * @return the empty match. | ||
178 | * | ||
179 | */ | ||
180 | public static OutputReflexive.Match newEmptyMatch() { | ||
181 | return new Mutable(null); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Returns a mutable (partial) match. | ||
186 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
187 | * | ||
188 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
189 | * @return the new, mutable (partial) match object. | ||
190 | * | ||
191 | */ | ||
192 | public static OutputReflexive.Match newMutableMatch(final Turnout pT) { | ||
193 | return new Mutable(pT); | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * Returns a new (partial) match. | ||
198 | * This can be used e.g. to call the matcher with a partial match. | ||
199 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
200 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
201 | * @return the (partial) match object. | ||
202 | * | ||
203 | */ | ||
204 | public static OutputReflexive.Match newMatch(final Turnout pT) { | ||
205 | return new Immutable(pT); | ||
206 | } | ||
207 | |||
208 | private static final class Mutable extends OutputReflexive.Match { | ||
209 | Mutable(final Turnout pT) { | ||
210 | super(pT); | ||
211 | } | ||
212 | |||
213 | @Override | ||
214 | public boolean isMutable() { | ||
215 | return true; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | private static final class Immutable extends OutputReflexive.Match { | ||
220 | Immutable(final Turnout pT) { | ||
221 | super(pT); | ||
222 | } | ||
223 | |||
224 | @Override | ||
225 | public boolean isMutable() { | ||
226 | return false; | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * Generated pattern matcher API of the modes3.queries.outputReflexive pattern, | ||
233 | * providing pattern-specific query methods. | ||
234 | * | ||
235 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
236 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
237 | * | ||
238 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
239 | * | ||
240 | * <p>Original source: | ||
241 | * <code><pre> | ||
242 | * {@literal @}Constraint(message = "outputReflexive", severity = "error", key = { T }) | ||
243 | * pattern outputReflexive(T : Turnout) { | ||
244 | * find turnoutOutput(T, T); | ||
245 | * } | ||
246 | * </pre></code> | ||
247 | * | ||
248 | * @see Match | ||
249 | * @see OutputReflexive | ||
250 | * | ||
251 | */ | ||
252 | public static class Matcher extends BaseMatcher<OutputReflexive.Match> { | ||
253 | /** | ||
254 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
255 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
256 | * | ||
257 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
258 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
259 | * | ||
260 | */ | ||
261 | public static OutputReflexive.Matcher on(final ViatraQueryEngine engine) { | ||
262 | // check if matcher already exists | ||
263 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
264 | if (matcher == null) { | ||
265 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
266 | } | ||
267 | return matcher; | ||
268 | } | ||
269 | |||
270 | /** | ||
271 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
272 | * @return an initialized matcher | ||
273 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
274 | * | ||
275 | */ | ||
276 | public static OutputReflexive.Matcher create() { | ||
277 | return new Matcher(); | ||
278 | } | ||
279 | |||
280 | private static final int POSITION_T = 0; | ||
281 | |||
282 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(OutputReflexive.Matcher.class); | ||
283 | |||
284 | /** | ||
285 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
286 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
287 | * | ||
288 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
289 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
290 | * | ||
291 | */ | ||
292 | private Matcher() { | ||
293 | super(querySpecification()); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
298 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
299 | * @return matches represented as a Match object. | ||
300 | * | ||
301 | */ | ||
302 | public Collection<OutputReflexive.Match> getAllMatches(final Turnout pT) { | ||
303 | return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); | ||
304 | } | ||
305 | |||
306 | /** | ||
307 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
308 | * </p> | ||
309 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
310 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
311 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
312 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
313 | * @return a stream of matches represented as a Match object. | ||
314 | * | ||
315 | */ | ||
316 | public Stream<OutputReflexive.Match> streamAllMatches(final Turnout pT) { | ||
317 | return rawStreamAllMatches(new Object[]{pT}); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
322 | * Neither determinism nor randomness of selection is guaranteed. | ||
323 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
324 | * @return a match represented as a Match object, or null if no match is found. | ||
325 | * | ||
326 | */ | ||
327 | public Optional<OutputReflexive.Match> getOneArbitraryMatch(final Turnout pT) { | ||
328 | return rawGetOneArbitraryMatch(new Object[]{pT}); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
333 | * under any possible substitution of the unspecified parameters (if any). | ||
334 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
335 | * @return true if the input is a valid (partial) match of the pattern. | ||
336 | * | ||
337 | */ | ||
338 | public boolean hasMatch(final Turnout pT) { | ||
339 | return rawHasMatch(new Object[]{pT}); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
344 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
345 | * @return the number of pattern matches found. | ||
346 | * | ||
347 | */ | ||
348 | public int countMatches(final Turnout pT) { | ||
349 | return rawCountMatches(new Object[]{pT}); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
354 | * Neither determinism nor randomness of selection is guaranteed. | ||
355 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
356 | * @param processor the action that will process the selected match. | ||
357 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
358 | * | ||
359 | */ | ||
360 | public boolean forOneArbitraryMatch(final Turnout pT, final Consumer<? super OutputReflexive.Match> processor) { | ||
361 | return rawForOneArbitraryMatch(new Object[]{pT}, processor); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Returns a new (partial) match. | ||
366 | * This can be used e.g. to call the matcher with a partial match. | ||
367 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
368 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
369 | * @return the (partial) match object. | ||
370 | * | ||
371 | */ | ||
372 | public OutputReflexive.Match newMatch(final Turnout pT) { | ||
373 | return OutputReflexive.Match.newMatch(pT); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Retrieve the set of values that occur in matches for T. | ||
378 | * @return the Set of all values or empty set if there are no matches | ||
379 | * | ||
380 | */ | ||
381 | protected Stream<Turnout> rawStreamAllValuesOfT(final Object[] parameters) { | ||
382 | return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * Retrieve the set of values that occur in matches for T. | ||
387 | * @return the Set of all values or empty set if there are no matches | ||
388 | * | ||
389 | */ | ||
390 | public Set<Turnout> getAllValuesOfT() { | ||
391 | return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Retrieve the set of values that occur in matches for T. | ||
396 | * @return the Set of all values or empty set if there are no matches | ||
397 | * | ||
398 | */ | ||
399 | public Stream<Turnout> streamAllValuesOfT() { | ||
400 | return rawStreamAllValuesOfT(emptyArray()); | ||
401 | } | ||
402 | |||
403 | @Override | ||
404 | protected OutputReflexive.Match tupleToMatch(final Tuple t) { | ||
405 | try { | ||
406 | return OutputReflexive.Match.newMatch((Turnout) t.get(POSITION_T)); | ||
407 | } catch(ClassCastException e) { | ||
408 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
409 | return null; | ||
410 | } | ||
411 | } | ||
412 | |||
413 | @Override | ||
414 | protected OutputReflexive.Match arrayToMatch(final Object[] match) { | ||
415 | try { | ||
416 | return OutputReflexive.Match.newMatch((Turnout) match[POSITION_T]); | ||
417 | } catch(ClassCastException e) { | ||
418 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
419 | return null; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | @Override | ||
424 | protected OutputReflexive.Match arrayToMatchMutable(final Object[] match) { | ||
425 | try { | ||
426 | return OutputReflexive.Match.newMutableMatch((Turnout) match[POSITION_T]); | ||
427 | } catch(ClassCastException e) { | ||
428 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
429 | return null; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * @return the singleton instance of the query specification of this pattern | ||
435 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
436 | * | ||
437 | */ | ||
438 | public static IQuerySpecification<OutputReflexive.Matcher> querySpecification() { | ||
439 | return OutputReflexive.instance(); | ||
440 | } | ||
441 | } | ||
442 | |||
443 | private OutputReflexive() { | ||
444 | super(GeneratedPQuery.INSTANCE); | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @return the singleton instance of the query specification | ||
449 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
450 | * | ||
451 | */ | ||
452 | public static OutputReflexive instance() { | ||
453 | try{ | ||
454 | return LazyHolder.INSTANCE; | ||
455 | } catch (ExceptionInInitializerError err) { | ||
456 | throw processInitializerError(err); | ||
457 | } | ||
458 | } | ||
459 | |||
460 | @Override | ||
461 | protected OutputReflexive.Matcher instantiate(final ViatraQueryEngine engine) { | ||
462 | return OutputReflexive.Matcher.on(engine); | ||
463 | } | ||
464 | |||
465 | @Override | ||
466 | public OutputReflexive.Matcher instantiate() { | ||
467 | return OutputReflexive.Matcher.create(); | ||
468 | } | ||
469 | |||
470 | @Override | ||
471 | public OutputReflexive.Match newEmptyMatch() { | ||
472 | return OutputReflexive.Match.newEmptyMatch(); | ||
473 | } | ||
474 | |||
475 | @Override | ||
476 | public OutputReflexive.Match newMatch(final Object... parameters) { | ||
477 | return OutputReflexive.Match.newMatch((modes3.Turnout) parameters[0]); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Inner class allowing the singleton instance of {@link OutputReflexive} to be created | ||
482 | * <b>not</b> at the class load time of the outer class, | ||
483 | * but rather at the first call to {@link OutputReflexive#instance()}. | ||
484 | * | ||
485 | * <p> This workaround is required e.g. to support recursion. | ||
486 | * | ||
487 | */ | ||
488 | private static class LazyHolder { | ||
489 | private static final OutputReflexive INSTANCE = new OutputReflexive(); | ||
490 | |||
491 | /** | ||
492 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
493 | * This initialization order is required to support indirect recursion. | ||
494 | * | ||
495 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
496 | * | ||
497 | */ | ||
498 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
499 | |||
500 | public static Object ensureInitialized() { | ||
501 | INSTANCE.ensureInitializedInternal(); | ||
502 | return null; | ||
503 | } | ||
504 | } | ||
505 | |||
506 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
507 | private static final OutputReflexive.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
508 | |||
509 | private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); | ||
510 | |||
511 | private final List<PParameter> parameters = Arrays.asList(parameter_T); | ||
512 | |||
513 | private GeneratedPQuery() { | ||
514 | super(PVisibility.PUBLIC); | ||
515 | } | ||
516 | |||
517 | @Override | ||
518 | public String getFullyQualifiedName() { | ||
519 | return "modes3.queries.outputReflexive"; | ||
520 | } | ||
521 | |||
522 | @Override | ||
523 | public List<String> getParameterNames() { | ||
524 | return Arrays.asList("T"); | ||
525 | } | ||
526 | |||
527 | @Override | ||
528 | public List<PParameter> getParameters() { | ||
529 | return parameters; | ||
530 | } | ||
531 | |||
532 | @Override | ||
533 | public Set<PBody> doGetContainedBodies() { | ||
534 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
535 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
536 | { | ||
537 | PBody body = new PBody(this); | ||
538 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
539 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
540 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
541 | new ExportedParameter(body, var_T, parameter_T) | ||
542 | )); | ||
543 | // find turnoutOutput(T, T) | ||
544 | new PositivePatternCall(body, Tuples.flatTupleOf(var_T, var_T), TurnoutOutput.instance().getInternalQueryRepresentation()); | ||
545 | bodies.add(body); | ||
546 | } | ||
547 | { | ||
548 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
549 | annotation.addAttribute("message", "outputReflexive"); | ||
550 | annotation.addAttribute("severity", "error"); | ||
551 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
552 | new ParameterReference("T") | ||
553 | })); | ||
554 | addAnnotation(annotation); | ||
555 | } | ||
556 | return bodies; | ||
557 | } | ||
558 | } | ||
559 | } | ||
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 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.queries.Adjacent; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern reachable(S1 : Segment, S2 : Segment) { | ||
48 | * S1 == S2; | ||
49 | * } or { | ||
50 | * find adjacent+(S1, S2); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class Reachable extends BaseGeneratedEMFQuerySpecification<Reachable.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.reachable pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Segment fS1; | ||
74 | |||
75 | private Segment fS2; | ||
76 | |||
77 | private static List<String> parameterNames = makeImmutableList("S1", "S2"); | ||
78 | |||
79 | private Match(final Segment pS1, final Segment pS2) { | ||
80 | this.fS1 = pS1; | ||
81 | this.fS2 = pS2; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | switch(parameterName) { | ||
87 | case "S1": return this.fS1; | ||
88 | case "S2": return this.fS2; | ||
89 | default: return null; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | @Override | ||
94 | public Object get(final int index) { | ||
95 | switch(index) { | ||
96 | case 0: return this.fS1; | ||
97 | case 1: return this.fS2; | ||
98 | default: return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public Segment getS1() { | ||
103 | return this.fS1; | ||
104 | } | ||
105 | |||
106 | public Segment getS2() { | ||
107 | return this.fS2; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public boolean set(final String parameterName, final Object newValue) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | if ("S1".equals(parameterName) ) { | ||
114 | this.fS1 = (Segment) newValue; | ||
115 | return true; | ||
116 | } | ||
117 | if ("S2".equals(parameterName) ) { | ||
118 | this.fS2 = (Segment) newValue; | ||
119 | return true; | ||
120 | } | ||
121 | return false; | ||
122 | } | ||
123 | |||
124 | public void setS1(final Segment pS1) { | ||
125 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
126 | this.fS1 = pS1; | ||
127 | } | ||
128 | |||
129 | public void setS2(final Segment pS2) { | ||
130 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
131 | this.fS2 = pS2; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public String patternName() { | ||
136 | return "modes3.queries.reachable"; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public List<String> parameterNames() { | ||
141 | return Reachable.Match.parameterNames; | ||
142 | } | ||
143 | |||
144 | @Override | ||
145 | public Object[] toArray() { | ||
146 | return new Object[]{fS1, fS2}; | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public Reachable.Match toImmutable() { | ||
151 | return isMutable() ? newMatch(fS1, fS2) : this; | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public String prettyPrint() { | ||
156 | StringBuilder result = new StringBuilder(); | ||
157 | result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); | ||
158 | result.append("\"S2\"=" + prettyPrintValue(fS2)); | ||
159 | return result.toString(); | ||
160 | } | ||
161 | |||
162 | @Override | ||
163 | public int hashCode() { | ||
164 | return Objects.hash(fS1, fS2); | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public boolean equals(final Object obj) { | ||
169 | if (this == obj) | ||
170 | return true; | ||
171 | if (obj == null) { | ||
172 | return false; | ||
173 | } | ||
174 | if ((obj instanceof Reachable.Match)) { | ||
175 | Reachable.Match other = (Reachable.Match) obj; | ||
176 | return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); | ||
177 | } else { | ||
178 | // this should be infrequent | ||
179 | if (!(obj instanceof IPatternMatch)) { | ||
180 | return false; | ||
181 | } | ||
182 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
183 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | @Override | ||
188 | public Reachable specification() { | ||
189 | return Reachable.instance(); | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * Returns an empty, mutable match. | ||
194 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
195 | * | ||
196 | * @return the empty match. | ||
197 | * | ||
198 | */ | ||
199 | public static Reachable.Match newEmptyMatch() { | ||
200 | return new Mutable(null, null); | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * Returns a mutable (partial) match. | ||
205 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
206 | * | ||
207 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
208 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
209 | * @return the new, mutable (partial) match object. | ||
210 | * | ||
211 | */ | ||
212 | public static Reachable.Match newMutableMatch(final Segment pS1, final Segment pS2) { | ||
213 | return new Mutable(pS1, pS2); | ||
214 | } | ||
215 | |||
216 | /** | ||
217 | * Returns a new (partial) match. | ||
218 | * This can be used e.g. to call the matcher with a partial match. | ||
219 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
220 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
221 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
222 | * @return the (partial) match object. | ||
223 | * | ||
224 | */ | ||
225 | public static Reachable.Match newMatch(final Segment pS1, final Segment pS2) { | ||
226 | return new Immutable(pS1, pS2); | ||
227 | } | ||
228 | |||
229 | private static final class Mutable extends Reachable.Match { | ||
230 | Mutable(final Segment pS1, final Segment pS2) { | ||
231 | super(pS1, pS2); | ||
232 | } | ||
233 | |||
234 | @Override | ||
235 | public boolean isMutable() { | ||
236 | return true; | ||
237 | } | ||
238 | } | ||
239 | |||
240 | private static final class Immutable extends Reachable.Match { | ||
241 | Immutable(final Segment pS1, final Segment pS2) { | ||
242 | super(pS1, pS2); | ||
243 | } | ||
244 | |||
245 | @Override | ||
246 | public boolean isMutable() { | ||
247 | return false; | ||
248 | } | ||
249 | } | ||
250 | } | ||
251 | |||
252 | /** | ||
253 | * Generated pattern matcher API of the modes3.queries.reachable pattern, | ||
254 | * providing pattern-specific query methods. | ||
255 | * | ||
256 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
257 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
258 | * | ||
259 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
260 | * | ||
261 | * <p>Original source: | ||
262 | * <code><pre> | ||
263 | * pattern reachable(S1 : Segment, S2 : Segment) { | ||
264 | * S1 == S2; | ||
265 | * } or { | ||
266 | * find adjacent+(S1, S2); | ||
267 | * } | ||
268 | * </pre></code> | ||
269 | * | ||
270 | * @see Match | ||
271 | * @see Reachable | ||
272 | * | ||
273 | */ | ||
274 | public static class Matcher extends BaseMatcher<Reachable.Match> { | ||
275 | /** | ||
276 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
277 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
278 | * | ||
279 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
280 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
281 | * | ||
282 | */ | ||
283 | public static Reachable.Matcher on(final ViatraQueryEngine engine) { | ||
284 | // check if matcher already exists | ||
285 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
286 | if (matcher == null) { | ||
287 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
288 | } | ||
289 | return matcher; | ||
290 | } | ||
291 | |||
292 | /** | ||
293 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
294 | * @return an initialized matcher | ||
295 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
296 | * | ||
297 | */ | ||
298 | public static Reachable.Matcher create() { | ||
299 | return new Matcher(); | ||
300 | } | ||
301 | |||
302 | private static final int POSITION_S1 = 0; | ||
303 | |||
304 | private static final int POSITION_S2 = 1; | ||
305 | |||
306 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Reachable.Matcher.class); | ||
307 | |||
308 | /** | ||
309 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
310 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
311 | * | ||
312 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
313 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
314 | * | ||
315 | */ | ||
316 | private Matcher() { | ||
317 | super(querySpecification()); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
322 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
323 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
324 | * @return matches represented as a Match object. | ||
325 | * | ||
326 | */ | ||
327 | public Collection<Reachable.Match> getAllMatches(final Segment pS1, final Segment pS2) { | ||
328 | return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
333 | * </p> | ||
334 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
335 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
336 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
337 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
338 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
339 | * @return a stream of matches represented as a Match object. | ||
340 | * | ||
341 | */ | ||
342 | public Stream<Reachable.Match> streamAllMatches(final Segment pS1, final Segment pS2) { | ||
343 | return rawStreamAllMatches(new Object[]{pS1, pS2}); | ||
344 | } | ||
345 | |||
346 | /** | ||
347 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
348 | * Neither determinism nor randomness of selection is guaranteed. | ||
349 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
350 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
351 | * @return a match represented as a Match object, or null if no match is found. | ||
352 | * | ||
353 | */ | ||
354 | public Optional<Reachable.Match> getOneArbitraryMatch(final Segment pS1, final Segment pS2) { | ||
355 | return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
360 | * under any possible substitution of the unspecified parameters (if any). | ||
361 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
362 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
363 | * @return true if the input is a valid (partial) match of the pattern. | ||
364 | * | ||
365 | */ | ||
366 | public boolean hasMatch(final Segment pS1, final Segment pS2) { | ||
367 | return rawHasMatch(new Object[]{pS1, pS2}); | ||
368 | } | ||
369 | |||
370 | /** | ||
371 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
372 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
373 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
374 | * @return the number of pattern matches found. | ||
375 | * | ||
376 | */ | ||
377 | public int countMatches(final Segment pS1, final Segment pS2) { | ||
378 | return rawCountMatches(new Object[]{pS1, pS2}); | ||
379 | } | ||
380 | |||
381 | /** | ||
382 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
383 | * Neither determinism nor randomness of selection is guaranteed. | ||
384 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
385 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
386 | * @param processor the action that will process the selected match. | ||
387 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
388 | * | ||
389 | */ | ||
390 | public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer<? super Reachable.Match> processor) { | ||
391 | return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Returns a new (partial) match. | ||
396 | * This can be used e.g. to call the matcher with a partial match. | ||
397 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
398 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
399 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
400 | * @return the (partial) match object. | ||
401 | * | ||
402 | */ | ||
403 | public Reachable.Match newMatch(final Segment pS1, final Segment pS2) { | ||
404 | return Reachable.Match.newMatch(pS1, pS2); | ||
405 | } | ||
406 | |||
407 | /** | ||
408 | * Retrieve the set of values that occur in matches for S1. | ||
409 | * @return the Set of all values or empty set if there are no matches | ||
410 | * | ||
411 | */ | ||
412 | protected Stream<Segment> rawStreamAllValuesOfS1(final Object[] parameters) { | ||
413 | return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); | ||
414 | } | ||
415 | |||
416 | /** | ||
417 | * Retrieve the set of values that occur in matches for S1. | ||
418 | * @return the Set of all values or empty set if there are no matches | ||
419 | * | ||
420 | */ | ||
421 | public Set<Segment> getAllValuesOfS1() { | ||
422 | return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); | ||
423 | } | ||
424 | |||
425 | /** | ||
426 | * Retrieve the set of values that occur in matches for S1. | ||
427 | * @return the Set of all values or empty set if there are no matches | ||
428 | * | ||
429 | */ | ||
430 | public Stream<Segment> streamAllValuesOfS1() { | ||
431 | return rawStreamAllValuesOfS1(emptyArray()); | ||
432 | } | ||
433 | |||
434 | /** | ||
435 | * Retrieve the set of values that occur in matches for S1. | ||
436 | * </p> | ||
437 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
438 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
439 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
440 | * | ||
441 | * @return the Stream of all values or empty set if there are no matches | ||
442 | * | ||
443 | */ | ||
444 | public Stream<Segment> streamAllValuesOfS1(final Reachable.Match partialMatch) { | ||
445 | return rawStreamAllValuesOfS1(partialMatch.toArray()); | ||
446 | } | ||
447 | |||
448 | /** | ||
449 | * Retrieve the set of values that occur in matches for S1. | ||
450 | * </p> | ||
451 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
452 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
453 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
454 | * | ||
455 | * @return the Stream of all values or empty set if there are no matches | ||
456 | * | ||
457 | */ | ||
458 | public Stream<Segment> streamAllValuesOfS1(final Segment pS2) { | ||
459 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}); | ||
460 | } | ||
461 | |||
462 | /** | ||
463 | * Retrieve the set of values that occur in matches for S1. | ||
464 | * @return the Set of all values or empty set if there are no matches | ||
465 | * | ||
466 | */ | ||
467 | public Set<Segment> getAllValuesOfS1(final Reachable.Match partialMatch) { | ||
468 | return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); | ||
469 | } | ||
470 | |||
471 | /** | ||
472 | * Retrieve the set of values that occur in matches for S1. | ||
473 | * @return the Set of all values or empty set if there are no matches | ||
474 | * | ||
475 | */ | ||
476 | public Set<Segment> getAllValuesOfS1(final Segment pS2) { | ||
477 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Retrieve the set of values that occur in matches for S2. | ||
482 | * @return the Set of all values or empty set if there are no matches | ||
483 | * | ||
484 | */ | ||
485 | protected Stream<Segment> rawStreamAllValuesOfS2(final Object[] parameters) { | ||
486 | return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); | ||
487 | } | ||
488 | |||
489 | /** | ||
490 | * Retrieve the set of values that occur in matches for S2. | ||
491 | * @return the Set of all values or empty set if there are no matches | ||
492 | * | ||
493 | */ | ||
494 | public Set<Segment> getAllValuesOfS2() { | ||
495 | return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); | ||
496 | } | ||
497 | |||
498 | /** | ||
499 | * Retrieve the set of values that occur in matches for S2. | ||
500 | * @return the Set of all values or empty set if there are no matches | ||
501 | * | ||
502 | */ | ||
503 | public Stream<Segment> streamAllValuesOfS2() { | ||
504 | return rawStreamAllValuesOfS2(emptyArray()); | ||
505 | } | ||
506 | |||
507 | /** | ||
508 | * Retrieve the set of values that occur in matches for S2. | ||
509 | * </p> | ||
510 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
511 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
512 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
513 | * | ||
514 | * @return the Stream of all values or empty set if there are no matches | ||
515 | * | ||
516 | */ | ||
517 | public Stream<Segment> streamAllValuesOfS2(final Reachable.Match partialMatch) { | ||
518 | return rawStreamAllValuesOfS2(partialMatch.toArray()); | ||
519 | } | ||
520 | |||
521 | /** | ||
522 | * Retrieve the set of values that occur in matches for S2. | ||
523 | * </p> | ||
524 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
525 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
526 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
527 | * | ||
528 | * @return the Stream of all values or empty set if there are no matches | ||
529 | * | ||
530 | */ | ||
531 | public Stream<Segment> streamAllValuesOfS2(final Segment pS1) { | ||
532 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}); | ||
533 | } | ||
534 | |||
535 | /** | ||
536 | * Retrieve the set of values that occur in matches for S2. | ||
537 | * @return the Set of all values or empty set if there are no matches | ||
538 | * | ||
539 | */ | ||
540 | public Set<Segment> getAllValuesOfS2(final Reachable.Match partialMatch) { | ||
541 | return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); | ||
542 | } | ||
543 | |||
544 | /** | ||
545 | * Retrieve the set of values that occur in matches for S2. | ||
546 | * @return the Set of all values or empty set if there are no matches | ||
547 | * | ||
548 | */ | ||
549 | public Set<Segment> getAllValuesOfS2(final Segment pS1) { | ||
550 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); | ||
551 | } | ||
552 | |||
553 | @Override | ||
554 | protected Reachable.Match tupleToMatch(final Tuple t) { | ||
555 | try { | ||
556 | return Reachable.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); | ||
557 | } catch(ClassCastException e) { | ||
558 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
559 | return null; | ||
560 | } | ||
561 | } | ||
562 | |||
563 | @Override | ||
564 | protected Reachable.Match arrayToMatch(final Object[] match) { | ||
565 | try { | ||
566 | return Reachable.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
567 | } catch(ClassCastException e) { | ||
568 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
569 | return null; | ||
570 | } | ||
571 | } | ||
572 | |||
573 | @Override | ||
574 | protected Reachable.Match arrayToMatchMutable(final Object[] match) { | ||
575 | try { | ||
576 | return Reachable.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
577 | } catch(ClassCastException e) { | ||
578 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
579 | return null; | ||
580 | } | ||
581 | } | ||
582 | |||
583 | /** | ||
584 | * @return the singleton instance of the query specification of this pattern | ||
585 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
586 | * | ||
587 | */ | ||
588 | public static IQuerySpecification<Reachable.Matcher> querySpecification() { | ||
589 | return Reachable.instance(); | ||
590 | } | ||
591 | } | ||
592 | |||
593 | private Reachable() { | ||
594 | super(GeneratedPQuery.INSTANCE); | ||
595 | } | ||
596 | |||
597 | /** | ||
598 | * @return the singleton instance of the query specification | ||
599 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
600 | * | ||
601 | */ | ||
602 | public static Reachable instance() { | ||
603 | try{ | ||
604 | return LazyHolder.INSTANCE; | ||
605 | } catch (ExceptionInInitializerError err) { | ||
606 | throw processInitializerError(err); | ||
607 | } | ||
608 | } | ||
609 | |||
610 | @Override | ||
611 | protected Reachable.Matcher instantiate(final ViatraQueryEngine engine) { | ||
612 | return Reachable.Matcher.on(engine); | ||
613 | } | ||
614 | |||
615 | @Override | ||
616 | public Reachable.Matcher instantiate() { | ||
617 | return Reachable.Matcher.create(); | ||
618 | } | ||
619 | |||
620 | @Override | ||
621 | public Reachable.Match newEmptyMatch() { | ||
622 | return Reachable.Match.newEmptyMatch(); | ||
623 | } | ||
624 | |||
625 | @Override | ||
626 | public Reachable.Match newMatch(final Object... parameters) { | ||
627 | return Reachable.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); | ||
628 | } | ||
629 | |||
630 | /** | ||
631 | * Inner class allowing the singleton instance of {@link Reachable} to be created | ||
632 | * <b>not</b> at the class load time of the outer class, | ||
633 | * but rather at the first call to {@link Reachable#instance()}. | ||
634 | * | ||
635 | * <p> This workaround is required e.g. to support recursion. | ||
636 | * | ||
637 | */ | ||
638 | private static class LazyHolder { | ||
639 | private static final Reachable INSTANCE = new Reachable(); | ||
640 | |||
641 | /** | ||
642 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
643 | * This initialization order is required to support indirect recursion. | ||
644 | * | ||
645 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
646 | * | ||
647 | */ | ||
648 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
649 | |||
650 | public static Object ensureInitialized() { | ||
651 | INSTANCE.ensureInitializedInternal(); | ||
652 | return null; | ||
653 | } | ||
654 | } | ||
655 | |||
656 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
657 | private static final Reachable.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
658 | |||
659 | private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
660 | |||
661 | private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
662 | |||
663 | private final List<PParameter> parameters = Arrays.asList(parameter_S1, parameter_S2); | ||
664 | |||
665 | private GeneratedPQuery() { | ||
666 | super(PVisibility.PUBLIC); | ||
667 | } | ||
668 | |||
669 | @Override | ||
670 | public String getFullyQualifiedName() { | ||
671 | return "modes3.queries.reachable"; | ||
672 | } | ||
673 | |||
674 | @Override | ||
675 | public List<String> getParameterNames() { | ||
676 | return Arrays.asList("S1","S2"); | ||
677 | } | ||
678 | |||
679 | @Override | ||
680 | public List<PParameter> getParameters() { | ||
681 | return parameters; | ||
682 | } | ||
683 | |||
684 | @Override | ||
685 | public Set<PBody> doGetContainedBodies() { | ||
686 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
687 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
688 | { | ||
689 | PBody body = new PBody(this); | ||
690 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
691 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
692 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
693 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
694 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
695 | new ExportedParameter(body, var_S1, parameter_S1), | ||
696 | new ExportedParameter(body, var_S2, parameter_S2) | ||
697 | )); | ||
698 | // S1 == S2 | ||
699 | new Equality(body, var_S1, var_S2); | ||
700 | bodies.add(body); | ||
701 | } | ||
702 | { | ||
703 | PBody body = new PBody(this); | ||
704 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
705 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
706 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
707 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
708 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
709 | new ExportedParameter(body, var_S1, parameter_S1), | ||
710 | new ExportedParameter(body, var_S2, parameter_S2) | ||
711 | )); | ||
712 | // find adjacent+(S1, S2) | ||
713 | new BinaryTransitiveClosure(body, Tuples.flatTupleOf(var_S1, var_S2), Adjacent.instance().getInternalQueryRepresentation()); | ||
714 | bodies.add(body); | ||
715 | } | ||
716 | return bodies; | ||
717 | } | ||
718 | } | ||
719 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooFewInputsOfTurnout.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooFewInputsOfTurnout.java new file mode 100644 index 00000000..088640ca --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooFewInputsOfTurnout.java | |||
@@ -0,0 +1,559 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Turnout; | ||
17 | import modes3.queries.InputsOfTurnout; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * {@literal @}Constraint(message = "tooFewInputsOfTurnout", severity = "error", key = { T }) | ||
49 | * pattern tooFewInputsOfTurnout(T : Turnout) { | ||
50 | * neg find inputsOfTurnout(T); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class TooFewInputsOfTurnout extends BaseGeneratedEMFQuerySpecification<TooFewInputsOfTurnout.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.tooFewInputsOfTurnout pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Turnout fT; | ||
74 | |||
75 | private static List<String> parameterNames = makeImmutableList("T"); | ||
76 | |||
77 | private Match(final Turnout pT) { | ||
78 | this.fT = pT; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "T": return this.fT; | ||
85 | default: return null; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final int index) { | ||
91 | switch(index) { | ||
92 | case 0: return this.fT; | ||
93 | default: return null; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | public Turnout getT() { | ||
98 | return this.fT; | ||
99 | } | ||
100 | |||
101 | @Override | ||
102 | public boolean set(final String parameterName, final Object newValue) { | ||
103 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
104 | if ("T".equals(parameterName) ) { | ||
105 | this.fT = (Turnout) newValue; | ||
106 | return true; | ||
107 | } | ||
108 | return false; | ||
109 | } | ||
110 | |||
111 | public void setT(final Turnout pT) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | this.fT = pT; | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public String patternName() { | ||
118 | return "modes3.queries.tooFewInputsOfTurnout"; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public List<String> parameterNames() { | ||
123 | return TooFewInputsOfTurnout.Match.parameterNames; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public Object[] toArray() { | ||
128 | return new Object[]{fT}; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public TooFewInputsOfTurnout.Match toImmutable() { | ||
133 | return isMutable() ? newMatch(fT) : this; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public String prettyPrint() { | ||
138 | StringBuilder result = new StringBuilder(); | ||
139 | result.append("\"T\"=" + prettyPrintValue(fT)); | ||
140 | return result.toString(); | ||
141 | } | ||
142 | |||
143 | @Override | ||
144 | public int hashCode() { | ||
145 | return Objects.hash(fT); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public boolean equals(final Object obj) { | ||
150 | if (this == obj) | ||
151 | return true; | ||
152 | if (obj == null) { | ||
153 | return false; | ||
154 | } | ||
155 | if ((obj instanceof TooFewInputsOfTurnout.Match)) { | ||
156 | TooFewInputsOfTurnout.Match other = (TooFewInputsOfTurnout.Match) obj; | ||
157 | return Objects.equals(fT, other.fT); | ||
158 | } else { | ||
159 | // this should be infrequent | ||
160 | if (!(obj instanceof IPatternMatch)) { | ||
161 | return false; | ||
162 | } | ||
163 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
164 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public TooFewInputsOfTurnout specification() { | ||
170 | return TooFewInputsOfTurnout.instance(); | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * Returns an empty, mutable match. | ||
175 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
176 | * | ||
177 | * @return the empty match. | ||
178 | * | ||
179 | */ | ||
180 | public static TooFewInputsOfTurnout.Match newEmptyMatch() { | ||
181 | return new Mutable(null); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Returns a mutable (partial) match. | ||
186 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
187 | * | ||
188 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
189 | * @return the new, mutable (partial) match object. | ||
190 | * | ||
191 | */ | ||
192 | public static TooFewInputsOfTurnout.Match newMutableMatch(final Turnout pT) { | ||
193 | return new Mutable(pT); | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * Returns a new (partial) match. | ||
198 | * This can be used e.g. to call the matcher with a partial match. | ||
199 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
200 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
201 | * @return the (partial) match object. | ||
202 | * | ||
203 | */ | ||
204 | public static TooFewInputsOfTurnout.Match newMatch(final Turnout pT) { | ||
205 | return new Immutable(pT); | ||
206 | } | ||
207 | |||
208 | private static final class Mutable extends TooFewInputsOfTurnout.Match { | ||
209 | Mutable(final Turnout pT) { | ||
210 | super(pT); | ||
211 | } | ||
212 | |||
213 | @Override | ||
214 | public boolean isMutable() { | ||
215 | return true; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | private static final class Immutable extends TooFewInputsOfTurnout.Match { | ||
220 | Immutable(final Turnout pT) { | ||
221 | super(pT); | ||
222 | } | ||
223 | |||
224 | @Override | ||
225 | public boolean isMutable() { | ||
226 | return false; | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * Generated pattern matcher API of the modes3.queries.tooFewInputsOfTurnout pattern, | ||
233 | * providing pattern-specific query methods. | ||
234 | * | ||
235 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
236 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
237 | * | ||
238 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
239 | * | ||
240 | * <p>Original source: | ||
241 | * <code><pre> | ||
242 | * {@literal @}Constraint(message = "tooFewInputsOfTurnout", severity = "error", key = { T }) | ||
243 | * pattern tooFewInputsOfTurnout(T : Turnout) { | ||
244 | * neg find inputsOfTurnout(T); | ||
245 | * } | ||
246 | * </pre></code> | ||
247 | * | ||
248 | * @see Match | ||
249 | * @see TooFewInputsOfTurnout | ||
250 | * | ||
251 | */ | ||
252 | public static class Matcher extends BaseMatcher<TooFewInputsOfTurnout.Match> { | ||
253 | /** | ||
254 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
255 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
256 | * | ||
257 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
258 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
259 | * | ||
260 | */ | ||
261 | public static TooFewInputsOfTurnout.Matcher on(final ViatraQueryEngine engine) { | ||
262 | // check if matcher already exists | ||
263 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
264 | if (matcher == null) { | ||
265 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
266 | } | ||
267 | return matcher; | ||
268 | } | ||
269 | |||
270 | /** | ||
271 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
272 | * @return an initialized matcher | ||
273 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
274 | * | ||
275 | */ | ||
276 | public static TooFewInputsOfTurnout.Matcher create() { | ||
277 | return new Matcher(); | ||
278 | } | ||
279 | |||
280 | private static final int POSITION_T = 0; | ||
281 | |||
282 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TooFewInputsOfTurnout.Matcher.class); | ||
283 | |||
284 | /** | ||
285 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
286 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
287 | * | ||
288 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
289 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
290 | * | ||
291 | */ | ||
292 | private Matcher() { | ||
293 | super(querySpecification()); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
298 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
299 | * @return matches represented as a Match object. | ||
300 | * | ||
301 | */ | ||
302 | public Collection<TooFewInputsOfTurnout.Match> getAllMatches(final Turnout pT) { | ||
303 | return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); | ||
304 | } | ||
305 | |||
306 | /** | ||
307 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
308 | * </p> | ||
309 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
310 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
311 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
312 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
313 | * @return a stream of matches represented as a Match object. | ||
314 | * | ||
315 | */ | ||
316 | public Stream<TooFewInputsOfTurnout.Match> streamAllMatches(final Turnout pT) { | ||
317 | return rawStreamAllMatches(new Object[]{pT}); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
322 | * Neither determinism nor randomness of selection is guaranteed. | ||
323 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
324 | * @return a match represented as a Match object, or null if no match is found. | ||
325 | * | ||
326 | */ | ||
327 | public Optional<TooFewInputsOfTurnout.Match> getOneArbitraryMatch(final Turnout pT) { | ||
328 | return rawGetOneArbitraryMatch(new Object[]{pT}); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
333 | * under any possible substitution of the unspecified parameters (if any). | ||
334 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
335 | * @return true if the input is a valid (partial) match of the pattern. | ||
336 | * | ||
337 | */ | ||
338 | public boolean hasMatch(final Turnout pT) { | ||
339 | return rawHasMatch(new Object[]{pT}); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
344 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
345 | * @return the number of pattern matches found. | ||
346 | * | ||
347 | */ | ||
348 | public int countMatches(final Turnout pT) { | ||
349 | return rawCountMatches(new Object[]{pT}); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
354 | * Neither determinism nor randomness of selection is guaranteed. | ||
355 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
356 | * @param processor the action that will process the selected match. | ||
357 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
358 | * | ||
359 | */ | ||
360 | public boolean forOneArbitraryMatch(final Turnout pT, final Consumer<? super TooFewInputsOfTurnout.Match> processor) { | ||
361 | return rawForOneArbitraryMatch(new Object[]{pT}, processor); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Returns a new (partial) match. | ||
366 | * This can be used e.g. to call the matcher with a partial match. | ||
367 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
368 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
369 | * @return the (partial) match object. | ||
370 | * | ||
371 | */ | ||
372 | public TooFewInputsOfTurnout.Match newMatch(final Turnout pT) { | ||
373 | return TooFewInputsOfTurnout.Match.newMatch(pT); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Retrieve the set of values that occur in matches for T. | ||
378 | * @return the Set of all values or empty set if there are no matches | ||
379 | * | ||
380 | */ | ||
381 | protected Stream<Turnout> rawStreamAllValuesOfT(final Object[] parameters) { | ||
382 | return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * Retrieve the set of values that occur in matches for T. | ||
387 | * @return the Set of all values or empty set if there are no matches | ||
388 | * | ||
389 | */ | ||
390 | public Set<Turnout> getAllValuesOfT() { | ||
391 | return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Retrieve the set of values that occur in matches for T. | ||
396 | * @return the Set of all values or empty set if there are no matches | ||
397 | * | ||
398 | */ | ||
399 | public Stream<Turnout> streamAllValuesOfT() { | ||
400 | return rawStreamAllValuesOfT(emptyArray()); | ||
401 | } | ||
402 | |||
403 | @Override | ||
404 | protected TooFewInputsOfTurnout.Match tupleToMatch(final Tuple t) { | ||
405 | try { | ||
406 | return TooFewInputsOfTurnout.Match.newMatch((Turnout) t.get(POSITION_T)); | ||
407 | } catch(ClassCastException e) { | ||
408 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
409 | return null; | ||
410 | } | ||
411 | } | ||
412 | |||
413 | @Override | ||
414 | protected TooFewInputsOfTurnout.Match arrayToMatch(final Object[] match) { | ||
415 | try { | ||
416 | return TooFewInputsOfTurnout.Match.newMatch((Turnout) match[POSITION_T]); | ||
417 | } catch(ClassCastException e) { | ||
418 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
419 | return null; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | @Override | ||
424 | protected TooFewInputsOfTurnout.Match arrayToMatchMutable(final Object[] match) { | ||
425 | try { | ||
426 | return TooFewInputsOfTurnout.Match.newMutableMatch((Turnout) match[POSITION_T]); | ||
427 | } catch(ClassCastException e) { | ||
428 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
429 | return null; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * @return the singleton instance of the query specification of this pattern | ||
435 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
436 | * | ||
437 | */ | ||
438 | public static IQuerySpecification<TooFewInputsOfTurnout.Matcher> querySpecification() { | ||
439 | return TooFewInputsOfTurnout.instance(); | ||
440 | } | ||
441 | } | ||
442 | |||
443 | private TooFewInputsOfTurnout() { | ||
444 | super(GeneratedPQuery.INSTANCE); | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @return the singleton instance of the query specification | ||
449 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
450 | * | ||
451 | */ | ||
452 | public static TooFewInputsOfTurnout instance() { | ||
453 | try{ | ||
454 | return LazyHolder.INSTANCE; | ||
455 | } catch (ExceptionInInitializerError err) { | ||
456 | throw processInitializerError(err); | ||
457 | } | ||
458 | } | ||
459 | |||
460 | @Override | ||
461 | protected TooFewInputsOfTurnout.Matcher instantiate(final ViatraQueryEngine engine) { | ||
462 | return TooFewInputsOfTurnout.Matcher.on(engine); | ||
463 | } | ||
464 | |||
465 | @Override | ||
466 | public TooFewInputsOfTurnout.Matcher instantiate() { | ||
467 | return TooFewInputsOfTurnout.Matcher.create(); | ||
468 | } | ||
469 | |||
470 | @Override | ||
471 | public TooFewInputsOfTurnout.Match newEmptyMatch() { | ||
472 | return TooFewInputsOfTurnout.Match.newEmptyMatch(); | ||
473 | } | ||
474 | |||
475 | @Override | ||
476 | public TooFewInputsOfTurnout.Match newMatch(final Object... parameters) { | ||
477 | return TooFewInputsOfTurnout.Match.newMatch((modes3.Turnout) parameters[0]); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Inner class allowing the singleton instance of {@link TooFewInputsOfTurnout} to be created | ||
482 | * <b>not</b> at the class load time of the outer class, | ||
483 | * but rather at the first call to {@link TooFewInputsOfTurnout#instance()}. | ||
484 | * | ||
485 | * <p> This workaround is required e.g. to support recursion. | ||
486 | * | ||
487 | */ | ||
488 | private static class LazyHolder { | ||
489 | private static final TooFewInputsOfTurnout INSTANCE = new TooFewInputsOfTurnout(); | ||
490 | |||
491 | /** | ||
492 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
493 | * This initialization order is required to support indirect recursion. | ||
494 | * | ||
495 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
496 | * | ||
497 | */ | ||
498 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
499 | |||
500 | public static Object ensureInitialized() { | ||
501 | INSTANCE.ensureInitializedInternal(); | ||
502 | return null; | ||
503 | } | ||
504 | } | ||
505 | |||
506 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
507 | private static final TooFewInputsOfTurnout.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
508 | |||
509 | private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); | ||
510 | |||
511 | private final List<PParameter> parameters = Arrays.asList(parameter_T); | ||
512 | |||
513 | private GeneratedPQuery() { | ||
514 | super(PVisibility.PUBLIC); | ||
515 | } | ||
516 | |||
517 | @Override | ||
518 | public String getFullyQualifiedName() { | ||
519 | return "modes3.queries.tooFewInputsOfTurnout"; | ||
520 | } | ||
521 | |||
522 | @Override | ||
523 | public List<String> getParameterNames() { | ||
524 | return Arrays.asList("T"); | ||
525 | } | ||
526 | |||
527 | @Override | ||
528 | public List<PParameter> getParameters() { | ||
529 | return parameters; | ||
530 | } | ||
531 | |||
532 | @Override | ||
533 | public Set<PBody> doGetContainedBodies() { | ||
534 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
535 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
536 | { | ||
537 | PBody body = new PBody(this); | ||
538 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
539 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
540 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
541 | new ExportedParameter(body, var_T, parameter_T) | ||
542 | )); | ||
543 | // neg find inputsOfTurnout(T) | ||
544 | new NegativePatternCall(body, Tuples.flatTupleOf(var_T), InputsOfTurnout.instance().getInternalQueryRepresentation()); | ||
545 | bodies.add(body); | ||
546 | } | ||
547 | { | ||
548 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
549 | annotation.addAttribute("message", "tooFewInputsOfTurnout"); | ||
550 | annotation.addAttribute("severity", "error"); | ||
551 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
552 | new ParameterReference("T") | ||
553 | })); | ||
554 | addAnnotation(annotation); | ||
555 | } | ||
556 | return bodies; | ||
557 | } | ||
558 | } | ||
559 | } | ||
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..d12ec23e --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfSegment.java | |||
@@ -0,0 +1,583 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.SimpleSegment; | ||
17 | import modes3.queries.Output; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
42 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
43 | |||
44 | /** | ||
45 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
46 | * | ||
47 | * <p>Original source: | ||
48 | * <code><pre> | ||
49 | * {@literal @}Constraint(message = "tooManyInputsOfSegment", severity = "error", key = { S }) | ||
50 | * pattern tooManyInputsOfSegment(S : SimpleSegment) { | ||
51 | * find output(I1, S); | ||
52 | * find output(I2, S); | ||
53 | * find output(I3, S); | ||
54 | * I1 != I2; | ||
55 | * I1 != I3; | ||
56 | * I2 != I3; | ||
57 | * } | ||
58 | * </pre></code> | ||
59 | * | ||
60 | * @see Matcher | ||
61 | * @see Match | ||
62 | * | ||
63 | */ | ||
64 | @SuppressWarnings("all") | ||
65 | public final class TooManyInputsOfSegment extends BaseGeneratedEMFQuerySpecification<TooManyInputsOfSegment.Matcher> { | ||
66 | /** | ||
67 | * Pattern-specific match representation of the modes3.queries.tooManyInputsOfSegment pattern, | ||
68 | * to be used in conjunction with {@link Matcher}. | ||
69 | * | ||
70 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
71 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
72 | * usable to represent a match of the pattern in the result of a query, | ||
73 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
74 | * | ||
75 | * @see Matcher | ||
76 | * | ||
77 | */ | ||
78 | public static abstract class Match extends BasePatternMatch { | ||
79 | private SimpleSegment fS; | ||
80 | |||
81 | private static List<String> parameterNames = makeImmutableList("S"); | ||
82 | |||
83 | private Match(final SimpleSegment pS) { | ||
84 | this.fS = pS; | ||
85 | } | ||
86 | |||
87 | @Override | ||
88 | public Object get(final String parameterName) { | ||
89 | switch(parameterName) { | ||
90 | case "S": return this.fS; | ||
91 | default: return null; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | @Override | ||
96 | public Object get(final int index) { | ||
97 | switch(index) { | ||
98 | case 0: return this.fS; | ||
99 | default: return null; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | public SimpleSegment getS() { | ||
104 | return this.fS; | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public boolean set(final String parameterName, final Object newValue) { | ||
109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
110 | if ("S".equals(parameterName) ) { | ||
111 | this.fS = (SimpleSegment) newValue; | ||
112 | return true; | ||
113 | } | ||
114 | return false; | ||
115 | } | ||
116 | |||
117 | public void setS(final SimpleSegment pS) { | ||
118 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
119 | this.fS = pS; | ||
120 | } | ||
121 | |||
122 | @Override | ||
123 | public String patternName() { | ||
124 | return "modes3.queries.tooManyInputsOfSegment"; | ||
125 | } | ||
126 | |||
127 | @Override | ||
128 | public List<String> parameterNames() { | ||
129 | return TooManyInputsOfSegment.Match.parameterNames; | ||
130 | } | ||
131 | |||
132 | @Override | ||
133 | public Object[] toArray() { | ||
134 | return new Object[]{fS}; | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public TooManyInputsOfSegment.Match toImmutable() { | ||
139 | return isMutable() ? newMatch(fS) : this; | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public String prettyPrint() { | ||
144 | StringBuilder result = new StringBuilder(); | ||
145 | result.append("\"S\"=" + prettyPrintValue(fS)); | ||
146 | return result.toString(); | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public int hashCode() { | ||
151 | return Objects.hash(fS); | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public boolean equals(final Object obj) { | ||
156 | if (this == obj) | ||
157 | return true; | ||
158 | if (obj == null) { | ||
159 | return false; | ||
160 | } | ||
161 | if ((obj instanceof TooManyInputsOfSegment.Match)) { | ||
162 | TooManyInputsOfSegment.Match other = (TooManyInputsOfSegment.Match) obj; | ||
163 | return Objects.equals(fS, other.fS); | ||
164 | } else { | ||
165 | // this should be infrequent | ||
166 | if (!(obj instanceof IPatternMatch)) { | ||
167 | return false; | ||
168 | } | ||
169 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
170 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
171 | } | ||
172 | } | ||
173 | |||
174 | @Override | ||
175 | public TooManyInputsOfSegment specification() { | ||
176 | return TooManyInputsOfSegment.instance(); | ||
177 | } | ||
178 | |||
179 | /** | ||
180 | * Returns an empty, mutable match. | ||
181 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
182 | * | ||
183 | * @return the empty match. | ||
184 | * | ||
185 | */ | ||
186 | public static TooManyInputsOfSegment.Match newEmptyMatch() { | ||
187 | return new Mutable(null); | ||
188 | } | ||
189 | |||
190 | /** | ||
191 | * Returns a mutable (partial) match. | ||
192 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
193 | * | ||
194 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
195 | * @return the new, mutable (partial) match object. | ||
196 | * | ||
197 | */ | ||
198 | public static TooManyInputsOfSegment.Match newMutableMatch(final SimpleSegment pS) { | ||
199 | return new Mutable(pS); | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * Returns a new (partial) match. | ||
204 | * This can be used e.g. to call the matcher with a partial match. | ||
205 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
206 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
207 | * @return the (partial) match object. | ||
208 | * | ||
209 | */ | ||
210 | public static TooManyInputsOfSegment.Match newMatch(final SimpleSegment pS) { | ||
211 | return new Immutable(pS); | ||
212 | } | ||
213 | |||
214 | private static final class Mutable extends TooManyInputsOfSegment.Match { | ||
215 | Mutable(final SimpleSegment pS) { | ||
216 | super(pS); | ||
217 | } | ||
218 | |||
219 | @Override | ||
220 | public boolean isMutable() { | ||
221 | return true; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | private static final class Immutable extends TooManyInputsOfSegment.Match { | ||
226 | Immutable(final SimpleSegment pS) { | ||
227 | super(pS); | ||
228 | } | ||
229 | |||
230 | @Override | ||
231 | public boolean isMutable() { | ||
232 | return false; | ||
233 | } | ||
234 | } | ||
235 | } | ||
236 | |||
237 | /** | ||
238 | * Generated pattern matcher API of the modes3.queries.tooManyInputsOfSegment pattern, | ||
239 | * providing pattern-specific query methods. | ||
240 | * | ||
241 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
242 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
243 | * | ||
244 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
245 | * | ||
246 | * <p>Original source: | ||
247 | * <code><pre> | ||
248 | * {@literal @}Constraint(message = "tooManyInputsOfSegment", severity = "error", key = { S }) | ||
249 | * pattern tooManyInputsOfSegment(S : SimpleSegment) { | ||
250 | * find output(I1, S); | ||
251 | * find output(I2, S); | ||
252 | * find output(I3, S); | ||
253 | * I1 != I2; | ||
254 | * I1 != I3; | ||
255 | * I2 != I3; | ||
256 | * } | ||
257 | * </pre></code> | ||
258 | * | ||
259 | * @see Match | ||
260 | * @see TooManyInputsOfSegment | ||
261 | * | ||
262 | */ | ||
263 | public static class Matcher extends BaseMatcher<TooManyInputsOfSegment.Match> { | ||
264 | /** | ||
265 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
266 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
267 | * | ||
268 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
269 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
270 | * | ||
271 | */ | ||
272 | public static TooManyInputsOfSegment.Matcher on(final ViatraQueryEngine engine) { | ||
273 | // check if matcher already exists | ||
274 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
275 | if (matcher == null) { | ||
276 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
277 | } | ||
278 | return matcher; | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
283 | * @return an initialized matcher | ||
284 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
285 | * | ||
286 | */ | ||
287 | public static TooManyInputsOfSegment.Matcher create() { | ||
288 | return new Matcher(); | ||
289 | } | ||
290 | |||
291 | private static final int POSITION_S = 0; | ||
292 | |||
293 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TooManyInputsOfSegment.Matcher.class); | ||
294 | |||
295 | /** | ||
296 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
297 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
298 | * | ||
299 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
300 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
301 | * | ||
302 | */ | ||
303 | private Matcher() { | ||
304 | super(querySpecification()); | ||
305 | } | ||
306 | |||
307 | /** | ||
308 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
309 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
310 | * @return matches represented as a Match object. | ||
311 | * | ||
312 | */ | ||
313 | public Collection<TooManyInputsOfSegment.Match> getAllMatches(final SimpleSegment pS) { | ||
314 | return rawStreamAllMatches(new Object[]{pS}).collect(Collectors.toSet()); | ||
315 | } | ||
316 | |||
317 | /** | ||
318 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
319 | * </p> | ||
320 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
321 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
322 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
323 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
324 | * @return a stream of matches represented as a Match object. | ||
325 | * | ||
326 | */ | ||
327 | public Stream<TooManyInputsOfSegment.Match> streamAllMatches(final SimpleSegment pS) { | ||
328 | return rawStreamAllMatches(new Object[]{pS}); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
333 | * Neither determinism nor randomness of selection is guaranteed. | ||
334 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
335 | * @return a match represented as a Match object, or null if no match is found. | ||
336 | * | ||
337 | */ | ||
338 | public Optional<TooManyInputsOfSegment.Match> getOneArbitraryMatch(final SimpleSegment pS) { | ||
339 | return rawGetOneArbitraryMatch(new Object[]{pS}); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
344 | * under any possible substitution of the unspecified parameters (if any). | ||
345 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
346 | * @return true if the input is a valid (partial) match of the pattern. | ||
347 | * | ||
348 | */ | ||
349 | public boolean hasMatch(final SimpleSegment pS) { | ||
350 | return rawHasMatch(new Object[]{pS}); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
355 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
356 | * @return the number of pattern matches found. | ||
357 | * | ||
358 | */ | ||
359 | public int countMatches(final SimpleSegment pS) { | ||
360 | return rawCountMatches(new Object[]{pS}); | ||
361 | } | ||
362 | |||
363 | /** | ||
364 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
365 | * Neither determinism nor randomness of selection is guaranteed. | ||
366 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
367 | * @param processor the action that will process the selected match. | ||
368 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
369 | * | ||
370 | */ | ||
371 | public boolean forOneArbitraryMatch(final SimpleSegment pS, final Consumer<? super TooManyInputsOfSegment.Match> processor) { | ||
372 | return rawForOneArbitraryMatch(new Object[]{pS}, processor); | ||
373 | } | ||
374 | |||
375 | /** | ||
376 | * Returns a new (partial) match. | ||
377 | * This can be used e.g. to call the matcher with a partial match. | ||
378 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
379 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
380 | * @return the (partial) match object. | ||
381 | * | ||
382 | */ | ||
383 | public TooManyInputsOfSegment.Match newMatch(final SimpleSegment pS) { | ||
384 | return TooManyInputsOfSegment.Match.newMatch(pS); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * Retrieve the set of values that occur in matches for S. | ||
389 | * @return the Set of all values or empty set if there are no matches | ||
390 | * | ||
391 | */ | ||
392 | protected Stream<SimpleSegment> rawStreamAllValuesOfS(final Object[] parameters) { | ||
393 | return rawStreamAllValues(POSITION_S, parameters).map(SimpleSegment.class::cast); | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * Retrieve the set of values that occur in matches for S. | ||
398 | * @return the Set of all values or empty set if there are no matches | ||
399 | * | ||
400 | */ | ||
401 | public Set<SimpleSegment> getAllValuesOfS() { | ||
402 | return rawStreamAllValuesOfS(emptyArray()).collect(Collectors.toSet()); | ||
403 | } | ||
404 | |||
405 | /** | ||
406 | * Retrieve the set of values that occur in matches for S. | ||
407 | * @return the Set of all values or empty set if there are no matches | ||
408 | * | ||
409 | */ | ||
410 | public Stream<SimpleSegment> streamAllValuesOfS() { | ||
411 | return rawStreamAllValuesOfS(emptyArray()); | ||
412 | } | ||
413 | |||
414 | @Override | ||
415 | protected TooManyInputsOfSegment.Match tupleToMatch(final Tuple t) { | ||
416 | try { | ||
417 | return TooManyInputsOfSegment.Match.newMatch((SimpleSegment) t.get(POSITION_S)); | ||
418 | } catch(ClassCastException e) { | ||
419 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
420 | return null; | ||
421 | } | ||
422 | } | ||
423 | |||
424 | @Override | ||
425 | protected TooManyInputsOfSegment.Match arrayToMatch(final Object[] match) { | ||
426 | try { | ||
427 | return TooManyInputsOfSegment.Match.newMatch((SimpleSegment) match[POSITION_S]); | ||
428 | } catch(ClassCastException e) { | ||
429 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
430 | return null; | ||
431 | } | ||
432 | } | ||
433 | |||
434 | @Override | ||
435 | protected TooManyInputsOfSegment.Match arrayToMatchMutable(final Object[] match) { | ||
436 | try { | ||
437 | return TooManyInputsOfSegment.Match.newMutableMatch((SimpleSegment) match[POSITION_S]); | ||
438 | } catch(ClassCastException e) { | ||
439 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
440 | return null; | ||
441 | } | ||
442 | } | ||
443 | |||
444 | /** | ||
445 | * @return the singleton instance of the query specification of this pattern | ||
446 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
447 | * | ||
448 | */ | ||
449 | public static IQuerySpecification<TooManyInputsOfSegment.Matcher> querySpecification() { | ||
450 | return TooManyInputsOfSegment.instance(); | ||
451 | } | ||
452 | } | ||
453 | |||
454 | private TooManyInputsOfSegment() { | ||
455 | super(GeneratedPQuery.INSTANCE); | ||
456 | } | ||
457 | |||
458 | /** | ||
459 | * @return the singleton instance of the query specification | ||
460 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
461 | * | ||
462 | */ | ||
463 | public static TooManyInputsOfSegment instance() { | ||
464 | try{ | ||
465 | return LazyHolder.INSTANCE; | ||
466 | } catch (ExceptionInInitializerError err) { | ||
467 | throw processInitializerError(err); | ||
468 | } | ||
469 | } | ||
470 | |||
471 | @Override | ||
472 | protected TooManyInputsOfSegment.Matcher instantiate(final ViatraQueryEngine engine) { | ||
473 | return TooManyInputsOfSegment.Matcher.on(engine); | ||
474 | } | ||
475 | |||
476 | @Override | ||
477 | public TooManyInputsOfSegment.Matcher instantiate() { | ||
478 | return TooManyInputsOfSegment.Matcher.create(); | ||
479 | } | ||
480 | |||
481 | @Override | ||
482 | public TooManyInputsOfSegment.Match newEmptyMatch() { | ||
483 | return TooManyInputsOfSegment.Match.newEmptyMatch(); | ||
484 | } | ||
485 | |||
486 | @Override | ||
487 | public TooManyInputsOfSegment.Match newMatch(final Object... parameters) { | ||
488 | return TooManyInputsOfSegment.Match.newMatch((modes3.SimpleSegment) parameters[0]); | ||
489 | } | ||
490 | |||
491 | /** | ||
492 | * Inner class allowing the singleton instance of {@link TooManyInputsOfSegment} to be created | ||
493 | * <b>not</b> at the class load time of the outer class, | ||
494 | * but rather at the first call to {@link TooManyInputsOfSegment#instance()}. | ||
495 | * | ||
496 | * <p> This workaround is required e.g. to support recursion. | ||
497 | * | ||
498 | */ | ||
499 | private static class LazyHolder { | ||
500 | private static final TooManyInputsOfSegment INSTANCE = new TooManyInputsOfSegment(); | ||
501 | |||
502 | /** | ||
503 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
504 | * This initialization order is required to support indirect recursion. | ||
505 | * | ||
506 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
507 | * | ||
508 | */ | ||
509 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
510 | |||
511 | public static Object ensureInitialized() { | ||
512 | INSTANCE.ensureInitializedInternal(); | ||
513 | return null; | ||
514 | } | ||
515 | } | ||
516 | |||
517 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
518 | private static final TooManyInputsOfSegment.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
519 | |||
520 | private final PParameter parameter_S = new PParameter("S", "modes3.SimpleSegment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "SimpleSegment")), PParameterDirection.INOUT); | ||
521 | |||
522 | private final List<PParameter> parameters = Arrays.asList(parameter_S); | ||
523 | |||
524 | private GeneratedPQuery() { | ||
525 | super(PVisibility.PUBLIC); | ||
526 | } | ||
527 | |||
528 | @Override | ||
529 | public String getFullyQualifiedName() { | ||
530 | return "modes3.queries.tooManyInputsOfSegment"; | ||
531 | } | ||
532 | |||
533 | @Override | ||
534 | public List<String> getParameterNames() { | ||
535 | return Arrays.asList("S"); | ||
536 | } | ||
537 | |||
538 | @Override | ||
539 | public List<PParameter> getParameters() { | ||
540 | return parameters; | ||
541 | } | ||
542 | |||
543 | @Override | ||
544 | public Set<PBody> doGetContainedBodies() { | ||
545 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
546 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
547 | { | ||
548 | PBody body = new PBody(this); | ||
549 | PVariable var_S = body.getOrCreateVariableByName("S"); | ||
550 | PVariable var_I1 = body.getOrCreateVariableByName("I1"); | ||
551 | PVariable var_I2 = body.getOrCreateVariableByName("I2"); | ||
552 | PVariable var_I3 = body.getOrCreateVariableByName("I3"); | ||
553 | new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "SimpleSegment"))); | ||
554 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
555 | new ExportedParameter(body, var_S, parameter_S) | ||
556 | )); | ||
557 | // find output(I1, S) | ||
558 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I1, var_S), Output.instance().getInternalQueryRepresentation()); | ||
559 | // find output(I2, S) | ||
560 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I2, var_S), Output.instance().getInternalQueryRepresentation()); | ||
561 | // find output(I3, S) | ||
562 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I3, var_S), Output.instance().getInternalQueryRepresentation()); | ||
563 | // I1 != I2 | ||
564 | new Inequality(body, var_I1, var_I2); | ||
565 | // I1 != I3 | ||
566 | new Inequality(body, var_I1, var_I3); | ||
567 | // I2 != I3 | ||
568 | new Inequality(body, var_I2, var_I3); | ||
569 | bodies.add(body); | ||
570 | } | ||
571 | { | ||
572 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
573 | annotation.addAttribute("message", "tooManyInputsOfSegment"); | ||
574 | annotation.addAttribute("severity", "error"); | ||
575 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
576 | new ParameterReference("S") | ||
577 | })); | ||
578 | addAnnotation(annotation); | ||
579 | } | ||
580 | return bodies; | ||
581 | } | ||
582 | } | ||
583 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfTurnout.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfTurnout.java new file mode 100644 index 00000000..93076cbb --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfTurnout.java | |||
@@ -0,0 +1,600 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Turnout; | ||
17 | import modes3.queries.Adjacent; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
42 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
43 | |||
44 | /** | ||
45 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
46 | * | ||
47 | * <p>Original source: | ||
48 | * <code><pre> | ||
49 | * {@literal @}Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) | ||
50 | * pattern tooManyInputsOfTurnout(T : Turnout) { | ||
51 | * find adjacent(I1, T); | ||
52 | * find adjacent(I2, T); | ||
53 | * find adjacent(I3, T); | ||
54 | * find adjacent(I4, T); | ||
55 | * I1 != I2; | ||
56 | * I1 != I3; | ||
57 | * I1 != I4; | ||
58 | * I2 != I3; | ||
59 | * I2 != I4; | ||
60 | * I3 != I4; | ||
61 | * } | ||
62 | * </pre></code> | ||
63 | * | ||
64 | * @see Matcher | ||
65 | * @see Match | ||
66 | * | ||
67 | */ | ||
68 | @SuppressWarnings("all") | ||
69 | public final class TooManyInputsOfTurnout extends BaseGeneratedEMFQuerySpecification<TooManyInputsOfTurnout.Matcher> { | ||
70 | /** | ||
71 | * Pattern-specific match representation of the modes3.queries.tooManyInputsOfTurnout pattern, | ||
72 | * to be used in conjunction with {@link Matcher}. | ||
73 | * | ||
74 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
75 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
76 | * usable to represent a match of the pattern in the result of a query, | ||
77 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
78 | * | ||
79 | * @see Matcher | ||
80 | * | ||
81 | */ | ||
82 | public static abstract class Match extends BasePatternMatch { | ||
83 | private Turnout fT; | ||
84 | |||
85 | private static List<String> parameterNames = makeImmutableList("T"); | ||
86 | |||
87 | private Match(final Turnout pT) { | ||
88 | this.fT = pT; | ||
89 | } | ||
90 | |||
91 | @Override | ||
92 | public Object get(final String parameterName) { | ||
93 | switch(parameterName) { | ||
94 | case "T": return this.fT; | ||
95 | default: return null; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | @Override | ||
100 | public Object get(final int index) { | ||
101 | switch(index) { | ||
102 | case 0: return this.fT; | ||
103 | default: return null; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | public Turnout getT() { | ||
108 | return this.fT; | ||
109 | } | ||
110 | |||
111 | @Override | ||
112 | public boolean set(final String parameterName, final Object newValue) { | ||
113 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
114 | if ("T".equals(parameterName) ) { | ||
115 | this.fT = (Turnout) newValue; | ||
116 | return true; | ||
117 | } | ||
118 | return false; | ||
119 | } | ||
120 | |||
121 | public void setT(final Turnout pT) { | ||
122 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
123 | this.fT = pT; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public String patternName() { | ||
128 | return "modes3.queries.tooManyInputsOfTurnout"; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public List<String> parameterNames() { | ||
133 | return TooManyInputsOfTurnout.Match.parameterNames; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public Object[] toArray() { | ||
138 | return new Object[]{fT}; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public TooManyInputsOfTurnout.Match toImmutable() { | ||
143 | return isMutable() ? newMatch(fT) : this; | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public String prettyPrint() { | ||
148 | StringBuilder result = new StringBuilder(); | ||
149 | result.append("\"T\"=" + prettyPrintValue(fT)); | ||
150 | return result.toString(); | ||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public int hashCode() { | ||
155 | return Objects.hash(fT); | ||
156 | } | ||
157 | |||
158 | @Override | ||
159 | public boolean equals(final Object obj) { | ||
160 | if (this == obj) | ||
161 | return true; | ||
162 | if (obj == null) { | ||
163 | return false; | ||
164 | } | ||
165 | if ((obj instanceof TooManyInputsOfTurnout.Match)) { | ||
166 | TooManyInputsOfTurnout.Match other = (TooManyInputsOfTurnout.Match) obj; | ||
167 | return Objects.equals(fT, other.fT); | ||
168 | } else { | ||
169 | // this should be infrequent | ||
170 | if (!(obj instanceof IPatternMatch)) { | ||
171 | return false; | ||
172 | } | ||
173 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
174 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
175 | } | ||
176 | } | ||
177 | |||
178 | @Override | ||
179 | public TooManyInputsOfTurnout specification() { | ||
180 | return TooManyInputsOfTurnout.instance(); | ||
181 | } | ||
182 | |||
183 | /** | ||
184 | * Returns an empty, mutable match. | ||
185 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
186 | * | ||
187 | * @return the empty match. | ||
188 | * | ||
189 | */ | ||
190 | public static TooManyInputsOfTurnout.Match newEmptyMatch() { | ||
191 | return new Mutable(null); | ||
192 | } | ||
193 | |||
194 | /** | ||
195 | * Returns a mutable (partial) match. | ||
196 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
197 | * | ||
198 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
199 | * @return the new, mutable (partial) match object. | ||
200 | * | ||
201 | */ | ||
202 | public static TooManyInputsOfTurnout.Match newMutableMatch(final Turnout pT) { | ||
203 | return new Mutable(pT); | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * Returns a new (partial) match. | ||
208 | * This can be used e.g. to call the matcher with a partial match. | ||
209 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
210 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
211 | * @return the (partial) match object. | ||
212 | * | ||
213 | */ | ||
214 | public static TooManyInputsOfTurnout.Match newMatch(final Turnout pT) { | ||
215 | return new Immutable(pT); | ||
216 | } | ||
217 | |||
218 | private static final class Mutable extends TooManyInputsOfTurnout.Match { | ||
219 | Mutable(final Turnout pT) { | ||
220 | super(pT); | ||
221 | } | ||
222 | |||
223 | @Override | ||
224 | public boolean isMutable() { | ||
225 | return true; | ||
226 | } | ||
227 | } | ||
228 | |||
229 | private static final class Immutable extends TooManyInputsOfTurnout.Match { | ||
230 | Immutable(final Turnout pT) { | ||
231 | super(pT); | ||
232 | } | ||
233 | |||
234 | @Override | ||
235 | public boolean isMutable() { | ||
236 | return false; | ||
237 | } | ||
238 | } | ||
239 | } | ||
240 | |||
241 | /** | ||
242 | * Generated pattern matcher API of the modes3.queries.tooManyInputsOfTurnout pattern, | ||
243 | * providing pattern-specific query methods. | ||
244 | * | ||
245 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
246 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
247 | * | ||
248 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
249 | * | ||
250 | * <p>Original source: | ||
251 | * <code><pre> | ||
252 | * {@literal @}Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) | ||
253 | * pattern tooManyInputsOfTurnout(T : Turnout) { | ||
254 | * find adjacent(I1, T); | ||
255 | * find adjacent(I2, T); | ||
256 | * find adjacent(I3, T); | ||
257 | * find adjacent(I4, T); | ||
258 | * I1 != I2; | ||
259 | * I1 != I3; | ||
260 | * I1 != I4; | ||
261 | * I2 != I3; | ||
262 | * I2 != I4; | ||
263 | * I3 != I4; | ||
264 | * } | ||
265 | * </pre></code> | ||
266 | * | ||
267 | * @see Match | ||
268 | * @see TooManyInputsOfTurnout | ||
269 | * | ||
270 | */ | ||
271 | public static class Matcher extends BaseMatcher<TooManyInputsOfTurnout.Match> { | ||
272 | /** | ||
273 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
274 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
275 | * | ||
276 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
277 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
278 | * | ||
279 | */ | ||
280 | public static TooManyInputsOfTurnout.Matcher on(final ViatraQueryEngine engine) { | ||
281 | // check if matcher already exists | ||
282 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
283 | if (matcher == null) { | ||
284 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
285 | } | ||
286 | return matcher; | ||
287 | } | ||
288 | |||
289 | /** | ||
290 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
291 | * @return an initialized matcher | ||
292 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
293 | * | ||
294 | */ | ||
295 | public static TooManyInputsOfTurnout.Matcher create() { | ||
296 | return new Matcher(); | ||
297 | } | ||
298 | |||
299 | private static final int POSITION_T = 0; | ||
300 | |||
301 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TooManyInputsOfTurnout.Matcher.class); | ||
302 | |||
303 | /** | ||
304 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
305 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
306 | * | ||
307 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
308 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
309 | * | ||
310 | */ | ||
311 | private Matcher() { | ||
312 | super(querySpecification()); | ||
313 | } | ||
314 | |||
315 | /** | ||
316 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
317 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
318 | * @return matches represented as a Match object. | ||
319 | * | ||
320 | */ | ||
321 | public Collection<TooManyInputsOfTurnout.Match> getAllMatches(final Turnout pT) { | ||
322 | return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); | ||
323 | } | ||
324 | |||
325 | /** | ||
326 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
327 | * </p> | ||
328 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
329 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
330 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
331 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
332 | * @return a stream of matches represented as a Match object. | ||
333 | * | ||
334 | */ | ||
335 | public Stream<TooManyInputsOfTurnout.Match> streamAllMatches(final Turnout pT) { | ||
336 | return rawStreamAllMatches(new Object[]{pT}); | ||
337 | } | ||
338 | |||
339 | /** | ||
340 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
341 | * Neither determinism nor randomness of selection is guaranteed. | ||
342 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
343 | * @return a match represented as a Match object, or null if no match is found. | ||
344 | * | ||
345 | */ | ||
346 | public Optional<TooManyInputsOfTurnout.Match> getOneArbitraryMatch(final Turnout pT) { | ||
347 | return rawGetOneArbitraryMatch(new Object[]{pT}); | ||
348 | } | ||
349 | |||
350 | /** | ||
351 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
352 | * under any possible substitution of the unspecified parameters (if any). | ||
353 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
354 | * @return true if the input is a valid (partial) match of the pattern. | ||
355 | * | ||
356 | */ | ||
357 | public boolean hasMatch(final Turnout pT) { | ||
358 | return rawHasMatch(new Object[]{pT}); | ||
359 | } | ||
360 | |||
361 | /** | ||
362 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
363 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
364 | * @return the number of pattern matches found. | ||
365 | * | ||
366 | */ | ||
367 | public int countMatches(final Turnout pT) { | ||
368 | return rawCountMatches(new Object[]{pT}); | ||
369 | } | ||
370 | |||
371 | /** | ||
372 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
373 | * Neither determinism nor randomness of selection is guaranteed. | ||
374 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
375 | * @param processor the action that will process the selected match. | ||
376 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
377 | * | ||
378 | */ | ||
379 | public boolean forOneArbitraryMatch(final Turnout pT, final Consumer<? super TooManyInputsOfTurnout.Match> processor) { | ||
380 | return rawForOneArbitraryMatch(new Object[]{pT}, processor); | ||
381 | } | ||
382 | |||
383 | /** | ||
384 | * Returns a new (partial) match. | ||
385 | * This can be used e.g. to call the matcher with a partial match. | ||
386 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
387 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
388 | * @return the (partial) match object. | ||
389 | * | ||
390 | */ | ||
391 | public TooManyInputsOfTurnout.Match newMatch(final Turnout pT) { | ||
392 | return TooManyInputsOfTurnout.Match.newMatch(pT); | ||
393 | } | ||
394 | |||
395 | /** | ||
396 | * Retrieve the set of values that occur in matches for T. | ||
397 | * @return the Set of all values or empty set if there are no matches | ||
398 | * | ||
399 | */ | ||
400 | protected Stream<Turnout> rawStreamAllValuesOfT(final Object[] parameters) { | ||
401 | return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); | ||
402 | } | ||
403 | |||
404 | /** | ||
405 | * Retrieve the set of values that occur in matches for T. | ||
406 | * @return the Set of all values or empty set if there are no matches | ||
407 | * | ||
408 | */ | ||
409 | public Set<Turnout> getAllValuesOfT() { | ||
410 | return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); | ||
411 | } | ||
412 | |||
413 | /** | ||
414 | * Retrieve the set of values that occur in matches for T. | ||
415 | * @return the Set of all values or empty set if there are no matches | ||
416 | * | ||
417 | */ | ||
418 | public Stream<Turnout> streamAllValuesOfT() { | ||
419 | return rawStreamAllValuesOfT(emptyArray()); | ||
420 | } | ||
421 | |||
422 | @Override | ||
423 | protected TooManyInputsOfTurnout.Match tupleToMatch(final Tuple t) { | ||
424 | try { | ||
425 | return TooManyInputsOfTurnout.Match.newMatch((Turnout) t.get(POSITION_T)); | ||
426 | } catch(ClassCastException e) { | ||
427 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
428 | return null; | ||
429 | } | ||
430 | } | ||
431 | |||
432 | @Override | ||
433 | protected TooManyInputsOfTurnout.Match arrayToMatch(final Object[] match) { | ||
434 | try { | ||
435 | return TooManyInputsOfTurnout.Match.newMatch((Turnout) match[POSITION_T]); | ||
436 | } catch(ClassCastException e) { | ||
437 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
438 | return null; | ||
439 | } | ||
440 | } | ||
441 | |||
442 | @Override | ||
443 | protected TooManyInputsOfTurnout.Match arrayToMatchMutable(final Object[] match) { | ||
444 | try { | ||
445 | return TooManyInputsOfTurnout.Match.newMutableMatch((Turnout) match[POSITION_T]); | ||
446 | } catch(ClassCastException e) { | ||
447 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
448 | return null; | ||
449 | } | ||
450 | } | ||
451 | |||
452 | /** | ||
453 | * @return the singleton instance of the query specification of this pattern | ||
454 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
455 | * | ||
456 | */ | ||
457 | public static IQuerySpecification<TooManyInputsOfTurnout.Matcher> querySpecification() { | ||
458 | return TooManyInputsOfTurnout.instance(); | ||
459 | } | ||
460 | } | ||
461 | |||
462 | private TooManyInputsOfTurnout() { | ||
463 | super(GeneratedPQuery.INSTANCE); | ||
464 | } | ||
465 | |||
466 | /** | ||
467 | * @return the singleton instance of the query specification | ||
468 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
469 | * | ||
470 | */ | ||
471 | public static TooManyInputsOfTurnout instance() { | ||
472 | try{ | ||
473 | return LazyHolder.INSTANCE; | ||
474 | } catch (ExceptionInInitializerError err) { | ||
475 | throw processInitializerError(err); | ||
476 | } | ||
477 | } | ||
478 | |||
479 | @Override | ||
480 | protected TooManyInputsOfTurnout.Matcher instantiate(final ViatraQueryEngine engine) { | ||
481 | return TooManyInputsOfTurnout.Matcher.on(engine); | ||
482 | } | ||
483 | |||
484 | @Override | ||
485 | public TooManyInputsOfTurnout.Matcher instantiate() { | ||
486 | return TooManyInputsOfTurnout.Matcher.create(); | ||
487 | } | ||
488 | |||
489 | @Override | ||
490 | public TooManyInputsOfTurnout.Match newEmptyMatch() { | ||
491 | return TooManyInputsOfTurnout.Match.newEmptyMatch(); | ||
492 | } | ||
493 | |||
494 | @Override | ||
495 | public TooManyInputsOfTurnout.Match newMatch(final Object... parameters) { | ||
496 | return TooManyInputsOfTurnout.Match.newMatch((modes3.Turnout) parameters[0]); | ||
497 | } | ||
498 | |||
499 | /** | ||
500 | * Inner class allowing the singleton instance of {@link TooManyInputsOfTurnout} to be created | ||
501 | * <b>not</b> at the class load time of the outer class, | ||
502 | * but rather at the first call to {@link TooManyInputsOfTurnout#instance()}. | ||
503 | * | ||
504 | * <p> This workaround is required e.g. to support recursion. | ||
505 | * | ||
506 | */ | ||
507 | private static class LazyHolder { | ||
508 | private static final TooManyInputsOfTurnout INSTANCE = new TooManyInputsOfTurnout(); | ||
509 | |||
510 | /** | ||
511 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
512 | * This initialization order is required to support indirect recursion. | ||
513 | * | ||
514 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
515 | * | ||
516 | */ | ||
517 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
518 | |||
519 | public static Object ensureInitialized() { | ||
520 | INSTANCE.ensureInitializedInternal(); | ||
521 | return null; | ||
522 | } | ||
523 | } | ||
524 | |||
525 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
526 | private static final TooManyInputsOfTurnout.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
527 | |||
528 | private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); | ||
529 | |||
530 | private final List<PParameter> parameters = Arrays.asList(parameter_T); | ||
531 | |||
532 | private GeneratedPQuery() { | ||
533 | super(PVisibility.PUBLIC); | ||
534 | } | ||
535 | |||
536 | @Override | ||
537 | public String getFullyQualifiedName() { | ||
538 | return "modes3.queries.tooManyInputsOfTurnout"; | ||
539 | } | ||
540 | |||
541 | @Override | ||
542 | public List<String> getParameterNames() { | ||
543 | return Arrays.asList("T"); | ||
544 | } | ||
545 | |||
546 | @Override | ||
547 | public List<PParameter> getParameters() { | ||
548 | return parameters; | ||
549 | } | ||
550 | |||
551 | @Override | ||
552 | public Set<PBody> doGetContainedBodies() { | ||
553 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
554 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
555 | { | ||
556 | PBody body = new PBody(this); | ||
557 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
558 | PVariable var_I1 = body.getOrCreateVariableByName("I1"); | ||
559 | PVariable var_I2 = body.getOrCreateVariableByName("I2"); | ||
560 | PVariable var_I3 = body.getOrCreateVariableByName("I3"); | ||
561 | PVariable var_I4 = body.getOrCreateVariableByName("I4"); | ||
562 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
563 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
564 | new ExportedParameter(body, var_T, parameter_T) | ||
565 | )); | ||
566 | // find adjacent(I1, T) | ||
567 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I1, var_T), Adjacent.instance().getInternalQueryRepresentation()); | ||
568 | // find adjacent(I2, T) | ||
569 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I2, var_T), Adjacent.instance().getInternalQueryRepresentation()); | ||
570 | // find adjacent(I3, T) | ||
571 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I3, var_T), Adjacent.instance().getInternalQueryRepresentation()); | ||
572 | // find adjacent(I4, T) | ||
573 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I4, var_T), Adjacent.instance().getInternalQueryRepresentation()); | ||
574 | // I1 != I2 | ||
575 | new Inequality(body, var_I1, var_I2); | ||
576 | // I1 != I3 | ||
577 | new Inequality(body, var_I1, var_I3); | ||
578 | // I1 != I4 | ||
579 | new Inequality(body, var_I1, var_I4); | ||
580 | // I2 != I3 | ||
581 | new Inequality(body, var_I2, var_I3); | ||
582 | // I2 != I4 | ||
583 | new Inequality(body, var_I2, var_I4); | ||
584 | // I3 != I4 | ||
585 | new Inequality(body, var_I3, var_I4); | ||
586 | bodies.add(body); | ||
587 | } | ||
588 | { | ||
589 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
590 | annotation.addAttribute("message", "turnoutConnectedToBothOutputs"); | ||
591 | annotation.addAttribute("severity", "error"); | ||
592 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
593 | new ParameterReference("T") | ||
594 | })); | ||
595 | addAnnotation(annotation); | ||
596 | } | ||
597 | return bodies; | ||
598 | } | ||
599 | } | ||
600 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TrainLocations_step_2.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TrainLocations_step_2.java new file mode 100644 index 00000000..5bf153c3 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TrainLocations_step_2.java | |||
@@ -0,0 +1,564 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Train; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
37 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
38 | |||
39 | /** | ||
40 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
41 | * | ||
42 | * <p>Original source: | ||
43 | * <code><pre> | ||
44 | * // | ||
45 | * // trainLocations | ||
46 | * // | ||
47 | * | ||
48 | * pattern trainLocations_step_2(in train : Train) { | ||
49 | * // frame-{@literal >}train = model-{@literal >}trains[i0]; | ||
50 | * // frame-{@literal >}location = frame-{@literal >}train-{@literal >}location; | ||
51 | * // if (frame-{@literal >}location != NULL) { | ||
52 | * // ... | ||
53 | * // } | ||
54 | * | ||
55 | * Train(train); | ||
56 | * } | ||
57 | * </pre></code> | ||
58 | * | ||
59 | * @see Matcher | ||
60 | * @see Match | ||
61 | * | ||
62 | */ | ||
63 | @SuppressWarnings("all") | ||
64 | public final class TrainLocations_step_2 extends BaseGeneratedEMFQuerySpecification<TrainLocations_step_2.Matcher> { | ||
65 | /** | ||
66 | * Pattern-specific match representation of the modes3.queries.trainLocations_step_2 pattern, | ||
67 | * to be used in conjunction with {@link Matcher}. | ||
68 | * | ||
69 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
70 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
71 | * usable to represent a match of the pattern in the result of a query, | ||
72 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
73 | * | ||
74 | * @see Matcher | ||
75 | * | ||
76 | */ | ||
77 | public static abstract class Match extends BasePatternMatch { | ||
78 | private Train fTrain; | ||
79 | |||
80 | private static List<String> parameterNames = makeImmutableList("train"); | ||
81 | |||
82 | private Match(final Train pTrain) { | ||
83 | this.fTrain = pTrain; | ||
84 | } | ||
85 | |||
86 | @Override | ||
87 | public Object get(final String parameterName) { | ||
88 | switch(parameterName) { | ||
89 | case "train": return this.fTrain; | ||
90 | default: return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | @Override | ||
95 | public Object get(final int index) { | ||
96 | switch(index) { | ||
97 | case 0: return this.fTrain; | ||
98 | default: return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public Train getTrain() { | ||
103 | return this.fTrain; | ||
104 | } | ||
105 | |||
106 | @Override | ||
107 | public boolean set(final String parameterName, final Object newValue) { | ||
108 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
109 | if ("train".equals(parameterName) ) { | ||
110 | this.fTrain = (Train) newValue; | ||
111 | return true; | ||
112 | } | ||
113 | return false; | ||
114 | } | ||
115 | |||
116 | public void setTrain(final Train pTrain) { | ||
117 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
118 | this.fTrain = pTrain; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public String patternName() { | ||
123 | return "modes3.queries.trainLocations_step_2"; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public List<String> parameterNames() { | ||
128 | return TrainLocations_step_2.Match.parameterNames; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public Object[] toArray() { | ||
133 | return new Object[]{fTrain}; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public TrainLocations_step_2.Match toImmutable() { | ||
138 | return isMutable() ? newMatch(fTrain) : this; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public String prettyPrint() { | ||
143 | StringBuilder result = new StringBuilder(); | ||
144 | result.append("\"train\"=" + prettyPrintValue(fTrain)); | ||
145 | return result.toString(); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public int hashCode() { | ||
150 | return Objects.hash(fTrain); | ||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public boolean equals(final Object obj) { | ||
155 | if (this == obj) | ||
156 | return true; | ||
157 | if (obj == null) { | ||
158 | return false; | ||
159 | } | ||
160 | if ((obj instanceof TrainLocations_step_2.Match)) { | ||
161 | TrainLocations_step_2.Match other = (TrainLocations_step_2.Match) obj; | ||
162 | return Objects.equals(fTrain, other.fTrain); | ||
163 | } else { | ||
164 | // this should be infrequent | ||
165 | if (!(obj instanceof IPatternMatch)) { | ||
166 | return false; | ||
167 | } | ||
168 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
169 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | @Override | ||
174 | public TrainLocations_step_2 specification() { | ||
175 | return TrainLocations_step_2.instance(); | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * Returns an empty, mutable match. | ||
180 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
181 | * | ||
182 | * @return the empty match. | ||
183 | * | ||
184 | */ | ||
185 | public static TrainLocations_step_2.Match newEmptyMatch() { | ||
186 | return new Mutable(null); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * Returns a mutable (partial) match. | ||
191 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
192 | * | ||
193 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
194 | * @return the new, mutable (partial) match object. | ||
195 | * | ||
196 | */ | ||
197 | public static TrainLocations_step_2.Match newMutableMatch(final Train pTrain) { | ||
198 | return new Mutable(pTrain); | ||
199 | } | ||
200 | |||
201 | /** | ||
202 | * Returns a new (partial) match. | ||
203 | * This can be used e.g. to call the matcher with a partial match. | ||
204 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
205 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
206 | * @return the (partial) match object. | ||
207 | * | ||
208 | */ | ||
209 | public static TrainLocations_step_2.Match newMatch(final Train pTrain) { | ||
210 | return new Immutable(pTrain); | ||
211 | } | ||
212 | |||
213 | private static final class Mutable extends TrainLocations_step_2.Match { | ||
214 | Mutable(final Train pTrain) { | ||
215 | super(pTrain); | ||
216 | } | ||
217 | |||
218 | @Override | ||
219 | public boolean isMutable() { | ||
220 | return true; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | private static final class Immutable extends TrainLocations_step_2.Match { | ||
225 | Immutable(final Train pTrain) { | ||
226 | super(pTrain); | ||
227 | } | ||
228 | |||
229 | @Override | ||
230 | public boolean isMutable() { | ||
231 | return false; | ||
232 | } | ||
233 | } | ||
234 | } | ||
235 | |||
236 | /** | ||
237 | * Generated pattern matcher API of the modes3.queries.trainLocations_step_2 pattern, | ||
238 | * providing pattern-specific query methods. | ||
239 | * | ||
240 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
241 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
242 | * | ||
243 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
244 | * | ||
245 | * <p>Original source: | ||
246 | * <code><pre> | ||
247 | * // | ||
248 | * // trainLocations | ||
249 | * // | ||
250 | * | ||
251 | * pattern trainLocations_step_2(in train : Train) { | ||
252 | * // frame-{@literal >}train = model-{@literal >}trains[i0]; | ||
253 | * // frame-{@literal >}location = frame-{@literal >}train-{@literal >}location; | ||
254 | * // if (frame-{@literal >}location != NULL) { | ||
255 | * // ... | ||
256 | * // } | ||
257 | * | ||
258 | * Train(train); | ||
259 | * } | ||
260 | * </pre></code> | ||
261 | * | ||
262 | * @see Match | ||
263 | * @see TrainLocations_step_2 | ||
264 | * | ||
265 | */ | ||
266 | public static class Matcher extends BaseMatcher<TrainLocations_step_2.Match> { | ||
267 | /** | ||
268 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
269 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
270 | * | ||
271 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
272 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
273 | * | ||
274 | */ | ||
275 | public static TrainLocations_step_2.Matcher on(final ViatraQueryEngine engine) { | ||
276 | // check if matcher already exists | ||
277 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
278 | if (matcher == null) { | ||
279 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
280 | } | ||
281 | return matcher; | ||
282 | } | ||
283 | |||
284 | /** | ||
285 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
286 | * @return an initialized matcher | ||
287 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
288 | * | ||
289 | */ | ||
290 | public static TrainLocations_step_2.Matcher create() { | ||
291 | return new Matcher(); | ||
292 | } | ||
293 | |||
294 | private static final int POSITION_TRAIN = 0; | ||
295 | |||
296 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TrainLocations_step_2.Matcher.class); | ||
297 | |||
298 | /** | ||
299 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
300 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
301 | * | ||
302 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
303 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
304 | * | ||
305 | */ | ||
306 | private Matcher() { | ||
307 | super(querySpecification()); | ||
308 | } | ||
309 | |||
310 | /** | ||
311 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
312 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
313 | * @return matches represented as a Match object. | ||
314 | * | ||
315 | */ | ||
316 | public Collection<TrainLocations_step_2.Match> getAllMatches(final Train pTrain) { | ||
317 | return rawStreamAllMatches(new Object[]{pTrain}).collect(Collectors.toSet()); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
322 | * </p> | ||
323 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
324 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
325 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
326 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
327 | * @return a stream of matches represented as a Match object. | ||
328 | * | ||
329 | */ | ||
330 | public Stream<TrainLocations_step_2.Match> streamAllMatches(final Train pTrain) { | ||
331 | return rawStreamAllMatches(new Object[]{pTrain}); | ||
332 | } | ||
333 | |||
334 | /** | ||
335 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
336 | * Neither determinism nor randomness of selection is guaranteed. | ||
337 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
338 | * @return a match represented as a Match object, or null if no match is found. | ||
339 | * | ||
340 | */ | ||
341 | public Optional<TrainLocations_step_2.Match> getOneArbitraryMatch(final Train pTrain) { | ||
342 | return rawGetOneArbitraryMatch(new Object[]{pTrain}); | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
347 | * under any possible substitution of the unspecified parameters (if any). | ||
348 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
349 | * @return true if the input is a valid (partial) match of the pattern. | ||
350 | * | ||
351 | */ | ||
352 | public boolean hasMatch(final Train pTrain) { | ||
353 | return rawHasMatch(new Object[]{pTrain}); | ||
354 | } | ||
355 | |||
356 | /** | ||
357 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
358 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
359 | * @return the number of pattern matches found. | ||
360 | * | ||
361 | */ | ||
362 | public int countMatches(final Train pTrain) { | ||
363 | return rawCountMatches(new Object[]{pTrain}); | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
368 | * Neither determinism nor randomness of selection is guaranteed. | ||
369 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
370 | * @param processor the action that will process the selected match. | ||
371 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
372 | * | ||
373 | */ | ||
374 | public boolean forOneArbitraryMatch(final Train pTrain, final Consumer<? super TrainLocations_step_2.Match> processor) { | ||
375 | return rawForOneArbitraryMatch(new Object[]{pTrain}, processor); | ||
376 | } | ||
377 | |||
378 | /** | ||
379 | * Returns a new (partial) match. | ||
380 | * This can be used e.g. to call the matcher with a partial match. | ||
381 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
382 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
383 | * @return the (partial) match object. | ||
384 | * | ||
385 | */ | ||
386 | public TrainLocations_step_2.Match newMatch(final Train pTrain) { | ||
387 | return TrainLocations_step_2.Match.newMatch(pTrain); | ||
388 | } | ||
389 | |||
390 | /** | ||
391 | * Retrieve the set of values that occur in matches for train. | ||
392 | * @return the Set of all values or empty set if there are no matches | ||
393 | * | ||
394 | */ | ||
395 | protected Stream<Train> rawStreamAllValuesOftrain(final Object[] parameters) { | ||
396 | return rawStreamAllValues(POSITION_TRAIN, parameters).map(Train.class::cast); | ||
397 | } | ||
398 | |||
399 | /** | ||
400 | * Retrieve the set of values that occur in matches for train. | ||
401 | * @return the Set of all values or empty set if there are no matches | ||
402 | * | ||
403 | */ | ||
404 | public Set<Train> getAllValuesOftrain() { | ||
405 | return rawStreamAllValuesOftrain(emptyArray()).collect(Collectors.toSet()); | ||
406 | } | ||
407 | |||
408 | /** | ||
409 | * Retrieve the set of values that occur in matches for train. | ||
410 | * @return the Set of all values or empty set if there are no matches | ||
411 | * | ||
412 | */ | ||
413 | public Stream<Train> streamAllValuesOftrain() { | ||
414 | return rawStreamAllValuesOftrain(emptyArray()); | ||
415 | } | ||
416 | |||
417 | @Override | ||
418 | protected TrainLocations_step_2.Match tupleToMatch(final Tuple t) { | ||
419 | try { | ||
420 | return TrainLocations_step_2.Match.newMatch((Train) t.get(POSITION_TRAIN)); | ||
421 | } catch(ClassCastException e) { | ||
422 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
423 | return null; | ||
424 | } | ||
425 | } | ||
426 | |||
427 | @Override | ||
428 | protected TrainLocations_step_2.Match arrayToMatch(final Object[] match) { | ||
429 | try { | ||
430 | return TrainLocations_step_2.Match.newMatch((Train) match[POSITION_TRAIN]); | ||
431 | } catch(ClassCastException e) { | ||
432 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
433 | return null; | ||
434 | } | ||
435 | } | ||
436 | |||
437 | @Override | ||
438 | protected TrainLocations_step_2.Match arrayToMatchMutable(final Object[] match) { | ||
439 | try { | ||
440 | return TrainLocations_step_2.Match.newMutableMatch((Train) match[POSITION_TRAIN]); | ||
441 | } catch(ClassCastException e) { | ||
442 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
443 | return null; | ||
444 | } | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @return the singleton instance of the query specification of this pattern | ||
449 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
450 | * | ||
451 | */ | ||
452 | public static IQuerySpecification<TrainLocations_step_2.Matcher> querySpecification() { | ||
453 | return TrainLocations_step_2.instance(); | ||
454 | } | ||
455 | } | ||
456 | |||
457 | private TrainLocations_step_2() { | ||
458 | super(GeneratedPQuery.INSTANCE); | ||
459 | } | ||
460 | |||
461 | /** | ||
462 | * @return the singleton instance of the query specification | ||
463 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
464 | * | ||
465 | */ | ||
466 | public static TrainLocations_step_2 instance() { | ||
467 | try{ | ||
468 | return LazyHolder.INSTANCE; | ||
469 | } catch (ExceptionInInitializerError err) { | ||
470 | throw processInitializerError(err); | ||
471 | } | ||
472 | } | ||
473 | |||
474 | @Override | ||
475 | protected TrainLocations_step_2.Matcher instantiate(final ViatraQueryEngine engine) { | ||
476 | return TrainLocations_step_2.Matcher.on(engine); | ||
477 | } | ||
478 | |||
479 | @Override | ||
480 | public TrainLocations_step_2.Matcher instantiate() { | ||
481 | return TrainLocations_step_2.Matcher.create(); | ||
482 | } | ||
483 | |||
484 | @Override | ||
485 | public TrainLocations_step_2.Match newEmptyMatch() { | ||
486 | return TrainLocations_step_2.Match.newEmptyMatch(); | ||
487 | } | ||
488 | |||
489 | @Override | ||
490 | public TrainLocations_step_2.Match newMatch(final Object... parameters) { | ||
491 | return TrainLocations_step_2.Match.newMatch((modes3.Train) parameters[0]); | ||
492 | } | ||
493 | |||
494 | /** | ||
495 | * Inner class allowing the singleton instance of {@link TrainLocations_step_2} to be created | ||
496 | * <b>not</b> at the class load time of the outer class, | ||
497 | * but rather at the first call to {@link TrainLocations_step_2#instance()}. | ||
498 | * | ||
499 | * <p> This workaround is required e.g. to support recursion. | ||
500 | * | ||
501 | */ | ||
502 | private static class LazyHolder { | ||
503 | private static final TrainLocations_step_2 INSTANCE = new TrainLocations_step_2(); | ||
504 | |||
505 | /** | ||
506 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
507 | * This initialization order is required to support indirect recursion. | ||
508 | * | ||
509 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
510 | * | ||
511 | */ | ||
512 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
513 | |||
514 | public static Object ensureInitialized() { | ||
515 | INSTANCE.ensureInitializedInternal(); | ||
516 | return null; | ||
517 | } | ||
518 | } | ||
519 | |||
520 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
521 | private static final TrainLocations_step_2.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
522 | |||
523 | private final PParameter parameter_train = new PParameter("train", "modes3.Train", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Train")), PParameterDirection.INOUT); | ||
524 | |||
525 | private final List<PParameter> parameters = Arrays.asList(parameter_train); | ||
526 | |||
527 | private GeneratedPQuery() { | ||
528 | super(PVisibility.PUBLIC); | ||
529 | } | ||
530 | |||
531 | @Override | ||
532 | public String getFullyQualifiedName() { | ||
533 | return "modes3.queries.trainLocations_step_2"; | ||
534 | } | ||
535 | |||
536 | @Override | ||
537 | public List<String> getParameterNames() { | ||
538 | return Arrays.asList("train"); | ||
539 | } | ||
540 | |||
541 | @Override | ||
542 | public List<PParameter> getParameters() { | ||
543 | return parameters; | ||
544 | } | ||
545 | |||
546 | @Override | ||
547 | public Set<PBody> doGetContainedBodies() { | ||
548 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
549 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
550 | { | ||
551 | PBody body = new PBody(this); | ||
552 | PVariable var_train = body.getOrCreateVariableByName("train"); | ||
553 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
554 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
555 | new ExportedParameter(body, var_train, parameter_train) | ||
556 | )); | ||
557 | // // frame->train = model->trains[i0];// frame->location = frame->train->location;// if (frame->location != NULL) {// ...// } Train(train) | ||
558 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
559 | bodies.add(body); | ||
560 | } | ||
561 | return bodies; | ||
562 | } | ||
563 | } | ||
564 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TrainLocations_step_3.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TrainLocations_step_3.java new file mode 100644 index 00000000..edbd4af3 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TrainLocations_step_3.java | |||
@@ -0,0 +1,713 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.Train; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern trainLocations_step_3(in train : Train, in location : Segment) { | ||
48 | * // results-{@literal >}matches[match_cntr].location = frame-{@literal >}location; | ||
49 | * // results-{@literal >}matches[match_cntr++].train = frame-{@literal >}train; | ||
50 | * Train(train); | ||
51 | * Train.location(train, location); | ||
52 | * } | ||
53 | * </pre></code> | ||
54 | * | ||
55 | * @see Matcher | ||
56 | * @see Match | ||
57 | * | ||
58 | */ | ||
59 | @SuppressWarnings("all") | ||
60 | public final class TrainLocations_step_3 extends BaseGeneratedEMFQuerySpecification<TrainLocations_step_3.Matcher> { | ||
61 | /** | ||
62 | * Pattern-specific match representation of the modes3.queries.trainLocations_step_3 pattern, | ||
63 | * to be used in conjunction with {@link Matcher}. | ||
64 | * | ||
65 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
66 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
67 | * usable to represent a match of the pattern in the result of a query, | ||
68 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
69 | * | ||
70 | * @see Matcher | ||
71 | * | ||
72 | */ | ||
73 | public static abstract class Match extends BasePatternMatch { | ||
74 | private Train fTrain; | ||
75 | |||
76 | private Segment fLocation; | ||
77 | |||
78 | private static List<String> parameterNames = makeImmutableList("train", "location"); | ||
79 | |||
80 | private Match(final Train pTrain, final Segment pLocation) { | ||
81 | this.fTrain = pTrain; | ||
82 | this.fLocation = pLocation; | ||
83 | } | ||
84 | |||
85 | @Override | ||
86 | public Object get(final String parameterName) { | ||
87 | switch(parameterName) { | ||
88 | case "train": return this.fTrain; | ||
89 | case "location": return this.fLocation; | ||
90 | default: return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | @Override | ||
95 | public Object get(final int index) { | ||
96 | switch(index) { | ||
97 | case 0: return this.fTrain; | ||
98 | case 1: return this.fLocation; | ||
99 | default: return null; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | public Train getTrain() { | ||
104 | return this.fTrain; | ||
105 | } | ||
106 | |||
107 | public Segment getLocation() { | ||
108 | return this.fLocation; | ||
109 | } | ||
110 | |||
111 | @Override | ||
112 | public boolean set(final String parameterName, final Object newValue) { | ||
113 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
114 | if ("train".equals(parameterName) ) { | ||
115 | this.fTrain = (Train) newValue; | ||
116 | return true; | ||
117 | } | ||
118 | if ("location".equals(parameterName) ) { | ||
119 | this.fLocation = (Segment) newValue; | ||
120 | return true; | ||
121 | } | ||
122 | return false; | ||
123 | } | ||
124 | |||
125 | public void setTrain(final Train pTrain) { | ||
126 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
127 | this.fTrain = pTrain; | ||
128 | } | ||
129 | |||
130 | public void setLocation(final Segment pLocation) { | ||
131 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
132 | this.fLocation = pLocation; | ||
133 | } | ||
134 | |||
135 | @Override | ||
136 | public String patternName() { | ||
137 | return "modes3.queries.trainLocations_step_3"; | ||
138 | } | ||
139 | |||
140 | @Override | ||
141 | public List<String> parameterNames() { | ||
142 | return TrainLocations_step_3.Match.parameterNames; | ||
143 | } | ||
144 | |||
145 | @Override | ||
146 | public Object[] toArray() { | ||
147 | return new Object[]{fTrain, fLocation}; | ||
148 | } | ||
149 | |||
150 | @Override | ||
151 | public TrainLocations_step_3.Match toImmutable() { | ||
152 | return isMutable() ? newMatch(fTrain, fLocation) : this; | ||
153 | } | ||
154 | |||
155 | @Override | ||
156 | public String prettyPrint() { | ||
157 | StringBuilder result = new StringBuilder(); | ||
158 | result.append("\"train\"=" + prettyPrintValue(fTrain) + ", "); | ||
159 | result.append("\"location\"=" + prettyPrintValue(fLocation)); | ||
160 | return result.toString(); | ||
161 | } | ||
162 | |||
163 | @Override | ||
164 | public int hashCode() { | ||
165 | return Objects.hash(fTrain, fLocation); | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public boolean equals(final Object obj) { | ||
170 | if (this == obj) | ||
171 | return true; | ||
172 | if (obj == null) { | ||
173 | return false; | ||
174 | } | ||
175 | if ((obj instanceof TrainLocations_step_3.Match)) { | ||
176 | TrainLocations_step_3.Match other = (TrainLocations_step_3.Match) obj; | ||
177 | return Objects.equals(fTrain, other.fTrain) && Objects.equals(fLocation, other.fLocation); | ||
178 | } else { | ||
179 | // this should be infrequent | ||
180 | if (!(obj instanceof IPatternMatch)) { | ||
181 | return false; | ||
182 | } | ||
183 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
184 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
185 | } | ||
186 | } | ||
187 | |||
188 | @Override | ||
189 | public TrainLocations_step_3 specification() { | ||
190 | return TrainLocations_step_3.instance(); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * Returns an empty, mutable match. | ||
195 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
196 | * | ||
197 | * @return the empty match. | ||
198 | * | ||
199 | */ | ||
200 | public static TrainLocations_step_3.Match newEmptyMatch() { | ||
201 | return new Mutable(null, null); | ||
202 | } | ||
203 | |||
204 | /** | ||
205 | * Returns a mutable (partial) match. | ||
206 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
207 | * | ||
208 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
209 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
210 | * @return the new, mutable (partial) match object. | ||
211 | * | ||
212 | */ | ||
213 | public static TrainLocations_step_3.Match newMutableMatch(final Train pTrain, final Segment pLocation) { | ||
214 | return new Mutable(pTrain, pLocation); | ||
215 | } | ||
216 | |||
217 | /** | ||
218 | * Returns a new (partial) match. | ||
219 | * This can be used e.g. to call the matcher with a partial match. | ||
220 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
221 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
222 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
223 | * @return the (partial) match object. | ||
224 | * | ||
225 | */ | ||
226 | public static TrainLocations_step_3.Match newMatch(final Train pTrain, final Segment pLocation) { | ||
227 | return new Immutable(pTrain, pLocation); | ||
228 | } | ||
229 | |||
230 | private static final class Mutable extends TrainLocations_step_3.Match { | ||
231 | Mutable(final Train pTrain, final Segment pLocation) { | ||
232 | super(pTrain, pLocation); | ||
233 | } | ||
234 | |||
235 | @Override | ||
236 | public boolean isMutable() { | ||
237 | return true; | ||
238 | } | ||
239 | } | ||
240 | |||
241 | private static final class Immutable extends TrainLocations_step_3.Match { | ||
242 | Immutable(final Train pTrain, final Segment pLocation) { | ||
243 | super(pTrain, pLocation); | ||
244 | } | ||
245 | |||
246 | @Override | ||
247 | public boolean isMutable() { | ||
248 | return false; | ||
249 | } | ||
250 | } | ||
251 | } | ||
252 | |||
253 | /** | ||
254 | * Generated pattern matcher API of the modes3.queries.trainLocations_step_3 pattern, | ||
255 | * providing pattern-specific query methods. | ||
256 | * | ||
257 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
258 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
259 | * | ||
260 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
261 | * | ||
262 | * <p>Original source: | ||
263 | * <code><pre> | ||
264 | * pattern trainLocations_step_3(in train : Train, in location : Segment) { | ||
265 | * // results-{@literal >}matches[match_cntr].location = frame-{@literal >}location; | ||
266 | * // results-{@literal >}matches[match_cntr++].train = frame-{@literal >}train; | ||
267 | * Train(train); | ||
268 | * Train.location(train, location); | ||
269 | * } | ||
270 | * </pre></code> | ||
271 | * | ||
272 | * @see Match | ||
273 | * @see TrainLocations_step_3 | ||
274 | * | ||
275 | */ | ||
276 | public static class Matcher extends BaseMatcher<TrainLocations_step_3.Match> { | ||
277 | /** | ||
278 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
279 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
280 | * | ||
281 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
282 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
283 | * | ||
284 | */ | ||
285 | public static TrainLocations_step_3.Matcher on(final ViatraQueryEngine engine) { | ||
286 | // check if matcher already exists | ||
287 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
288 | if (matcher == null) { | ||
289 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
290 | } | ||
291 | return matcher; | ||
292 | } | ||
293 | |||
294 | /** | ||
295 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
296 | * @return an initialized matcher | ||
297 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
298 | * | ||
299 | */ | ||
300 | public static TrainLocations_step_3.Matcher create() { | ||
301 | return new Matcher(); | ||
302 | } | ||
303 | |||
304 | private static final int POSITION_TRAIN = 0; | ||
305 | |||
306 | private static final int POSITION_LOCATION = 1; | ||
307 | |||
308 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TrainLocations_step_3.Matcher.class); | ||
309 | |||
310 | /** | ||
311 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
312 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
313 | * | ||
314 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
315 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
316 | * | ||
317 | */ | ||
318 | private Matcher() { | ||
319 | super(querySpecification()); | ||
320 | } | ||
321 | |||
322 | /** | ||
323 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
324 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
325 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
326 | * @return matches represented as a Match object. | ||
327 | * | ||
328 | */ | ||
329 | public Collection<TrainLocations_step_3.Match> getAllMatches(final Train pTrain, final Segment pLocation) { | ||
330 | return rawStreamAllMatches(new Object[]{pTrain, pLocation}).collect(Collectors.toSet()); | ||
331 | } | ||
332 | |||
333 | /** | ||
334 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
335 | * </p> | ||
336 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
337 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
338 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
339 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
340 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
341 | * @return a stream of matches represented as a Match object. | ||
342 | * | ||
343 | */ | ||
344 | public Stream<TrainLocations_step_3.Match> streamAllMatches(final Train pTrain, final Segment pLocation) { | ||
345 | return rawStreamAllMatches(new Object[]{pTrain, pLocation}); | ||
346 | } | ||
347 | |||
348 | /** | ||
349 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
350 | * Neither determinism nor randomness of selection is guaranteed. | ||
351 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
352 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
353 | * @return a match represented as a Match object, or null if no match is found. | ||
354 | * | ||
355 | */ | ||
356 | public Optional<TrainLocations_step_3.Match> getOneArbitraryMatch(final Train pTrain, final Segment pLocation) { | ||
357 | return rawGetOneArbitraryMatch(new Object[]{pTrain, pLocation}); | ||
358 | } | ||
359 | |||
360 | /** | ||
361 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
362 | * under any possible substitution of the unspecified parameters (if any). | ||
363 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
364 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
365 | * @return true if the input is a valid (partial) match of the pattern. | ||
366 | * | ||
367 | */ | ||
368 | public boolean hasMatch(final Train pTrain, final Segment pLocation) { | ||
369 | return rawHasMatch(new Object[]{pTrain, pLocation}); | ||
370 | } | ||
371 | |||
372 | /** | ||
373 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
374 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
375 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
376 | * @return the number of pattern matches found. | ||
377 | * | ||
378 | */ | ||
379 | public int countMatches(final Train pTrain, final Segment pLocation) { | ||
380 | return rawCountMatches(new Object[]{pTrain, pLocation}); | ||
381 | } | ||
382 | |||
383 | /** | ||
384 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
385 | * Neither determinism nor randomness of selection is guaranteed. | ||
386 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
387 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
388 | * @param processor the action that will process the selected match. | ||
389 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
390 | * | ||
391 | */ | ||
392 | public boolean forOneArbitraryMatch(final Train pTrain, final Segment pLocation, final Consumer<? super TrainLocations_step_3.Match> processor) { | ||
393 | return rawForOneArbitraryMatch(new Object[]{pTrain, pLocation}, processor); | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * Returns a new (partial) match. | ||
398 | * This can be used e.g. to call the matcher with a partial match. | ||
399 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
400 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
401 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
402 | * @return the (partial) match object. | ||
403 | * | ||
404 | */ | ||
405 | public TrainLocations_step_3.Match newMatch(final Train pTrain, final Segment pLocation) { | ||
406 | return TrainLocations_step_3.Match.newMatch(pTrain, pLocation); | ||
407 | } | ||
408 | |||
409 | /** | ||
410 | * Retrieve the set of values that occur in matches for train. | ||
411 | * @return the Set of all values or empty set if there are no matches | ||
412 | * | ||
413 | */ | ||
414 | protected Stream<Train> rawStreamAllValuesOftrain(final Object[] parameters) { | ||
415 | return rawStreamAllValues(POSITION_TRAIN, parameters).map(Train.class::cast); | ||
416 | } | ||
417 | |||
418 | /** | ||
419 | * Retrieve the set of values that occur in matches for train. | ||
420 | * @return the Set of all values or empty set if there are no matches | ||
421 | * | ||
422 | */ | ||
423 | public Set<Train> getAllValuesOftrain() { | ||
424 | return rawStreamAllValuesOftrain(emptyArray()).collect(Collectors.toSet()); | ||
425 | } | ||
426 | |||
427 | /** | ||
428 | * Retrieve the set of values that occur in matches for train. | ||
429 | * @return the Set of all values or empty set if there are no matches | ||
430 | * | ||
431 | */ | ||
432 | public Stream<Train> streamAllValuesOftrain() { | ||
433 | return rawStreamAllValuesOftrain(emptyArray()); | ||
434 | } | ||
435 | |||
436 | /** | ||
437 | * Retrieve the set of values that occur in matches for train. | ||
438 | * </p> | ||
439 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
440 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
441 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
442 | * | ||
443 | * @return the Stream of all values or empty set if there are no matches | ||
444 | * | ||
445 | */ | ||
446 | public Stream<Train> streamAllValuesOftrain(final TrainLocations_step_3.Match partialMatch) { | ||
447 | return rawStreamAllValuesOftrain(partialMatch.toArray()); | ||
448 | } | ||
449 | |||
450 | /** | ||
451 | * Retrieve the set of values that occur in matches for train. | ||
452 | * </p> | ||
453 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
454 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
455 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
456 | * | ||
457 | * @return the Stream of all values or empty set if there are no matches | ||
458 | * | ||
459 | */ | ||
460 | public Stream<Train> streamAllValuesOftrain(final Segment pLocation) { | ||
461 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation}); | ||
462 | } | ||
463 | |||
464 | /** | ||
465 | * Retrieve the set of values that occur in matches for train. | ||
466 | * @return the Set of all values or empty set if there are no matches | ||
467 | * | ||
468 | */ | ||
469 | public Set<Train> getAllValuesOftrain(final TrainLocations_step_3.Match partialMatch) { | ||
470 | return rawStreamAllValuesOftrain(partialMatch.toArray()).collect(Collectors.toSet()); | ||
471 | } | ||
472 | |||
473 | /** | ||
474 | * Retrieve the set of values that occur in matches for train. | ||
475 | * @return the Set of all values or empty set if there are no matches | ||
476 | * | ||
477 | */ | ||
478 | public Set<Train> getAllValuesOftrain(final Segment pLocation) { | ||
479 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation}).collect(Collectors.toSet()); | ||
480 | } | ||
481 | |||
482 | /** | ||
483 | * Retrieve the set of values that occur in matches for location. | ||
484 | * @return the Set of all values or empty set if there are no matches | ||
485 | * | ||
486 | */ | ||
487 | protected Stream<Segment> rawStreamAllValuesOflocation(final Object[] parameters) { | ||
488 | return rawStreamAllValues(POSITION_LOCATION, parameters).map(Segment.class::cast); | ||
489 | } | ||
490 | |||
491 | /** | ||
492 | * Retrieve the set of values that occur in matches for location. | ||
493 | * @return the Set of all values or empty set if there are no matches | ||
494 | * | ||
495 | */ | ||
496 | public Set<Segment> getAllValuesOflocation() { | ||
497 | return rawStreamAllValuesOflocation(emptyArray()).collect(Collectors.toSet()); | ||
498 | } | ||
499 | |||
500 | /** | ||
501 | * Retrieve the set of values that occur in matches for location. | ||
502 | * @return the Set of all values or empty set if there are no matches | ||
503 | * | ||
504 | */ | ||
505 | public Stream<Segment> streamAllValuesOflocation() { | ||
506 | return rawStreamAllValuesOflocation(emptyArray()); | ||
507 | } | ||
508 | |||
509 | /** | ||
510 | * Retrieve the set of values that occur in matches for location. | ||
511 | * </p> | ||
512 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
513 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
514 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
515 | * | ||
516 | * @return the Stream of all values or empty set if there are no matches | ||
517 | * | ||
518 | */ | ||
519 | public Stream<Segment> streamAllValuesOflocation(final TrainLocations_step_3.Match partialMatch) { | ||
520 | return rawStreamAllValuesOflocation(partialMatch.toArray()); | ||
521 | } | ||
522 | |||
523 | /** | ||
524 | * Retrieve the set of values that occur in matches for location. | ||
525 | * </p> | ||
526 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
527 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
528 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
529 | * | ||
530 | * @return the Stream of all values or empty set if there are no matches | ||
531 | * | ||
532 | */ | ||
533 | public Stream<Segment> streamAllValuesOflocation(final Train pTrain) { | ||
534 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null}); | ||
535 | } | ||
536 | |||
537 | /** | ||
538 | * Retrieve the set of values that occur in matches for location. | ||
539 | * @return the Set of all values or empty set if there are no matches | ||
540 | * | ||
541 | */ | ||
542 | public Set<Segment> getAllValuesOflocation(final TrainLocations_step_3.Match partialMatch) { | ||
543 | return rawStreamAllValuesOflocation(partialMatch.toArray()).collect(Collectors.toSet()); | ||
544 | } | ||
545 | |||
546 | /** | ||
547 | * Retrieve the set of values that occur in matches for location. | ||
548 | * @return the Set of all values or empty set if there are no matches | ||
549 | * | ||
550 | */ | ||
551 | public Set<Segment> getAllValuesOflocation(final Train pTrain) { | ||
552 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null}).collect(Collectors.toSet()); | ||
553 | } | ||
554 | |||
555 | @Override | ||
556 | protected TrainLocations_step_3.Match tupleToMatch(final Tuple t) { | ||
557 | try { | ||
558 | return TrainLocations_step_3.Match.newMatch((Train) t.get(POSITION_TRAIN), (Segment) t.get(POSITION_LOCATION)); | ||
559 | } catch(ClassCastException e) { | ||
560 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
561 | return null; | ||
562 | } | ||
563 | } | ||
564 | |||
565 | @Override | ||
566 | protected TrainLocations_step_3.Match arrayToMatch(final Object[] match) { | ||
567 | try { | ||
568 | return TrainLocations_step_3.Match.newMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION]); | ||
569 | } catch(ClassCastException e) { | ||
570 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
571 | return null; | ||
572 | } | ||
573 | } | ||
574 | |||
575 | @Override | ||
576 | protected TrainLocations_step_3.Match arrayToMatchMutable(final Object[] match) { | ||
577 | try { | ||
578 | return TrainLocations_step_3.Match.newMutableMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION]); | ||
579 | } catch(ClassCastException e) { | ||
580 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
581 | return null; | ||
582 | } | ||
583 | } | ||
584 | |||
585 | /** | ||
586 | * @return the singleton instance of the query specification of this pattern | ||
587 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
588 | * | ||
589 | */ | ||
590 | public static IQuerySpecification<TrainLocations_step_3.Matcher> querySpecification() { | ||
591 | return TrainLocations_step_3.instance(); | ||
592 | } | ||
593 | } | ||
594 | |||
595 | private TrainLocations_step_3() { | ||
596 | super(GeneratedPQuery.INSTANCE); | ||
597 | } | ||
598 | |||
599 | /** | ||
600 | * @return the singleton instance of the query specification | ||
601 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
602 | * | ||
603 | */ | ||
604 | public static TrainLocations_step_3 instance() { | ||
605 | try{ | ||
606 | return LazyHolder.INSTANCE; | ||
607 | } catch (ExceptionInInitializerError err) { | ||
608 | throw processInitializerError(err); | ||
609 | } | ||
610 | } | ||
611 | |||
612 | @Override | ||
613 | protected TrainLocations_step_3.Matcher instantiate(final ViatraQueryEngine engine) { | ||
614 | return TrainLocations_step_3.Matcher.on(engine); | ||
615 | } | ||
616 | |||
617 | @Override | ||
618 | public TrainLocations_step_3.Matcher instantiate() { | ||
619 | return TrainLocations_step_3.Matcher.create(); | ||
620 | } | ||
621 | |||
622 | @Override | ||
623 | public TrainLocations_step_3.Match newEmptyMatch() { | ||
624 | return TrainLocations_step_3.Match.newEmptyMatch(); | ||
625 | } | ||
626 | |||
627 | @Override | ||
628 | public TrainLocations_step_3.Match newMatch(final Object... parameters) { | ||
629 | return TrainLocations_step_3.Match.newMatch((modes3.Train) parameters[0], (modes3.Segment) parameters[1]); | ||
630 | } | ||
631 | |||
632 | /** | ||
633 | * Inner class allowing the singleton instance of {@link TrainLocations_step_3} to be created | ||
634 | * <b>not</b> at the class load time of the outer class, | ||
635 | * but rather at the first call to {@link TrainLocations_step_3#instance()}. | ||
636 | * | ||
637 | * <p> This workaround is required e.g. to support recursion. | ||
638 | * | ||
639 | */ | ||
640 | private static class LazyHolder { | ||
641 | private static final TrainLocations_step_3 INSTANCE = new TrainLocations_step_3(); | ||
642 | |||
643 | /** | ||
644 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
645 | * This initialization order is required to support indirect recursion. | ||
646 | * | ||
647 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
648 | * | ||
649 | */ | ||
650 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
651 | |||
652 | public static Object ensureInitialized() { | ||
653 | INSTANCE.ensureInitializedInternal(); | ||
654 | return null; | ||
655 | } | ||
656 | } | ||
657 | |||
658 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
659 | private static final TrainLocations_step_3.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
660 | |||
661 | private final PParameter parameter_train = new PParameter("train", "modes3.Train", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Train")), PParameterDirection.INOUT); | ||
662 | |||
663 | private final PParameter parameter_location = new PParameter("location", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
664 | |||
665 | private final List<PParameter> parameters = Arrays.asList(parameter_train, parameter_location); | ||
666 | |||
667 | private GeneratedPQuery() { | ||
668 | super(PVisibility.PUBLIC); | ||
669 | } | ||
670 | |||
671 | @Override | ||
672 | public String getFullyQualifiedName() { | ||
673 | return "modes3.queries.trainLocations_step_3"; | ||
674 | } | ||
675 | |||
676 | @Override | ||
677 | public List<String> getParameterNames() { | ||
678 | return Arrays.asList("train","location"); | ||
679 | } | ||
680 | |||
681 | @Override | ||
682 | public List<PParameter> getParameters() { | ||
683 | return parameters; | ||
684 | } | ||
685 | |||
686 | @Override | ||
687 | public Set<PBody> doGetContainedBodies() { | ||
688 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
689 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
690 | { | ||
691 | PBody body = new PBody(this); | ||
692 | PVariable var_train = body.getOrCreateVariableByName("train"); | ||
693 | PVariable var_location = body.getOrCreateVariableByName("location"); | ||
694 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
695 | new TypeConstraint(body, Tuples.flatTupleOf(var_location), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
696 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
697 | new ExportedParameter(body, var_train, parameter_train), | ||
698 | new ExportedParameter(body, var_location, parameter_location) | ||
699 | )); | ||
700 | // // results->matches[match_cntr].location = frame->location;// results->matches[match_cntr++].train = frame->train; Train(train) | ||
701 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
702 | // Train.location(train, location) | ||
703 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
704 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
705 | new TypeConstraint(body, Tuples.flatTupleOf(var_train, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train", "location"))); | ||
706 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
707 | new Equality(body, var__virtual_0_, var_location); | ||
708 | bodies.add(body); | ||
709 | } | ||
710 | return bodies; | ||
711 | } | ||
712 | } | ||
713 | } | ||
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 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Turnout; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * {@literal @}Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) | ||
49 | * pattern turnoutConnectedToBothOutputs(T : Turnout) { | ||
50 | * Turnout.straight(T, Straight); | ||
51 | * Turnout.divergent(T, Divergent); | ||
52 | * Segment.connectedTo(T, Straight); | ||
53 | * Segment.connectedTo(T, Divergent); | ||
54 | * } | ||
55 | * </pre></code> | ||
56 | * | ||
57 | * @see Matcher | ||
58 | * @see Match | ||
59 | * | ||
60 | */ | ||
61 | @SuppressWarnings("all") | ||
62 | public final class TurnoutConnectedToBothOutputs extends BaseGeneratedEMFQuerySpecification<TurnoutConnectedToBothOutputs.Matcher> { | ||
63 | /** | ||
64 | * Pattern-specific match representation of the modes3.queries.turnoutConnectedToBothOutputs pattern, | ||
65 | * to be used in conjunction with {@link Matcher}. | ||
66 | * | ||
67 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
68 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
69 | * usable to represent a match of the pattern in the result of a query, | ||
70 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
71 | * | ||
72 | * @see Matcher | ||
73 | * | ||
74 | */ | ||
75 | public static abstract class Match extends BasePatternMatch { | ||
76 | private Turnout fT; | ||
77 | |||
78 | private static List<String> parameterNames = makeImmutableList("T"); | ||
79 | |||
80 | private Match(final Turnout pT) { | ||
81 | this.fT = pT; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | switch(parameterName) { | ||
87 | case "T": return this.fT; | ||
88 | default: return null; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | @Override | ||
93 | public Object get(final int index) { | ||
94 | switch(index) { | ||
95 | case 0: return this.fT; | ||
96 | default: return null; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | public Turnout getT() { | ||
101 | return this.fT; | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public boolean set(final String parameterName, final Object newValue) { | ||
106 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
107 | if ("T".equals(parameterName) ) { | ||
108 | this.fT = (Turnout) newValue; | ||
109 | return true; | ||
110 | } | ||
111 | return false; | ||
112 | } | ||
113 | |||
114 | public void setT(final Turnout pT) { | ||
115 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
116 | this.fT = pT; | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public String patternName() { | ||
121 | return "modes3.queries.turnoutConnectedToBothOutputs"; | ||
122 | } | ||
123 | |||
124 | @Override | ||
125 | public List<String> parameterNames() { | ||
126 | return TurnoutConnectedToBothOutputs.Match.parameterNames; | ||
127 | } | ||
128 | |||
129 | @Override | ||
130 | public Object[] toArray() { | ||
131 | return new Object[]{fT}; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public TurnoutConnectedToBothOutputs.Match toImmutable() { | ||
136 | return isMutable() ? newMatch(fT) : this; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public String prettyPrint() { | ||
141 | StringBuilder result = new StringBuilder(); | ||
142 | result.append("\"T\"=" + prettyPrintValue(fT)); | ||
143 | return result.toString(); | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public int hashCode() { | ||
148 | return Objects.hash(fT); | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public boolean equals(final Object obj) { | ||
153 | if (this == obj) | ||
154 | return true; | ||
155 | if (obj == null) { | ||
156 | return false; | ||
157 | } | ||
158 | if ((obj instanceof TurnoutConnectedToBothOutputs.Match)) { | ||
159 | TurnoutConnectedToBothOutputs.Match other = (TurnoutConnectedToBothOutputs.Match) obj; | ||
160 | return Objects.equals(fT, other.fT); | ||
161 | } else { | ||
162 | // this should be infrequent | ||
163 | if (!(obj instanceof IPatternMatch)) { | ||
164 | return false; | ||
165 | } | ||
166 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
167 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
168 | } | ||
169 | } | ||
170 | |||
171 | @Override | ||
172 | public TurnoutConnectedToBothOutputs specification() { | ||
173 | return TurnoutConnectedToBothOutputs.instance(); | ||
174 | } | ||
175 | |||
176 | /** | ||
177 | * Returns an empty, mutable match. | ||
178 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
179 | * | ||
180 | * @return the empty match. | ||
181 | * | ||
182 | */ | ||
183 | public static TurnoutConnectedToBothOutputs.Match newEmptyMatch() { | ||
184 | return new Mutable(null); | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * Returns a mutable (partial) match. | ||
189 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
190 | * | ||
191 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
192 | * @return the new, mutable (partial) match object. | ||
193 | * | ||
194 | */ | ||
195 | public static TurnoutConnectedToBothOutputs.Match newMutableMatch(final Turnout pT) { | ||
196 | return new Mutable(pT); | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * Returns a new (partial) match. | ||
201 | * This can be used e.g. to call the matcher with a partial match. | ||
202 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
203 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
204 | * @return the (partial) match object. | ||
205 | * | ||
206 | */ | ||
207 | public static TurnoutConnectedToBothOutputs.Match newMatch(final Turnout pT) { | ||
208 | return new Immutable(pT); | ||
209 | } | ||
210 | |||
211 | private static final class Mutable extends TurnoutConnectedToBothOutputs.Match { | ||
212 | Mutable(final Turnout pT) { | ||
213 | super(pT); | ||
214 | } | ||
215 | |||
216 | @Override | ||
217 | public boolean isMutable() { | ||
218 | return true; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | private static final class Immutable extends TurnoutConnectedToBothOutputs.Match { | ||
223 | Immutable(final Turnout pT) { | ||
224 | super(pT); | ||
225 | } | ||
226 | |||
227 | @Override | ||
228 | public boolean isMutable() { | ||
229 | return false; | ||
230 | } | ||
231 | } | ||
232 | } | ||
233 | |||
234 | /** | ||
235 | * Generated pattern matcher API of the modes3.queries.turnoutConnectedToBothOutputs pattern, | ||
236 | * providing pattern-specific query methods. | ||
237 | * | ||
238 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
239 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
240 | * | ||
241 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
242 | * | ||
243 | * <p>Original source: | ||
244 | * <code><pre> | ||
245 | * {@literal @}Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) | ||
246 | * pattern turnoutConnectedToBothOutputs(T : Turnout) { | ||
247 | * Turnout.straight(T, Straight); | ||
248 | * Turnout.divergent(T, Divergent); | ||
249 | * Segment.connectedTo(T, Straight); | ||
250 | * Segment.connectedTo(T, Divergent); | ||
251 | * } | ||
252 | * </pre></code> | ||
253 | * | ||
254 | * @see Match | ||
255 | * @see TurnoutConnectedToBothOutputs | ||
256 | * | ||
257 | */ | ||
258 | public static class Matcher extends BaseMatcher<TurnoutConnectedToBothOutputs.Match> { | ||
259 | /** | ||
260 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
261 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
262 | * | ||
263 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
264 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
265 | * | ||
266 | */ | ||
267 | public static TurnoutConnectedToBothOutputs.Matcher on(final ViatraQueryEngine engine) { | ||
268 | // check if matcher already exists | ||
269 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
270 | if (matcher == null) { | ||
271 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
272 | } | ||
273 | return matcher; | ||
274 | } | ||
275 | |||
276 | /** | ||
277 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
278 | * @return an initialized matcher | ||
279 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
280 | * | ||
281 | */ | ||
282 | public static TurnoutConnectedToBothOutputs.Matcher create() { | ||
283 | return new Matcher(); | ||
284 | } | ||
285 | |||
286 | private static final int POSITION_T = 0; | ||
287 | |||
288 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TurnoutConnectedToBothOutputs.Matcher.class); | ||
289 | |||
290 | /** | ||
291 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
292 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
293 | * | ||
294 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
295 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
296 | * | ||
297 | */ | ||
298 | private Matcher() { | ||
299 | super(querySpecification()); | ||
300 | } | ||
301 | |||
302 | /** | ||
303 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
304 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
305 | * @return matches represented as a Match object. | ||
306 | * | ||
307 | */ | ||
308 | public Collection<TurnoutConnectedToBothOutputs.Match> getAllMatches(final Turnout pT) { | ||
309 | return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); | ||
310 | } | ||
311 | |||
312 | /** | ||
313 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
314 | * </p> | ||
315 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
316 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
317 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
318 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
319 | * @return a stream of matches represented as a Match object. | ||
320 | * | ||
321 | */ | ||
322 | public Stream<TurnoutConnectedToBothOutputs.Match> streamAllMatches(final Turnout pT) { | ||
323 | return rawStreamAllMatches(new Object[]{pT}); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
328 | * Neither determinism nor randomness of selection is guaranteed. | ||
329 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
330 | * @return a match represented as a Match object, or null if no match is found. | ||
331 | * | ||
332 | */ | ||
333 | public Optional<TurnoutConnectedToBothOutputs.Match> getOneArbitraryMatch(final Turnout pT) { | ||
334 | return rawGetOneArbitraryMatch(new Object[]{pT}); | ||
335 | } | ||
336 | |||
337 | /** | ||
338 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
339 | * under any possible substitution of the unspecified parameters (if any). | ||
340 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
341 | * @return true if the input is a valid (partial) match of the pattern. | ||
342 | * | ||
343 | */ | ||
344 | public boolean hasMatch(final Turnout pT) { | ||
345 | return rawHasMatch(new Object[]{pT}); | ||
346 | } | ||
347 | |||
348 | /** | ||
349 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
350 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
351 | * @return the number of pattern matches found. | ||
352 | * | ||
353 | */ | ||
354 | public int countMatches(final Turnout pT) { | ||
355 | return rawCountMatches(new Object[]{pT}); | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
360 | * Neither determinism nor randomness of selection is guaranteed. | ||
361 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
362 | * @param processor the action that will process the selected match. | ||
363 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
364 | * | ||
365 | */ | ||
366 | public boolean forOneArbitraryMatch(final Turnout pT, final Consumer<? super TurnoutConnectedToBothOutputs.Match> processor) { | ||
367 | return rawForOneArbitraryMatch(new Object[]{pT}, processor); | ||
368 | } | ||
369 | |||
370 | /** | ||
371 | * Returns a new (partial) match. | ||
372 | * This can be used e.g. to call the matcher with a partial match. | ||
373 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
374 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
375 | * @return the (partial) match object. | ||
376 | * | ||
377 | */ | ||
378 | public TurnoutConnectedToBothOutputs.Match newMatch(final Turnout pT) { | ||
379 | return TurnoutConnectedToBothOutputs.Match.newMatch(pT); | ||
380 | } | ||
381 | |||
382 | /** | ||
383 | * Retrieve the set of values that occur in matches for T. | ||
384 | * @return the Set of all values or empty set if there are no matches | ||
385 | * | ||
386 | */ | ||
387 | protected Stream<Turnout> rawStreamAllValuesOfT(final Object[] parameters) { | ||
388 | return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); | ||
389 | } | ||
390 | |||
391 | /** | ||
392 | * Retrieve the set of values that occur in matches for T. | ||
393 | * @return the Set of all values or empty set if there are no matches | ||
394 | * | ||
395 | */ | ||
396 | public Set<Turnout> getAllValuesOfT() { | ||
397 | return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); | ||
398 | } | ||
399 | |||
400 | /** | ||
401 | * Retrieve the set of values that occur in matches for T. | ||
402 | * @return the Set of all values or empty set if there are no matches | ||
403 | * | ||
404 | */ | ||
405 | public Stream<Turnout> streamAllValuesOfT() { | ||
406 | return rawStreamAllValuesOfT(emptyArray()); | ||
407 | } | ||
408 | |||
409 | @Override | ||
410 | protected TurnoutConnectedToBothOutputs.Match tupleToMatch(final Tuple t) { | ||
411 | try { | ||
412 | return TurnoutConnectedToBothOutputs.Match.newMatch((Turnout) t.get(POSITION_T)); | ||
413 | } catch(ClassCastException e) { | ||
414 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
415 | return null; | ||
416 | } | ||
417 | } | ||
418 | |||
419 | @Override | ||
420 | protected TurnoutConnectedToBothOutputs.Match arrayToMatch(final Object[] match) { | ||
421 | try { | ||
422 | return TurnoutConnectedToBothOutputs.Match.newMatch((Turnout) match[POSITION_T]); | ||
423 | } catch(ClassCastException e) { | ||
424 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
425 | return null; | ||
426 | } | ||
427 | } | ||
428 | |||
429 | @Override | ||
430 | protected TurnoutConnectedToBothOutputs.Match arrayToMatchMutable(final Object[] match) { | ||
431 | try { | ||
432 | return TurnoutConnectedToBothOutputs.Match.newMutableMatch((Turnout) match[POSITION_T]); | ||
433 | } catch(ClassCastException e) { | ||
434 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
435 | return null; | ||
436 | } | ||
437 | } | ||
438 | |||
439 | /** | ||
440 | * @return the singleton instance of the query specification of this pattern | ||
441 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
442 | * | ||
443 | */ | ||
444 | public static IQuerySpecification<TurnoutConnectedToBothOutputs.Matcher> querySpecification() { | ||
445 | return TurnoutConnectedToBothOutputs.instance(); | ||
446 | } | ||
447 | } | ||
448 | |||
449 | private TurnoutConnectedToBothOutputs() { | ||
450 | super(GeneratedPQuery.INSTANCE); | ||
451 | } | ||
452 | |||
453 | /** | ||
454 | * @return the singleton instance of the query specification | ||
455 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
456 | * | ||
457 | */ | ||
458 | public static TurnoutConnectedToBothOutputs instance() { | ||
459 | try{ | ||
460 | return LazyHolder.INSTANCE; | ||
461 | } catch (ExceptionInInitializerError err) { | ||
462 | throw processInitializerError(err); | ||
463 | } | ||
464 | } | ||
465 | |||
466 | @Override | ||
467 | protected TurnoutConnectedToBothOutputs.Matcher instantiate(final ViatraQueryEngine engine) { | ||
468 | return TurnoutConnectedToBothOutputs.Matcher.on(engine); | ||
469 | } | ||
470 | |||
471 | @Override | ||
472 | public TurnoutConnectedToBothOutputs.Matcher instantiate() { | ||
473 | return TurnoutConnectedToBothOutputs.Matcher.create(); | ||
474 | } | ||
475 | |||
476 | @Override | ||
477 | public TurnoutConnectedToBothOutputs.Match newEmptyMatch() { | ||
478 | return TurnoutConnectedToBothOutputs.Match.newEmptyMatch(); | ||
479 | } | ||
480 | |||
481 | @Override | ||
482 | public TurnoutConnectedToBothOutputs.Match newMatch(final Object... parameters) { | ||
483 | return TurnoutConnectedToBothOutputs.Match.newMatch((modes3.Turnout) parameters[0]); | ||
484 | } | ||
485 | |||
486 | /** | ||
487 | * Inner class allowing the singleton instance of {@link TurnoutConnectedToBothOutputs} to be created | ||
488 | * <b>not</b> at the class load time of the outer class, | ||
489 | * but rather at the first call to {@link TurnoutConnectedToBothOutputs#instance()}. | ||
490 | * | ||
491 | * <p> This workaround is required e.g. to support recursion. | ||
492 | * | ||
493 | */ | ||
494 | private static class LazyHolder { | ||
495 | private static final TurnoutConnectedToBothOutputs INSTANCE = new TurnoutConnectedToBothOutputs(); | ||
496 | |||
497 | /** | ||
498 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
499 | * This initialization order is required to support indirect recursion. | ||
500 | * | ||
501 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
502 | * | ||
503 | */ | ||
504 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
505 | |||
506 | public static Object ensureInitialized() { | ||
507 | INSTANCE.ensureInitializedInternal(); | ||
508 | return null; | ||
509 | } | ||
510 | } | ||
511 | |||
512 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
513 | private static final TurnoutConnectedToBothOutputs.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
514 | |||
515 | private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); | ||
516 | |||
517 | private final List<PParameter> parameters = Arrays.asList(parameter_T); | ||
518 | |||
519 | private GeneratedPQuery() { | ||
520 | super(PVisibility.PUBLIC); | ||
521 | } | ||
522 | |||
523 | @Override | ||
524 | public String getFullyQualifiedName() { | ||
525 | return "modes3.queries.turnoutConnectedToBothOutputs"; | ||
526 | } | ||
527 | |||
528 | @Override | ||
529 | public List<String> getParameterNames() { | ||
530 | return Arrays.asList("T"); | ||
531 | } | ||
532 | |||
533 | @Override | ||
534 | public List<PParameter> getParameters() { | ||
535 | return parameters; | ||
536 | } | ||
537 | |||
538 | @Override | ||
539 | public Set<PBody> doGetContainedBodies() { | ||
540 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
541 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
542 | { | ||
543 | PBody body = new PBody(this); | ||
544 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
545 | PVariable var_Straight = body.getOrCreateVariableByName("Straight"); | ||
546 | PVariable var_Divergent = body.getOrCreateVariableByName("Divergent"); | ||
547 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
548 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
549 | new ExportedParameter(body, var_T, parameter_T) | ||
550 | )); | ||
551 | // Turnout.straight(T, Straight) | ||
552 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
553 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
554 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "straight"))); | ||
555 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
556 | new Equality(body, var__virtual_0_, var_Straight); | ||
557 | // Turnout.divergent(T, Divergent) | ||
558 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
559 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
560 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "divergent"))); | ||
561 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
562 | new Equality(body, var__virtual_1_, var_Divergent); | ||
563 | // Segment.connectedTo(T, Straight) | ||
564 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
565 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
566 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
567 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
568 | new Equality(body, var__virtual_2_, var_Straight); | ||
569 | // Segment.connectedTo(T, Divergent) | ||
570 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
571 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); | ||
572 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
573 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
574 | new Equality(body, var__virtual_3_, var_Divergent); | ||
575 | bodies.add(body); | ||
576 | } | ||
577 | { | ||
578 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
579 | annotation.addAttribute("message", "turnoutConnectedToBothOutputs"); | ||
580 | annotation.addAttribute("severity", "error"); | ||
581 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
582 | new ParameterReference("T") | ||
583 | })); | ||
584 | addAnnotation(annotation); | ||
585 | } | ||
586 | return bodies; | ||
587 | } | ||
588 | } | ||
589 | } | ||
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 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.Turnout; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern turnoutOutput(T : Turnout, S : Segment) { | ||
48 | * Turnout.straight(T, S); | ||
49 | * } or { | ||
50 | * Turnout.divergent(T, S); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class TurnoutOutput extends BaseGeneratedEMFQuerySpecification<TurnoutOutput.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.turnoutOutput pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Turnout fT; | ||
74 | |||
75 | private Segment fS; | ||
76 | |||
77 | private static List<String> parameterNames = makeImmutableList("T", "S"); | ||
78 | |||
79 | private Match(final Turnout pT, final Segment pS) { | ||
80 | this.fT = pT; | ||
81 | this.fS = pS; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | switch(parameterName) { | ||
87 | case "T": return this.fT; | ||
88 | case "S": return this.fS; | ||
89 | default: return null; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | @Override | ||
94 | public Object get(final int index) { | ||
95 | switch(index) { | ||
96 | case 0: return this.fT; | ||
97 | case 1: return this.fS; | ||
98 | default: return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public Turnout getT() { | ||
103 | return this.fT; | ||
104 | } | ||
105 | |||
106 | public Segment getS() { | ||
107 | return this.fS; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public boolean set(final String parameterName, final Object newValue) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | if ("T".equals(parameterName) ) { | ||
114 | this.fT = (Turnout) newValue; | ||
115 | return true; | ||
116 | } | ||
117 | if ("S".equals(parameterName) ) { | ||
118 | this.fS = (Segment) newValue; | ||
119 | return true; | ||
120 | } | ||
121 | return false; | ||
122 | } | ||
123 | |||
124 | public void setT(final Turnout pT) { | ||
125 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
126 | this.fT = pT; | ||
127 | } | ||
128 | |||
129 | public void setS(final Segment pS) { | ||
130 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
131 | this.fS = pS; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public String patternName() { | ||
136 | return "modes3.queries.turnoutOutput"; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public List<String> parameterNames() { | ||
141 | return TurnoutOutput.Match.parameterNames; | ||
142 | } | ||
143 | |||
144 | @Override | ||
145 | public Object[] toArray() { | ||
146 | return new Object[]{fT, fS}; | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public TurnoutOutput.Match toImmutable() { | ||
151 | return isMutable() ? newMatch(fT, fS) : this; | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public String prettyPrint() { | ||
156 | StringBuilder result = new StringBuilder(); | ||
157 | result.append("\"T\"=" + prettyPrintValue(fT) + ", "); | ||
158 | result.append("\"S\"=" + prettyPrintValue(fS)); | ||
159 | return result.toString(); | ||
160 | } | ||
161 | |||
162 | @Override | ||
163 | public int hashCode() { | ||
164 | return Objects.hash(fT, fS); | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public boolean equals(final Object obj) { | ||
169 | if (this == obj) | ||
170 | return true; | ||
171 | if (obj == null) { | ||
172 | return false; | ||
173 | } | ||
174 | if ((obj instanceof TurnoutOutput.Match)) { | ||
175 | TurnoutOutput.Match other = (TurnoutOutput.Match) obj; | ||
176 | return Objects.equals(fT, other.fT) && Objects.equals(fS, other.fS); | ||
177 | } else { | ||
178 | // this should be infrequent | ||
179 | if (!(obj instanceof IPatternMatch)) { | ||
180 | return false; | ||
181 | } | ||
182 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
183 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | @Override | ||
188 | public TurnoutOutput specification() { | ||
189 | return TurnoutOutput.instance(); | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * Returns an empty, mutable match. | ||
194 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
195 | * | ||
196 | * @return the empty match. | ||
197 | * | ||
198 | */ | ||
199 | public static TurnoutOutput.Match newEmptyMatch() { | ||
200 | return new Mutable(null, null); | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * Returns a mutable (partial) match. | ||
205 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
206 | * | ||
207 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
208 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
209 | * @return the new, mutable (partial) match object. | ||
210 | * | ||
211 | */ | ||
212 | public static TurnoutOutput.Match newMutableMatch(final Turnout pT, final Segment pS) { | ||
213 | return new Mutable(pT, pS); | ||
214 | } | ||
215 | |||
216 | /** | ||
217 | * Returns a new (partial) match. | ||
218 | * This can be used e.g. to call the matcher with a partial match. | ||
219 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
220 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
221 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
222 | * @return the (partial) match object. | ||
223 | * | ||
224 | */ | ||
225 | public static TurnoutOutput.Match newMatch(final Turnout pT, final Segment pS) { | ||
226 | return new Immutable(pT, pS); | ||
227 | } | ||
228 | |||
229 | private static final class Mutable extends TurnoutOutput.Match { | ||
230 | Mutable(final Turnout pT, final Segment pS) { | ||
231 | super(pT, pS); | ||
232 | } | ||
233 | |||
234 | @Override | ||
235 | public boolean isMutable() { | ||
236 | return true; | ||
237 | } | ||
238 | } | ||
239 | |||
240 | private static final class Immutable extends TurnoutOutput.Match { | ||
241 | Immutable(final Turnout pT, final Segment pS) { | ||
242 | super(pT, pS); | ||
243 | } | ||
244 | |||
245 | @Override | ||
246 | public boolean isMutable() { | ||
247 | return false; | ||
248 | } | ||
249 | } | ||
250 | } | ||
251 | |||
252 | /** | ||
253 | * Generated pattern matcher API of the modes3.queries.turnoutOutput pattern, | ||
254 | * providing pattern-specific query methods. | ||
255 | * | ||
256 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
257 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
258 | * | ||
259 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
260 | * | ||
261 | * <p>Original source: | ||
262 | * <code><pre> | ||
263 | * pattern turnoutOutput(T : Turnout, S : Segment) { | ||
264 | * Turnout.straight(T, S); | ||
265 | * } or { | ||
266 | * Turnout.divergent(T, S); | ||
267 | * } | ||
268 | * </pre></code> | ||
269 | * | ||
270 | * @see Match | ||
271 | * @see TurnoutOutput | ||
272 | * | ||
273 | */ | ||
274 | public static class Matcher extends BaseMatcher<TurnoutOutput.Match> { | ||
275 | /** | ||
276 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
277 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
278 | * | ||
279 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
280 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
281 | * | ||
282 | */ | ||
283 | public static TurnoutOutput.Matcher on(final ViatraQueryEngine engine) { | ||
284 | // check if matcher already exists | ||
285 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
286 | if (matcher == null) { | ||
287 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
288 | } | ||
289 | return matcher; | ||
290 | } | ||
291 | |||
292 | /** | ||
293 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
294 | * @return an initialized matcher | ||
295 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
296 | * | ||
297 | */ | ||
298 | public static TurnoutOutput.Matcher create() { | ||
299 | return new Matcher(); | ||
300 | } | ||
301 | |||
302 | private static final int POSITION_T = 0; | ||
303 | |||
304 | private static final int POSITION_S = 1; | ||
305 | |||
306 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TurnoutOutput.Matcher.class); | ||
307 | |||
308 | /** | ||
309 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
310 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
311 | * | ||
312 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
313 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
314 | * | ||
315 | */ | ||
316 | private Matcher() { | ||
317 | super(querySpecification()); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
322 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
323 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
324 | * @return matches represented as a Match object. | ||
325 | * | ||
326 | */ | ||
327 | public Collection<TurnoutOutput.Match> getAllMatches(final Turnout pT, final Segment pS) { | ||
328 | return rawStreamAllMatches(new Object[]{pT, pS}).collect(Collectors.toSet()); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
333 | * </p> | ||
334 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
335 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
336 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
337 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
338 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
339 | * @return a stream of matches represented as a Match object. | ||
340 | * | ||
341 | */ | ||
342 | public Stream<TurnoutOutput.Match> streamAllMatches(final Turnout pT, final Segment pS) { | ||
343 | return rawStreamAllMatches(new Object[]{pT, pS}); | ||
344 | } | ||
345 | |||
346 | /** | ||
347 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
348 | * Neither determinism nor randomness of selection is guaranteed. | ||
349 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
350 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
351 | * @return a match represented as a Match object, or null if no match is found. | ||
352 | * | ||
353 | */ | ||
354 | public Optional<TurnoutOutput.Match> getOneArbitraryMatch(final Turnout pT, final Segment pS) { | ||
355 | return rawGetOneArbitraryMatch(new Object[]{pT, pS}); | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
360 | * under any possible substitution of the unspecified parameters (if any). | ||
361 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
362 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
363 | * @return true if the input is a valid (partial) match of the pattern. | ||
364 | * | ||
365 | */ | ||
366 | public boolean hasMatch(final Turnout pT, final Segment pS) { | ||
367 | return rawHasMatch(new Object[]{pT, pS}); | ||
368 | } | ||
369 | |||
370 | /** | ||
371 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
372 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
373 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
374 | * @return the number of pattern matches found. | ||
375 | * | ||
376 | */ | ||
377 | public int countMatches(final Turnout pT, final Segment pS) { | ||
378 | return rawCountMatches(new Object[]{pT, pS}); | ||
379 | } | ||
380 | |||
381 | /** | ||
382 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
383 | * Neither determinism nor randomness of selection is guaranteed. | ||
384 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
385 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
386 | * @param processor the action that will process the selected match. | ||
387 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
388 | * | ||
389 | */ | ||
390 | public boolean forOneArbitraryMatch(final Turnout pT, final Segment pS, final Consumer<? super TurnoutOutput.Match> processor) { | ||
391 | return rawForOneArbitraryMatch(new Object[]{pT, pS}, processor); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Returns a new (partial) match. | ||
396 | * This can be used e.g. to call the matcher with a partial match. | ||
397 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
398 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
399 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
400 | * @return the (partial) match object. | ||
401 | * | ||
402 | */ | ||
403 | public TurnoutOutput.Match newMatch(final Turnout pT, final Segment pS) { | ||
404 | return TurnoutOutput.Match.newMatch(pT, pS); | ||
405 | } | ||
406 | |||
407 | /** | ||
408 | * Retrieve the set of values that occur in matches for T. | ||
409 | * @return the Set of all values or empty set if there are no matches | ||
410 | * | ||
411 | */ | ||
412 | protected Stream<Turnout> rawStreamAllValuesOfT(final Object[] parameters) { | ||
413 | return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); | ||
414 | } | ||
415 | |||
416 | /** | ||
417 | * Retrieve the set of values that occur in matches for T. | ||
418 | * @return the Set of all values or empty set if there are no matches | ||
419 | * | ||
420 | */ | ||
421 | public Set<Turnout> getAllValuesOfT() { | ||
422 | return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); | ||
423 | } | ||
424 | |||
425 | /** | ||
426 | * Retrieve the set of values that occur in matches for T. | ||
427 | * @return the Set of all values or empty set if there are no matches | ||
428 | * | ||
429 | */ | ||
430 | public Stream<Turnout> streamAllValuesOfT() { | ||
431 | return rawStreamAllValuesOfT(emptyArray()); | ||
432 | } | ||
433 | |||
434 | /** | ||
435 | * Retrieve the set of values that occur in matches for T. | ||
436 | * </p> | ||
437 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
438 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
439 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
440 | * | ||
441 | * @return the Stream of all values or empty set if there are no matches | ||
442 | * | ||
443 | */ | ||
444 | public Stream<Turnout> streamAllValuesOfT(final TurnoutOutput.Match partialMatch) { | ||
445 | return rawStreamAllValuesOfT(partialMatch.toArray()); | ||
446 | } | ||
447 | |||
448 | /** | ||
449 | * Retrieve the set of values that occur in matches for T. | ||
450 | * </p> | ||
451 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
452 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
453 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
454 | * | ||
455 | * @return the Stream of all values or empty set if there are no matches | ||
456 | * | ||
457 | */ | ||
458 | public Stream<Turnout> streamAllValuesOfT(final Segment pS) { | ||
459 | return rawStreamAllValuesOfT(new Object[]{null, pS}); | ||
460 | } | ||
461 | |||
462 | /** | ||
463 | * Retrieve the set of values that occur in matches for T. | ||
464 | * @return the Set of all values or empty set if there are no matches | ||
465 | * | ||
466 | */ | ||
467 | public Set<Turnout> getAllValuesOfT(final TurnoutOutput.Match partialMatch) { | ||
468 | return rawStreamAllValuesOfT(partialMatch.toArray()).collect(Collectors.toSet()); | ||
469 | } | ||
470 | |||
471 | /** | ||
472 | * Retrieve the set of values that occur in matches for T. | ||
473 | * @return the Set of all values or empty set if there are no matches | ||
474 | * | ||
475 | */ | ||
476 | public Set<Turnout> getAllValuesOfT(final Segment pS) { | ||
477 | return rawStreamAllValuesOfT(new Object[]{null, pS}).collect(Collectors.toSet()); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Retrieve the set of values that occur in matches for S. | ||
482 | * @return the Set of all values or empty set if there are no matches | ||
483 | * | ||
484 | */ | ||
485 | protected Stream<Segment> rawStreamAllValuesOfS(final Object[] parameters) { | ||
486 | return rawStreamAllValues(POSITION_S, parameters).map(Segment.class::cast); | ||
487 | } | ||
488 | |||
489 | /** | ||
490 | * Retrieve the set of values that occur in matches for S. | ||
491 | * @return the Set of all values or empty set if there are no matches | ||
492 | * | ||
493 | */ | ||
494 | public Set<Segment> getAllValuesOfS() { | ||
495 | return rawStreamAllValuesOfS(emptyArray()).collect(Collectors.toSet()); | ||
496 | } | ||
497 | |||
498 | /** | ||
499 | * Retrieve the set of values that occur in matches for S. | ||
500 | * @return the Set of all values or empty set if there are no matches | ||
501 | * | ||
502 | */ | ||
503 | public Stream<Segment> streamAllValuesOfS() { | ||
504 | return rawStreamAllValuesOfS(emptyArray()); | ||
505 | } | ||
506 | |||
507 | /** | ||
508 | * Retrieve the set of values that occur in matches for S. | ||
509 | * </p> | ||
510 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
511 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
512 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
513 | * | ||
514 | * @return the Stream of all values or empty set if there are no matches | ||
515 | * | ||
516 | */ | ||
517 | public Stream<Segment> streamAllValuesOfS(final TurnoutOutput.Match partialMatch) { | ||
518 | return rawStreamAllValuesOfS(partialMatch.toArray()); | ||
519 | } | ||
520 | |||
521 | /** | ||
522 | * Retrieve the set of values that occur in matches for S. | ||
523 | * </p> | ||
524 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
525 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
526 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
527 | * | ||
528 | * @return the Stream of all values or empty set if there are no matches | ||
529 | * | ||
530 | */ | ||
531 | public Stream<Segment> streamAllValuesOfS(final Turnout pT) { | ||
532 | return rawStreamAllValuesOfS(new Object[]{pT, null}); | ||
533 | } | ||
534 | |||
535 | /** | ||
536 | * Retrieve the set of values that occur in matches for S. | ||
537 | * @return the Set of all values or empty set if there are no matches | ||
538 | * | ||
539 | */ | ||
540 | public Set<Segment> getAllValuesOfS(final TurnoutOutput.Match partialMatch) { | ||
541 | return rawStreamAllValuesOfS(partialMatch.toArray()).collect(Collectors.toSet()); | ||
542 | } | ||
543 | |||
544 | /** | ||
545 | * Retrieve the set of values that occur in matches for S. | ||
546 | * @return the Set of all values or empty set if there are no matches | ||
547 | * | ||
548 | */ | ||
549 | public Set<Segment> getAllValuesOfS(final Turnout pT) { | ||
550 | return rawStreamAllValuesOfS(new Object[]{pT, null}).collect(Collectors.toSet()); | ||
551 | } | ||
552 | |||
553 | @Override | ||
554 | protected TurnoutOutput.Match tupleToMatch(final Tuple t) { | ||
555 | try { | ||
556 | return TurnoutOutput.Match.newMatch((Turnout) t.get(POSITION_T), (Segment) t.get(POSITION_S)); | ||
557 | } catch(ClassCastException e) { | ||
558 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
559 | return null; | ||
560 | } | ||
561 | } | ||
562 | |||
563 | @Override | ||
564 | protected TurnoutOutput.Match arrayToMatch(final Object[] match) { | ||
565 | try { | ||
566 | return TurnoutOutput.Match.newMatch((Turnout) match[POSITION_T], (Segment) match[POSITION_S]); | ||
567 | } catch(ClassCastException e) { | ||
568 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
569 | return null; | ||
570 | } | ||
571 | } | ||
572 | |||
573 | @Override | ||
574 | protected TurnoutOutput.Match arrayToMatchMutable(final Object[] match) { | ||
575 | try { | ||
576 | return TurnoutOutput.Match.newMutableMatch((Turnout) match[POSITION_T], (Segment) match[POSITION_S]); | ||
577 | } catch(ClassCastException e) { | ||
578 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
579 | return null; | ||
580 | } | ||
581 | } | ||
582 | |||
583 | /** | ||
584 | * @return the singleton instance of the query specification of this pattern | ||
585 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
586 | * | ||
587 | */ | ||
588 | public static IQuerySpecification<TurnoutOutput.Matcher> querySpecification() { | ||
589 | return TurnoutOutput.instance(); | ||
590 | } | ||
591 | } | ||
592 | |||
593 | private TurnoutOutput() { | ||
594 | super(GeneratedPQuery.INSTANCE); | ||
595 | } | ||
596 | |||
597 | /** | ||
598 | * @return the singleton instance of the query specification | ||
599 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
600 | * | ||
601 | */ | ||
602 | public static TurnoutOutput instance() { | ||
603 | try{ | ||
604 | return LazyHolder.INSTANCE; | ||
605 | } catch (ExceptionInInitializerError err) { | ||
606 | throw processInitializerError(err); | ||
607 | } | ||
608 | } | ||
609 | |||
610 | @Override | ||
611 | protected TurnoutOutput.Matcher instantiate(final ViatraQueryEngine engine) { | ||
612 | return TurnoutOutput.Matcher.on(engine); | ||
613 | } | ||
614 | |||
615 | @Override | ||
616 | public TurnoutOutput.Matcher instantiate() { | ||
617 | return TurnoutOutput.Matcher.create(); | ||
618 | } | ||
619 | |||
620 | @Override | ||
621 | public TurnoutOutput.Match newEmptyMatch() { | ||
622 | return TurnoutOutput.Match.newEmptyMatch(); | ||
623 | } | ||
624 | |||
625 | @Override | ||
626 | public TurnoutOutput.Match newMatch(final Object... parameters) { | ||
627 | return TurnoutOutput.Match.newMatch((modes3.Turnout) parameters[0], (modes3.Segment) parameters[1]); | ||
628 | } | ||
629 | |||
630 | /** | ||
631 | * Inner class allowing the singleton instance of {@link TurnoutOutput} to be created | ||
632 | * <b>not</b> at the class load time of the outer class, | ||
633 | * but rather at the first call to {@link TurnoutOutput#instance()}. | ||
634 | * | ||
635 | * <p> This workaround is required e.g. to support recursion. | ||
636 | * | ||
637 | */ | ||
638 | private static class LazyHolder { | ||
639 | private static final TurnoutOutput INSTANCE = new TurnoutOutput(); | ||
640 | |||
641 | /** | ||
642 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
643 | * This initialization order is required to support indirect recursion. | ||
644 | * | ||
645 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
646 | * | ||
647 | */ | ||
648 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
649 | |||
650 | public static Object ensureInitialized() { | ||
651 | INSTANCE.ensureInitializedInternal(); | ||
652 | return null; | ||
653 | } | ||
654 | } | ||
655 | |||
656 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
657 | private static final TurnoutOutput.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
658 | |||
659 | private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); | ||
660 | |||
661 | private final PParameter parameter_S = new PParameter("S", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
662 | |||
663 | private final List<PParameter> parameters = Arrays.asList(parameter_T, parameter_S); | ||
664 | |||
665 | private GeneratedPQuery() { | ||
666 | super(PVisibility.PUBLIC); | ||
667 | } | ||
668 | |||
669 | @Override | ||
670 | public String getFullyQualifiedName() { | ||
671 | return "modes3.queries.turnoutOutput"; | ||
672 | } | ||
673 | |||
674 | @Override | ||
675 | public List<String> getParameterNames() { | ||
676 | return Arrays.asList("T","S"); | ||
677 | } | ||
678 | |||
679 | @Override | ||
680 | public List<PParameter> getParameters() { | ||
681 | return parameters; | ||
682 | } | ||
683 | |||
684 | @Override | ||
685 | public Set<PBody> doGetContainedBodies() { | ||
686 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
687 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
688 | { | ||
689 | PBody body = new PBody(this); | ||
690 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
691 | PVariable var_S = body.getOrCreateVariableByName("S"); | ||
692 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
693 | new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
694 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
695 | new ExportedParameter(body, var_T, parameter_T), | ||
696 | new ExportedParameter(body, var_S, parameter_S) | ||
697 | )); | ||
698 | // Turnout.straight(T, S) | ||
699 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
700 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
701 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "straight"))); | ||
702 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
703 | new Equality(body, var__virtual_0_, var_S); | ||
704 | bodies.add(body); | ||
705 | } | ||
706 | { | ||
707 | PBody body = new PBody(this); | ||
708 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
709 | PVariable var_S = body.getOrCreateVariableByName("S"); | ||
710 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
711 | new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
712 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
713 | new ExportedParameter(body, var_T, parameter_T), | ||
714 | new ExportedParameter(body, var_S, parameter_S) | ||
715 | )); | ||
716 | // Turnout.divergent(T, S) | ||
717 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
718 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
719 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "divergent"))); | ||
720 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
721 | new Equality(body, var__virtual_0_, var_S); | ||
722 | bodies.add(body); | ||
723 | } | ||
724 | return bodies; | ||
725 | } | ||
726 | } | ||
727 | } | ||
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 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Turnout; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * {@literal @}Constraint(message = "turnoutOutputsAreSame", severity = "error", key = { T }) | ||
49 | * pattern turnoutOutputsAreSame(T : Turnout) { | ||
50 | * Turnout.straight(T, S); | ||
51 | * Turnout.divergent(T, S); | ||
52 | * } | ||
53 | * </pre></code> | ||
54 | * | ||
55 | * @see Matcher | ||
56 | * @see Match | ||
57 | * | ||
58 | */ | ||
59 | @SuppressWarnings("all") | ||
60 | public final class TurnoutOutputsAreSame extends BaseGeneratedEMFQuerySpecification<TurnoutOutputsAreSame.Matcher> { | ||
61 | /** | ||
62 | * Pattern-specific match representation of the modes3.queries.turnoutOutputsAreSame pattern, | ||
63 | * to be used in conjunction with {@link Matcher}. | ||
64 | * | ||
65 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
66 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
67 | * usable to represent a match of the pattern in the result of a query, | ||
68 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
69 | * | ||
70 | * @see Matcher | ||
71 | * | ||
72 | */ | ||
73 | public static abstract class Match extends BasePatternMatch { | ||
74 | private Turnout fT; | ||
75 | |||
76 | private static List<String> parameterNames = makeImmutableList("T"); | ||
77 | |||
78 | private Match(final Turnout pT) { | ||
79 | this.fT = pT; | ||
80 | } | ||
81 | |||
82 | @Override | ||
83 | public Object get(final String parameterName) { | ||
84 | switch(parameterName) { | ||
85 | case "T": return this.fT; | ||
86 | default: return null; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | @Override | ||
91 | public Object get(final int index) { | ||
92 | switch(index) { | ||
93 | case 0: return this.fT; | ||
94 | default: return null; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public Turnout getT() { | ||
99 | return this.fT; | ||
100 | } | ||
101 | |||
102 | @Override | ||
103 | public boolean set(final String parameterName, final Object newValue) { | ||
104 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
105 | if ("T".equals(parameterName) ) { | ||
106 | this.fT = (Turnout) newValue; | ||
107 | return true; | ||
108 | } | ||
109 | return false; | ||
110 | } | ||
111 | |||
112 | public void setT(final Turnout pT) { | ||
113 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
114 | this.fT = pT; | ||
115 | } | ||
116 | |||
117 | @Override | ||
118 | public String patternName() { | ||
119 | return "modes3.queries.turnoutOutputsAreSame"; | ||
120 | } | ||
121 | |||
122 | @Override | ||
123 | public List<String> parameterNames() { | ||
124 | return TurnoutOutputsAreSame.Match.parameterNames; | ||
125 | } | ||
126 | |||
127 | @Override | ||
128 | public Object[] toArray() { | ||
129 | return new Object[]{fT}; | ||
130 | } | ||
131 | |||
132 | @Override | ||
133 | public TurnoutOutputsAreSame.Match toImmutable() { | ||
134 | return isMutable() ? newMatch(fT) : this; | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public String prettyPrint() { | ||
139 | StringBuilder result = new StringBuilder(); | ||
140 | result.append("\"T\"=" + prettyPrintValue(fT)); | ||
141 | return result.toString(); | ||
142 | } | ||
143 | |||
144 | @Override | ||
145 | public int hashCode() { | ||
146 | return Objects.hash(fT); | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public boolean equals(final Object obj) { | ||
151 | if (this == obj) | ||
152 | return true; | ||
153 | if (obj == null) { | ||
154 | return false; | ||
155 | } | ||
156 | if ((obj instanceof TurnoutOutputsAreSame.Match)) { | ||
157 | TurnoutOutputsAreSame.Match other = (TurnoutOutputsAreSame.Match) obj; | ||
158 | return Objects.equals(fT, other.fT); | ||
159 | } else { | ||
160 | // this should be infrequent | ||
161 | if (!(obj instanceof IPatternMatch)) { | ||
162 | return false; | ||
163 | } | ||
164 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
165 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
166 | } | ||
167 | } | ||
168 | |||
169 | @Override | ||
170 | public TurnoutOutputsAreSame specification() { | ||
171 | return TurnoutOutputsAreSame.instance(); | ||
172 | } | ||
173 | |||
174 | /** | ||
175 | * Returns an empty, mutable match. | ||
176 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
177 | * | ||
178 | * @return the empty match. | ||
179 | * | ||
180 | */ | ||
181 | public static TurnoutOutputsAreSame.Match newEmptyMatch() { | ||
182 | return new Mutable(null); | ||
183 | } | ||
184 | |||
185 | /** | ||
186 | * Returns a mutable (partial) match. | ||
187 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
188 | * | ||
189 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
190 | * @return the new, mutable (partial) match object. | ||
191 | * | ||
192 | */ | ||
193 | public static TurnoutOutputsAreSame.Match newMutableMatch(final Turnout pT) { | ||
194 | return new Mutable(pT); | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * Returns a new (partial) match. | ||
199 | * This can be used e.g. to call the matcher with a partial match. | ||
200 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
201 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
202 | * @return the (partial) match object. | ||
203 | * | ||
204 | */ | ||
205 | public static TurnoutOutputsAreSame.Match newMatch(final Turnout pT) { | ||
206 | return new Immutable(pT); | ||
207 | } | ||
208 | |||
209 | private static final class Mutable extends TurnoutOutputsAreSame.Match { | ||
210 | Mutable(final Turnout pT) { | ||
211 | super(pT); | ||
212 | } | ||
213 | |||
214 | @Override | ||
215 | public boolean isMutable() { | ||
216 | return true; | ||
217 | } | ||
218 | } | ||
219 | |||
220 | private static final class Immutable extends TurnoutOutputsAreSame.Match { | ||
221 | Immutable(final Turnout pT) { | ||
222 | super(pT); | ||
223 | } | ||
224 | |||
225 | @Override | ||
226 | public boolean isMutable() { | ||
227 | return false; | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | |||
232 | /** | ||
233 | * Generated pattern matcher API of the modes3.queries.turnoutOutputsAreSame pattern, | ||
234 | * providing pattern-specific query methods. | ||
235 | * | ||
236 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
237 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
238 | * | ||
239 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
240 | * | ||
241 | * <p>Original source: | ||
242 | * <code><pre> | ||
243 | * {@literal @}Constraint(message = "turnoutOutputsAreSame", severity = "error", key = { T }) | ||
244 | * pattern turnoutOutputsAreSame(T : Turnout) { | ||
245 | * Turnout.straight(T, S); | ||
246 | * Turnout.divergent(T, S); | ||
247 | * } | ||
248 | * </pre></code> | ||
249 | * | ||
250 | * @see Match | ||
251 | * @see TurnoutOutputsAreSame | ||
252 | * | ||
253 | */ | ||
254 | public static class Matcher extends BaseMatcher<TurnoutOutputsAreSame.Match> { | ||
255 | /** | ||
256 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
257 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
258 | * | ||
259 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
260 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
261 | * | ||
262 | */ | ||
263 | public static TurnoutOutputsAreSame.Matcher on(final ViatraQueryEngine engine) { | ||
264 | // check if matcher already exists | ||
265 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
266 | if (matcher == null) { | ||
267 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
268 | } | ||
269 | return matcher; | ||
270 | } | ||
271 | |||
272 | /** | ||
273 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
274 | * @return an initialized matcher | ||
275 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
276 | * | ||
277 | */ | ||
278 | public static TurnoutOutputsAreSame.Matcher create() { | ||
279 | return new Matcher(); | ||
280 | } | ||
281 | |||
282 | private static final int POSITION_T = 0; | ||
283 | |||
284 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TurnoutOutputsAreSame.Matcher.class); | ||
285 | |||
286 | /** | ||
287 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
288 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
289 | * | ||
290 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
291 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
292 | * | ||
293 | */ | ||
294 | private Matcher() { | ||
295 | super(querySpecification()); | ||
296 | } | ||
297 | |||
298 | /** | ||
299 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
300 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
301 | * @return matches represented as a Match object. | ||
302 | * | ||
303 | */ | ||
304 | public Collection<TurnoutOutputsAreSame.Match> getAllMatches(final Turnout pT) { | ||
305 | return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); | ||
306 | } | ||
307 | |||
308 | /** | ||
309 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
310 | * </p> | ||
311 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
312 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
313 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
314 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
315 | * @return a stream of matches represented as a Match object. | ||
316 | * | ||
317 | */ | ||
318 | public Stream<TurnoutOutputsAreSame.Match> streamAllMatches(final Turnout pT) { | ||
319 | return rawStreamAllMatches(new Object[]{pT}); | ||
320 | } | ||
321 | |||
322 | /** | ||
323 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
324 | * Neither determinism nor randomness of selection is guaranteed. | ||
325 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
326 | * @return a match represented as a Match object, or null if no match is found. | ||
327 | * | ||
328 | */ | ||
329 | public Optional<TurnoutOutputsAreSame.Match> getOneArbitraryMatch(final Turnout pT) { | ||
330 | return rawGetOneArbitraryMatch(new Object[]{pT}); | ||
331 | } | ||
332 | |||
333 | /** | ||
334 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
335 | * under any possible substitution of the unspecified parameters (if any). | ||
336 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
337 | * @return true if the input is a valid (partial) match of the pattern. | ||
338 | * | ||
339 | */ | ||
340 | public boolean hasMatch(final Turnout pT) { | ||
341 | return rawHasMatch(new Object[]{pT}); | ||
342 | } | ||
343 | |||
344 | /** | ||
345 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
346 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
347 | * @return the number of pattern matches found. | ||
348 | * | ||
349 | */ | ||
350 | public int countMatches(final Turnout pT) { | ||
351 | return rawCountMatches(new Object[]{pT}); | ||
352 | } | ||
353 | |||
354 | /** | ||
355 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
356 | * Neither determinism nor randomness of selection is guaranteed. | ||
357 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
358 | * @param processor the action that will process the selected match. | ||
359 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
360 | * | ||
361 | */ | ||
362 | public boolean forOneArbitraryMatch(final Turnout pT, final Consumer<? super TurnoutOutputsAreSame.Match> processor) { | ||
363 | return rawForOneArbitraryMatch(new Object[]{pT}, processor); | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * Returns a new (partial) match. | ||
368 | * This can be used e.g. to call the matcher with a partial match. | ||
369 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
370 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
371 | * @return the (partial) match object. | ||
372 | * | ||
373 | */ | ||
374 | public TurnoutOutputsAreSame.Match newMatch(final Turnout pT) { | ||
375 | return TurnoutOutputsAreSame.Match.newMatch(pT); | ||
376 | } | ||
377 | |||
378 | /** | ||
379 | * Retrieve the set of values that occur in matches for T. | ||
380 | * @return the Set of all values or empty set if there are no matches | ||
381 | * | ||
382 | */ | ||
383 | protected Stream<Turnout> rawStreamAllValuesOfT(final Object[] parameters) { | ||
384 | return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * Retrieve the set of values that occur in matches for T. | ||
389 | * @return the Set of all values or empty set if there are no matches | ||
390 | * | ||
391 | */ | ||
392 | public Set<Turnout> getAllValuesOfT() { | ||
393 | return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * Retrieve the set of values that occur in matches for T. | ||
398 | * @return the Set of all values or empty set if there are no matches | ||
399 | * | ||
400 | */ | ||
401 | public Stream<Turnout> streamAllValuesOfT() { | ||
402 | return rawStreamAllValuesOfT(emptyArray()); | ||
403 | } | ||
404 | |||
405 | @Override | ||
406 | protected TurnoutOutputsAreSame.Match tupleToMatch(final Tuple t) { | ||
407 | try { | ||
408 | return TurnoutOutputsAreSame.Match.newMatch((Turnout) t.get(POSITION_T)); | ||
409 | } catch(ClassCastException e) { | ||
410 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
411 | return null; | ||
412 | } | ||
413 | } | ||
414 | |||
415 | @Override | ||
416 | protected TurnoutOutputsAreSame.Match arrayToMatch(final Object[] match) { | ||
417 | try { | ||
418 | return TurnoutOutputsAreSame.Match.newMatch((Turnout) match[POSITION_T]); | ||
419 | } catch(ClassCastException e) { | ||
420 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
421 | return null; | ||
422 | } | ||
423 | } | ||
424 | |||
425 | @Override | ||
426 | protected TurnoutOutputsAreSame.Match arrayToMatchMutable(final Object[] match) { | ||
427 | try { | ||
428 | return TurnoutOutputsAreSame.Match.newMutableMatch((Turnout) match[POSITION_T]); | ||
429 | } catch(ClassCastException e) { | ||
430 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
431 | return null; | ||
432 | } | ||
433 | } | ||
434 | |||
435 | /** | ||
436 | * @return the singleton instance of the query specification of this pattern | ||
437 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
438 | * | ||
439 | */ | ||
440 | public static IQuerySpecification<TurnoutOutputsAreSame.Matcher> querySpecification() { | ||
441 | return TurnoutOutputsAreSame.instance(); | ||
442 | } | ||
443 | } | ||
444 | |||
445 | private TurnoutOutputsAreSame() { | ||
446 | super(GeneratedPQuery.INSTANCE); | ||
447 | } | ||
448 | |||
449 | /** | ||
450 | * @return the singleton instance of the query specification | ||
451 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
452 | * | ||
453 | */ | ||
454 | public static TurnoutOutputsAreSame instance() { | ||
455 | try{ | ||
456 | return LazyHolder.INSTANCE; | ||
457 | } catch (ExceptionInInitializerError err) { | ||
458 | throw processInitializerError(err); | ||
459 | } | ||
460 | } | ||
461 | |||
462 | @Override | ||
463 | protected TurnoutOutputsAreSame.Matcher instantiate(final ViatraQueryEngine engine) { | ||
464 | return TurnoutOutputsAreSame.Matcher.on(engine); | ||
465 | } | ||
466 | |||
467 | @Override | ||
468 | public TurnoutOutputsAreSame.Matcher instantiate() { | ||
469 | return TurnoutOutputsAreSame.Matcher.create(); | ||
470 | } | ||
471 | |||
472 | @Override | ||
473 | public TurnoutOutputsAreSame.Match newEmptyMatch() { | ||
474 | return TurnoutOutputsAreSame.Match.newEmptyMatch(); | ||
475 | } | ||
476 | |||
477 | @Override | ||
478 | public TurnoutOutputsAreSame.Match newMatch(final Object... parameters) { | ||
479 | return TurnoutOutputsAreSame.Match.newMatch((modes3.Turnout) parameters[0]); | ||
480 | } | ||
481 | |||
482 | /** | ||
483 | * Inner class allowing the singleton instance of {@link TurnoutOutputsAreSame} to be created | ||
484 | * <b>not</b> at the class load time of the outer class, | ||
485 | * but rather at the first call to {@link TurnoutOutputsAreSame#instance()}. | ||
486 | * | ||
487 | * <p> This workaround is required e.g. to support recursion. | ||
488 | * | ||
489 | */ | ||
490 | private static class LazyHolder { | ||
491 | private static final TurnoutOutputsAreSame INSTANCE = new TurnoutOutputsAreSame(); | ||
492 | |||
493 | /** | ||
494 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
495 | * This initialization order is required to support indirect recursion. | ||
496 | * | ||
497 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
498 | * | ||
499 | */ | ||
500 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
501 | |||
502 | public static Object ensureInitialized() { | ||
503 | INSTANCE.ensureInitializedInternal(); | ||
504 | return null; | ||
505 | } | ||
506 | } | ||
507 | |||
508 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
509 | private static final TurnoutOutputsAreSame.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
510 | |||
511 | private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); | ||
512 | |||
513 | private final List<PParameter> parameters = Arrays.asList(parameter_T); | ||
514 | |||
515 | private GeneratedPQuery() { | ||
516 | super(PVisibility.PUBLIC); | ||
517 | } | ||
518 | |||
519 | @Override | ||
520 | public String getFullyQualifiedName() { | ||
521 | return "modes3.queries.turnoutOutputsAreSame"; | ||
522 | } | ||
523 | |||
524 | @Override | ||
525 | public List<String> getParameterNames() { | ||
526 | return Arrays.asList("T"); | ||
527 | } | ||
528 | |||
529 | @Override | ||
530 | public List<PParameter> getParameters() { | ||
531 | return parameters; | ||
532 | } | ||
533 | |||
534 | @Override | ||
535 | public Set<PBody> doGetContainedBodies() { | ||
536 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
537 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
538 | { | ||
539 | PBody body = new PBody(this); | ||
540 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
541 | PVariable var_S = body.getOrCreateVariableByName("S"); | ||
542 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
543 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
544 | new ExportedParameter(body, var_T, parameter_T) | ||
545 | )); | ||
546 | // Turnout.straight(T, S) | ||
547 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
548 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
549 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "straight"))); | ||
550 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
551 | new Equality(body, var__virtual_0_, var_S); | ||
552 | // Turnout.divergent(T, S) | ||
553 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
554 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
555 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "divergent"))); | ||
556 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
557 | new Equality(body, var__virtual_1_, var_S); | ||
558 | bodies.add(body); | ||
559 | } | ||
560 | { | ||
561 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
562 | annotation.addAttribute("message", "turnoutOutputsAreSame"); | ||
563 | annotation.addAttribute("severity", "error"); | ||
564 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
565 | new ParameterReference("T") | ||
566 | })); | ||
567 | addAnnotation(annotation); | ||
568 | } | ||
569 | return bodies; | ||
570 | } | ||
571 | } | ||
572 | } | ||
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 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.queries.Reachable; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * {@literal @}Constraint(message = "unreachable", severity = "error", key = { S1, S2 }) | ||
49 | * pattern unreachable(S1 : Segment, S2 : Segment) { | ||
50 | * neg find reachable(S1, S2); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class Unreachable extends BaseGeneratedEMFQuerySpecification<Unreachable.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.unreachable pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Segment fS1; | ||
74 | |||
75 | private Segment fS2; | ||
76 | |||
77 | private static List<String> parameterNames = makeImmutableList("S1", "S2"); | ||
78 | |||
79 | private Match(final Segment pS1, final Segment pS2) { | ||
80 | this.fS1 = pS1; | ||
81 | this.fS2 = pS2; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | switch(parameterName) { | ||
87 | case "S1": return this.fS1; | ||
88 | case "S2": return this.fS2; | ||
89 | default: return null; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | @Override | ||
94 | public Object get(final int index) { | ||
95 | switch(index) { | ||
96 | case 0: return this.fS1; | ||
97 | case 1: return this.fS2; | ||
98 | default: return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public Segment getS1() { | ||
103 | return this.fS1; | ||
104 | } | ||
105 | |||
106 | public Segment getS2() { | ||
107 | return this.fS2; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public boolean set(final String parameterName, final Object newValue) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | if ("S1".equals(parameterName) ) { | ||
114 | this.fS1 = (Segment) newValue; | ||
115 | return true; | ||
116 | } | ||
117 | if ("S2".equals(parameterName) ) { | ||
118 | this.fS2 = (Segment) newValue; | ||
119 | return true; | ||
120 | } | ||
121 | return false; | ||
122 | } | ||
123 | |||
124 | public void setS1(final Segment pS1) { | ||
125 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
126 | this.fS1 = pS1; | ||
127 | } | ||
128 | |||
129 | public void setS2(final Segment pS2) { | ||
130 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
131 | this.fS2 = pS2; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public String patternName() { | ||
136 | return "modes3.queries.unreachable"; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public List<String> parameterNames() { | ||
141 | return Unreachable.Match.parameterNames; | ||
142 | } | ||
143 | |||
144 | @Override | ||
145 | public Object[] toArray() { | ||
146 | return new Object[]{fS1, fS2}; | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public Unreachable.Match toImmutable() { | ||
151 | return isMutable() ? newMatch(fS1, fS2) : this; | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public String prettyPrint() { | ||
156 | StringBuilder result = new StringBuilder(); | ||
157 | result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); | ||
158 | result.append("\"S2\"=" + prettyPrintValue(fS2)); | ||
159 | return result.toString(); | ||
160 | } | ||
161 | |||
162 | @Override | ||
163 | public int hashCode() { | ||
164 | return Objects.hash(fS1, fS2); | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public boolean equals(final Object obj) { | ||
169 | if (this == obj) | ||
170 | return true; | ||
171 | if (obj == null) { | ||
172 | return false; | ||
173 | } | ||
174 | if ((obj instanceof Unreachable.Match)) { | ||
175 | Unreachable.Match other = (Unreachable.Match) obj; | ||
176 | return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); | ||
177 | } else { | ||
178 | // this should be infrequent | ||
179 | if (!(obj instanceof IPatternMatch)) { | ||
180 | return false; | ||
181 | } | ||
182 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
183 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | @Override | ||
188 | public Unreachable specification() { | ||
189 | return Unreachable.instance(); | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * Returns an empty, mutable match. | ||
194 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
195 | * | ||
196 | * @return the empty match. | ||
197 | * | ||
198 | */ | ||
199 | public static Unreachable.Match newEmptyMatch() { | ||
200 | return new Mutable(null, null); | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * Returns a mutable (partial) match. | ||
205 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
206 | * | ||
207 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
208 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
209 | * @return the new, mutable (partial) match object. | ||
210 | * | ||
211 | */ | ||
212 | public static Unreachable.Match newMutableMatch(final Segment pS1, final Segment pS2) { | ||
213 | return new Mutable(pS1, pS2); | ||
214 | } | ||
215 | |||
216 | /** | ||
217 | * Returns a new (partial) match. | ||
218 | * This can be used e.g. to call the matcher with a partial match. | ||
219 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
220 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
221 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
222 | * @return the (partial) match object. | ||
223 | * | ||
224 | */ | ||
225 | public static Unreachable.Match newMatch(final Segment pS1, final Segment pS2) { | ||
226 | return new Immutable(pS1, pS2); | ||
227 | } | ||
228 | |||
229 | private static final class Mutable extends Unreachable.Match { | ||
230 | Mutable(final Segment pS1, final Segment pS2) { | ||
231 | super(pS1, pS2); | ||
232 | } | ||
233 | |||
234 | @Override | ||
235 | public boolean isMutable() { | ||
236 | return true; | ||
237 | } | ||
238 | } | ||
239 | |||
240 | private static final class Immutable extends Unreachable.Match { | ||
241 | Immutable(final Segment pS1, final Segment pS2) { | ||
242 | super(pS1, pS2); | ||
243 | } | ||
244 | |||
245 | @Override | ||
246 | public boolean isMutable() { | ||
247 | return false; | ||
248 | } | ||
249 | } | ||
250 | } | ||
251 | |||
252 | /** | ||
253 | * Generated pattern matcher API of the modes3.queries.unreachable pattern, | ||
254 | * providing pattern-specific query methods. | ||
255 | * | ||
256 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
257 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
258 | * | ||
259 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
260 | * | ||
261 | * <p>Original source: | ||
262 | * <code><pre> | ||
263 | * {@literal @}Constraint(message = "unreachable", severity = "error", key = { S1, S2 }) | ||
264 | * pattern unreachable(S1 : Segment, S2 : Segment) { | ||
265 | * neg find reachable(S1, S2); | ||
266 | * } | ||
267 | * </pre></code> | ||
268 | * | ||
269 | * @see Match | ||
270 | * @see Unreachable | ||
271 | * | ||
272 | */ | ||
273 | public static class Matcher extends BaseMatcher<Unreachable.Match> { | ||
274 | /** | ||
275 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
276 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
277 | * | ||
278 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
279 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
280 | * | ||
281 | */ | ||
282 | public static Unreachable.Matcher on(final ViatraQueryEngine engine) { | ||
283 | // check if matcher already exists | ||
284 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
285 | if (matcher == null) { | ||
286 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
287 | } | ||
288 | return matcher; | ||
289 | } | ||
290 | |||
291 | /** | ||
292 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
293 | * @return an initialized matcher | ||
294 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
295 | * | ||
296 | */ | ||
297 | public static Unreachable.Matcher create() { | ||
298 | return new Matcher(); | ||
299 | } | ||
300 | |||
301 | private static final int POSITION_S1 = 0; | ||
302 | |||
303 | private static final int POSITION_S2 = 1; | ||
304 | |||
305 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Unreachable.Matcher.class); | ||
306 | |||
307 | /** | ||
308 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
309 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
310 | * | ||
311 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
312 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
313 | * | ||
314 | */ | ||
315 | private Matcher() { | ||
316 | super(querySpecification()); | ||
317 | } | ||
318 | |||
319 | /** | ||
320 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
321 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
322 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
323 | * @return matches represented as a Match object. | ||
324 | * | ||
325 | */ | ||
326 | public Collection<Unreachable.Match> getAllMatches(final Segment pS1, final Segment pS2) { | ||
327 | return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); | ||
328 | } | ||
329 | |||
330 | /** | ||
331 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
332 | * </p> | ||
333 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
334 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
335 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
336 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
337 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
338 | * @return a stream of matches represented as a Match object. | ||
339 | * | ||
340 | */ | ||
341 | public Stream<Unreachable.Match> streamAllMatches(final Segment pS1, final Segment pS2) { | ||
342 | return rawStreamAllMatches(new Object[]{pS1, pS2}); | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
347 | * Neither determinism nor randomness of selection is guaranteed. | ||
348 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
349 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
350 | * @return a match represented as a Match object, or null if no match is found. | ||
351 | * | ||
352 | */ | ||
353 | public Optional<Unreachable.Match> getOneArbitraryMatch(final Segment pS1, final Segment pS2) { | ||
354 | return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); | ||
355 | } | ||
356 | |||
357 | /** | ||
358 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
359 | * under any possible substitution of the unspecified parameters (if any). | ||
360 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
361 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
362 | * @return true if the input is a valid (partial) match of the pattern. | ||
363 | * | ||
364 | */ | ||
365 | public boolean hasMatch(final Segment pS1, final Segment pS2) { | ||
366 | return rawHasMatch(new Object[]{pS1, pS2}); | ||
367 | } | ||
368 | |||
369 | /** | ||
370 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
371 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
372 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
373 | * @return the number of pattern matches found. | ||
374 | * | ||
375 | */ | ||
376 | public int countMatches(final Segment pS1, final Segment pS2) { | ||
377 | return rawCountMatches(new Object[]{pS1, pS2}); | ||
378 | } | ||
379 | |||
380 | /** | ||
381 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
382 | * Neither determinism nor randomness of selection is guaranteed. | ||
383 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
384 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
385 | * @param processor the action that will process the selected match. | ||
386 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
387 | * | ||
388 | */ | ||
389 | public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer<? super Unreachable.Match> processor) { | ||
390 | return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); | ||
391 | } | ||
392 | |||
393 | /** | ||
394 | * Returns a new (partial) match. | ||
395 | * This can be used e.g. to call the matcher with a partial match. | ||
396 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
397 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
398 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
399 | * @return the (partial) match object. | ||
400 | * | ||
401 | */ | ||
402 | public Unreachable.Match newMatch(final Segment pS1, final Segment pS2) { | ||
403 | return Unreachable.Match.newMatch(pS1, pS2); | ||
404 | } | ||
405 | |||
406 | /** | ||
407 | * Retrieve the set of values that occur in matches for S1. | ||
408 | * @return the Set of all values or empty set if there are no matches | ||
409 | * | ||
410 | */ | ||
411 | protected Stream<Segment> rawStreamAllValuesOfS1(final Object[] parameters) { | ||
412 | return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); | ||
413 | } | ||
414 | |||
415 | /** | ||
416 | * Retrieve the set of values that occur in matches for S1. | ||
417 | * @return the Set of all values or empty set if there are no matches | ||
418 | * | ||
419 | */ | ||
420 | public Set<Segment> getAllValuesOfS1() { | ||
421 | return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); | ||
422 | } | ||
423 | |||
424 | /** | ||
425 | * Retrieve the set of values that occur in matches for S1. | ||
426 | * @return the Set of all values or empty set if there are no matches | ||
427 | * | ||
428 | */ | ||
429 | public Stream<Segment> streamAllValuesOfS1() { | ||
430 | return rawStreamAllValuesOfS1(emptyArray()); | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * Retrieve the set of values that occur in matches for S1. | ||
435 | * </p> | ||
436 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
437 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
438 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
439 | * | ||
440 | * @return the Stream of all values or empty set if there are no matches | ||
441 | * | ||
442 | */ | ||
443 | public Stream<Segment> streamAllValuesOfS1(final Unreachable.Match partialMatch) { | ||
444 | return rawStreamAllValuesOfS1(partialMatch.toArray()); | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * Retrieve the set of values that occur in matches for S1. | ||
449 | * </p> | ||
450 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
451 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
452 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
453 | * | ||
454 | * @return the Stream of all values or empty set if there are no matches | ||
455 | * | ||
456 | */ | ||
457 | public Stream<Segment> streamAllValuesOfS1(final Segment pS2) { | ||
458 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}); | ||
459 | } | ||
460 | |||
461 | /** | ||
462 | * Retrieve the set of values that occur in matches for S1. | ||
463 | * @return the Set of all values or empty set if there are no matches | ||
464 | * | ||
465 | */ | ||
466 | public Set<Segment> getAllValuesOfS1(final Unreachable.Match partialMatch) { | ||
467 | return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); | ||
468 | } | ||
469 | |||
470 | /** | ||
471 | * Retrieve the set of values that occur in matches for S1. | ||
472 | * @return the Set of all values or empty set if there are no matches | ||
473 | * | ||
474 | */ | ||
475 | public Set<Segment> getAllValuesOfS1(final Segment pS2) { | ||
476 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); | ||
477 | } | ||
478 | |||
479 | /** | ||
480 | * Retrieve the set of values that occur in matches for S2. | ||
481 | * @return the Set of all values or empty set if there are no matches | ||
482 | * | ||
483 | */ | ||
484 | protected Stream<Segment> rawStreamAllValuesOfS2(final Object[] parameters) { | ||
485 | return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); | ||
486 | } | ||
487 | |||
488 | /** | ||
489 | * Retrieve the set of values that occur in matches for S2. | ||
490 | * @return the Set of all values or empty set if there are no matches | ||
491 | * | ||
492 | */ | ||
493 | public Set<Segment> getAllValuesOfS2() { | ||
494 | return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); | ||
495 | } | ||
496 | |||
497 | /** | ||
498 | * Retrieve the set of values that occur in matches for S2. | ||
499 | * @return the Set of all values or empty set if there are no matches | ||
500 | * | ||
501 | */ | ||
502 | public Stream<Segment> streamAllValuesOfS2() { | ||
503 | return rawStreamAllValuesOfS2(emptyArray()); | ||
504 | } | ||
505 | |||
506 | /** | ||
507 | * Retrieve the set of values that occur in matches for S2. | ||
508 | * </p> | ||
509 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
510 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
511 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
512 | * | ||
513 | * @return the Stream of all values or empty set if there are no matches | ||
514 | * | ||
515 | */ | ||
516 | public Stream<Segment> streamAllValuesOfS2(final Unreachable.Match partialMatch) { | ||
517 | return rawStreamAllValuesOfS2(partialMatch.toArray()); | ||
518 | } | ||
519 | |||
520 | /** | ||
521 | * Retrieve the set of values that occur in matches for S2. | ||
522 | * </p> | ||
523 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
524 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
525 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
526 | * | ||
527 | * @return the Stream of all values or empty set if there are no matches | ||
528 | * | ||
529 | */ | ||
530 | public Stream<Segment> streamAllValuesOfS2(final Segment pS1) { | ||
531 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}); | ||
532 | } | ||
533 | |||
534 | /** | ||
535 | * Retrieve the set of values that occur in matches for S2. | ||
536 | * @return the Set of all values or empty set if there are no matches | ||
537 | * | ||
538 | */ | ||
539 | public Set<Segment> getAllValuesOfS2(final Unreachable.Match partialMatch) { | ||
540 | return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); | ||
541 | } | ||
542 | |||
543 | /** | ||
544 | * Retrieve the set of values that occur in matches for S2. | ||
545 | * @return the Set of all values or empty set if there are no matches | ||
546 | * | ||
547 | */ | ||
548 | public Set<Segment> getAllValuesOfS2(final Segment pS1) { | ||
549 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); | ||
550 | } | ||
551 | |||
552 | @Override | ||
553 | protected Unreachable.Match tupleToMatch(final Tuple t) { | ||
554 | try { | ||
555 | return Unreachable.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); | ||
556 | } catch(ClassCastException e) { | ||
557 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
558 | return null; | ||
559 | } | ||
560 | } | ||
561 | |||
562 | @Override | ||
563 | protected Unreachable.Match arrayToMatch(final Object[] match) { | ||
564 | try { | ||
565 | return Unreachable.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
566 | } catch(ClassCastException e) { | ||
567 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
568 | return null; | ||
569 | } | ||
570 | } | ||
571 | |||
572 | @Override | ||
573 | protected Unreachable.Match arrayToMatchMutable(final Object[] match) { | ||
574 | try { | ||
575 | return Unreachable.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
576 | } catch(ClassCastException e) { | ||
577 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
578 | return null; | ||
579 | } | ||
580 | } | ||
581 | |||
582 | /** | ||
583 | * @return the singleton instance of the query specification of this pattern | ||
584 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
585 | * | ||
586 | */ | ||
587 | public static IQuerySpecification<Unreachable.Matcher> querySpecification() { | ||
588 | return Unreachable.instance(); | ||
589 | } | ||
590 | } | ||
591 | |||
592 | private Unreachable() { | ||
593 | super(GeneratedPQuery.INSTANCE); | ||
594 | } | ||
595 | |||
596 | /** | ||
597 | * @return the singleton instance of the query specification | ||
598 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
599 | * | ||
600 | */ | ||
601 | public static Unreachable instance() { | ||
602 | try{ | ||
603 | return LazyHolder.INSTANCE; | ||
604 | } catch (ExceptionInInitializerError err) { | ||
605 | throw processInitializerError(err); | ||
606 | } | ||
607 | } | ||
608 | |||
609 | @Override | ||
610 | protected Unreachable.Matcher instantiate(final ViatraQueryEngine engine) { | ||
611 | return Unreachable.Matcher.on(engine); | ||
612 | } | ||
613 | |||
614 | @Override | ||
615 | public Unreachable.Matcher instantiate() { | ||
616 | return Unreachable.Matcher.create(); | ||
617 | } | ||
618 | |||
619 | @Override | ||
620 | public Unreachable.Match newEmptyMatch() { | ||
621 | return Unreachable.Match.newEmptyMatch(); | ||
622 | } | ||
623 | |||
624 | @Override | ||
625 | public Unreachable.Match newMatch(final Object... parameters) { | ||
626 | return Unreachable.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); | ||
627 | } | ||
628 | |||
629 | /** | ||
630 | * Inner class allowing the singleton instance of {@link Unreachable} to be created | ||
631 | * <b>not</b> at the class load time of the outer class, | ||
632 | * but rather at the first call to {@link Unreachable#instance()}. | ||
633 | * | ||
634 | * <p> This workaround is required e.g. to support recursion. | ||
635 | * | ||
636 | */ | ||
637 | private static class LazyHolder { | ||
638 | private static final Unreachable INSTANCE = new Unreachable(); | ||
639 | |||
640 | /** | ||
641 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
642 | * This initialization order is required to support indirect recursion. | ||
643 | * | ||
644 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
645 | * | ||
646 | */ | ||
647 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
648 | |||
649 | public static Object ensureInitialized() { | ||
650 | INSTANCE.ensureInitializedInternal(); | ||
651 | return null; | ||
652 | } | ||
653 | } | ||
654 | |||
655 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
656 | private static final Unreachable.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
657 | |||
658 | private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
659 | |||
660 | private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
661 | |||
662 | private final List<PParameter> parameters = Arrays.asList(parameter_S1, parameter_S2); | ||
663 | |||
664 | private GeneratedPQuery() { | ||
665 | super(PVisibility.PUBLIC); | ||
666 | } | ||
667 | |||
668 | @Override | ||
669 | public String getFullyQualifiedName() { | ||
670 | return "modes3.queries.unreachable"; | ||
671 | } | ||
672 | |||
673 | @Override | ||
674 | public List<String> getParameterNames() { | ||
675 | return Arrays.asList("S1","S2"); | ||
676 | } | ||
677 | |||
678 | @Override | ||
679 | public List<PParameter> getParameters() { | ||
680 | return parameters; | ||
681 | } | ||
682 | |||
683 | @Override | ||
684 | public Set<PBody> doGetContainedBodies() { | ||
685 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
686 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
687 | { | ||
688 | PBody body = new PBody(this); | ||
689 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
690 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
691 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
692 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
693 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
694 | new ExportedParameter(body, var_S1, parameter_S1), | ||
695 | new ExportedParameter(body, var_S2, parameter_S2) | ||
696 | )); | ||
697 | // neg find reachable(S1, S2) | ||
698 | new NegativePatternCall(body, Tuples.flatTupleOf(var_S1, var_S2), Reachable.instance().getInternalQueryRepresentation()); | ||
699 | bodies.add(body); | ||
700 | } | ||
701 | { | ||
702 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
703 | annotation.addAttribute("message", "unreachable"); | ||
704 | annotation.addAttribute("severity", "error"); | ||
705 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
706 | new ParameterReference("S1"), | ||
707 | new ParameterReference("S2") | ||
708 | })); | ||
709 | addAnnotation(annotation); | ||
710 | } | ||
711 | return bodies; | ||
712 | } | ||
713 | } | ||
714 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.CloseTrainsObjectiveHint.xtendbin b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.CloseTrainsObjectiveHint.xtendbin new file mode 100644 index 00000000..87975792 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.CloseTrainsObjectiveHint.xtendbin | |||
Binary files differ | |||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.EndOfSidingObjectiveHint.xtendbin b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.EndOfSidingObjectiveHint.xtendbin new file mode 100644 index 00000000..f243e180 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.EndOfSidingObjectiveHint.xtendbin | |||
Binary files differ | |||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.MisalignedTurnoutObjectiveHint.xtendbin b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.MisalignedTurnoutObjectiveHint.xtendbin new file mode 100644 index 00000000..cdef4dc7 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.MisalignedTurnoutObjectiveHint.xtendbin | |||
Binary files differ | |||
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..759ac9e4 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3ModelGenerator.xtendbin | |||
Binary files differ | |||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3TypeScopeHint.xtendbin b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3TypeScopeHint.xtendbin new file mode 100644 index 00000000..386baeda --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3TypeScopeHint.xtendbin | |||
Binary files 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..79059b7f --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3UnitPropagationGenerator.xtendbin | |||
Binary files differ | |||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.TrainLocationsObjectiveHint.xtendbin b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.TrainLocationsObjectiveHint.xtendbin new file mode 100644 index 00000000..3c3a380e --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.TrainLocationsObjectiveHint.xtendbin | |||
Binary files 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..1a7df1d9 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.gitignore | |||
@@ -0,0 +1,13 @@ | |||
1 | /.Modes3ModelGenerator.java._trace | ||
2 | /.Modes3UnitPropagationGenerator.java._trace | ||
3 | /.Modes3TypeScopeHint.java._trace | ||
4 | /.Modes3TypeScopeHint.xtendbin | ||
5 | /.Modes3UnitPropagationGenerator.xtendbin | ||
6 | /Modes3TypeScopeHint.java | ||
7 | /.Modes3ModelGenerator.xtendbin | ||
8 | /Modes3ModelGenerator.java | ||
9 | /Modes3UnitPropagationGenerator.java | ||
10 | /.CloseTrainsObjectiveHint.java._trace | ||
11 | /.TrainLocationsObjectiveHint.java._trace | ||
12 | /.MisalignedTurnoutObjectiveHint.java._trace | ||
13 | /.EndOfSidingObjectiveHint.java._trace | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/CloseTrainsObjectiveHint.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/CloseTrainsObjectiveHint.java new file mode 100644 index 00000000..babfa7e1 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/CloseTrainsObjectiveHint.java | |||
@@ -0,0 +1,279 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import com.google.common.collect.ImmutableList; | ||
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
6 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Dimension; | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilder; | ||
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory; | ||
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator; | ||
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch; | ||
13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers; | ||
14 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint; | ||
15 | import java.util.Collection; | ||
16 | import java.util.List; | ||
17 | import java.util.Map; | ||
18 | import java.util.Set; | ||
19 | import modes3.Modes3Package; | ||
20 | import modes3.queries.CloseTrains_step_2; | ||
21 | import modes3.queries.CloseTrains_step_3; | ||
22 | import modes3.queries.CloseTrains_step_4; | ||
23 | import modes3.queries.CloseTrains_step_5; | ||
24 | import modes3.queries.CloseTrains_step_6; | ||
25 | import modes3.queries.CloseTrains_step_7; | ||
26 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
27 | import org.eclipse.xtext.xbase.lib.Extension; | ||
28 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
29 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
30 | |||
31 | @SuppressWarnings("all") | ||
32 | public class CloseTrainsObjectiveHint extends CostObjectiveHint { | ||
33 | private final Type segmentType; | ||
34 | |||
35 | private final Type trainType; | ||
36 | |||
37 | public CloseTrainsObjectiveHint(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { | ||
38 | @Extension | ||
39 | final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; | ||
40 | this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); | ||
41 | this.trainType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTrain()); | ||
42 | } | ||
43 | |||
44 | @Override | ||
45 | public boolean isExact() { | ||
46 | return true; | ||
47 | } | ||
48 | |||
49 | @Override | ||
50 | public PolyhedronExtensionOperator createPolyhedronExtensionOperator(final Map<String, CostElementMatchers> costElementMatchers) { | ||
51 | PolyhedronExtensionOperator _xblockexpression = null; | ||
52 | { | ||
53 | final CostElementMatchers step2 = costElementMatchers.get(CloseTrains_step_2.instance().getFullyQualifiedName()); | ||
54 | final CostElementMatchers step3 = costElementMatchers.get(CloseTrains_step_3.instance().getFullyQualifiedName()); | ||
55 | final CostElementMatchers step4 = costElementMatchers.get(CloseTrains_step_4.instance().getFullyQualifiedName()); | ||
56 | final CostElementMatchers step5 = costElementMatchers.get(CloseTrains_step_5.instance().getFullyQualifiedName()); | ||
57 | final CostElementMatchers step6 = costElementMatchers.get(CloseTrains_step_6.instance().getFullyQualifiedName()); | ||
58 | final CostElementMatchers step7 = costElementMatchers.get(CloseTrains_step_7.instance().getFullyQualifiedName()); | ||
59 | final PolyhedronExtensionOperator _function = (ExtendedLinearExpressionBuilderFactory it) -> { | ||
60 | final ExtendedLinearExpressionBuilder objectiveBuilder = it.createBuilder(); | ||
61 | ImmutableList<CostElementMatch> _matches = step2.getMatches(); | ||
62 | for (final CostElementMatch m : _matches) { | ||
63 | { | ||
64 | final Dimension dimension = it.getDimension(m.getMatch()); | ||
65 | objectiveBuilder.add(step2.getWeight(), dimension); | ||
66 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
67 | boolean _isMulti = m.isMulti(); | ||
68 | if (_isMulti) { | ||
69 | it.createBuilder().add(1, dimension).add((-1), this.trainType).build().assertEqualsTo(0); | ||
70 | } else { | ||
71 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
72 | boolean _isMust = m.isMust(); | ||
73 | if (_isMust) { | ||
74 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 | final ImmutableList<CostElementMatch> step3Matches = step3.getMatches(); | ||
80 | for (final CostElementMatch m_1 : step3Matches) { | ||
81 | { | ||
82 | final Dimension dimension = it.getDimension(m_1.getMatch()); | ||
83 | objectiveBuilder.add(step3.getWeight(), dimension); | ||
84 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
85 | boolean _isMulti = m_1.isMulti(); | ||
86 | boolean _not = (!_isMulti); | ||
87 | if (_not) { | ||
88 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
89 | boolean _isMust = m_1.isMust(); | ||
90 | if (_isMust) { | ||
91 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | } | ||
96 | final Function1<CostElementMatch, IPatternMatch> _function_1 = (CostElementMatch it_1) -> { | ||
97 | return step2.projectMayMatch(it_1.getMatch(), 2); | ||
98 | }; | ||
99 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step3Matches, _function_1).entrySet(); | ||
100 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair : _entrySet) { | ||
101 | { | ||
102 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
103 | List<CostElementMatch> _value = pair.getValue(); | ||
104 | for (final CostElementMatch m_2 : _value) { | ||
105 | multiplicityBuilder.add(1, m_2.getMatch()); | ||
106 | } | ||
107 | multiplicityBuilder.add((-1), pair.getKey()); | ||
108 | multiplicityBuilder.build().assertEqualsTo(0); | ||
109 | } | ||
110 | } | ||
111 | CloseTrainsObjectiveHint.boundLimit(it, step3Matches, 2, this.trainType, 1); | ||
112 | CloseTrainsObjectiveHint.boundLimit(it, step3Matches, 3, this.segmentType, 1); | ||
113 | final ImmutableList<CostElementMatch> step4Matches = step4.getMatches(); | ||
114 | for (final CostElementMatch m_2 : step4Matches) { | ||
115 | { | ||
116 | final Dimension dimension = it.getDimension(m_2.getMatch()); | ||
117 | objectiveBuilder.add(step4.getWeight(), dimension); | ||
118 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
119 | boolean _isMulti = m_2.isMulti(); | ||
120 | boolean _not = (!_isMulti); | ||
121 | if (_not) { | ||
122 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
123 | boolean _isMust = m_2.isMust(); | ||
124 | if (_isMust) { | ||
125 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | final Function1<CostElementMatch, IPatternMatch> _function_2 = (CostElementMatch it_1) -> { | ||
131 | return step3.projectMayMatch(it_1.getMatch(), 2, 3); | ||
132 | }; | ||
133 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet_1 = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step4Matches, _function_2).entrySet(); | ||
134 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair_1 : _entrySet_1) { | ||
135 | { | ||
136 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
137 | List<CostElementMatch> _value = pair_1.getValue(); | ||
138 | for (final CostElementMatch m_3 : _value) { | ||
139 | multiplicityBuilder.add(1, m_3.getMatch()); | ||
140 | } | ||
141 | multiplicityBuilder.add((-2), pair_1.getKey()); | ||
142 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
143 | } | ||
144 | } | ||
145 | CloseTrainsObjectiveHint.boundLimit(it, step4Matches, 2, this.trainType, 2); | ||
146 | CloseTrainsObjectiveHint.boundLimit(it, step4Matches, 3, this.segmentType, 2); | ||
147 | CloseTrainsObjectiveHint.boundLimit(it, step4Matches, 4, this.segmentType, 2); | ||
148 | final ImmutableList<CostElementMatch> step5Matches = step5.getMatches(); | ||
149 | for (final CostElementMatch m_3 : step5Matches) { | ||
150 | { | ||
151 | final Dimension dimension = it.getDimension(m_3.getMatch()); | ||
152 | objectiveBuilder.add(step5.getWeight(), dimension); | ||
153 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
154 | boolean _isMulti = m_3.isMulti(); | ||
155 | boolean _not = (!_isMulti); | ||
156 | if (_not) { | ||
157 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
158 | boolean _isMust = m_3.isMust(); | ||
159 | if (_isMust) { | ||
160 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
161 | } | ||
162 | } | ||
163 | } | ||
164 | } | ||
165 | final Function1<CostElementMatch, IPatternMatch> _function_3 = (CostElementMatch it_1) -> { | ||
166 | return step4.projectMayMatch(it_1.getMatch(), 2, 3, 4); | ||
167 | }; | ||
168 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet_2 = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step5Matches, _function_3).entrySet(); | ||
169 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair_2 : _entrySet_2) { | ||
170 | { | ||
171 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
172 | List<CostElementMatch> _value = pair_2.getValue(); | ||
173 | for (final CostElementMatch m_4 : _value) { | ||
174 | multiplicityBuilder.add(1, m_4.getMatch()); | ||
175 | } | ||
176 | multiplicityBuilder.add((-2), pair_2.getKey()); | ||
177 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
178 | } | ||
179 | } | ||
180 | CloseTrainsObjectiveHint.boundLimit(it, step5Matches, 2, this.trainType, 4); | ||
181 | CloseTrainsObjectiveHint.boundLimit(it, step5Matches, 3, this.segmentType, 4); | ||
182 | CloseTrainsObjectiveHint.boundLimit(it, step5Matches, 4, this.segmentType, 4); | ||
183 | CloseTrainsObjectiveHint.boundLimit(it, step5Matches, 5, this.segmentType, 4); | ||
184 | final ImmutableList<CostElementMatch> step6Matches = step6.getMatches(); | ||
185 | for (final CostElementMatch m_4 : step6Matches) { | ||
186 | { | ||
187 | final Dimension dimension = it.getDimension(m_4.getMatch()); | ||
188 | objectiveBuilder.add(step6.getWeight(), dimension); | ||
189 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
190 | boolean _isMulti = m_4.isMulti(); | ||
191 | if (_isMulti) { | ||
192 | Object _get = m_4.getMatch().get(3); | ||
193 | Object _get_1 = m_4.getMatch().get(5); | ||
194 | boolean _equals = Objects.equal(_get, _get_1); | ||
195 | if (_equals) { | ||
196 | it.createBuilder().add(2, m_4.getMatch()).add((-1), step5.projectMayMatch(m_4.getMatch(), 2, 3, 4, 5)).build().assertEqualsTo(0); | ||
197 | } else { | ||
198 | it.createBuilder().add(1, m_4.getMatch()).add((-1), step5.projectMayMatch(m_4.getMatch(), 2, 3, 4, 5)).build().assertEqualsTo(0); | ||
199 | } | ||
200 | } else { | ||
201 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
202 | boolean _isMust = m_4.isMust(); | ||
203 | if (_isMust) { | ||
204 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | CloseTrainsObjectiveHint.boundLimit(it, step6Matches, 2, this.trainType, 2); | ||
210 | CloseTrainsObjectiveHint.boundLimit(it, step6Matches, 3, this.segmentType, 2); | ||
211 | CloseTrainsObjectiveHint.boundLimit(it, step6Matches, 4, this.segmentType, 2); | ||
212 | CloseTrainsObjectiveHint.boundLimit(it, step6Matches, 5, this.segmentType, 2); | ||
213 | final ImmutableList<CostElementMatch> step7Matches = step7.getMatches(); | ||
214 | for (final CostElementMatch m_5 : step7Matches) { | ||
215 | { | ||
216 | final Dimension dimension = it.getDimension(m_5.getMatch()); | ||
217 | objectiveBuilder.add(step7.getWeight(), dimension); | ||
218 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
219 | boolean _isMulti = m_5.isMulti(); | ||
220 | boolean _not = (!_isMulti); | ||
221 | if (_not) { | ||
222 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
223 | boolean _isMust = m_5.isMust(); | ||
224 | if (_isMust) { | ||
225 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | final Function1<CostElementMatch, IPatternMatch> _function_4 = (CostElementMatch it_1) -> { | ||
231 | return step6.projectMayMatch(it_1.getMatch(), 2, 3, 4, 5); | ||
232 | }; | ||
233 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet_3 = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step7Matches, _function_4).entrySet(); | ||
234 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair_3 : _entrySet_3) { | ||
235 | { | ||
236 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
237 | List<CostElementMatch> _value = pair_3.getValue(); | ||
238 | for (final CostElementMatch m_6 : _value) { | ||
239 | multiplicityBuilder.add(1, m_6.getMatch()); | ||
240 | } | ||
241 | multiplicityBuilder.add((-1), pair_3.getKey()); | ||
242 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
243 | } | ||
244 | } | ||
245 | CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 2, this.trainType, 2); | ||
246 | CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 3, this.segmentType, 2); | ||
247 | CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 4, this.segmentType, 2); | ||
248 | CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 5, this.segmentType, 2); | ||
249 | CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 6, this.trainType, 2); | ||
250 | this.buildWithBounds(objectiveBuilder); | ||
251 | }; | ||
252 | _xblockexpression = _function; | ||
253 | } | ||
254 | return _xblockexpression; | ||
255 | } | ||
256 | |||
257 | private static void boundLimit(@Extension final ExtendedLinearExpressionBuilderFactory factory, final Collection<CostElementMatch> matches, final int index, final Type type, final int count) { | ||
258 | final Function1<CostElementMatch, Object> _function = (CostElementMatch it) -> { | ||
259 | return it.getMatch().get(index); | ||
260 | }; | ||
261 | Set<Map.Entry<Object, List<CostElementMatch>>> _entrySet = IterableExtensions.<Object, CostElementMatch>groupBy(matches, _function).entrySet(); | ||
262 | for (final Map.Entry<Object, List<CostElementMatch>> pair : _entrySet) { | ||
263 | { | ||
264 | final ExtendedLinearExpressionBuilder multiplicityBuilder = factory.createBuilder(); | ||
265 | List<CostElementMatch> _value = pair.getValue(); | ||
266 | for (final CostElementMatch m : _value) { | ||
267 | multiplicityBuilder.add(1, m.getMatch()); | ||
268 | } | ||
269 | boolean _isMulti = CostElementMatchers.isMulti(pair.getKey()); | ||
270 | if (_isMulti) { | ||
271 | multiplicityBuilder.add((-count), type); | ||
272 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
273 | } else { | ||
274 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(count)); | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | } | ||
279 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/EndOfSidingObjectiveHint.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/EndOfSidingObjectiveHint.java new file mode 100644 index 00000000..77c513e1 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/EndOfSidingObjectiveHint.java | |||
@@ -0,0 +1,193 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import com.google.common.collect.ImmutableList; | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Dimension; | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilder; | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory; | ||
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator; | ||
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch; | ||
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers; | ||
13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint; | ||
14 | import java.util.Collection; | ||
15 | import java.util.List; | ||
16 | import java.util.Map; | ||
17 | import java.util.Set; | ||
18 | import modes3.Modes3Package; | ||
19 | import modes3.queries.EndOfSiding_step_2; | ||
20 | import modes3.queries.EndOfSiding_step_3; | ||
21 | import modes3.queries.EndOfSiding_step_4; | ||
22 | import modes3.queries.EndOfSiding_step_5; | ||
23 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
24 | import org.eclipse.xtext.xbase.lib.Extension; | ||
25 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
26 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
27 | |||
28 | @SuppressWarnings("all") | ||
29 | public class EndOfSidingObjectiveHint extends CostObjectiveHint { | ||
30 | private final Type segmentType; | ||
31 | |||
32 | private final Type trainType; | ||
33 | |||
34 | public EndOfSidingObjectiveHint(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { | ||
35 | @Extension | ||
36 | final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; | ||
37 | this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); | ||
38 | this.trainType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTrain()); | ||
39 | } | ||
40 | |||
41 | @Override | ||
42 | public boolean isExact() { | ||
43 | return true; | ||
44 | } | ||
45 | |||
46 | @Override | ||
47 | public PolyhedronExtensionOperator createPolyhedronExtensionOperator(final Map<String, CostElementMatchers> costElementMatchers) { | ||
48 | PolyhedronExtensionOperator _xblockexpression = null; | ||
49 | { | ||
50 | final CostElementMatchers step2 = costElementMatchers.get(EndOfSiding_step_2.instance().getFullyQualifiedName()); | ||
51 | final CostElementMatchers step3 = costElementMatchers.get(EndOfSiding_step_3.instance().getFullyQualifiedName()); | ||
52 | final CostElementMatchers step4 = costElementMatchers.get(EndOfSiding_step_4.instance().getFullyQualifiedName()); | ||
53 | final CostElementMatchers step5 = costElementMatchers.get(EndOfSiding_step_5.instance().getFullyQualifiedName()); | ||
54 | final PolyhedronExtensionOperator _function = (ExtendedLinearExpressionBuilderFactory it) -> { | ||
55 | final ExtendedLinearExpressionBuilder objectiveBuilder = it.createBuilder(); | ||
56 | ImmutableList<CostElementMatch> _matches = step2.getMatches(); | ||
57 | for (final CostElementMatch m : _matches) { | ||
58 | { | ||
59 | final Dimension dimension = it.getDimension(m.getMatch()); | ||
60 | objectiveBuilder.add(step2.getWeight(), dimension); | ||
61 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
62 | boolean _isMulti = m.isMulti(); | ||
63 | if (_isMulti) { | ||
64 | it.createBuilder().add(1, dimension).add((-1), this.trainType).build().assertEqualsTo(0); | ||
65 | } else { | ||
66 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
67 | boolean _isMust = m.isMust(); | ||
68 | if (_isMust) { | ||
69 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
70 | } | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | final ImmutableList<CostElementMatch> step3Matches = step3.getMatches(); | ||
75 | for (final CostElementMatch m_1 : step3Matches) { | ||
76 | { | ||
77 | final Dimension dimension = it.getDimension(m_1.getMatch()); | ||
78 | objectiveBuilder.add(step3.getWeight(), dimension); | ||
79 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
80 | boolean _isMulti = m_1.isMulti(); | ||
81 | boolean _not = (!_isMulti); | ||
82 | if (_not) { | ||
83 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
84 | boolean _isMust = m_1.isMust(); | ||
85 | if (_isMust) { | ||
86 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | } | ||
91 | final Function1<CostElementMatch, IPatternMatch> _function_1 = (CostElementMatch it_1) -> { | ||
92 | return step2.projectMayMatch(it_1.getMatch(), 2); | ||
93 | }; | ||
94 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step3Matches, _function_1).entrySet(); | ||
95 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair : _entrySet) { | ||
96 | { | ||
97 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
98 | List<CostElementMatch> _value = pair.getValue(); | ||
99 | for (final CostElementMatch m_2 : _value) { | ||
100 | multiplicityBuilder.add(1, m_2.getMatch()); | ||
101 | } | ||
102 | multiplicityBuilder.add((-1), pair.getKey()); | ||
103 | multiplicityBuilder.build().assertEqualsTo(0); | ||
104 | } | ||
105 | } | ||
106 | EndOfSidingObjectiveHint.boundLimit(it, step3Matches, 2, this.trainType, 1); | ||
107 | EndOfSidingObjectiveHint.boundLimit(it, step3Matches, 3, this.segmentType, 1); | ||
108 | final ImmutableList<CostElementMatch> step4Matches = step4.getMatches(); | ||
109 | for (final CostElementMatch m_2 : step4Matches) { | ||
110 | { | ||
111 | final Dimension dimension = it.getDimension(m_2.getMatch()); | ||
112 | objectiveBuilder.add(step4.getWeight(), dimension); | ||
113 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
114 | boolean _isMulti = m_2.isMulti(); | ||
115 | boolean _not = (!_isMulti); | ||
116 | if (_not) { | ||
117 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
118 | boolean _isMust = m_2.isMust(); | ||
119 | if (_isMust) { | ||
120 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | final Function1<CostElementMatch, IPatternMatch> _function_2 = (CostElementMatch it_1) -> { | ||
126 | return step3.projectMayMatch(it_1.getMatch(), 2, 3); | ||
127 | }; | ||
128 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet_1 = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step4Matches, _function_2).entrySet(); | ||
129 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair_1 : _entrySet_1) { | ||
130 | { | ||
131 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
132 | List<CostElementMatch> _value = pair_1.getValue(); | ||
133 | for (final CostElementMatch m_3 : _value) { | ||
134 | multiplicityBuilder.add(1, m_3.getMatch()); | ||
135 | } | ||
136 | multiplicityBuilder.add((-2), pair_1.getKey()); | ||
137 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
138 | } | ||
139 | } | ||
140 | EndOfSidingObjectiveHint.boundLimit(it, step4Matches, 2, this.trainType, 2); | ||
141 | EndOfSidingObjectiveHint.boundLimit(it, step4Matches, 3, this.segmentType, 2); | ||
142 | EndOfSidingObjectiveHint.boundLimit(it, step4Matches, 4, this.segmentType, 2); | ||
143 | final ImmutableList<CostElementMatch> step5Matches = step5.getMatches(); | ||
144 | for (final CostElementMatch m_3 : step5Matches) { | ||
145 | { | ||
146 | final Dimension dimension = it.getDimension(m_3.getMatch()); | ||
147 | objectiveBuilder.add(step5.getWeight(), dimension); | ||
148 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
149 | boolean _isMulti = m_3.isMulti(); | ||
150 | boolean _not = (!_isMulti); | ||
151 | if (_not) { | ||
152 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
153 | boolean _isMust = m_3.isMust(); | ||
154 | if (_isMust) { | ||
155 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
156 | } | ||
157 | } | ||
158 | it.createBuilder().add(1, m_3.getMatch()).add((-1), step4.projectMayMatch(m_3.getMatch(), 2, 3, 4)).build().tightenUpperBound(Integer.valueOf(0)); | ||
159 | } | ||
160 | } | ||
161 | EndOfSidingObjectiveHint.boundLimit(it, step5Matches, 2, this.trainType, 1); | ||
162 | EndOfSidingObjectiveHint.boundLimit(it, step5Matches, 3, this.segmentType, 2); | ||
163 | EndOfSidingObjectiveHint.boundLimit(it, step5Matches, 4, this.segmentType, 1); | ||
164 | this.buildWithBounds(objectiveBuilder); | ||
165 | }; | ||
166 | _xblockexpression = _function; | ||
167 | } | ||
168 | return _xblockexpression; | ||
169 | } | ||
170 | |||
171 | private static void boundLimit(@Extension final ExtendedLinearExpressionBuilderFactory factory, final Collection<CostElementMatch> matches, final int index, final Type type, final int count) { | ||
172 | final Function1<CostElementMatch, Object> _function = (CostElementMatch it) -> { | ||
173 | return it.getMatch().get(index); | ||
174 | }; | ||
175 | Set<Map.Entry<Object, List<CostElementMatch>>> _entrySet = IterableExtensions.<Object, CostElementMatch>groupBy(matches, _function).entrySet(); | ||
176 | for (final Map.Entry<Object, List<CostElementMatch>> pair : _entrySet) { | ||
177 | { | ||
178 | final ExtendedLinearExpressionBuilder multiplicityBuilder = factory.createBuilder(); | ||
179 | List<CostElementMatch> _value = pair.getValue(); | ||
180 | for (final CostElementMatch m : _value) { | ||
181 | multiplicityBuilder.add(1, m.getMatch()); | ||
182 | } | ||
183 | boolean _isMulti = CostElementMatchers.isMulti(pair.getKey()); | ||
184 | if (_isMulti) { | ||
185 | multiplicityBuilder.add((-count), type); | ||
186 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
187 | } else { | ||
188 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(count)); | ||
189 | } | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/MisalignedTurnoutObjectiveHint.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/MisalignedTurnoutObjectiveHint.java new file mode 100644 index 00000000..835a6559 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/MisalignedTurnoutObjectiveHint.java | |||
@@ -0,0 +1,195 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import com.google.common.collect.ImmutableList; | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Dimension; | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilder; | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory; | ||
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator; | ||
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch; | ||
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers; | ||
13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint; | ||
14 | import java.util.Collection; | ||
15 | import java.util.List; | ||
16 | import java.util.Map; | ||
17 | import java.util.Set; | ||
18 | import modes3.Modes3Package; | ||
19 | import modes3.queries.MisalignedTurnout_step_2; | ||
20 | import modes3.queries.MisalignedTurnout_step_3; | ||
21 | import modes3.queries.MisalignedTurnout_step_4; | ||
22 | import modes3.queries.MisalignedTurnout_step_5; | ||
23 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
24 | import org.eclipse.xtext.xbase.lib.Extension; | ||
25 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
26 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
27 | |||
28 | @SuppressWarnings("all") | ||
29 | public class MisalignedTurnoutObjectiveHint extends CostObjectiveHint { | ||
30 | private final Type segmentType; | ||
31 | |||
32 | private final Type turnoutType; | ||
33 | |||
34 | private final Type trainType; | ||
35 | |||
36 | public MisalignedTurnoutObjectiveHint(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { | ||
37 | @Extension | ||
38 | final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; | ||
39 | this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); | ||
40 | this.turnoutType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTurnout()); | ||
41 | this.trainType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTrain()); | ||
42 | } | ||
43 | |||
44 | @Override | ||
45 | public boolean isExact() { | ||
46 | return true; | ||
47 | } | ||
48 | |||
49 | @Override | ||
50 | public PolyhedronExtensionOperator createPolyhedronExtensionOperator(final Map<String, CostElementMatchers> costElementMatchers) { | ||
51 | PolyhedronExtensionOperator _xblockexpression = null; | ||
52 | { | ||
53 | final CostElementMatchers step2 = costElementMatchers.get(MisalignedTurnout_step_2.instance().getFullyQualifiedName()); | ||
54 | final CostElementMatchers step3 = costElementMatchers.get(MisalignedTurnout_step_3.instance().getFullyQualifiedName()); | ||
55 | final CostElementMatchers step4 = costElementMatchers.get(MisalignedTurnout_step_4.instance().getFullyQualifiedName()); | ||
56 | final CostElementMatchers step5 = costElementMatchers.get(MisalignedTurnout_step_5.instance().getFullyQualifiedName()); | ||
57 | final PolyhedronExtensionOperator _function = (ExtendedLinearExpressionBuilderFactory it) -> { | ||
58 | final ExtendedLinearExpressionBuilder objectiveBuilder = it.createBuilder(); | ||
59 | ImmutableList<CostElementMatch> _matches = step2.getMatches(); | ||
60 | for (final CostElementMatch m : _matches) { | ||
61 | { | ||
62 | final Dimension dimension = it.getDimension(m.getMatch()); | ||
63 | objectiveBuilder.add(step2.getWeight(), dimension); | ||
64 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
65 | boolean _isMulti = m.isMulti(); | ||
66 | if (_isMulti) { | ||
67 | it.createBuilder().add(1, dimension).add((-1), this.turnoutType).build().assertEqualsTo(0); | ||
68 | } else { | ||
69 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
70 | boolean _isMust = m.isMust(); | ||
71 | if (_isMust) { | ||
72 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | final ImmutableList<CostElementMatch> step3Matches = step3.getMatches(); | ||
78 | for (final CostElementMatch m_1 : step3Matches) { | ||
79 | { | ||
80 | final Dimension dimension = it.getDimension(m_1.getMatch()); | ||
81 | objectiveBuilder.add(step3.getWeight(), dimension); | ||
82 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
83 | boolean _isMulti = m_1.isMulti(); | ||
84 | boolean _not = (!_isMulti); | ||
85 | if (_not) { | ||
86 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
87 | boolean _isMust = m_1.isMust(); | ||
88 | if (_isMust) { | ||
89 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | final Function1<CostElementMatch, IPatternMatch> _function_1 = (CostElementMatch it_1) -> { | ||
95 | return step2.projectMayMatch(it_1.getMatch(), 2); | ||
96 | }; | ||
97 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step3Matches, _function_1).entrySet(); | ||
98 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair : _entrySet) { | ||
99 | { | ||
100 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
101 | List<CostElementMatch> _value = pair.getValue(); | ||
102 | for (final CostElementMatch m_2 : _value) { | ||
103 | multiplicityBuilder.add(1, m_2.getMatch()); | ||
104 | } | ||
105 | multiplicityBuilder.add((-1), pair.getKey()); | ||
106 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
107 | } | ||
108 | } | ||
109 | MisalignedTurnoutObjectiveHint.boundLimit(it, step3Matches, 2, this.turnoutType, 1); | ||
110 | MisalignedTurnoutObjectiveHint.boundLimit(it, step3Matches, 3, this.segmentType, 2); | ||
111 | final ImmutableList<CostElementMatch> step4Matches = step4.getMatches(); | ||
112 | for (final CostElementMatch m_2 : step4Matches) { | ||
113 | { | ||
114 | final Dimension dimension = it.getDimension(m_2.getMatch()); | ||
115 | objectiveBuilder.add(step4.getWeight(), dimension); | ||
116 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
117 | boolean _isMulti = m_2.isMulti(); | ||
118 | boolean _not = (!_isMulti); | ||
119 | if (_not) { | ||
120 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
121 | boolean _isMust = m_2.isMust(); | ||
122 | if (_isMust) { | ||
123 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
124 | } | ||
125 | } | ||
126 | it.createBuilder().add(1, m_2.getMatch()).add((-1), step3.projectMayMatch(m_2.getMatch(), 2, 3)).build().tightenUpperBound(Integer.valueOf(0)); | ||
127 | } | ||
128 | } | ||
129 | MisalignedTurnoutObjectiveHint.boundLimit(it, step4Matches, 2, this.turnoutType, 1); | ||
130 | MisalignedTurnoutObjectiveHint.boundLimit(it, step4Matches, 3, this.segmentType, 2); | ||
131 | final ImmutableList<CostElementMatch> step5Matches = step5.getMatches(); | ||
132 | for (final CostElementMatch m_3 : step5Matches) { | ||
133 | { | ||
134 | final Dimension dimension = it.getDimension(m_3.getMatch()); | ||
135 | objectiveBuilder.add(step5.getWeight(), dimension); | ||
136 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
137 | boolean _isMulti = m_3.isMulti(); | ||
138 | boolean _not = (!_isMulti); | ||
139 | if (_not) { | ||
140 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
141 | boolean _isMust = m_3.isMust(); | ||
142 | if (_isMust) { | ||
143 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
144 | } | ||
145 | } | ||
146 | } | ||
147 | } | ||
148 | final Function1<CostElementMatch, IPatternMatch> _function_2 = (CostElementMatch it_1) -> { | ||
149 | return step4.projectMayMatch(it_1.getMatch(), 2, 3); | ||
150 | }; | ||
151 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet_1 = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step5Matches, _function_2).entrySet(); | ||
152 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair_1 : _entrySet_1) { | ||
153 | { | ||
154 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
155 | List<CostElementMatch> _value = pair_1.getValue(); | ||
156 | for (final CostElementMatch m_4 : _value) { | ||
157 | multiplicityBuilder.add(1, m_4.getMatch()); | ||
158 | } | ||
159 | multiplicityBuilder.add((-1), pair_1.getKey()); | ||
160 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
161 | } | ||
162 | } | ||
163 | MisalignedTurnoutObjectiveHint.boundLimit(it, step5Matches, 2, this.turnoutType, 1); | ||
164 | MisalignedTurnoutObjectiveHint.boundLimit(it, step5Matches, 3, this.segmentType, 2); | ||
165 | MisalignedTurnoutObjectiveHint.boundLimit(it, step5Matches, 4, this.trainType, 2); | ||
166 | this.buildWithBounds(objectiveBuilder); | ||
167 | }; | ||
168 | _xblockexpression = _function; | ||
169 | } | ||
170 | return _xblockexpression; | ||
171 | } | ||
172 | |||
173 | private static void boundLimit(@Extension final ExtendedLinearExpressionBuilderFactory factory, final Collection<CostElementMatch> matches, final int index, final Type type, final int count) { | ||
174 | final Function1<CostElementMatch, Object> _function = (CostElementMatch it) -> { | ||
175 | return it.getMatch().get(index); | ||
176 | }; | ||
177 | Set<Map.Entry<Object, List<CostElementMatch>>> _entrySet = IterableExtensions.<Object, CostElementMatch>groupBy(matches, _function).entrySet(); | ||
178 | for (final Map.Entry<Object, List<CostElementMatch>> pair : _entrySet) { | ||
179 | { | ||
180 | final ExtendedLinearExpressionBuilder multiplicityBuilder = factory.createBuilder(); | ||
181 | List<CostElementMatch> _value = pair.getValue(); | ||
182 | for (final CostElementMatch m : _value) { | ||
183 | multiplicityBuilder.add(1, m.getMatch()); | ||
184 | } | ||
185 | boolean _isMulti = CostElementMatchers.isMulti(pair.getKey()); | ||
186 | if (_isMulti) { | ||
187 | multiplicityBuilder.add((-count), type); | ||
188 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
189 | } else { | ||
190 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(count)); | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | } | ||
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..16db7053 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java | |||
@@ -0,0 +1,598 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import com.google.common.collect.ImmutableList; | ||
5 | import com.google.common.collect.ImmutableSet; | ||
6 | import com.google.common.collect.Iterables; | ||
7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EReferenceMapper_RelationsOverTypes_Trace; | ||
8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
9 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration; | ||
10 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
11 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | ||
12 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsFactory; | ||
13 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsPackage; | ||
14 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion; | ||
15 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; | ||
16 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicModelInterpretation; | ||
17 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder; | ||
18 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.SolutionScope; | ||
19 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput; | ||
20 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes; | ||
21 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.VariableContext; | ||
22 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Assertion; | ||
23 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Iff; | ||
24 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage; | ||
25 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration; | ||
26 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.SymbolicValue; | ||
27 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TermDescription; | ||
28 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
29 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition; | ||
30 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Variable; | ||
31 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.Annotation; | ||
32 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; | ||
33 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage; | ||
34 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; | ||
35 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult; | ||
36 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore; | ||
37 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic; | ||
38 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration; | ||
39 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicTrace; | ||
40 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; | ||
41 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.Viatra2LogicAnnotationsPackage; | ||
42 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod; | ||
43 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorConstraints; | ||
44 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorSolver; | ||
45 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy; | ||
46 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic; | ||
47 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink; | ||
48 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation; | ||
49 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; | ||
50 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation; | ||
51 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage; | ||
52 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.RelationLink; | ||
53 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; | ||
54 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; | ||
55 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.CostObjectiveConfiguration; | ||
56 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.CostObjectiveElementConfiguration; | ||
57 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.DebugConfiguration; | ||
58 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.StateCoderStrategy; | ||
59 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; | ||
60 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; | ||
61 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.PartialModelAsLogicInterpretation; | ||
62 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind; | ||
63 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold; | ||
64 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser; | ||
65 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; | ||
66 | import java.util.Collections; | ||
67 | import java.util.List; | ||
68 | import java.util.Map; | ||
69 | import java.util.Set; | ||
70 | import java.util.function.Predicate; | ||
71 | import modes3.Modes3Factory; | ||
72 | import modes3.Modes3ModelRoot; | ||
73 | import modes3.Modes3Package; | ||
74 | import modes3.queries.CloseTrains_step_2; | ||
75 | import modes3.queries.CloseTrains_step_3; | ||
76 | import modes3.queries.CloseTrains_step_4; | ||
77 | import modes3.queries.CloseTrains_step_5; | ||
78 | import modes3.queries.CloseTrains_step_6; | ||
79 | import modes3.queries.CloseTrains_step_7; | ||
80 | import modes3.queries.EndOfSiding_step_2; | ||
81 | import modes3.queries.EndOfSiding_step_3; | ||
82 | import modes3.queries.EndOfSiding_step_4; | ||
83 | import modes3.queries.EndOfSiding_step_5; | ||
84 | import modes3.queries.MisalignedTurnout_step_2; | ||
85 | import modes3.queries.MisalignedTurnout_step_3; | ||
86 | import modes3.queries.MisalignedTurnout_step_4; | ||
87 | import modes3.queries.MisalignedTurnout_step_5; | ||
88 | import modes3.queries.Modes3Queries; | ||
89 | import modes3.queries.TrainLocations_step_2; | ||
90 | import modes3.queries.TrainLocations_step_3; | ||
91 | import modes3.run.CloseTrainsObjectiveHint; | ||
92 | import modes3.run.EndOfSidingObjectiveHint; | ||
93 | import modes3.run.MisalignedTurnoutObjectiveHint; | ||
94 | import modes3.run.Modes3TypeScopeHint; | ||
95 | import modes3.run.Modes3UnitPropagationGenerator; | ||
96 | import modes3.run.TrainLocationsObjectiveHint; | ||
97 | import org.eclipse.emf.common.util.EList; | ||
98 | import org.eclipse.emf.common.util.TreeIterator; | ||
99 | import org.eclipse.emf.common.util.URI; | ||
100 | import org.eclipse.emf.ecore.EAttribute; | ||
101 | import org.eclipse.emf.ecore.EClass; | ||
102 | import org.eclipse.emf.ecore.EEnum; | ||
103 | import org.eclipse.emf.ecore.EEnumLiteral; | ||
104 | import org.eclipse.emf.ecore.EObject; | ||
105 | import org.eclipse.emf.ecore.EReference; | ||
106 | import org.eclipse.emf.ecore.EStructuralFeature; | ||
107 | import org.eclipse.emf.ecore.resource.Resource; | ||
108 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; | ||
109 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup; | ||
110 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
111 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions; | ||
112 | import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchEMFBackendFactory; | ||
113 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
114 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory; | ||
115 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor; | ||
116 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
117 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
118 | import org.eclipse.xtext.xbase.lib.Exceptions; | ||
119 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; | ||
120 | import org.eclipse.xtext.xbase.lib.Extension; | ||
121 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
122 | import org.eclipse.xtext.xbase.lib.InputOutput; | ||
123 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
124 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; | ||
125 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | ||
126 | |||
127 | @FinalFieldsConstructor | ||
128 | @SuppressWarnings("all") | ||
129 | public class Modes3ModelGenerator { | ||
130 | private enum MonitoringQuery { | ||
131 | closeTrains, | ||
132 | |||
133 | trainLocations, | ||
134 | |||
135 | endOfSiding, | ||
136 | |||
137 | misalignedTurnout; | ||
138 | } | ||
139 | |||
140 | private final Modes3ModelGenerator.MonitoringQuery monitoringQuery; | ||
141 | |||
142 | private final int modelSize; | ||
143 | |||
144 | private final Ecore2Logic ecore2Logic = new Ecore2Logic(); | ||
145 | |||
146 | private final InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic(); | ||
147 | |||
148 | private final Viatra2Logic viatra2Logic = new Viatra2Logic(this.ecore2Logic); | ||
149 | |||
150 | private final ViatraReasoner solver = new ViatraReasoner(); | ||
151 | |||
152 | @Extension | ||
153 | private final LogicProblemBuilder _logicProblemBuilder = new LogicProblemBuilder(); | ||
154 | |||
155 | public URI generate() { | ||
156 | try { | ||
157 | URI _xblockexpression = null; | ||
158 | { | ||
159 | final EcoreMetamodelDescriptor metamodel = Modes3ModelGenerator.createMetamodelDescriptor(); | ||
160 | Ecore2LogicConfiguration _ecore2LogicConfiguration = new Ecore2LogicConfiguration(); | ||
161 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelLogic = this.ecore2Logic.transformMetamodel(metamodel, _ecore2LogicConfiguration); | ||
162 | final Type segment = this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getSegment()); | ||
163 | final RelationDeclaration connectedTo = this.ecore2Logic.relationOfReference(metamodelLogic.getTrace(), | ||
164 | Modes3Package.eINSTANCE.getSegment_ConnectedTo()); | ||
165 | final RelationDeclaration connectedToIndicator = ((EReferenceMapper_RelationsOverTypes_Trace) metamodelLogic.getTrace().referenceMapperTrace).indicators.get( | ||
166 | Modes3Package.eINSTANCE.getSegment_ConnectedTo()); | ||
167 | StringConcatenation _builder = new StringConcatenation(); | ||
168 | _builder.append("oppositeReference "); | ||
169 | String _name = connectedTo.getName(); | ||
170 | _builder.append(_name); | ||
171 | _builder.append(" "); | ||
172 | String _name_1 = connectedTo.getName(); | ||
173 | _builder.append(_name_1); | ||
174 | final Function1<VariableContext, TermDescription> _function = (VariableContext it) -> { | ||
175 | Iff _xblockexpression_1 = null; | ||
176 | { | ||
177 | StringConcatenation _builder_1 = new StringConcatenation(); | ||
178 | _builder_1.append("src"); | ||
179 | final Variable src = it.addVar(_builder_1, segment); | ||
180 | StringConcatenation _builder_2 = new StringConcatenation(); | ||
181 | _builder_2.append("trg"); | ||
182 | final Variable trg = it.addVar(_builder_2, segment); | ||
183 | SymbolicValue _call = this._logicProblemBuilder.call(connectedToIndicator, src, trg); | ||
184 | SymbolicValue _call_1 = this._logicProblemBuilder.call(connectedToIndicator, trg, src); | ||
185 | _xblockexpression_1 = this._logicProblemBuilder.operator_spaceship(_call, _call_1); | ||
186 | } | ||
187 | return _xblockexpression_1; | ||
188 | }; | ||
189 | final Assertion inverseAssertion = this._logicProblemBuilder.Assertion(_builder, | ||
190 | this._logicProblemBuilder.Forall(_function)); | ||
191 | EList<Assertion> _assertions = metamodelLogic.getOutput().getAssertions(); | ||
192 | _assertions.add(inverseAssertion); | ||
193 | InverseRelationAssertion _createInverseRelationAssertion = Ecore2logicannotationsFactory.eINSTANCE.createInverseRelationAssertion(); | ||
194 | final Procedure1<InverseRelationAssertion> _function_1 = (InverseRelationAssertion it) -> { | ||
195 | it.setTarget(inverseAssertion); | ||
196 | it.setInverseA(connectedTo); | ||
197 | it.setInverseB(connectedTo); | ||
198 | }; | ||
199 | final InverseRelationAssertion inverseAnnotation = ObjectExtensions.<InverseRelationAssertion>operator_doubleArrow(_createInverseRelationAssertion, _function_1); | ||
200 | EList<Annotation> _annotations = metamodelLogic.getOutput().getAnnotations(); | ||
201 | _annotations.add(inverseAnnotation); | ||
202 | final List<EObject> initialModel = Modes3ModelGenerator.loadInitialModel(); | ||
203 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> initialModelLogic = this.instanceModel2Logic.transform(metamodelLogic, initialModel); | ||
204 | final ViatraQuerySetDescriptor queries = this.loadQueries(); | ||
205 | Viatra2LogicConfiguration _viatra2LogicConfiguration = new Viatra2LogicConfiguration(); | ||
206 | final TracedOutput<LogicProblem, Viatra2LogicTrace> logic = this.viatra2Logic.transformQueries(queries, initialModelLogic, _viatra2LogicConfiguration); | ||
207 | ViatraReasonerConfiguration _viatraReasonerConfiguration = new ViatraReasonerConfiguration(); | ||
208 | final Procedure1<ViatraReasonerConfiguration> _function_2 = (ViatraReasonerConfiguration it) -> { | ||
209 | it.runtimeLimit = 3600; | ||
210 | final Procedure1<TypeScopes> _function_3 = (TypeScopes it_1) -> { | ||
211 | it_1.minNewElements = this.modelSize; | ||
212 | it_1.maxNewElements = this.modelSize; | ||
213 | final Procedure1<Map<Type, Integer>> _function_4 = (Map<Type, Integer> it_2) -> { | ||
214 | }; | ||
215 | ObjectExtensions.<Map<Type, Integer>>operator_doubleArrow( | ||
216 | it_1.minNewElementsByType, _function_4); | ||
217 | final Procedure1<Map<Type, Integer>> _function_5 = (Map<Type, Integer> it_2) -> { | ||
218 | it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTrain()), Integer.valueOf((this.modelSize / 5))); | ||
219 | it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTurnout()), Integer.valueOf((this.modelSize / 5))); | ||
220 | it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getSimpleSegment()), Integer.valueOf(((3 * this.modelSize) / 5))); | ||
221 | }; | ||
222 | ObjectExtensions.<Map<Type, Integer>>operator_doubleArrow( | ||
223 | it_1.maxNewElementsByType, _function_5); | ||
224 | }; | ||
225 | ObjectExtensions.<TypeScopes>operator_doubleArrow( | ||
226 | it.typeScopes, _function_3); | ||
227 | final Procedure1<SolutionScope> _function_4 = (SolutionScope it_1) -> { | ||
228 | it_1.numberOfRequiredSolutions = 1; | ||
229 | }; | ||
230 | ObjectExtensions.<SolutionScope>operator_doubleArrow( | ||
231 | it.solutionScope, _function_4); | ||
232 | CostObjectiveConfiguration _objective = this.getObjective(this.ecore2Logic, metamodelLogic.getTrace()); | ||
233 | it.costObjectives.add(_objective); | ||
234 | it.scopeWeight = 6; | ||
235 | it.nameNewElements = false; | ||
236 | it.typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis; | ||
237 | it.stateCoderStrategy = StateCoderStrategy.PairwiseNeighbourhood; | ||
238 | ScopePropagatorStrategy.Polyhedral _polyhedral = new ScopePropagatorStrategy.Polyhedral( | ||
239 | PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp); | ||
240 | it.scopePropagatorStrategy = _polyhedral; | ||
241 | Ecore2Logic_Trace _trace = metamodelLogic.getTrace(); | ||
242 | Modes3TypeScopeHint _modes3TypeScopeHint = new Modes3TypeScopeHint(this.ecore2Logic, _trace); | ||
243 | it.hints.add(_modes3TypeScopeHint); | ||
244 | Ecore2Logic_Trace _trace_1 = metamodelLogic.getTrace(); | ||
245 | Modes3UnitPropagationGenerator _modes3UnitPropagationGenerator = new Modes3UnitPropagationGenerator(this.ecore2Logic, _trace_1); | ||
246 | it.unitPropagationPatternGenerators.add(_modes3UnitPropagationGenerator); | ||
247 | final Procedure1<DebugConfiguration> _function_5 = (DebugConfiguration it_1) -> { | ||
248 | GraphvizVisualiser _graphvizVisualiser = new GraphvizVisualiser(); | ||
249 | it_1.partialInterpretatioVisualiser = _graphvizVisualiser; | ||
250 | }; | ||
251 | ObjectExtensions.<DebugConfiguration>operator_doubleArrow( | ||
252 | it.debugConfiguration, _function_5); | ||
253 | it.documentationLevel = DocumentationLevel.NORMAL; | ||
254 | }; | ||
255 | final ViatraReasonerConfiguration config = ObjectExtensions.<ViatraReasonerConfiguration>operator_doubleArrow(_viatraReasonerConfiguration, _function_2); | ||
256 | final FileSystemWorkspace workspace = new FileSystemWorkspace("output/", ""); | ||
257 | workspace.writeModel(logic.getOutput(), "problem.logicproblem"); | ||
258 | final LogicResult solution = this.solver.solve(logic.getOutput(), config, workspace); | ||
259 | URI _xifexpression = null; | ||
260 | if ((solution instanceof ModelResult)) { | ||
261 | InputOutput.<String>println("Saving generated solutions"); | ||
262 | final Logic2Ecore logic2Ecore = new Logic2Ecore(this.ecore2Logic); | ||
263 | final List<? extends LogicModelInterpretation> interpretations = this.solver.getInterpretations(((ModelResult)solution)); | ||
264 | int _size = interpretations.size(); | ||
265 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | ||
266 | for (final Integer representationIndex : _doubleDotLessThan) { | ||
267 | { | ||
268 | final LogicModelInterpretation interpretation = interpretations.get((representationIndex).intValue()); | ||
269 | final int representationNumber = ((representationIndex).intValue() + 1); | ||
270 | if ((interpretation instanceof PartialModelAsLogicInterpretation)) { | ||
271 | final PartialInterpretation representation = ((PartialModelAsLogicInterpretation)interpretation).getPartialInterpretation(); | ||
272 | StringConcatenation _builder_1 = new StringConcatenation(); | ||
273 | _builder_1.append("solution"); | ||
274 | _builder_1.append(representationNumber); | ||
275 | _builder_1.append(".partialinterpretation"); | ||
276 | workspace.writeModel(representation, _builder_1.toString()); | ||
277 | final PartialInterpretation2Gml partialInterpretation2GML = new PartialInterpretation2Gml(); | ||
278 | final String gml = partialInterpretation2GML.transform(representation); | ||
279 | StringConcatenation _builder_2 = new StringConcatenation(); | ||
280 | _builder_2.append("solution"); | ||
281 | _builder_2.append(representationNumber); | ||
282 | _builder_2.append(".gml"); | ||
283 | workspace.writeText(_builder_2.toString(), gml); | ||
284 | final EObject model = logic2Ecore.transformInterpretation(interpretation, metamodelLogic.getTrace()); | ||
285 | final TreeIterator<EObject> iterator = model.eAllContents(); | ||
286 | int id = 0; | ||
287 | while (iterator.hasNext()) { | ||
288 | { | ||
289 | final EObject obj = iterator.next(); | ||
290 | final Function1<EAttribute, Boolean> _function_3 = (EAttribute it) -> { | ||
291 | String _name_2 = it.getName(); | ||
292 | return Boolean.valueOf(Objects.equal(_name_2, "id")); | ||
293 | }; | ||
294 | final EAttribute idFeature = IterableExtensions.<EAttribute>findFirst(obj.eClass().getEAllAttributes(), _function_3); | ||
295 | if ((idFeature != null)) { | ||
296 | obj.eSet(idFeature, Integer.valueOf(id)); | ||
297 | id++; | ||
298 | } | ||
299 | } | ||
300 | } | ||
301 | StringConcatenation _builder_3 = new StringConcatenation(); | ||
302 | _builder_3.append("solution"); | ||
303 | _builder_3.append(representationNumber); | ||
304 | _builder_3.append(".modes3"); | ||
305 | workspace.writeModel(model, _builder_3.toString()); | ||
306 | int _size_1 = representation.getNewElements().size(); | ||
307 | boolean _lessThan = (_size_1 < 160); | ||
308 | if (_lessThan) { | ||
309 | final Function1<Type, Boolean> _function_3 = (Type it) -> { | ||
310 | String _name_2 = it.getName(); | ||
311 | return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class DefinedPart")); | ||
312 | }; | ||
313 | Type _findFirst = IterableExtensions.<Type>findFirst(representation.getProblem().getTypes(), _function_3); | ||
314 | final TypeDefinition rootType = ((TypeDefinition) _findFirst); | ||
315 | final Function1<PartialComplexTypeInterpretation, Boolean> _function_4 = (PartialComplexTypeInterpretation it) -> { | ||
316 | String _name_2 = it.getInterpretationOf().getName(); | ||
317 | return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class")); | ||
318 | }; | ||
319 | final PartialComplexTypeInterpretation rootIntepretation = IterableExtensions.<PartialComplexTypeInterpretation>findFirst(Iterables.<PartialComplexTypeInterpretation>filter(representation.getPartialtypeinterpratation(), | ||
320 | PartialComplexTypeInterpretation.class), _function_4); | ||
321 | rootIntepretation.getElements().removeAll(rootType.getElements()); | ||
322 | representation.getProblem().getElements().removeAll(rootType.getElements()); | ||
323 | EList<PartialRelationInterpretation> _partialrelationinterpretation = representation.getPartialrelationinterpretation(); | ||
324 | for (final PartialRelationInterpretation relationInterpretation : _partialrelationinterpretation) { | ||
325 | final Predicate<RelationLink> _function_5 = (RelationLink link) -> { | ||
326 | boolean _xifexpression_1 = false; | ||
327 | if ((link instanceof BinaryElementRelationLink)) { | ||
328 | _xifexpression_1 = (rootType.getElements().contains(((BinaryElementRelationLink)link).getParam1()) || | ||
329 | rootType.getElements().contains(((BinaryElementRelationLink)link).getParam2())); | ||
330 | } else { | ||
331 | _xifexpression_1 = false; | ||
332 | } | ||
333 | return _xifexpression_1; | ||
334 | }; | ||
335 | relationInterpretation.getRelationlinks().removeIf(_function_5); | ||
336 | } | ||
337 | rootType.getElements().clear(); | ||
338 | final GraphvizVisualiser visualiser = new GraphvizVisualiser(); | ||
339 | final PartialInterpretationVisualisation visualisation = visualiser.visualiseConcretization(representation); | ||
340 | StringConcatenation _builder_4 = new StringConcatenation(); | ||
341 | _builder_4.append("solution"); | ||
342 | _builder_4.append(representationNumber); | ||
343 | _builder_4.append(".png"); | ||
344 | visualisation.writeToFile(workspace, _builder_4.toString()); | ||
345 | } | ||
346 | } else { | ||
347 | StringConcatenation _builder_5 = new StringConcatenation(); | ||
348 | _builder_5.append("solution"); | ||
349 | _builder_5.append(representationNumber); | ||
350 | _builder_5.append(".txt"); | ||
351 | workspace.writeText(_builder_5.toString(), interpretation.toString()); | ||
352 | } | ||
353 | } | ||
354 | } | ||
355 | } else { | ||
356 | URI _xblockexpression_1 = null; | ||
357 | { | ||
358 | InputOutput.<String>println("Failed to solve problem"); | ||
359 | final LogicProblem partial = logic.getOutput(); | ||
360 | _xblockexpression_1 = workspace.writeModel(partial, "solution.partialinterpretation"); | ||
361 | } | ||
362 | _xifexpression = _xblockexpression_1; | ||
363 | } | ||
364 | _xblockexpression = _xifexpression; | ||
365 | } | ||
366 | return _xblockexpression; | ||
367 | } catch (Throwable _e) { | ||
368 | throw Exceptions.sneakyThrow(_e); | ||
369 | } | ||
370 | } | ||
371 | |||
372 | public static EcoreMetamodelDescriptor createMetamodelDescriptor() { | ||
373 | EcoreMetamodelDescriptor _xblockexpression = null; | ||
374 | { | ||
375 | final ImmutableList<EClass> eClasses = ImmutableList.<EClass>copyOf(Iterables.<EClass>filter(Modes3Package.eINSTANCE.getEClassifiers(), EClass.class)); | ||
376 | Set<EClass> _emptySet = CollectionLiterals.<EClass>emptySet(); | ||
377 | List<EEnum> _emptyList = CollectionLiterals.<EEnum>emptyList(); | ||
378 | List<EEnumLiteral> _emptyList_1 = CollectionLiterals.<EEnumLiteral>emptyList(); | ||
379 | final Function1<EClass, EList<EReference>> _function = (EClass it) -> { | ||
380 | return it.getEReferences(); | ||
381 | }; | ||
382 | ImmutableList<EReference> _copyOf = ImmutableList.<EReference>copyOf(IterableExtensions.<EClass, EReference>flatMap(eClasses, _function)); | ||
383 | List<EAttribute> _emptyList_2 = CollectionLiterals.<EAttribute>emptyList(); | ||
384 | _xblockexpression = new EcoreMetamodelDescriptor(eClasses, _emptySet, | ||
385 | false, _emptyList, _emptyList_1, _copyOf, _emptyList_2); | ||
386 | } | ||
387 | return _xblockexpression; | ||
388 | } | ||
389 | |||
390 | public static List<EObject> loadInitialModel() { | ||
391 | Modes3ModelRoot _createModes3ModelRoot = Modes3Factory.eINSTANCE.createModes3ModelRoot(); | ||
392 | return Collections.<EObject>unmodifiableList(CollectionLiterals.<EObject>newArrayList(_createModes3ModelRoot)); | ||
393 | } | ||
394 | |||
395 | public ViatraQuerySetDescriptor loadQueries() { | ||
396 | ViatraQuerySetDescriptor _xblockexpression = null; | ||
397 | { | ||
398 | final ImmutableList.Builder<IQuerySpecification<?>> patternsBuilder = ImmutableList.<IQuerySpecification<?>>builder(); | ||
399 | patternsBuilder.addAll(Modes3Queries.instance().getSpecifications()); | ||
400 | final ImmutableList<IQuerySpecification<?>> patterns = patternsBuilder.build(); | ||
401 | final Function1<IQuerySpecification<?>, Boolean> _function = (IQuerySpecification<?> pattern) -> { | ||
402 | final Function1<PAnnotation, Boolean> _function_1 = (PAnnotation it) -> { | ||
403 | String _name = it.getName(); | ||
404 | return Boolean.valueOf(Objects.equal(_name, "Constraint")); | ||
405 | }; | ||
406 | return Boolean.valueOf(IterableExtensions.<PAnnotation>exists(pattern.getAllAnnotations(), _function_1)); | ||
407 | }; | ||
408 | final ImmutableSet<IQuerySpecification<?>> validationPatterns = ImmutableSet.<IQuerySpecification<?>>copyOf(IterableExtensions.<IQuerySpecification<?>>filter(patterns, _function)); | ||
409 | Map<IQuerySpecification<?>, EStructuralFeature> _emptyMap = CollectionLiterals.<IQuerySpecification<?>, EStructuralFeature>emptyMap(); | ||
410 | _xblockexpression = new ViatraQuerySetDescriptor(patterns, validationPatterns, _emptyMap); | ||
411 | } | ||
412 | return _xblockexpression; | ||
413 | } | ||
414 | |||
415 | public CostObjectiveConfiguration getObjective(final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { | ||
416 | CostObjectiveConfiguration _costObjectiveConfiguration = new CostObjectiveConfiguration(); | ||
417 | final Procedure1<CostObjectiveConfiguration> _function = (CostObjectiveConfiguration it) -> { | ||
418 | final Modes3ModelGenerator.MonitoringQuery monitoringQuery = this.monitoringQuery; | ||
419 | if (monitoringQuery != null) { | ||
420 | switch (monitoringQuery) { | ||
421 | case closeTrains: | ||
422 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration = new CostObjectiveElementConfiguration(); | ||
423 | final Procedure1<CostObjectiveElementConfiguration> _function_1 = (CostObjectiveElementConfiguration it_1) -> { | ||
424 | it_1.patternQualifiedName = CloseTrains_step_2.instance().getFullyQualifiedName(); | ||
425 | it_1.weight = ((14 + 53) + 11); | ||
426 | }; | ||
427 | CostObjectiveElementConfiguration _doubleArrow = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration, _function_1); | ||
428 | it.elements.add(_doubleArrow); | ||
429 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_1 = new CostObjectiveElementConfiguration(); | ||
430 | final Procedure1<CostObjectiveElementConfiguration> _function_2 = (CostObjectiveElementConfiguration it_1) -> { | ||
431 | it_1.patternQualifiedName = CloseTrains_step_3.instance().getFullyQualifiedName(); | ||
432 | it_1.weight = (21 + 14); | ||
433 | }; | ||
434 | CostObjectiveElementConfiguration _doubleArrow_1 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_1, _function_2); | ||
435 | it.elements.add(_doubleArrow_1); | ||
436 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_2 = new CostObjectiveElementConfiguration(); | ||
437 | final Procedure1<CostObjectiveElementConfiguration> _function_3 = (CostObjectiveElementConfiguration it_1) -> { | ||
438 | it_1.patternQualifiedName = CloseTrains_step_4.instance().getFullyQualifiedName(); | ||
439 | it_1.weight = (((14 + 44) + 14) + 9); | ||
440 | }; | ||
441 | CostObjectiveElementConfiguration _doubleArrow_2 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_2, _function_3); | ||
442 | it.elements.add(_doubleArrow_2); | ||
443 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_3 = new CostObjectiveElementConfiguration(); | ||
444 | final Procedure1<CostObjectiveElementConfiguration> _function_4 = (CostObjectiveElementConfiguration it_1) -> { | ||
445 | it_1.patternQualifiedName = CloseTrains_step_5.instance().getFullyQualifiedName(); | ||
446 | it_1.weight = ((14 + 41) + 11); | ||
447 | }; | ||
448 | CostObjectiveElementConfiguration _doubleArrow_3 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_3, _function_4); | ||
449 | it.elements.add(_doubleArrow_3); | ||
450 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_4 = new CostObjectiveElementConfiguration(); | ||
451 | final Procedure1<CostObjectiveElementConfiguration> _function_5 = (CostObjectiveElementConfiguration it_1) -> { | ||
452 | it_1.patternQualifiedName = CloseTrains_step_6.instance().getFullyQualifiedName(); | ||
453 | it_1.weight = 27; | ||
454 | }; | ||
455 | CostObjectiveElementConfiguration _doubleArrow_4 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_4, _function_5); | ||
456 | it.elements.add(_doubleArrow_4); | ||
457 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_5 = new CostObjectiveElementConfiguration(); | ||
458 | final Procedure1<CostObjectiveElementConfiguration> _function_6 = (CostObjectiveElementConfiguration it_1) -> { | ||
459 | it_1.patternQualifiedName = CloseTrains_step_7.instance().getFullyQualifiedName(); | ||
460 | it_1.weight = 48; | ||
461 | }; | ||
462 | CostObjectiveElementConfiguration _doubleArrow_5 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_5, _function_6); | ||
463 | it.elements.add(_doubleArrow_5); | ||
464 | CloseTrainsObjectiveHint _closeTrainsObjectiveHint = new CloseTrainsObjectiveHint(ecore2Logic, ecore2LogicTrace); | ||
465 | it.hint = _closeTrainsObjectiveHint; | ||
466 | break; | ||
467 | case trainLocations: | ||
468 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_6 = new CostObjectiveElementConfiguration(); | ||
469 | final Procedure1<CostObjectiveElementConfiguration> _function_7 = (CostObjectiveElementConfiguration it_1) -> { | ||
470 | it_1.patternQualifiedName = TrainLocations_step_2.instance().getFullyQualifiedName(); | ||
471 | it_1.weight = ((14 + 53) + 11); | ||
472 | }; | ||
473 | CostObjectiveElementConfiguration _doubleArrow_6 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_6, _function_7); | ||
474 | it.elements.add(_doubleArrow_6); | ||
475 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_7 = new CostObjectiveElementConfiguration(); | ||
476 | final Procedure1<CostObjectiveElementConfiguration> _function_8 = (CostObjectiveElementConfiguration it_1) -> { | ||
477 | it_1.patternQualifiedName = TrainLocations_step_3.instance().getFullyQualifiedName(); | ||
478 | it_1.weight = 48; | ||
479 | }; | ||
480 | CostObjectiveElementConfiguration _doubleArrow_7 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_7, _function_8); | ||
481 | it.elements.add(_doubleArrow_7); | ||
482 | TrainLocationsObjectiveHint _trainLocationsObjectiveHint = new TrainLocationsObjectiveHint(ecore2Logic, ecore2LogicTrace); | ||
483 | it.hint = _trainLocationsObjectiveHint; | ||
484 | break; | ||
485 | case misalignedTurnout: | ||
486 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_8 = new CostObjectiveElementConfiguration(); | ||
487 | final Procedure1<CostObjectiveElementConfiguration> _function_9 = (CostObjectiveElementConfiguration it_1) -> { | ||
488 | it_1.patternQualifiedName = MisalignedTurnout_step_2.instance().getFullyQualifiedName(); | ||
489 | it_1.weight = ((14 + 53) + 11); | ||
490 | }; | ||
491 | CostObjectiveElementConfiguration _doubleArrow_8 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_8, _function_9); | ||
492 | it.elements.add(_doubleArrow_8); | ||
493 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_9 = new CostObjectiveElementConfiguration(); | ||
494 | final Procedure1<CostObjectiveElementConfiguration> _function_10 = (CostObjectiveElementConfiguration it_1) -> { | ||
495 | it_1.patternQualifiedName = MisalignedTurnout_step_3.instance().getFullyQualifiedName(); | ||
496 | it_1.weight = 108; | ||
497 | }; | ||
498 | CostObjectiveElementConfiguration _doubleArrow_9 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_9, _function_10); | ||
499 | it.elements.add(_doubleArrow_9); | ||
500 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_10 = new CostObjectiveElementConfiguration(); | ||
501 | final Procedure1<CostObjectiveElementConfiguration> _function_11 = (CostObjectiveElementConfiguration it_1) -> { | ||
502 | it_1.patternQualifiedName = MisalignedTurnout_step_4.instance().getFullyQualifiedName(); | ||
503 | it_1.weight = 27; | ||
504 | }; | ||
505 | CostObjectiveElementConfiguration _doubleArrow_10 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_10, _function_11); | ||
506 | it.elements.add(_doubleArrow_10); | ||
507 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_11 = new CostObjectiveElementConfiguration(); | ||
508 | final Procedure1<CostObjectiveElementConfiguration> _function_12 = (CostObjectiveElementConfiguration it_1) -> { | ||
509 | it_1.patternQualifiedName = MisalignedTurnout_step_5.instance().getFullyQualifiedName(); | ||
510 | it_1.weight = 48; | ||
511 | }; | ||
512 | CostObjectiveElementConfiguration _doubleArrow_11 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_11, _function_12); | ||
513 | it.elements.add(_doubleArrow_11); | ||
514 | MisalignedTurnoutObjectiveHint _misalignedTurnoutObjectiveHint = new MisalignedTurnoutObjectiveHint(ecore2Logic, ecore2LogicTrace); | ||
515 | it.hint = _misalignedTurnoutObjectiveHint; | ||
516 | break; | ||
517 | case endOfSiding: | ||
518 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_12 = new CostObjectiveElementConfiguration(); | ||
519 | final Procedure1<CostObjectiveElementConfiguration> _function_13 = (CostObjectiveElementConfiguration it_1) -> { | ||
520 | it_1.patternQualifiedName = EndOfSiding_step_2.instance().getFullyQualifiedName(); | ||
521 | it_1.weight = ((14 + 53) + 11); | ||
522 | }; | ||
523 | CostObjectiveElementConfiguration _doubleArrow_12 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_12, _function_13); | ||
524 | it.elements.add(_doubleArrow_12); | ||
525 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_13 = new CostObjectiveElementConfiguration(); | ||
526 | final Procedure1<CostObjectiveElementConfiguration> _function_14 = (CostObjectiveElementConfiguration it_1) -> { | ||
527 | it_1.patternQualifiedName = EndOfSiding_step_3.instance().getFullyQualifiedName(); | ||
528 | it_1.weight = (21 + 14); | ||
529 | }; | ||
530 | CostObjectiveElementConfiguration _doubleArrow_13 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_13, _function_14); | ||
531 | it.elements.add(_doubleArrow_13); | ||
532 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_14 = new CostObjectiveElementConfiguration(); | ||
533 | final Procedure1<CostObjectiveElementConfiguration> _function_15 = (CostObjectiveElementConfiguration it_1) -> { | ||
534 | it_1.patternQualifiedName = EndOfSiding_step_4.instance().getFullyQualifiedName(); | ||
535 | it_1.weight = (((((((14 + 35) + 21) + 15) + 14) + 21) + 15) + 11); | ||
536 | }; | ||
537 | CostObjectiveElementConfiguration _doubleArrow_14 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_14, _function_15); | ||
538 | it.elements.add(_doubleArrow_14); | ||
539 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_15 = new CostObjectiveElementConfiguration(); | ||
540 | final Procedure1<CostObjectiveElementConfiguration> _function_16 = (CostObjectiveElementConfiguration it_1) -> { | ||
541 | it_1.patternQualifiedName = EndOfSiding_step_5.instance().getFullyQualifiedName(); | ||
542 | it_1.weight = 48; | ||
543 | }; | ||
544 | CostObjectiveElementConfiguration _doubleArrow_15 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_15, _function_16); | ||
545 | it.elements.add(_doubleArrow_15); | ||
546 | EndOfSidingObjectiveHint _endOfSidingObjectiveHint = new EndOfSidingObjectiveHint(ecore2Logic, ecore2LogicTrace); | ||
547 | it.hint = _endOfSidingObjectiveHint; | ||
548 | break; | ||
549 | default: | ||
550 | throw new IllegalArgumentException(("Unknown monitoring query: " + this.monitoringQuery)); | ||
551 | } | ||
552 | } else { | ||
553 | throw new IllegalArgumentException(("Unknown monitoring query: " + this.monitoringQuery)); | ||
554 | } | ||
555 | it.kind = ObjectiveKind.HIGHER_IS_BETTER; | ||
556 | it.threshold = ObjectiveThreshold.NO_THRESHOLD; | ||
557 | it.findExtremum = true; | ||
558 | }; | ||
559 | return ObjectExtensions.<CostObjectiveConfiguration>operator_doubleArrow(_costObjectiveConfiguration, _function); | ||
560 | } | ||
561 | |||
562 | public static Object init() { | ||
563 | Object _xblockexpression = null; | ||
564 | { | ||
565 | EMFPatternLanguageStandaloneSetup.doSetup(); | ||
566 | ViatraQueryEngineOptions.setSystemDefaultBackends(ReteBackendFactory.INSTANCE, ReteBackendFactory.INSTANCE, | ||
567 | LocalSearchEMFBackendFactory.INSTANCE); | ||
568 | LogiclanguagePackage.eINSTANCE.getClass(); | ||
569 | LogicproblemPackage.eINSTANCE.getClass(); | ||
570 | PartialinterpretationPackage.eINSTANCE.getClass(); | ||
571 | Ecore2logicannotationsPackage.eINSTANCE.getClass(); | ||
572 | Viatra2LogicAnnotationsPackage.eINSTANCE.getClass(); | ||
573 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | ||
574 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | ||
575 | _xblockexpression = _extensionToFactoryMap.put("*", _xMIResourceFactoryImpl); | ||
576 | } | ||
577 | return _xblockexpression; | ||
578 | } | ||
579 | |||
580 | public static void main(final String[] args) { | ||
581 | int _length = args.length; | ||
582 | boolean _notEquals = (_length != 2); | ||
583 | if (_notEquals) { | ||
584 | System.err.println("Usage: <query> <model size>"); | ||
585 | } | ||
586 | final Modes3ModelGenerator.MonitoringQuery monitoringQuery = Modes3ModelGenerator.MonitoringQuery.valueOf(args[0]); | ||
587 | final int modelSize = Integer.parseInt(args[1]); | ||
588 | Modes3ModelGenerator.init(); | ||
589 | final Modes3ModelGenerator generator = new Modes3ModelGenerator(monitoringQuery, modelSize); | ||
590 | generator.generate(); | ||
591 | } | ||
592 | |||
593 | public Modes3ModelGenerator(final Modes3ModelGenerator.MonitoringQuery monitoringQuery, final int modelSize) { | ||
594 | super(); | ||
595 | this.monitoringQuery = monitoringQuery; | ||
596 | this.modelSize = modelSize; | ||
597 | } | ||
598 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3TypeScopeHint.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3TypeScopeHint.java new file mode 100644 index 00000000..adb69760 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3TypeScopeHint.java | |||
@@ -0,0 +1,133 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality; | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearBoundedExpression; | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint; | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory; | ||
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationConstraintUpdater; | ||
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator; | ||
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; | ||
13 | import java.util.Iterator; | ||
14 | import java.util.Map; | ||
15 | import modes3.Modes3Package; | ||
16 | import modes3.queries.Adjacent; | ||
17 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
18 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; | ||
20 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
21 | import org.eclipse.xtext.xbase.lib.Extension; | ||
22 | |||
23 | @SuppressWarnings("all") | ||
24 | public class Modes3TypeScopeHint implements LinearTypeConstraintHint { | ||
25 | private static final String TURNOUT_NEIGHBOR_COUNT = "turnoutNeighborCount"; | ||
26 | |||
27 | private final Type segmentType; | ||
28 | |||
29 | private final Type turnoutType; | ||
30 | |||
31 | public Modes3TypeScopeHint(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { | ||
32 | @Extension | ||
33 | final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; | ||
34 | this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); | ||
35 | this.turnoutType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTurnout()); | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | public CharSequence getAdditionalPatterns(@Extension final PatternGenerator patternGenerator, final Map<String, PQuery> fqnToPQuery) { | ||
40 | StringConcatenation _builder = new StringConcatenation(); | ||
41 | _builder.append("\t"); | ||
42 | _builder.append("pattern "); | ||
43 | _builder.append(Modes3TypeScopeHint.TURNOUT_NEIGHBOR_COUNT, "\t"); | ||
44 | _builder.append("_helper(problem: LogicProblem, interpretation: PartialInterpretation, source: DefinedElement, target: DefinedElement) {"); | ||
45 | _builder.newLineIfNotEmpty(); | ||
46 | _builder.append("\t\t"); | ||
47 | _builder.append("find interpretation(problem, interpretation);"); | ||
48 | _builder.newLine(); | ||
49 | _builder.append("\t\t"); | ||
50 | _builder.append("find mustExist(problem, interpretation, source);"); | ||
51 | _builder.newLine(); | ||
52 | _builder.append("\t\t"); | ||
53 | _builder.append("find mustExist(problem, interpretation, target);"); | ||
54 | _builder.newLine(); | ||
55 | _builder.append("\t\t"); | ||
56 | CharSequence _referInstanceOf = patternGenerator.getTypeIndexer().referInstanceOf(this.turnoutType, Modality.MUST, "source"); | ||
57 | _builder.append(_referInstanceOf, "\t\t"); | ||
58 | _builder.newLineIfNotEmpty(); | ||
59 | _builder.append("\t\t"); | ||
60 | CharSequence _referInstanceOf_1 = patternGenerator.getTypeIndexer().referInstanceOf(this.segmentType, Modality.MUST, "target"); | ||
61 | _builder.append(_referInstanceOf_1, "\t\t"); | ||
62 | _builder.newLineIfNotEmpty(); | ||
63 | _builder.append("\t\t"); | ||
64 | CharSequence _referPattern = patternGenerator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "source", "target" }, Modality.MUST, true, false); | ||
65 | _builder.append(_referPattern, "\t\t"); | ||
66 | _builder.newLineIfNotEmpty(); | ||
67 | _builder.append("\t"); | ||
68 | _builder.append("}"); | ||
69 | _builder.newLine(); | ||
70 | _builder.newLine(); | ||
71 | _builder.append("\t"); | ||
72 | _builder.append("pattern "); | ||
73 | _builder.append(Modes3TypeScopeHint.TURNOUT_NEIGHBOR_COUNT, "\t"); | ||
74 | _builder.append("(problem: LogicProblem, interpretation: PartialInterpretation, element: DefinedElement, N) {"); | ||
75 | _builder.newLineIfNotEmpty(); | ||
76 | _builder.append("\t\t"); | ||
77 | _builder.append("find interpretation(problem, interpretation);"); | ||
78 | _builder.newLine(); | ||
79 | _builder.append("\t\t"); | ||
80 | _builder.append("find mustExist(problem, interpretation, element);"); | ||
81 | _builder.newLine(); | ||
82 | _builder.append("\t\t"); | ||
83 | CharSequence _referInstanceOf_2 = patternGenerator.getTypeIndexer().referInstanceOf(this.turnoutType, Modality.MUST, "element"); | ||
84 | _builder.append(_referInstanceOf_2, "\t\t"); | ||
85 | _builder.newLineIfNotEmpty(); | ||
86 | _builder.append("\t\t"); | ||
87 | _builder.append("N == count find "); | ||
88 | _builder.append(Modes3TypeScopeHint.TURNOUT_NEIGHBOR_COUNT, "\t\t"); | ||
89 | _builder.append("_helper(problem, interpretation, element, _);"); | ||
90 | _builder.newLineIfNotEmpty(); | ||
91 | _builder.append("\t"); | ||
92 | _builder.append("}"); | ||
93 | _builder.newLine(); | ||
94 | return _builder; | ||
95 | } | ||
96 | |||
97 | @Override | ||
98 | public RelationConstraintUpdater createConstraintUpdater(final LinearTypeExpressionBuilderFactory builderFactory) { | ||
99 | final ViatraQueryMatcher<? extends IPatternMatch> turnoutNeighborCountMatcher = builderFactory.createMatcher(Modes3TypeScopeHint.TURNOUT_NEIGHBOR_COUNT); | ||
100 | final LinearBoundedExpression newNeighbors = builderFactory.createBuilder().add(1, this.segmentType).build(); | ||
101 | final RelationConstraintUpdater _function = (PartialInterpretation partialInterpretation) -> { | ||
102 | final int requiredNeighbbors = Modes3TypeScopeHint.getRemainingCount(turnoutNeighborCountMatcher, partialInterpretation, 3); | ||
103 | newNeighbors.tightenLowerBound(Integer.valueOf(requiredNeighbbors)); | ||
104 | }; | ||
105 | return _function; | ||
106 | } | ||
107 | |||
108 | private static <T extends IPatternMatch> int getRemainingCount(final ViatraQueryMatcher<T> matcher, final PartialInterpretation partialInterpretation, final int capacity) { | ||
109 | int _xblockexpression = (int) 0; | ||
110 | { | ||
111 | final T partialMatch = matcher.newEmptyMatch(); | ||
112 | partialMatch.set(0, partialInterpretation.getProblem()); | ||
113 | partialMatch.set(1, partialInterpretation); | ||
114 | final Iterator<T> iterator = matcher.streamAllMatches(partialMatch).iterator(); | ||
115 | int max = 0; | ||
116 | while (iterator.hasNext()) { | ||
117 | { | ||
118 | final T match = iterator.next(); | ||
119 | Object _get = match.get(3); | ||
120 | final int n = ((Integer) _get).intValue(); | ||
121 | if ((n < capacity)) { | ||
122 | final int required = (capacity - n); | ||
123 | if ((max < required)) { | ||
124 | max = required; | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | _xblockexpression = max; | ||
130 | } | ||
131 | return _xblockexpression; | ||
132 | } | ||
133 | } | ||
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..5c5f82c5 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3UnitPropagationGenerator.java | |||
@@ -0,0 +1,1174 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation; | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality; | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator; | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.UnitPropagationPatternGenerator; | ||
10 | import java.util.Collections; | ||
11 | import java.util.Map; | ||
12 | import modes3.Modes3Package; | ||
13 | import modes3.queries.Adjacent; | ||
14 | import modes3.queries.Output; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; | ||
16 | import org.eclipse.xtend2.lib.StringConcatenationClient; | ||
17 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
18 | import org.eclipse.xtext.xbase.lib.Extension; | ||
19 | import org.eclipse.xtext.xbase.lib.Pair; | ||
20 | |||
21 | @SuppressWarnings("all") | ||
22 | public class Modes3UnitPropagationGenerator implements UnitPropagationPatternGenerator { | ||
23 | private static final String MUST_NOT_CONNECTED_TO = "mustNotConnectedTo"; | ||
24 | |||
25 | private static final String MUST_NOT_STRAIGHT = "mustNotStraight"; | ||
26 | |||
27 | private static final String MUST_NOT_DIVERGENT = "mustNotDivergent"; | ||
28 | |||
29 | private static final String MUST_CONNECTED_TO = "mustConnectedTo"; | ||
30 | |||
31 | private static final String MUST_STRAIGHT = "mustStraight"; | ||
32 | |||
33 | private static final String MUST_DIVERGENT = "mustDivergent"; | ||
34 | |||
35 | private final Type segmentType; | ||
36 | |||
37 | private final Type simpleSegmentType; | ||
38 | |||
39 | private final Type turnoutType; | ||
40 | |||
41 | private final Relation connectedToRelation; | ||
42 | |||
43 | private final Relation straightRelation; | ||
44 | |||
45 | private final Relation divergentRelation; | ||
46 | |||
47 | public Modes3UnitPropagationGenerator(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { | ||
48 | @Extension | ||
49 | final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; | ||
50 | this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); | ||
51 | this.simpleSegmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSimpleSegment()); | ||
52 | this.turnoutType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTurnout()); | ||
53 | this.connectedToRelation = ecore2Logic.relationOfReference(ecore2LogicTrace, Modes3Package.getSegment_ConnectedTo()); | ||
54 | this.straightRelation = ecore2Logic.relationOfReference(ecore2LogicTrace, Modes3Package.getTurnout_Straight()); | ||
55 | this.divergentRelation = ecore2Logic.relationOfReference(ecore2LogicTrace, Modes3Package.getTurnout_Divergent()); | ||
56 | } | ||
57 | |||
58 | @Override | ||
59 | public Map<Relation, String> getMustPatterns() { | ||
60 | Pair<Relation, String> _mappedTo = Pair.<Relation, String>of(this.connectedToRelation, Modes3UnitPropagationGenerator.MUST_CONNECTED_TO); | ||
61 | Pair<Relation, String> _mappedTo_1 = Pair.<Relation, String>of(this.straightRelation, Modes3UnitPropagationGenerator.MUST_STRAIGHT); | ||
62 | Pair<Relation, String> _mappedTo_2 = Pair.<Relation, String>of(this.divergentRelation, Modes3UnitPropagationGenerator.MUST_DIVERGENT); | ||
63 | return Collections.<Relation, String>unmodifiableMap(CollectionLiterals.<Relation, String>newHashMap(_mappedTo, _mappedTo_1, _mappedTo_2)); | ||
64 | } | ||
65 | |||
66 | @Override | ||
67 | public Map<Relation, String> getMustNotPatterns() { | ||
68 | Pair<Relation, String> _mappedTo = Pair.<Relation, String>of(this.connectedToRelation, Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO); | ||
69 | Pair<Relation, String> _mappedTo_1 = Pair.<Relation, String>of(this.straightRelation, Modes3UnitPropagationGenerator.MUST_NOT_STRAIGHT); | ||
70 | Pair<Relation, String> _mappedTo_2 = Pair.<Relation, String>of(this.divergentRelation, Modes3UnitPropagationGenerator.MUST_NOT_DIVERGENT); | ||
71 | return Collections.<Relation, String>unmodifiableMap(CollectionLiterals.<Relation, String>newHashMap(_mappedTo, _mappedTo_1, _mappedTo_2)); | ||
72 | } | ||
73 | |||
74 | @Override | ||
75 | public StringConcatenationClient getAdditionalPatterns(@Extension final PatternGenerator generator, final Map<String, PQuery> fqnToPQuery) { | ||
76 | StringConcatenationClient _xblockexpression = null; | ||
77 | { | ||
78 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
79 | @Override | ||
80 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
81 | _builder.append("problem: LogicProblem, interpretation: PartialInterpretation,"); | ||
82 | _builder.newLine(); | ||
83 | _builder.append("source: DefinedElement, target: DefinedElement"); | ||
84 | _builder.newLine(); | ||
85 | } | ||
86 | }; | ||
87 | final StringConcatenationClient parameters = _client; | ||
88 | StringConcatenationClient _client_1 = new StringConcatenationClient() { | ||
89 | @Override | ||
90 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
91 | _builder.append("find interpretation(problem, interpretation);"); | ||
92 | _builder.newLine(); | ||
93 | _builder.append("find mustExist(problem, interpretation, source);"); | ||
94 | _builder.newLine(); | ||
95 | _builder.append("find mustExist(problem, interpretation, target);"); | ||
96 | _builder.newLine(); | ||
97 | } | ||
98 | }; | ||
99 | final StringConcatenationClient commonMustParameterConstraints = _client_1; | ||
100 | StringConcatenationClient _client_2 = new StringConcatenationClient() { | ||
101 | @Override | ||
102 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
103 | _builder.append("find interpretation(problem, interpretation);"); | ||
104 | _builder.newLine(); | ||
105 | _builder.append("find mayExist(problem, interpretation, source);"); | ||
106 | _builder.newLine(); | ||
107 | _builder.append("find mayExist(problem, interpretation, target);"); | ||
108 | _builder.newLine(); | ||
109 | } | ||
110 | }; | ||
111 | final StringConcatenationClient commonMayParameterConstraints = _client_2; | ||
112 | StringConcatenationClient _client_3 = new StringConcatenationClient() { | ||
113 | @Override | ||
114 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
115 | _builder.append("pattern mayInput("); | ||
116 | _builder.append(parameters); | ||
117 | _builder.append(") {"); | ||
118 | _builder.newLineIfNotEmpty(); | ||
119 | _builder.append("\t"); | ||
120 | _builder.append(commonMayParameterConstraints, "\t"); | ||
121 | _builder.newLineIfNotEmpty(); | ||
122 | _builder.append("\t"); | ||
123 | CharSequence _referInstanceOf = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
124 | _builder.append(_referInstanceOf, "\t"); | ||
125 | _builder.newLineIfNotEmpty(); | ||
126 | _builder.append("\t"); | ||
127 | CharSequence _referPattern = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "target", "source" }, Modality.MAY, true, false); | ||
128 | _builder.append(_referPattern, "\t"); | ||
129 | _builder.newLineIfNotEmpty(); | ||
130 | _builder.append("\t"); | ||
131 | _builder.append("neg "); | ||
132 | CharSequence _referRelation = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "target", "source", Modality.MUST, fqnToPQuery); | ||
133 | _builder.append(_referRelation, "\t"); | ||
134 | _builder.newLineIfNotEmpty(); | ||
135 | _builder.append("\t"); | ||
136 | _builder.append("neg "); | ||
137 | CharSequence _referRelation_1 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "target", "source", Modality.MUST, fqnToPQuery); | ||
138 | _builder.append(_referRelation_1, "\t"); | ||
139 | _builder.newLineIfNotEmpty(); | ||
140 | _builder.append("}"); | ||
141 | _builder.newLine(); | ||
142 | _builder.newLine(); | ||
143 | _builder.append("pattern multipleMayInput(problem: LogicProblem, interpretation: PartialInterpretation,"); | ||
144 | _builder.newLine(); | ||
145 | _builder.append("\t\t\t"); | ||
146 | _builder.append("target: DefinedElement) {"); | ||
147 | _builder.newLine(); | ||
148 | _builder.append("\t"); | ||
149 | _builder.append("find interpretation(problem, interpretation);"); | ||
150 | _builder.newLine(); | ||
151 | _builder.append("\t"); | ||
152 | _builder.append("find mustExist(problem, interpretation, target);"); | ||
153 | _builder.newLine(); | ||
154 | _builder.append("\t"); | ||
155 | _builder.append("find mayInput(problem, interpretaton, source1, target);"); | ||
156 | _builder.newLine(); | ||
157 | _builder.append("\t"); | ||
158 | _builder.append("find mayInput(problem, interpretaton, source2, target);"); | ||
159 | _builder.newLine(); | ||
160 | _builder.append("\t"); | ||
161 | _builder.append("neg find mustEquivalent(problem, interpretation, source1, source2);"); | ||
162 | _builder.newLine(); | ||
163 | _builder.append("}"); | ||
164 | _builder.newLine(); | ||
165 | _builder.newLine(); | ||
166 | _builder.append("pattern multipleMayStraight(problem: LogicProblem, interpretation: PartialInterpretation,"); | ||
167 | _builder.newLine(); | ||
168 | _builder.append("\t\t\t"); | ||
169 | _builder.append("source: DefinedElement) {"); | ||
170 | _builder.newLine(); | ||
171 | _builder.append("\t"); | ||
172 | _builder.append("find interpretation(problem, interpretation);"); | ||
173 | _builder.newLine(); | ||
174 | _builder.append("\t"); | ||
175 | _builder.append("find mustExist(problem, interpretation, source);"); | ||
176 | _builder.newLine(); | ||
177 | _builder.append("\t"); | ||
178 | CharSequence _referInstanceOf_1 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
179 | _builder.append(_referInstanceOf_1, "\t"); | ||
180 | _builder.newLineIfNotEmpty(); | ||
181 | _builder.append("\t"); | ||
182 | CharSequence _referRelation_2 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target1", Modality.MAY, fqnToPQuery); | ||
183 | _builder.append(_referRelation_2, "\t"); | ||
184 | _builder.newLineIfNotEmpty(); | ||
185 | _builder.append("\t"); | ||
186 | CharSequence _referRelation_3 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target2", Modality.MAY, fqnToPQuery); | ||
187 | _builder.append(_referRelation_3, "\t"); | ||
188 | _builder.newLineIfNotEmpty(); | ||
189 | _builder.append("\t"); | ||
190 | _builder.append("neg find mustEquivalent(problem, interpretation, target1, target2);"); | ||
191 | _builder.newLine(); | ||
192 | _builder.append("}"); | ||
193 | _builder.newLine(); | ||
194 | _builder.newLine(); | ||
195 | _builder.append("pattern multipleMayDivergent(problem: LogicProblem, interpretation: PartialInterpretation,"); | ||
196 | _builder.newLine(); | ||
197 | _builder.append("\t\t\t"); | ||
198 | _builder.append("source: DefinedElement) {"); | ||
199 | _builder.newLine(); | ||
200 | _builder.append("\t"); | ||
201 | _builder.append("find interpretation(problem, interpretation);"); | ||
202 | _builder.newLine(); | ||
203 | _builder.append("\t"); | ||
204 | _builder.append("find mustExist(problem, interpretation, source);"); | ||
205 | _builder.newLine(); | ||
206 | _builder.append("\t"); | ||
207 | CharSequence _referInstanceOf_2 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
208 | _builder.append(_referInstanceOf_2, "\t"); | ||
209 | _builder.newLineIfNotEmpty(); | ||
210 | _builder.append("\t"); | ||
211 | CharSequence _referRelation_4 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target1", Modality.MAY, fqnToPQuery); | ||
212 | _builder.append(_referRelation_4, "\t"); | ||
213 | _builder.newLineIfNotEmpty(); | ||
214 | _builder.append("\t"); | ||
215 | CharSequence _referRelation_5 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target2", Modality.MAY, fqnToPQuery); | ||
216 | _builder.append(_referRelation_5, "\t"); | ||
217 | _builder.newLineIfNotEmpty(); | ||
218 | _builder.append("\t"); | ||
219 | _builder.append("neg find mustEquivalent(problem, interpretation, target1, target2);"); | ||
220 | _builder.newLine(); | ||
221 | _builder.append("}"); | ||
222 | _builder.newLine(); | ||
223 | _builder.newLine(); | ||
224 | _builder.append("pattern "); | ||
225 | _builder.append(Modes3UnitPropagationGenerator.MUST_CONNECTED_TO); | ||
226 | _builder.append("("); | ||
227 | _builder.append(parameters); | ||
228 | _builder.append(") {"); | ||
229 | _builder.newLineIfNotEmpty(); | ||
230 | _builder.append("\t"); | ||
231 | _builder.append(commonMustParameterConstraints, "\t"); | ||
232 | _builder.newLineIfNotEmpty(); | ||
233 | _builder.append("\t"); | ||
234 | CharSequence _referInstanceOf_3 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
235 | _builder.append(_referInstanceOf_3, "\t"); | ||
236 | _builder.newLineIfNotEmpty(); | ||
237 | _builder.append("\t"); | ||
238 | _builder.append("find mayInput(problem, interpretaton, source, target);"); | ||
239 | _builder.newLine(); | ||
240 | _builder.append("\t"); | ||
241 | _builder.append("neg find multipleMayInput(problem, interpretaton, target);"); | ||
242 | _builder.newLine(); | ||
243 | _builder.append("\t"); | ||
244 | CharSequence _referRelation_6 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
245 | _builder.append(_referRelation_6, "\t"); | ||
246 | _builder.newLineIfNotEmpty(); | ||
247 | _builder.append("\t"); | ||
248 | _builder.append("neg "); | ||
249 | CharSequence _referRelation_7 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "target", Modality.MUST, fqnToPQuery); | ||
250 | _builder.append(_referRelation_7, "\t"); | ||
251 | _builder.newLineIfNotEmpty(); | ||
252 | _builder.append("\t"); | ||
253 | _builder.append("neg "); | ||
254 | CharSequence _referRelation_8 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
255 | _builder.append(_referRelation_8, "\t"); | ||
256 | _builder.newLineIfNotEmpty(); | ||
257 | _builder.append("\t"); | ||
258 | _builder.append("neg "); | ||
259 | CharSequence _referRelation_9 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
260 | _builder.append(_referRelation_9, "\t"); | ||
261 | _builder.newLineIfNotEmpty(); | ||
262 | _builder.append("}"); | ||
263 | _builder.newLine(); | ||
264 | _builder.newLine(); | ||
265 | _builder.append("pattern "); | ||
266 | _builder.append(Modes3UnitPropagationGenerator.MUST_STRAIGHT); | ||
267 | _builder.append("("); | ||
268 | _builder.append(parameters); | ||
269 | _builder.append(") {"); | ||
270 | _builder.newLineIfNotEmpty(); | ||
271 | _builder.append("\t"); | ||
272 | _builder.append(commonMustParameterConstraints, "\t"); | ||
273 | _builder.newLineIfNotEmpty(); | ||
274 | _builder.append("\t"); | ||
275 | _builder.append("neg "); | ||
276 | CharSequence _referRelation_10 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "_", Modality.MUST, fqnToPQuery); | ||
277 | _builder.append(_referRelation_10, "\t"); | ||
278 | _builder.newLineIfNotEmpty(); | ||
279 | _builder.append("\t"); | ||
280 | _builder.append("neg find multipleMayStraight(problem, interpretation, source);"); | ||
281 | _builder.newLine(); | ||
282 | _builder.append("\t"); | ||
283 | CharSequence _referRelation_11 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
284 | _builder.append(_referRelation_11, "\t"); | ||
285 | _builder.newLineIfNotEmpty(); | ||
286 | _builder.append("\t"); | ||
287 | _builder.append("neg "); | ||
288 | CharSequence _referRelation_12 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target", Modality.MUST, fqnToPQuery); | ||
289 | _builder.append(_referRelation_12, "\t"); | ||
290 | _builder.newLineIfNotEmpty(); | ||
291 | _builder.append("} or {"); | ||
292 | _builder.newLine(); | ||
293 | _builder.append("\t"); | ||
294 | _builder.append(commonMustParameterConstraints, "\t"); | ||
295 | _builder.newLineIfNotEmpty(); | ||
296 | _builder.append("\t"); | ||
297 | CharSequence _referInstanceOf_4 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
298 | _builder.append(_referInstanceOf_4, "\t"); | ||
299 | _builder.newLineIfNotEmpty(); | ||
300 | _builder.append("\t"); | ||
301 | _builder.append("find mayInput(problem, interpretaton, source, target);"); | ||
302 | _builder.newLine(); | ||
303 | _builder.append("\t"); | ||
304 | _builder.append("neg find multipleMayInput(problem, interpretaton, target);"); | ||
305 | _builder.newLine(); | ||
306 | _builder.append("\t"); | ||
307 | _builder.append("neg "); | ||
308 | CharSequence _referRelation_13 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
309 | _builder.append(_referRelation_13, "\t"); | ||
310 | _builder.newLineIfNotEmpty(); | ||
311 | _builder.append("\t"); | ||
312 | CharSequence _referRelation_14 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
313 | _builder.append(_referRelation_14, "\t"); | ||
314 | _builder.newLineIfNotEmpty(); | ||
315 | _builder.append("\t"); | ||
316 | _builder.append("neg "); | ||
317 | CharSequence _referRelation_15 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target", Modality.MUST, fqnToPQuery); | ||
318 | _builder.append(_referRelation_15, "\t"); | ||
319 | _builder.newLineIfNotEmpty(); | ||
320 | _builder.append("\t"); | ||
321 | _builder.append("neg "); | ||
322 | CharSequence _referRelation_16 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
323 | _builder.append(_referRelation_16, "\t"); | ||
324 | _builder.newLineIfNotEmpty(); | ||
325 | _builder.append("}"); | ||
326 | _builder.newLine(); | ||
327 | _builder.newLine(); | ||
328 | _builder.append("pattern "); | ||
329 | _builder.append(Modes3UnitPropagationGenerator.MUST_DIVERGENT); | ||
330 | _builder.append("("); | ||
331 | _builder.append(parameters); | ||
332 | _builder.append(") {"); | ||
333 | _builder.newLineIfNotEmpty(); | ||
334 | _builder.append("\t"); | ||
335 | _builder.append(commonMustParameterConstraints, "\t"); | ||
336 | _builder.newLineIfNotEmpty(); | ||
337 | _builder.append("\t"); | ||
338 | _builder.append("neg "); | ||
339 | CharSequence _referRelation_17 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "_", Modality.MUST, fqnToPQuery); | ||
340 | _builder.append(_referRelation_17, "\t"); | ||
341 | _builder.newLineIfNotEmpty(); | ||
342 | _builder.append("\t"); | ||
343 | _builder.append("neg find multipleMayDivergent(problem, interpretation, source);"); | ||
344 | _builder.newLine(); | ||
345 | _builder.append("\t"); | ||
346 | CharSequence _referRelation_18 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
347 | _builder.append(_referRelation_18, "\t"); | ||
348 | _builder.newLineIfNotEmpty(); | ||
349 | _builder.append("\t"); | ||
350 | _builder.append("neg "); | ||
351 | CharSequence _referRelation_19 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target", Modality.MUST, fqnToPQuery); | ||
352 | _builder.append(_referRelation_19, "\t"); | ||
353 | _builder.newLineIfNotEmpty(); | ||
354 | _builder.append("} or {"); | ||
355 | _builder.newLine(); | ||
356 | _builder.append("\t"); | ||
357 | _builder.append(commonMustParameterConstraints, "\t"); | ||
358 | _builder.newLineIfNotEmpty(); | ||
359 | _builder.append("\t"); | ||
360 | CharSequence _referInstanceOf_5 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
361 | _builder.append(_referInstanceOf_5, "\t"); | ||
362 | _builder.newLineIfNotEmpty(); | ||
363 | _builder.append("\t"); | ||
364 | _builder.append("find mayInput(problem, interpretaton, source, target);"); | ||
365 | _builder.newLine(); | ||
366 | _builder.append("\t"); | ||
367 | _builder.append("neg find multipleMayInput(problem, interpretaton, target);"); | ||
368 | _builder.newLine(); | ||
369 | _builder.append("\t"); | ||
370 | _builder.append("neg "); | ||
371 | CharSequence _referRelation_20 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
372 | _builder.append(_referRelation_20, "\t"); | ||
373 | _builder.newLineIfNotEmpty(); | ||
374 | _builder.append("\t"); | ||
375 | _builder.append("neg "); | ||
376 | CharSequence _referRelation_21 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
377 | _builder.append(_referRelation_21, "\t"); | ||
378 | _builder.newLineIfNotEmpty(); | ||
379 | _builder.append("\t"); | ||
380 | CharSequence _referRelation_22 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
381 | _builder.append(_referRelation_22, "\t"); | ||
382 | _builder.newLineIfNotEmpty(); | ||
383 | _builder.append("\t"); | ||
384 | _builder.append("neg "); | ||
385 | CharSequence _referRelation_23 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target", Modality.MUST, fqnToPQuery); | ||
386 | _builder.append(_referRelation_23, "\t"); | ||
387 | _builder.newLineIfNotEmpty(); | ||
388 | _builder.append("}"); | ||
389 | _builder.newLine(); | ||
390 | _builder.newLine(); | ||
391 | _builder.append("pattern turnoutOutput_must_to_true_by_straight("); | ||
392 | _builder.append(parameters); | ||
393 | _builder.append(", T : DefinedElement, S : DefinedElement) {"); | ||
394 | _builder.newLineIfNotEmpty(); | ||
395 | _builder.append("\t"); | ||
396 | _builder.append(commonMayParameterConstraints, "\t"); | ||
397 | _builder.newLineIfNotEmpty(); | ||
398 | _builder.append("\t"); | ||
399 | CharSequence _referInstanceOf_6 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
400 | _builder.append(_referInstanceOf_6, "\t"); | ||
401 | _builder.newLineIfNotEmpty(); | ||
402 | _builder.append("\t"); | ||
403 | CharSequence _referInstanceOf_7 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
404 | _builder.append(_referInstanceOf_7, "\t"); | ||
405 | _builder.newLineIfNotEmpty(); | ||
406 | _builder.append("\t"); | ||
407 | _builder.append("T == source;"); | ||
408 | _builder.newLine(); | ||
409 | _builder.append("\t"); | ||
410 | _builder.append("S == target;"); | ||
411 | _builder.newLine(); | ||
412 | _builder.append("}"); | ||
413 | _builder.newLine(); | ||
414 | _builder.newLine(); | ||
415 | _builder.append("pattern turnoutOutput_must_to_true_by_divergent("); | ||
416 | _builder.append(parameters); | ||
417 | _builder.append(", T : DefinedElement, S : DefinedElement) {"); | ||
418 | _builder.newLineIfNotEmpty(); | ||
419 | _builder.append("\t"); | ||
420 | _builder.append(commonMayParameterConstraints, "\t"); | ||
421 | _builder.newLineIfNotEmpty(); | ||
422 | _builder.append("\t"); | ||
423 | CharSequence _referInstanceOf_8 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
424 | _builder.append(_referInstanceOf_8, "\t"); | ||
425 | _builder.newLineIfNotEmpty(); | ||
426 | _builder.append("\t"); | ||
427 | CharSequence _referInstanceOf_9 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
428 | _builder.append(_referInstanceOf_9, "\t"); | ||
429 | _builder.newLineIfNotEmpty(); | ||
430 | _builder.append("\t"); | ||
431 | _builder.append("T == source;"); | ||
432 | _builder.newLine(); | ||
433 | _builder.append("\t"); | ||
434 | _builder.append("S == target;"); | ||
435 | _builder.newLine(); | ||
436 | _builder.append("}"); | ||
437 | _builder.newLine(); | ||
438 | _builder.newLine(); | ||
439 | _builder.append("pattern output_must_to_true_by_connectedTo("); | ||
440 | _builder.append(parameters); | ||
441 | _builder.append(", S1 : DefinedElement, S2 : DefinedElement) {"); | ||
442 | _builder.newLineIfNotEmpty(); | ||
443 | _builder.append("\t"); | ||
444 | _builder.append(commonMayParameterConstraints, "\t"); | ||
445 | _builder.newLineIfNotEmpty(); | ||
446 | _builder.append("\t"); | ||
447 | CharSequence _referInstanceOf_10 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "source"); | ||
448 | _builder.append(_referInstanceOf_10, "\t"); | ||
449 | _builder.newLineIfNotEmpty(); | ||
450 | _builder.append("\t"); | ||
451 | CharSequence _referInstanceOf_11 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
452 | _builder.append(_referInstanceOf_11, "\t"); | ||
453 | _builder.newLineIfNotEmpty(); | ||
454 | _builder.append("\t"); | ||
455 | _builder.append("S1 == source;"); | ||
456 | _builder.newLine(); | ||
457 | _builder.append("\t"); | ||
458 | _builder.append("S2 == target;"); | ||
459 | _builder.newLine(); | ||
460 | _builder.append("}"); | ||
461 | _builder.newLine(); | ||
462 | _builder.newLine(); | ||
463 | _builder.append("pattern output_must_to_true_by_straight("); | ||
464 | _builder.append(parameters); | ||
465 | _builder.append(", S1 : DefinedElement, S2 : DefinedElement) {"); | ||
466 | _builder.newLineIfNotEmpty(); | ||
467 | _builder.append("\t"); | ||
468 | _builder.append("find turnoutOutput_must_to_true_by_straight(problem, interpretation, source, target, S1, S2);"); | ||
469 | _builder.newLine(); | ||
470 | _builder.append("}"); | ||
471 | _builder.newLine(); | ||
472 | _builder.newLine(); | ||
473 | _builder.append("pattern output_must_to_true_by_divergent("); | ||
474 | _builder.append(parameters); | ||
475 | _builder.append(", S1 : DefinedElement, S2 : DefinedElement) {"); | ||
476 | _builder.newLineIfNotEmpty(); | ||
477 | _builder.append("\t"); | ||
478 | _builder.append("find turnoutOutput_must_to_true_by_divergent(problem, interpretation, source, target, S1, S2);"); | ||
479 | _builder.newLine(); | ||
480 | _builder.append("}"); | ||
481 | _builder.newLine(); | ||
482 | _builder.newLine(); | ||
483 | _builder.append("pattern adjacent_must_to_true_by_connectedTo("); | ||
484 | _builder.append(parameters); | ||
485 | _builder.append(", S1 : DefinedElement, S2 : DefinedElement) {"); | ||
486 | _builder.newLineIfNotEmpty(); | ||
487 | _builder.append("\t"); | ||
488 | _builder.append("find output_must_to_true_by_connectedTo(problem, interpretation, source, target, S1, S2);"); | ||
489 | _builder.newLine(); | ||
490 | _builder.append("}"); | ||
491 | _builder.newLine(); | ||
492 | _builder.newLine(); | ||
493 | _builder.append("pattern adjacent_must_to_true_by_straight("); | ||
494 | _builder.append(parameters); | ||
495 | _builder.append(", S1 : DefinedElement, S2 : DefinedElement) {"); | ||
496 | _builder.newLineIfNotEmpty(); | ||
497 | _builder.append("\t"); | ||
498 | _builder.append("find output_must_to_true_by_straight(problem, interpretation, source, target, S1, S2);"); | ||
499 | _builder.newLine(); | ||
500 | _builder.append("} or {"); | ||
501 | _builder.newLine(); | ||
502 | _builder.append("\t"); | ||
503 | _builder.append("find turnoutOutput_must_to_true_by_straight(problem, interpretation, source, target, S2, S1);"); | ||
504 | _builder.newLine(); | ||
505 | _builder.append("}"); | ||
506 | _builder.newLine(); | ||
507 | _builder.newLine(); | ||
508 | _builder.append("pattern adjacent_must_to_true_by_divergent("); | ||
509 | _builder.append(parameters); | ||
510 | _builder.append(", S1 : DefinedElement, S2 : DefinedElement) {"); | ||
511 | _builder.newLineIfNotEmpty(); | ||
512 | _builder.append("\t"); | ||
513 | _builder.append("find output_must_to_true_by_divergent(problem, interpretation, source, target, S1, S2);"); | ||
514 | _builder.newLine(); | ||
515 | _builder.append("} or {"); | ||
516 | _builder.newLine(); | ||
517 | _builder.append("\t"); | ||
518 | _builder.append("find turnoutOutput_must_to_true_by_divergent(problem, interpretation, source, target, S2, S1);"); | ||
519 | _builder.newLine(); | ||
520 | _builder.append("}"); | ||
521 | _builder.newLine(); | ||
522 | _builder.newLine(); | ||
523 | _builder.append("pattern connectedToReflexive_must_to_true_by_connectedTo("); | ||
524 | _builder.append(parameters); | ||
525 | _builder.append(", S : DefinedElement) {"); | ||
526 | _builder.newLineIfNotEmpty(); | ||
527 | _builder.append("\t"); | ||
528 | _builder.append("find mustExist(problem, interpretation, source);"); | ||
529 | _builder.newLine(); | ||
530 | _builder.append("\t"); | ||
531 | CharSequence _referInstanceOf_12 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "source"); | ||
532 | _builder.append(_referInstanceOf_12, "\t"); | ||
533 | _builder.newLineIfNotEmpty(); | ||
534 | _builder.append("\t"); | ||
535 | _builder.append("S == source;"); | ||
536 | _builder.newLine(); | ||
537 | _builder.append("\t"); | ||
538 | _builder.append("S == target;"); | ||
539 | _builder.newLine(); | ||
540 | _builder.append("}"); | ||
541 | _builder.newLine(); | ||
542 | _builder.newLine(); | ||
543 | _builder.append("pattern outputReflexive_must_to_true_by_straight("); | ||
544 | _builder.append(parameters); | ||
545 | _builder.append(", T : DefinedElement) {"); | ||
546 | _builder.newLineIfNotEmpty(); | ||
547 | _builder.append("\t"); | ||
548 | _builder.append("find turnoutOutput_must_to_true_by_straight(problem, interpretation, source, target, T, T);"); | ||
549 | _builder.newLine(); | ||
550 | _builder.append("}"); | ||
551 | _builder.newLine(); | ||
552 | _builder.newLine(); | ||
553 | _builder.append("pattern outputReflexive_must_to_true_by_divergent("); | ||
554 | _builder.append(parameters); | ||
555 | _builder.append(", T : DefinedElement) {"); | ||
556 | _builder.newLineIfNotEmpty(); | ||
557 | _builder.append("\t"); | ||
558 | _builder.append("find turnoutOutput_must_to_true_by_divergent(problem, interpretation, source, target, T, T);"); | ||
559 | _builder.newLine(); | ||
560 | _builder.append("}"); | ||
561 | _builder.newLine(); | ||
562 | _builder.newLine(); | ||
563 | _builder.append("pattern turnoutOutputsAreSame_must_to_true_by_straight("); | ||
564 | _builder.append(parameters); | ||
565 | _builder.append(", T : DefinedElement) {"); | ||
566 | _builder.newLineIfNotEmpty(); | ||
567 | _builder.append("\t"); | ||
568 | _builder.append(commonMayParameterConstraints, "\t"); | ||
569 | _builder.newLineIfNotEmpty(); | ||
570 | _builder.append("\t"); | ||
571 | CharSequence _referInstanceOf_13 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
572 | _builder.append(_referInstanceOf_13, "\t"); | ||
573 | _builder.newLineIfNotEmpty(); | ||
574 | _builder.append("\t"); | ||
575 | CharSequence _referInstanceOf_14 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
576 | _builder.append(_referInstanceOf_14, "\t"); | ||
577 | _builder.newLineIfNotEmpty(); | ||
578 | _builder.append("\t"); | ||
579 | _builder.append("T == source;"); | ||
580 | _builder.newLine(); | ||
581 | _builder.append("\t"); | ||
582 | _builder.append("S == target;"); | ||
583 | _builder.newLine(); | ||
584 | _builder.append("\t"); | ||
585 | CharSequence _referRelation_24 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "T", "S", Modality.MUST, fqnToPQuery); | ||
586 | _builder.append(_referRelation_24, "\t"); | ||
587 | _builder.newLineIfNotEmpty(); | ||
588 | _builder.append("}"); | ||
589 | _builder.newLine(); | ||
590 | _builder.newLine(); | ||
591 | _builder.append("pattern turnoutOutputsAreSame_must_to_true_by_divergent("); | ||
592 | _builder.append(parameters); | ||
593 | _builder.append(", T : DefinedElement) {"); | ||
594 | _builder.newLineIfNotEmpty(); | ||
595 | _builder.append("\t"); | ||
596 | _builder.append(commonMayParameterConstraints, "\t"); | ||
597 | _builder.newLineIfNotEmpty(); | ||
598 | _builder.append("\t"); | ||
599 | CharSequence _referInstanceOf_15 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
600 | _builder.append(_referInstanceOf_15, "\t"); | ||
601 | _builder.newLineIfNotEmpty(); | ||
602 | _builder.append("\t"); | ||
603 | CharSequence _referInstanceOf_16 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
604 | _builder.append(_referInstanceOf_16, "\t"); | ||
605 | _builder.newLineIfNotEmpty(); | ||
606 | _builder.append("\t"); | ||
607 | _builder.append("T == source;"); | ||
608 | _builder.newLine(); | ||
609 | _builder.append("\t"); | ||
610 | _builder.append("S == target;"); | ||
611 | _builder.newLine(); | ||
612 | _builder.append("\t"); | ||
613 | CharSequence _referRelation_25 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "T", "S", Modality.MUST, fqnToPQuery); | ||
614 | _builder.append(_referRelation_25, "\t"); | ||
615 | _builder.newLineIfNotEmpty(); | ||
616 | _builder.append("}"); | ||
617 | _builder.newLine(); | ||
618 | _builder.newLine(); | ||
619 | _builder.append("pattern tooManyInputsOfSegment_must_to_true_by_connectedTo("); | ||
620 | _builder.append(parameters); | ||
621 | _builder.append(", S : DefinedElement) {"); | ||
622 | _builder.newLineIfNotEmpty(); | ||
623 | _builder.append("\t"); | ||
624 | _builder.append("find mustExist(problem, interpretation, S);"); | ||
625 | _builder.newLine(); | ||
626 | _builder.append("\t"); | ||
627 | CharSequence _referInstanceOf_17 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.simpleSegmentType, Modality.MUST, "S"); | ||
628 | _builder.append(_referInstanceOf_17, "\t"); | ||
629 | _builder.newLineIfNotEmpty(); | ||
630 | _builder.append("\t"); | ||
631 | _builder.append("find output_must_to_true_by_connectedTo(problem, interpretation, source, target, I1, S);"); | ||
632 | _builder.newLine(); | ||
633 | _builder.append("\t"); | ||
634 | CharSequence _referPattern_1 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "I2", "S" }, Modality.MUST, true, false); | ||
635 | _builder.append(_referPattern_1, "\t"); | ||
636 | _builder.newLineIfNotEmpty(); | ||
637 | _builder.append("\t"); | ||
638 | CharSequence _referPattern_2 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "I3", "S" }, Modality.MUST, true, false); | ||
639 | _builder.append(_referPattern_2, "\t"); | ||
640 | _builder.newLineIfNotEmpty(); | ||
641 | _builder.append("\t"); | ||
642 | _builder.append("I1 != I2;"); | ||
643 | _builder.newLine(); | ||
644 | _builder.append("\t"); | ||
645 | _builder.append("I1 != I3;"); | ||
646 | _builder.newLine(); | ||
647 | _builder.append("\t"); | ||
648 | _builder.append("I2 != I3;"); | ||
649 | _builder.newLine(); | ||
650 | _builder.append("}"); | ||
651 | _builder.newLine(); | ||
652 | _builder.newLine(); | ||
653 | _builder.append("pattern tooManyInputsOfSegment_must_to_true_by_straight("); | ||
654 | _builder.append(parameters); | ||
655 | _builder.append(", S : DefinedElement) {"); | ||
656 | _builder.newLineIfNotEmpty(); | ||
657 | _builder.append("\t"); | ||
658 | _builder.append("find mustExist(problem, interpretation, S);"); | ||
659 | _builder.newLine(); | ||
660 | _builder.append("\t"); | ||
661 | CharSequence _referInstanceOf_18 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.simpleSegmentType, Modality.MUST, "S"); | ||
662 | _builder.append(_referInstanceOf_18, "\t"); | ||
663 | _builder.newLineIfNotEmpty(); | ||
664 | _builder.append("\t"); | ||
665 | _builder.append("find output_must_to_true_by_straight(problem, interpretation, source, target, I1, S);"); | ||
666 | _builder.newLine(); | ||
667 | _builder.append("\t"); | ||
668 | CharSequence _referPattern_3 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "I2", "S" }, Modality.MUST, true, false); | ||
669 | _builder.append(_referPattern_3, "\t"); | ||
670 | _builder.newLineIfNotEmpty(); | ||
671 | _builder.append("\t"); | ||
672 | CharSequence _referPattern_4 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "I3", "S" }, Modality.MUST, true, false); | ||
673 | _builder.append(_referPattern_4, "\t"); | ||
674 | _builder.newLineIfNotEmpty(); | ||
675 | _builder.append("\t"); | ||
676 | _builder.append("I1 != I2;"); | ||
677 | _builder.newLine(); | ||
678 | _builder.append("\t"); | ||
679 | _builder.append("I1 != I3;"); | ||
680 | _builder.newLine(); | ||
681 | _builder.append("\t"); | ||
682 | _builder.append("I2 != I3;"); | ||
683 | _builder.newLine(); | ||
684 | _builder.append("}"); | ||
685 | _builder.newLine(); | ||
686 | _builder.newLine(); | ||
687 | _builder.append("pattern tooManyInputsOfSegment_must_to_true_by_divergent("); | ||
688 | _builder.append(parameters); | ||
689 | _builder.append(", S : DefinedElement) {"); | ||
690 | _builder.newLineIfNotEmpty(); | ||
691 | _builder.append("\t"); | ||
692 | _builder.append("find mustExist(problem, interpretation, S);"); | ||
693 | _builder.newLine(); | ||
694 | _builder.append("\t"); | ||
695 | CharSequence _referInstanceOf_19 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.simpleSegmentType, Modality.MUST, "S"); | ||
696 | _builder.append(_referInstanceOf_19, "\t"); | ||
697 | _builder.newLineIfNotEmpty(); | ||
698 | _builder.append("\t"); | ||
699 | _builder.append("find output_must_to_true_by_divergent(problem, interpretation, source, target, I1, S);"); | ||
700 | _builder.newLine(); | ||
701 | _builder.append("\t"); | ||
702 | CharSequence _referPattern_5 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "I2", "S" }, Modality.MUST, true, false); | ||
703 | _builder.append(_referPattern_5, "\t"); | ||
704 | _builder.newLineIfNotEmpty(); | ||
705 | _builder.append("\t"); | ||
706 | CharSequence _referPattern_6 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "I3", "S" }, Modality.MUST, true, false); | ||
707 | _builder.append(_referPattern_6, "\t"); | ||
708 | _builder.newLineIfNotEmpty(); | ||
709 | _builder.append("\t"); | ||
710 | _builder.append("I1 != I2;"); | ||
711 | _builder.newLine(); | ||
712 | _builder.append("\t"); | ||
713 | _builder.append("I1 != I3;"); | ||
714 | _builder.newLine(); | ||
715 | _builder.append("\t"); | ||
716 | _builder.append("I2 != I3;"); | ||
717 | _builder.newLine(); | ||
718 | _builder.append("}"); | ||
719 | _builder.newLine(); | ||
720 | _builder.newLine(); | ||
721 | _builder.append("pattern turnoutConnectedToBothOutputs_must_to_true_by_connectedTo("); | ||
722 | _builder.append(parameters); | ||
723 | _builder.append(", T : DefinedElement) {"); | ||
724 | _builder.newLineIfNotEmpty(); | ||
725 | _builder.append("\t"); | ||
726 | _builder.append(commonMayParameterConstraints, "\t"); | ||
727 | _builder.newLineIfNotEmpty(); | ||
728 | _builder.append("\t"); | ||
729 | _builder.append("find mustExist(problem, interpretation, Straight);"); | ||
730 | _builder.newLine(); | ||
731 | _builder.append("\t"); | ||
732 | _builder.append("find mustExist(problem, interpretation, Divergent);"); | ||
733 | _builder.newLine(); | ||
734 | _builder.append("\t"); | ||
735 | CharSequence _referInstanceOf_20 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
736 | _builder.append(_referInstanceOf_20, "\t"); | ||
737 | _builder.newLineIfNotEmpty(); | ||
738 | _builder.append("\t"); | ||
739 | CharSequence _referInstanceOf_21 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
740 | _builder.append(_referInstanceOf_21, "\t"); | ||
741 | _builder.newLineIfNotEmpty(); | ||
742 | _builder.append("\t"); | ||
743 | CharSequence _referInstanceOf_22 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Straight"); | ||
744 | _builder.append(_referInstanceOf_22, "\t"); | ||
745 | _builder.newLineIfNotEmpty(); | ||
746 | _builder.append("\t"); | ||
747 | CharSequence _referInstanceOf_23 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Divergent"); | ||
748 | _builder.append(_referInstanceOf_23, "\t"); | ||
749 | _builder.newLineIfNotEmpty(); | ||
750 | _builder.append("\t"); | ||
751 | CharSequence _referRelation_26 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "T", "Straight", Modality.MUST, fqnToPQuery); | ||
752 | _builder.append(_referRelation_26, "\t"); | ||
753 | _builder.newLineIfNotEmpty(); | ||
754 | _builder.append("\t"); | ||
755 | CharSequence _referRelation_27 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "T", "Divergent", Modality.MUST, fqnToPQuery); | ||
756 | _builder.append(_referRelation_27, "\t"); | ||
757 | _builder.newLineIfNotEmpty(); | ||
758 | _builder.append("\t"); | ||
759 | _builder.append("T == source;"); | ||
760 | _builder.newLine(); | ||
761 | _builder.append("\t"); | ||
762 | _builder.append("Straight == target;"); | ||
763 | _builder.newLine(); | ||
764 | _builder.append("\t"); | ||
765 | CharSequence _referRelation_28 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "T", "Divergent", Modality.MUST, fqnToPQuery); | ||
766 | _builder.append(_referRelation_28, "\t"); | ||
767 | _builder.newLineIfNotEmpty(); | ||
768 | _builder.append("} or {"); | ||
769 | _builder.newLine(); | ||
770 | _builder.append("\t"); | ||
771 | _builder.append(commonMayParameterConstraints, "\t"); | ||
772 | _builder.newLineIfNotEmpty(); | ||
773 | _builder.append("\t"); | ||
774 | _builder.append("find mustExist(problem, interpretation, Straight);"); | ||
775 | _builder.newLine(); | ||
776 | _builder.append("\t"); | ||
777 | _builder.append("find mustExist(problem, interpretation, Divergent);"); | ||
778 | _builder.newLine(); | ||
779 | _builder.append("\t"); | ||
780 | CharSequence _referInstanceOf_24 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
781 | _builder.append(_referInstanceOf_24, "\t"); | ||
782 | _builder.newLineIfNotEmpty(); | ||
783 | _builder.append("\t"); | ||
784 | CharSequence _referInstanceOf_25 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
785 | _builder.append(_referInstanceOf_25, "\t"); | ||
786 | _builder.newLineIfNotEmpty(); | ||
787 | _builder.append("\t"); | ||
788 | CharSequence _referInstanceOf_26 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Straight"); | ||
789 | _builder.append(_referInstanceOf_26, "\t"); | ||
790 | _builder.newLineIfNotEmpty(); | ||
791 | _builder.append("\t"); | ||
792 | CharSequence _referInstanceOf_27 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Divergent"); | ||
793 | _builder.append(_referInstanceOf_27, "\t"); | ||
794 | _builder.newLineIfNotEmpty(); | ||
795 | _builder.append("\t"); | ||
796 | CharSequence _referRelation_29 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "T", "Straight", Modality.MUST, fqnToPQuery); | ||
797 | _builder.append(_referRelation_29, "\t"); | ||
798 | _builder.newLineIfNotEmpty(); | ||
799 | _builder.append("\t"); | ||
800 | CharSequence _referRelation_30 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "T", "Divergent", Modality.MUST, fqnToPQuery); | ||
801 | _builder.append(_referRelation_30, "\t"); | ||
802 | _builder.newLineIfNotEmpty(); | ||
803 | _builder.append("\t"); | ||
804 | CharSequence _referRelation_31 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "T", "Straight", Modality.MUST, fqnToPQuery); | ||
805 | _builder.append(_referRelation_31, "\t"); | ||
806 | _builder.newLineIfNotEmpty(); | ||
807 | _builder.append("\t"); | ||
808 | _builder.append("T == source;"); | ||
809 | _builder.newLine(); | ||
810 | _builder.append("\t"); | ||
811 | _builder.append("Straight == target;"); | ||
812 | _builder.newLine(); | ||
813 | _builder.append("}"); | ||
814 | _builder.newLine(); | ||
815 | _builder.newLine(); | ||
816 | _builder.append("pattern turnoutConnectedToBothOutputs_must_to_true_by_straight("); | ||
817 | _builder.append(parameters); | ||
818 | _builder.append(", T : DefinedElement) {"); | ||
819 | _builder.newLineIfNotEmpty(); | ||
820 | _builder.append("\t"); | ||
821 | _builder.append(commonMayParameterConstraints, "\t"); | ||
822 | _builder.newLineIfNotEmpty(); | ||
823 | _builder.append("\t"); | ||
824 | _builder.append("find mustExist(problem, interpretation, Straight);"); | ||
825 | _builder.newLine(); | ||
826 | _builder.append("\t"); | ||
827 | _builder.append("find mustExist(problem, interpretation, Divergent);"); | ||
828 | _builder.newLine(); | ||
829 | _builder.append("\t"); | ||
830 | CharSequence _referInstanceOf_28 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
831 | _builder.append(_referInstanceOf_28, "\t"); | ||
832 | _builder.newLineIfNotEmpty(); | ||
833 | _builder.append("\t"); | ||
834 | CharSequence _referInstanceOf_29 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
835 | _builder.append(_referInstanceOf_29, "\t"); | ||
836 | _builder.newLineIfNotEmpty(); | ||
837 | _builder.append("\t"); | ||
838 | CharSequence _referInstanceOf_30 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Straight"); | ||
839 | _builder.append(_referInstanceOf_30, "\t"); | ||
840 | _builder.newLineIfNotEmpty(); | ||
841 | _builder.append("\t"); | ||
842 | CharSequence _referInstanceOf_31 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Divergent"); | ||
843 | _builder.append(_referInstanceOf_31, "\t"); | ||
844 | _builder.newLineIfNotEmpty(); | ||
845 | _builder.append("\t"); | ||
846 | _builder.append("T == source;"); | ||
847 | _builder.newLine(); | ||
848 | _builder.append("\t"); | ||
849 | _builder.append("Straight == target;"); | ||
850 | _builder.newLine(); | ||
851 | _builder.append("\t"); | ||
852 | CharSequence _referRelation_32 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "T", "Divergent", Modality.MUST, fqnToPQuery); | ||
853 | _builder.append(_referRelation_32, "\t"); | ||
854 | _builder.newLineIfNotEmpty(); | ||
855 | _builder.append("\t"); | ||
856 | CharSequence _referRelation_33 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "T", "Straight", Modality.MUST, fqnToPQuery); | ||
857 | _builder.append(_referRelation_33, "\t"); | ||
858 | _builder.newLineIfNotEmpty(); | ||
859 | _builder.append("\t"); | ||
860 | CharSequence _referRelation_34 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "T", "Divergent", Modality.MUST, fqnToPQuery); | ||
861 | _builder.append(_referRelation_34, "\t"); | ||
862 | _builder.newLineIfNotEmpty(); | ||
863 | _builder.append("}"); | ||
864 | _builder.newLine(); | ||
865 | _builder.newLine(); | ||
866 | _builder.append("pattern turnoutConnectedToBothOutputs_must_to_true_by_divergent("); | ||
867 | _builder.append(parameters); | ||
868 | _builder.append(", T : DefinedElement) {"); | ||
869 | _builder.newLineIfNotEmpty(); | ||
870 | _builder.append("\t"); | ||
871 | _builder.append(commonMayParameterConstraints, "\t"); | ||
872 | _builder.newLineIfNotEmpty(); | ||
873 | _builder.append("\t"); | ||
874 | _builder.append("find mustExist(problem, interpretation, Straight);"); | ||
875 | _builder.newLine(); | ||
876 | _builder.append("\t"); | ||
877 | _builder.append("find mustExist(problem, interpretation, Divergent);"); | ||
878 | _builder.newLine(); | ||
879 | _builder.append("\t"); | ||
880 | CharSequence _referInstanceOf_32 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
881 | _builder.append(_referInstanceOf_32, "\t"); | ||
882 | _builder.newLineIfNotEmpty(); | ||
883 | _builder.append("\t"); | ||
884 | CharSequence _referInstanceOf_33 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
885 | _builder.append(_referInstanceOf_33, "\t"); | ||
886 | _builder.newLineIfNotEmpty(); | ||
887 | _builder.append("\t"); | ||
888 | CharSequence _referInstanceOf_34 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Straight"); | ||
889 | _builder.append(_referInstanceOf_34, "\t"); | ||
890 | _builder.newLineIfNotEmpty(); | ||
891 | _builder.append("\t"); | ||
892 | CharSequence _referInstanceOf_35 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Divergent"); | ||
893 | _builder.append(_referInstanceOf_35, "\t"); | ||
894 | _builder.newLineIfNotEmpty(); | ||
895 | _builder.append("\t"); | ||
896 | CharSequence _referRelation_35 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "T", "Straight", Modality.MUST, fqnToPQuery); | ||
897 | _builder.append(_referRelation_35, "\t"); | ||
898 | _builder.newLineIfNotEmpty(); | ||
899 | _builder.append("\t"); | ||
900 | _builder.append("T == source;"); | ||
901 | _builder.newLine(); | ||
902 | _builder.append("\t"); | ||
903 | _builder.append("Divergent == target;"); | ||
904 | _builder.newLine(); | ||
905 | _builder.append("\t"); | ||
906 | CharSequence _referRelation_36 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "T", "Straight", Modality.MUST, fqnToPQuery); | ||
907 | _builder.append(_referRelation_36, "\t"); | ||
908 | _builder.newLineIfNotEmpty(); | ||
909 | _builder.append("\t"); | ||
910 | CharSequence _referRelation_37 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "T", "Divergent", Modality.MUST, fqnToPQuery); | ||
911 | _builder.append(_referRelation_37, "\t"); | ||
912 | _builder.newLineIfNotEmpty(); | ||
913 | _builder.append("}"); | ||
914 | _builder.newLine(); | ||
915 | _builder.newLine(); | ||
916 | _builder.append("pattern tooManyInputsOfTurnout_must_to_true_by_connectedTo("); | ||
917 | _builder.append(parameters); | ||
918 | _builder.append(", T : DefinedElement) {"); | ||
919 | _builder.newLineIfNotEmpty(); | ||
920 | _builder.append("\t"); | ||
921 | _builder.append("find mustExist(problem, interpretation, S);"); | ||
922 | _builder.newLine(); | ||
923 | _builder.append("\t"); | ||
924 | CharSequence _referInstanceOf_36 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "S"); | ||
925 | _builder.append(_referInstanceOf_36, "\t"); | ||
926 | _builder.newLineIfNotEmpty(); | ||
927 | _builder.append("\t"); | ||
928 | _builder.append("find adjacent_must_to_true_by_connectedTo(problem, interpretation, source, target, I1, S);"); | ||
929 | _builder.newLine(); | ||
930 | _builder.append("\t"); | ||
931 | CharSequence _referPattern_7 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I2", "S" }, Modality.MUST, true, false); | ||
932 | _builder.append(_referPattern_7, "\t"); | ||
933 | _builder.newLineIfNotEmpty(); | ||
934 | _builder.append("\t"); | ||
935 | CharSequence _referPattern_8 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I3", "S" }, Modality.MUST, true, false); | ||
936 | _builder.append(_referPattern_8, "\t"); | ||
937 | _builder.newLineIfNotEmpty(); | ||
938 | _builder.append("\t"); | ||
939 | CharSequence _referPattern_9 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I4", "S" }, Modality.MUST, true, false); | ||
940 | _builder.append(_referPattern_9, "\t"); | ||
941 | _builder.newLineIfNotEmpty(); | ||
942 | _builder.append("\t"); | ||
943 | _builder.append("I1 != I2;"); | ||
944 | _builder.newLine(); | ||
945 | _builder.append("\t"); | ||
946 | _builder.append("I1 != I3;"); | ||
947 | _builder.newLine(); | ||
948 | _builder.append("\t"); | ||
949 | _builder.append("I1 != I4;"); | ||
950 | _builder.newLine(); | ||
951 | _builder.append("\t"); | ||
952 | _builder.append("I2 != I3;"); | ||
953 | _builder.newLine(); | ||
954 | _builder.append("\t"); | ||
955 | _builder.append("I2 != I4;"); | ||
956 | _builder.newLine(); | ||
957 | _builder.append("\t"); | ||
958 | _builder.append("I3 != I4;"); | ||
959 | _builder.newLine(); | ||
960 | _builder.append("}"); | ||
961 | _builder.newLine(); | ||
962 | _builder.newLine(); | ||
963 | _builder.append("pattern tooManyInputsOfTurnout_must_to_true_by_straight("); | ||
964 | _builder.append(parameters); | ||
965 | _builder.append(", T : DefinedElement) {"); | ||
966 | _builder.newLineIfNotEmpty(); | ||
967 | _builder.append("\t"); | ||
968 | _builder.append("find mustExist(problem, interpretation, S);"); | ||
969 | _builder.newLine(); | ||
970 | _builder.append("\t"); | ||
971 | CharSequence _referInstanceOf_37 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "S"); | ||
972 | _builder.append(_referInstanceOf_37, "\t"); | ||
973 | _builder.newLineIfNotEmpty(); | ||
974 | _builder.append("\t"); | ||
975 | _builder.append("find adjacent_must_to_true_by_straight(problem, interpretation, source, target, I1, S);"); | ||
976 | _builder.newLine(); | ||
977 | _builder.append("\t"); | ||
978 | CharSequence _referPattern_10 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I2", "S" }, Modality.MUST, true, false); | ||
979 | _builder.append(_referPattern_10, "\t"); | ||
980 | _builder.newLineIfNotEmpty(); | ||
981 | _builder.append("\t"); | ||
982 | CharSequence _referPattern_11 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I3", "S" }, Modality.MUST, true, false); | ||
983 | _builder.append(_referPattern_11, "\t"); | ||
984 | _builder.newLineIfNotEmpty(); | ||
985 | _builder.append("\t"); | ||
986 | CharSequence _referPattern_12 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I4", "S" }, Modality.MUST, true, false); | ||
987 | _builder.append(_referPattern_12, "\t"); | ||
988 | _builder.newLineIfNotEmpty(); | ||
989 | _builder.append("\t"); | ||
990 | _builder.append("I1 != I2;"); | ||
991 | _builder.newLine(); | ||
992 | _builder.append("\t"); | ||
993 | _builder.append("I1 != I3;"); | ||
994 | _builder.newLine(); | ||
995 | _builder.append("\t"); | ||
996 | _builder.append("I1 != I4;"); | ||
997 | _builder.newLine(); | ||
998 | _builder.append("\t"); | ||
999 | _builder.append("I2 != I3;"); | ||
1000 | _builder.newLine(); | ||
1001 | _builder.append("\t"); | ||
1002 | _builder.append("I2 != I4;"); | ||
1003 | _builder.newLine(); | ||
1004 | _builder.append("\t"); | ||
1005 | _builder.append("I3 != I4;"); | ||
1006 | _builder.newLine(); | ||
1007 | _builder.append("}"); | ||
1008 | _builder.newLine(); | ||
1009 | _builder.newLine(); | ||
1010 | _builder.append("pattern tooManyInputsOfTurnout_must_to_true_by_divergent("); | ||
1011 | _builder.append(parameters); | ||
1012 | _builder.append(", T : DefinedElement) {"); | ||
1013 | _builder.newLineIfNotEmpty(); | ||
1014 | _builder.append("\t"); | ||
1015 | _builder.append("find mustExist(problem, interpretation, S);"); | ||
1016 | _builder.newLine(); | ||
1017 | _builder.append("\t"); | ||
1018 | CharSequence _referInstanceOf_38 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "S"); | ||
1019 | _builder.append(_referInstanceOf_38, "\t"); | ||
1020 | _builder.newLineIfNotEmpty(); | ||
1021 | _builder.append("\t"); | ||
1022 | _builder.append("find adjacent_must_to_true_by_divergent(problem, interpretation, source, target, I1, S);"); | ||
1023 | _builder.newLine(); | ||
1024 | _builder.append("\t"); | ||
1025 | CharSequence _referPattern_13 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I2", "S" }, Modality.MUST, true, false); | ||
1026 | _builder.append(_referPattern_13, "\t"); | ||
1027 | _builder.newLineIfNotEmpty(); | ||
1028 | _builder.append("\t"); | ||
1029 | CharSequence _referPattern_14 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I3", "S" }, Modality.MUST, true, false); | ||
1030 | _builder.append(_referPattern_14, "\t"); | ||
1031 | _builder.newLineIfNotEmpty(); | ||
1032 | _builder.append("\t"); | ||
1033 | CharSequence _referPattern_15 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I4", "S" }, Modality.MUST, true, false); | ||
1034 | _builder.append(_referPattern_15, "\t"); | ||
1035 | _builder.newLineIfNotEmpty(); | ||
1036 | _builder.append("\t"); | ||
1037 | _builder.append("I1 != I2;"); | ||
1038 | _builder.newLine(); | ||
1039 | _builder.append("\t"); | ||
1040 | _builder.append("I1 != I3;"); | ||
1041 | _builder.newLine(); | ||
1042 | _builder.append("\t"); | ||
1043 | _builder.append("I1 != I4;"); | ||
1044 | _builder.newLine(); | ||
1045 | _builder.append("\t"); | ||
1046 | _builder.append("I2 != I3;"); | ||
1047 | _builder.newLine(); | ||
1048 | _builder.append("\t"); | ||
1049 | _builder.append("I2 != I4;"); | ||
1050 | _builder.newLine(); | ||
1051 | _builder.append("\t"); | ||
1052 | _builder.append("I3 != I4;"); | ||
1053 | _builder.newLine(); | ||
1054 | _builder.append("}"); | ||
1055 | _builder.newLine(); | ||
1056 | _builder.newLine(); | ||
1057 | _builder.append("pattern "); | ||
1058 | _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO); | ||
1059 | _builder.append("_helper("); | ||
1060 | _builder.append(parameters); | ||
1061 | _builder.append(") {"); | ||
1062 | _builder.newLineIfNotEmpty(); | ||
1063 | _builder.append("\t"); | ||
1064 | _builder.append("find connectedToReflexive_must_to_true_by_connectedTo(problem, interpretation, source, target, _);"); | ||
1065 | _builder.newLine(); | ||
1066 | _builder.append("} or {"); | ||
1067 | _builder.newLine(); | ||
1068 | _builder.append("\t"); | ||
1069 | _builder.append("find tooManyInputsOfSegment_must_to_true_by_connectedTo(problem, interpretation, source, target, _);"); | ||
1070 | _builder.newLine(); | ||
1071 | _builder.append("} or {"); | ||
1072 | _builder.newLine(); | ||
1073 | _builder.append("\t"); | ||
1074 | _builder.append("find turnoutConnectedToBothOutputs_must_to_true_by_connectedTo(problem, interpretation, source, target, _);"); | ||
1075 | _builder.newLine(); | ||
1076 | _builder.append("} or {"); | ||
1077 | _builder.newLine(); | ||
1078 | _builder.append("\t"); | ||
1079 | _builder.append("find tooManyInputsOfTurnout_must_to_true_by_connectedTo(problem, interpretation, source, target, _);"); | ||
1080 | _builder.newLine(); | ||
1081 | _builder.append("}"); | ||
1082 | _builder.newLine(); | ||
1083 | _builder.newLine(); | ||
1084 | _builder.append("pattern "); | ||
1085 | _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO); | ||
1086 | _builder.append("("); | ||
1087 | _builder.append(parameters); | ||
1088 | _builder.append(") {"); | ||
1089 | _builder.newLineIfNotEmpty(); | ||
1090 | _builder.append("\t"); | ||
1091 | _builder.append("find "); | ||
1092 | _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO, "\t"); | ||
1093 | _builder.append("_helper(problem, interpretation, source, target);"); | ||
1094 | _builder.newLineIfNotEmpty(); | ||
1095 | _builder.append("} or {"); | ||
1096 | _builder.newLine(); | ||
1097 | _builder.append("\t"); | ||
1098 | _builder.append("find "); | ||
1099 | _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO, "\t"); | ||
1100 | _builder.append("_helper(problem, interpretation, target, source);"); | ||
1101 | _builder.newLineIfNotEmpty(); | ||
1102 | _builder.append("}"); | ||
1103 | _builder.newLine(); | ||
1104 | _builder.newLine(); | ||
1105 | _builder.append("pattern "); | ||
1106 | _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_STRAIGHT); | ||
1107 | _builder.append("("); | ||
1108 | _builder.append(parameters); | ||
1109 | _builder.append(") {"); | ||
1110 | _builder.newLineIfNotEmpty(); | ||
1111 | _builder.append("\t"); | ||
1112 | _builder.append("find outputReflexive_must_to_true_by_straight(problem, interpretation, source, target, _);"); | ||
1113 | _builder.newLine(); | ||
1114 | _builder.append("} or {"); | ||
1115 | _builder.newLine(); | ||
1116 | _builder.append("\t"); | ||
1117 | _builder.append("find turnoutOutputsAreSame_must_to_true_by_straight(problem, interpretation, source, target, _);"); | ||
1118 | _builder.newLine(); | ||
1119 | _builder.append("} or {"); | ||
1120 | _builder.newLine(); | ||
1121 | _builder.append("\t"); | ||
1122 | _builder.append("find tooManyInputsOfSegment_must_to_true_by_straight(problem, interpretation, source, target, _);"); | ||
1123 | _builder.newLine(); | ||
1124 | _builder.append("} or {"); | ||
1125 | _builder.newLine(); | ||
1126 | _builder.append("\t"); | ||
1127 | _builder.append("find turnoutConnectedToBothOutputs_must_to_true_by_straight(problem, interpretation, source, target, _);"); | ||
1128 | _builder.newLine(); | ||
1129 | _builder.append("} or {"); | ||
1130 | _builder.newLine(); | ||
1131 | _builder.append("\t"); | ||
1132 | _builder.append("find tooManyInputsOfTurnout_must_to_true_by_straight(problem, interpretation, source, target, _);"); | ||
1133 | _builder.newLine(); | ||
1134 | _builder.append("}"); | ||
1135 | _builder.newLine(); | ||
1136 | _builder.newLine(); | ||
1137 | _builder.append("pattern "); | ||
1138 | _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_DIVERGENT); | ||
1139 | _builder.append("("); | ||
1140 | _builder.append(parameters); | ||
1141 | _builder.append(") {"); | ||
1142 | _builder.newLineIfNotEmpty(); | ||
1143 | _builder.append("\t"); | ||
1144 | _builder.append("find outputReflexive_must_to_true_by_divergent(problem, interpretation, source, target, _);"); | ||
1145 | _builder.newLine(); | ||
1146 | _builder.append("} or {"); | ||
1147 | _builder.newLine(); | ||
1148 | _builder.append("\t"); | ||
1149 | _builder.append("find turnoutOutputsAreSame_must_to_true_by_divergent(problem, interpretation, source, target, _);"); | ||
1150 | _builder.newLine(); | ||
1151 | _builder.append("} or {"); | ||
1152 | _builder.newLine(); | ||
1153 | _builder.append("\t"); | ||
1154 | _builder.append("find tooManyInputsOfSegment_must_to_true_by_divergent(problem, interpretation, source, target, _);"); | ||
1155 | _builder.newLine(); | ||
1156 | _builder.append("} or {"); | ||
1157 | _builder.newLine(); | ||
1158 | _builder.append("\t"); | ||
1159 | _builder.append("find turnoutConnectedToBothOutputs_must_to_true_by_divergent(problem, interpretation, source, target, _);"); | ||
1160 | _builder.newLine(); | ||
1161 | _builder.append("} or {"); | ||
1162 | _builder.newLine(); | ||
1163 | _builder.append("\t"); | ||
1164 | _builder.append("find tooManyInputsOfTurnout_must_to_true_by_divergent(problem, interpretation, source, target, _);"); | ||
1165 | _builder.newLine(); | ||
1166 | _builder.append("}"); | ||
1167 | _builder.newLine(); | ||
1168 | } | ||
1169 | }; | ||
1170 | _xblockexpression = _client_3; | ||
1171 | } | ||
1172 | return _xblockexpression; | ||
1173 | } | ||
1174 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/TrainLocationsObjectiveHint.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/TrainLocationsObjectiveHint.java new file mode 100644 index 00000000..570f9deb --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/TrainLocationsObjectiveHint.java | |||
@@ -0,0 +1,117 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import com.google.common.collect.ImmutableList; | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Dimension; | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilder; | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory; | ||
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator; | ||
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch; | ||
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers; | ||
13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint; | ||
14 | import java.util.Collection; | ||
15 | import java.util.List; | ||
16 | import java.util.Map; | ||
17 | import java.util.Set; | ||
18 | import modes3.Modes3Package; | ||
19 | import modes3.queries.TrainLocations_step_2; | ||
20 | import modes3.queries.TrainLocations_step_3; | ||
21 | import org.eclipse.xtext.xbase.lib.Extension; | ||
22 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
23 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
24 | |||
25 | @SuppressWarnings("all") | ||
26 | public class TrainLocationsObjectiveHint extends CostObjectiveHint { | ||
27 | private final Type segmentType; | ||
28 | |||
29 | private final Type trainType; | ||
30 | |||
31 | public TrainLocationsObjectiveHint(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { | ||
32 | @Extension | ||
33 | final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; | ||
34 | this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); | ||
35 | this.trainType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTrain()); | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | public boolean isExact() { | ||
40 | return true; | ||
41 | } | ||
42 | |||
43 | @Override | ||
44 | public PolyhedronExtensionOperator createPolyhedronExtensionOperator(final Map<String, CostElementMatchers> costElementMatchers) { | ||
45 | PolyhedronExtensionOperator _xblockexpression = null; | ||
46 | { | ||
47 | final CostElementMatchers step2 = costElementMatchers.get(TrainLocations_step_2.instance().getFullyQualifiedName()); | ||
48 | final CostElementMatchers step3 = costElementMatchers.get(TrainLocations_step_3.instance().getFullyQualifiedName()); | ||
49 | final PolyhedronExtensionOperator _function = (ExtendedLinearExpressionBuilderFactory it) -> { | ||
50 | final ExtendedLinearExpressionBuilder objectiveBuilder = it.createBuilder(); | ||
51 | ImmutableList<CostElementMatch> _matches = step2.getMatches(); | ||
52 | for (final CostElementMatch m : _matches) { | ||
53 | { | ||
54 | final Dimension dimension = it.getDimension(m.getMatch()); | ||
55 | objectiveBuilder.add(step2.getWeight(), dimension); | ||
56 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
57 | boolean _isMulti = m.isMulti(); | ||
58 | if (_isMulti) { | ||
59 | it.createBuilder().add(1, dimension).add((-1), this.trainType).build().assertEqualsTo(0); | ||
60 | } else { | ||
61 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
62 | boolean _isMust = m.isMust(); | ||
63 | if (_isMust) { | ||
64 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | final ImmutableList<CostElementMatch> step3Matches = step3.getMatches(); | ||
70 | for (final CostElementMatch m_1 : step3Matches) { | ||
71 | { | ||
72 | final Dimension dimension = it.getDimension(m_1.getMatch()); | ||
73 | objectiveBuilder.add(step3.getWeight(), dimension); | ||
74 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
75 | boolean _isMulti = m_1.isMulti(); | ||
76 | boolean _not = (!_isMulti); | ||
77 | if (_not) { | ||
78 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
79 | boolean _isMust = m_1.isMust(); | ||
80 | if (_isMust) { | ||
81 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | TrainLocationsObjectiveHint.boundLimit(it, step3Matches, 2, this.trainType, 1); | ||
87 | TrainLocationsObjectiveHint.boundLimit(it, step3Matches, 3, this.segmentType, 1); | ||
88 | this.buildWithBounds(objectiveBuilder); | ||
89 | }; | ||
90 | _xblockexpression = _function; | ||
91 | } | ||
92 | return _xblockexpression; | ||
93 | } | ||
94 | |||
95 | private static void boundLimit(@Extension final ExtendedLinearExpressionBuilderFactory factory, final Collection<CostElementMatch> matches, final int index, final Type type, final int count) { | ||
96 | final Function1<CostElementMatch, Object> _function = (CostElementMatch it) -> { | ||
97 | return it.getMatch().get(index); | ||
98 | }; | ||
99 | Set<Map.Entry<Object, List<CostElementMatch>>> _entrySet = IterableExtensions.<Object, CostElementMatch>groupBy(matches, _function).entrySet(); | ||
100 | for (final Map.Entry<Object, List<CostElementMatch>> pair : _entrySet) { | ||
101 | { | ||
102 | final ExtendedLinearExpressionBuilder multiplicityBuilder = factory.createBuilder(); | ||
103 | List<CostElementMatch> _value = pair.getValue(); | ||
104 | for (final CostElementMatch m : _value) { | ||
105 | multiplicityBuilder.add(1, m.getMatch()); | ||
106 | } | ||
107 | boolean _isMulti = CostElementMatchers.isMulti(pair.getKey()); | ||
108 | if (_isMulti) { | ||
109 | multiplicityBuilder.add((-count), type); | ||
110 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
111 | } else { | ||
112 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(count)); | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/META-INF/MANIFEST.MF b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/META-INF/MANIFEST.MF index 5fb85170..cc71bd06 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/META-INF/MANIFEST.MF +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/META-INF/MANIFEST.MF | |||
@@ -15,7 +15,6 @@ Require-Bundle: org.eclipse.viatra.addon.querybasedfeatures.runtime, | |||
15 | org.eclipse.viatra.query.runtime, | 15 | org.eclipse.viatra.query.runtime, |
16 | org.eclipse.core.runtime, | 16 | org.eclipse.core.runtime, |
17 | org.eclipse.emf.ecore;visibility:=reexport, | 17 | org.eclipse.emf.ecore;visibility:=reexport, |
18 | org.eclipse.emf.emfstore.common, | ||
19 | com.google.guava, | 18 | com.google.guava, |
20 | org.eclipse.xtext.xbase.lib, | 19 | org.eclipse.xtext.xbase.lib, |
21 | org.eclipse.xtend.lib, | 20 | org.eclipse.xtend.lib, |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/.gitignore index 52338993..1e7d444f 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/.gitignore +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/.gitignore | |||
@@ -42,3 +42,11 @@ | |||
42 | /.Opposite.java._trace | 42 | /.Opposite.java._trace |
43 | /.OppositeDifferentClass.java._trace | 43 | /.OppositeDifferentClass.java._trace |
44 | /.PatternContent.java._trace | 44 | /.PatternContent.java._trace |
45 | /ContentInNotLive.java | ||
46 | /DirectSupertype.java | ||
47 | /Live.java | ||
48 | /LoopInInheritence.java | ||
49 | /NonSymmetricOpposite.java | ||
50 | /Opposite.java | ||
51 | /OppositeDifferentClass.java | ||
52 | /PatternContent.java | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Dir.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Dir.java new file mode 100644 index 00000000..83195aea --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Dir.java | |||
@@ -0,0 +1,543 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/FileSystem.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.alloyexamples; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import org.apache.log4j.Logger; | ||
17 | import org.eclipse.emf.ecore.EClass; | ||
18 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
19 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
20 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
21 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
25 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
36 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
37 | |||
38 | /** | ||
39 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
40 | * | ||
41 | * <p>Original source: | ||
42 | * <code><pre> | ||
43 | * pattern dir(d: Dir) { | ||
44 | * Dir(d); | ||
45 | * } | ||
46 | * </pre></code> | ||
47 | * | ||
48 | * @see Matcher | ||
49 | * @see Match | ||
50 | * | ||
51 | */ | ||
52 | @SuppressWarnings("all") | ||
53 | public final class Dir extends BaseGeneratedEMFQuerySpecification<Dir.Matcher> { | ||
54 | /** | ||
55 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.dir pattern, | ||
56 | * to be used in conjunction with {@link Matcher}. | ||
57 | * | ||
58 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
59 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
60 | * usable to represent a match of the pattern in the result of a query, | ||
61 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
62 | * | ||
63 | * @see Matcher | ||
64 | * | ||
65 | */ | ||
66 | public static abstract class Match extends BasePatternMatch { | ||
67 | private hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir fD; | ||
68 | |||
69 | private static List<String> parameterNames = makeImmutableList("d"); | ||
70 | |||
71 | private Match(final hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir pD) { | ||
72 | this.fD = pD; | ||
73 | } | ||
74 | |||
75 | @Override | ||
76 | public Object get(final String parameterName) { | ||
77 | switch(parameterName) { | ||
78 | case "d": return this.fD; | ||
79 | default: return null; | ||
80 | } | ||
81 | } | ||
82 | |||
83 | @Override | ||
84 | public Object get(final int index) { | ||
85 | switch(index) { | ||
86 | case 0: return this.fD; | ||
87 | default: return null; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | public hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir getD() { | ||
92 | return this.fD; | ||
93 | } | ||
94 | |||
95 | @Override | ||
96 | public boolean set(final String parameterName, final Object newValue) { | ||
97 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
98 | if ("d".equals(parameterName) ) { | ||
99 | this.fD = (hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir) newValue; | ||
100 | return true; | ||
101 | } | ||
102 | return false; | ||
103 | } | ||
104 | |||
105 | public void setD(final hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir pD) { | ||
106 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
107 | this.fD = pD; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public String patternName() { | ||
112 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.dir"; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public List<String> parameterNames() { | ||
117 | return Dir.Match.parameterNames; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public Object[] toArray() { | ||
122 | return new Object[]{fD}; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public Dir.Match toImmutable() { | ||
127 | return isMutable() ? newMatch(fD) : this; | ||
128 | } | ||
129 | |||
130 | @Override | ||
131 | public String prettyPrint() { | ||
132 | StringBuilder result = new StringBuilder(); | ||
133 | result.append("\"d\"=" + prettyPrintValue(fD)); | ||
134 | return result.toString(); | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public int hashCode() { | ||
139 | return Objects.hash(fD); | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public boolean equals(final Object obj) { | ||
144 | if (this == obj) | ||
145 | return true; | ||
146 | if (obj == null) { | ||
147 | return false; | ||
148 | } | ||
149 | if ((obj instanceof Dir.Match)) { | ||
150 | Dir.Match other = (Dir.Match) obj; | ||
151 | return Objects.equals(fD, other.fD); | ||
152 | } else { | ||
153 | // this should be infrequent | ||
154 | if (!(obj instanceof IPatternMatch)) { | ||
155 | return false; | ||
156 | } | ||
157 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
158 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
159 | } | ||
160 | } | ||
161 | |||
162 | @Override | ||
163 | public Dir specification() { | ||
164 | return Dir.instance(); | ||
165 | } | ||
166 | |||
167 | /** | ||
168 | * Returns an empty, mutable match. | ||
169 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
170 | * | ||
171 | * @return the empty match. | ||
172 | * | ||
173 | */ | ||
174 | public static Dir.Match newEmptyMatch() { | ||
175 | return new Mutable(null); | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * Returns a mutable (partial) match. | ||
180 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
181 | * | ||
182 | * @param pD the fixed value of pattern parameter d, or null if not bound. | ||
183 | * @return the new, mutable (partial) match object. | ||
184 | * | ||
185 | */ | ||
186 | public static Dir.Match newMutableMatch(final hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir pD) { | ||
187 | return new Mutable(pD); | ||
188 | } | ||
189 | |||
190 | /** | ||
191 | * Returns a new (partial) match. | ||
192 | * This can be used e.g. to call the matcher with a partial match. | ||
193 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
194 | * @param pD the fixed value of pattern parameter d, or null if not bound. | ||
195 | * @return the (partial) match object. | ||
196 | * | ||
197 | */ | ||
198 | public static Dir.Match newMatch(final hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir pD) { | ||
199 | return new Immutable(pD); | ||
200 | } | ||
201 | |||
202 | private static final class Mutable extends Dir.Match { | ||
203 | Mutable(final hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir pD) { | ||
204 | super(pD); | ||
205 | } | ||
206 | |||
207 | @Override | ||
208 | public boolean isMutable() { | ||
209 | return true; | ||
210 | } | ||
211 | } | ||
212 | |||
213 | private static final class Immutable extends Dir.Match { | ||
214 | Immutable(final hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir pD) { | ||
215 | super(pD); | ||
216 | } | ||
217 | |||
218 | @Override | ||
219 | public boolean isMutable() { | ||
220 | return false; | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | |||
225 | /** | ||
226 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.dir pattern, | ||
227 | * providing pattern-specific query methods. | ||
228 | * | ||
229 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
230 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
231 | * | ||
232 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
233 | * | ||
234 | * <p>Original source: | ||
235 | * <code><pre> | ||
236 | * pattern dir(d: Dir) { | ||
237 | * Dir(d); | ||
238 | * } | ||
239 | * </pre></code> | ||
240 | * | ||
241 | * @see Match | ||
242 | * @see Dir | ||
243 | * | ||
244 | */ | ||
245 | public static class Matcher extends BaseMatcher<Dir.Match> { | ||
246 | /** | ||
247 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
248 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
249 | * | ||
250 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
251 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
252 | * | ||
253 | */ | ||
254 | public static Dir.Matcher on(final ViatraQueryEngine engine) { | ||
255 | // check if matcher already exists | ||
256 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
257 | if (matcher == null) { | ||
258 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
259 | } | ||
260 | return matcher; | ||
261 | } | ||
262 | |||
263 | /** | ||
264 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
265 | * @return an initialized matcher | ||
266 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
267 | * | ||
268 | */ | ||
269 | public static Dir.Matcher create() { | ||
270 | return new Matcher(); | ||
271 | } | ||
272 | |||
273 | private static final int POSITION_D = 0; | ||
274 | |||
275 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Dir.Matcher.class); | ||
276 | |||
277 | /** | ||
278 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
279 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
280 | * | ||
281 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
282 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
283 | * | ||
284 | */ | ||
285 | private Matcher() { | ||
286 | super(querySpecification()); | ||
287 | } | ||
288 | |||
289 | /** | ||
290 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
291 | * @param pD the fixed value of pattern parameter d, or null if not bound. | ||
292 | * @return matches represented as a Match object. | ||
293 | * | ||
294 | */ | ||
295 | public Collection<Dir.Match> getAllMatches(final hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir pD) { | ||
296 | return rawStreamAllMatches(new Object[]{pD}).collect(Collectors.toSet()); | ||
297 | } | ||
298 | |||
299 | /** | ||
300 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
301 | * </p> | ||
302 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
303 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
304 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
305 | * @param pD the fixed value of pattern parameter d, or null if not bound. | ||
306 | * @return a stream of matches represented as a Match object. | ||
307 | * | ||
308 | */ | ||
309 | public Stream<Dir.Match> streamAllMatches(final hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir pD) { | ||
310 | return rawStreamAllMatches(new Object[]{pD}); | ||
311 | } | ||
312 | |||
313 | /** | ||
314 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
315 | * Neither determinism nor randomness of selection is guaranteed. | ||
316 | * @param pD the fixed value of pattern parameter d, or null if not bound. | ||
317 | * @return a match represented as a Match object, or null if no match is found. | ||
318 | * | ||
319 | */ | ||
320 | public Optional<Dir.Match> getOneArbitraryMatch(final hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir pD) { | ||
321 | return rawGetOneArbitraryMatch(new Object[]{pD}); | ||
322 | } | ||
323 | |||
324 | /** | ||
325 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
326 | * under any possible substitution of the unspecified parameters (if any). | ||
327 | * @param pD the fixed value of pattern parameter d, or null if not bound. | ||
328 | * @return true if the input is a valid (partial) match of the pattern. | ||
329 | * | ||
330 | */ | ||
331 | public boolean hasMatch(final hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir pD) { | ||
332 | return rawHasMatch(new Object[]{pD}); | ||
333 | } | ||
334 | |||
335 | /** | ||
336 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
337 | * @param pD the fixed value of pattern parameter d, or null if not bound. | ||
338 | * @return the number of pattern matches found. | ||
339 | * | ||
340 | */ | ||
341 | public int countMatches(final hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir pD) { | ||
342 | return rawCountMatches(new Object[]{pD}); | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
347 | * Neither determinism nor randomness of selection is guaranteed. | ||
348 | * @param pD the fixed value of pattern parameter d, or null if not bound. | ||
349 | * @param processor the action that will process the selected match. | ||
350 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
351 | * | ||
352 | */ | ||
353 | public boolean forOneArbitraryMatch(final hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir pD, final Consumer<? super Dir.Match> processor) { | ||
354 | return rawForOneArbitraryMatch(new Object[]{pD}, processor); | ||
355 | } | ||
356 | |||
357 | /** | ||
358 | * Returns a new (partial) match. | ||
359 | * This can be used e.g. to call the matcher with a partial match. | ||
360 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
361 | * @param pD the fixed value of pattern parameter d, or null if not bound. | ||
362 | * @return the (partial) match object. | ||
363 | * | ||
364 | */ | ||
365 | public Dir.Match newMatch(final hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir pD) { | ||
366 | return Dir.Match.newMatch(pD); | ||
367 | } | ||
368 | |||
369 | /** | ||
370 | * Retrieve the set of values that occur in matches for d. | ||
371 | * @return the Set of all values or empty set if there are no matches | ||
372 | * | ||
373 | */ | ||
374 | protected Stream<hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir> rawStreamAllValuesOfd(final Object[] parameters) { | ||
375 | return rawStreamAllValues(POSITION_D, parameters).map(hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir.class::cast); | ||
376 | } | ||
377 | |||
378 | /** | ||
379 | * Retrieve the set of values that occur in matches for d. | ||
380 | * @return the Set of all values or empty set if there are no matches | ||
381 | * | ||
382 | */ | ||
383 | public Set<hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir> getAllValuesOfd() { | ||
384 | return rawStreamAllValuesOfd(emptyArray()).collect(Collectors.toSet()); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * Retrieve the set of values that occur in matches for d. | ||
389 | * @return the Set of all values or empty set if there are no matches | ||
390 | * | ||
391 | */ | ||
392 | public Stream<hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir> streamAllValuesOfd() { | ||
393 | return rawStreamAllValuesOfd(emptyArray()); | ||
394 | } | ||
395 | |||
396 | @Override | ||
397 | protected Dir.Match tupleToMatch(final Tuple t) { | ||
398 | try { | ||
399 | return Dir.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir) t.get(POSITION_D)); | ||
400 | } catch(ClassCastException e) { | ||
401 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
402 | return null; | ||
403 | } | ||
404 | } | ||
405 | |||
406 | @Override | ||
407 | protected Dir.Match arrayToMatch(final Object[] match) { | ||
408 | try { | ||
409 | return Dir.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir) match[POSITION_D]); | ||
410 | } catch(ClassCastException e) { | ||
411 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
412 | return null; | ||
413 | } | ||
414 | } | ||
415 | |||
416 | @Override | ||
417 | protected Dir.Match arrayToMatchMutable(final Object[] match) { | ||
418 | try { | ||
419 | return Dir.Match.newMutableMatch((hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir) match[POSITION_D]); | ||
420 | } catch(ClassCastException e) { | ||
421 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
422 | return null; | ||
423 | } | ||
424 | } | ||
425 | |||
426 | /** | ||
427 | * @return the singleton instance of the query specification of this pattern | ||
428 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
429 | * | ||
430 | */ | ||
431 | public static IQuerySpecification<Dir.Matcher> querySpecification() { | ||
432 | return Dir.instance(); | ||
433 | } | ||
434 | } | ||
435 | |||
436 | private Dir() { | ||
437 | super(GeneratedPQuery.INSTANCE); | ||
438 | } | ||
439 | |||
440 | /** | ||
441 | * @return the singleton instance of the query specification | ||
442 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
443 | * | ||
444 | */ | ||
445 | public static Dir instance() { | ||
446 | try{ | ||
447 | return LazyHolder.INSTANCE; | ||
448 | } catch (ExceptionInInitializerError err) { | ||
449 | throw processInitializerError(err); | ||
450 | } | ||
451 | } | ||
452 | |||
453 | @Override | ||
454 | protected Dir.Matcher instantiate(final ViatraQueryEngine engine) { | ||
455 | return Dir.Matcher.on(engine); | ||
456 | } | ||
457 | |||
458 | @Override | ||
459 | public Dir.Matcher instantiate() { | ||
460 | return Dir.Matcher.create(); | ||
461 | } | ||
462 | |||
463 | @Override | ||
464 | public Dir.Match newEmptyMatch() { | ||
465 | return Dir.Match.newEmptyMatch(); | ||
466 | } | ||
467 | |||
468 | @Override | ||
469 | public Dir.Match newMatch(final Object... parameters) { | ||
470 | return Dir.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir) parameters[0]); | ||
471 | } | ||
472 | |||
473 | /** | ||
474 | * Inner class allowing the singleton instance of {@link Dir} to be created | ||
475 | * <b>not</b> at the class load time of the outer class, | ||
476 | * but rather at the first call to {@link Dir#instance()}. | ||
477 | * | ||
478 | * <p> This workaround is required e.g. to support recursion. | ||
479 | * | ||
480 | */ | ||
481 | private static class LazyHolder { | ||
482 | private static final Dir INSTANCE = new Dir(); | ||
483 | |||
484 | /** | ||
485 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
486 | * This initialization order is required to support indirect recursion. | ||
487 | * | ||
488 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
489 | * | ||
490 | */ | ||
491 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
492 | |||
493 | public static Object ensureInitialized() { | ||
494 | INSTANCE.ensureInitializedInternal(); | ||
495 | return null; | ||
496 | } | ||
497 | } | ||
498 | |||
499 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
500 | private static final Dir.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
501 | |||
502 | private final PParameter parameter_d = new PParameter("d", "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("FS", "Dir")), PParameterDirection.INOUT); | ||
503 | |||
504 | private final List<PParameter> parameters = Arrays.asList(parameter_d); | ||
505 | |||
506 | private GeneratedPQuery() { | ||
507 | super(PVisibility.PUBLIC); | ||
508 | } | ||
509 | |||
510 | @Override | ||
511 | public String getFullyQualifiedName() { | ||
512 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.dir"; | ||
513 | } | ||
514 | |||
515 | @Override | ||
516 | public List<String> getParameterNames() { | ||
517 | return Arrays.asList("d"); | ||
518 | } | ||
519 | |||
520 | @Override | ||
521 | public List<PParameter> getParameters() { | ||
522 | return parameters; | ||
523 | } | ||
524 | |||
525 | @Override | ||
526 | public Set<PBody> doGetContainedBodies() { | ||
527 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
528 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
529 | { | ||
530 | PBody body = new PBody(this); | ||
531 | PVariable var_d = body.getOrCreateVariableByName("d"); | ||
532 | new TypeConstraint(body, Tuples.flatTupleOf(var_d), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "Dir"))); | ||
533 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
534 | new ExportedParameter(body, var_d, parameter_d) | ||
535 | )); | ||
536 | // Dir(d) | ||
537 | new TypeConstraint(body, Tuples.flatTupleOf(var_d), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "Dir"))); | ||
538 | bodies.add(body); | ||
539 | } | ||
540 | return bodies; | ||
541 | } | ||
542 | } | ||
543 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/RootIsNotDir.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/RootIsNotDir.java new file mode 100644 index 00000000..e2d9c175 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/RootIsNotDir.java | |||
@@ -0,0 +1,570 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/FileSystem.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.alloyexamples; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Dir; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FileSystem; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
43 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
44 | |||
45 | /** | ||
46 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
47 | * | ||
48 | * <p>Original source: | ||
49 | * <code><pre> | ||
50 | * {@literal @}Constraint(key={fs}, severity="error", message="error") | ||
51 | * pattern rootIsNotDir(fs: FileSystem) { | ||
52 | * FileSystem.root(fs, root); | ||
53 | * neg find dir(root); | ||
54 | * } | ||
55 | * </pre></code> | ||
56 | * | ||
57 | * @see Matcher | ||
58 | * @see Match | ||
59 | * | ||
60 | */ | ||
61 | @SuppressWarnings("all") | ||
62 | public final class RootIsNotDir extends BaseGeneratedEMFQuerySpecification<RootIsNotDir.Matcher> { | ||
63 | /** | ||
64 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.rootIsNotDir pattern, | ||
65 | * to be used in conjunction with {@link Matcher}. | ||
66 | * | ||
67 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
68 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
69 | * usable to represent a match of the pattern in the result of a query, | ||
70 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
71 | * | ||
72 | * @see Matcher | ||
73 | * | ||
74 | */ | ||
75 | public static abstract class Match extends BasePatternMatch { | ||
76 | private FileSystem fFs; | ||
77 | |||
78 | private static List<String> parameterNames = makeImmutableList("fs"); | ||
79 | |||
80 | private Match(final FileSystem pFs) { | ||
81 | this.fFs = pFs; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | switch(parameterName) { | ||
87 | case "fs": return this.fFs; | ||
88 | default: return null; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | @Override | ||
93 | public Object get(final int index) { | ||
94 | switch(index) { | ||
95 | case 0: return this.fFs; | ||
96 | default: return null; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | public FileSystem getFs() { | ||
101 | return this.fFs; | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public boolean set(final String parameterName, final Object newValue) { | ||
106 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
107 | if ("fs".equals(parameterName) ) { | ||
108 | this.fFs = (FileSystem) newValue; | ||
109 | return true; | ||
110 | } | ||
111 | return false; | ||
112 | } | ||
113 | |||
114 | public void setFs(final FileSystem pFs) { | ||
115 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
116 | this.fFs = pFs; | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public String patternName() { | ||
121 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.rootIsNotDir"; | ||
122 | } | ||
123 | |||
124 | @Override | ||
125 | public List<String> parameterNames() { | ||
126 | return RootIsNotDir.Match.parameterNames; | ||
127 | } | ||
128 | |||
129 | @Override | ||
130 | public Object[] toArray() { | ||
131 | return new Object[]{fFs}; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public RootIsNotDir.Match toImmutable() { | ||
136 | return isMutable() ? newMatch(fFs) : this; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public String prettyPrint() { | ||
141 | StringBuilder result = new StringBuilder(); | ||
142 | result.append("\"fs\"=" + prettyPrintValue(fFs)); | ||
143 | return result.toString(); | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public int hashCode() { | ||
148 | return Objects.hash(fFs); | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public boolean equals(final Object obj) { | ||
153 | if (this == obj) | ||
154 | return true; | ||
155 | if (obj == null) { | ||
156 | return false; | ||
157 | } | ||
158 | if ((obj instanceof RootIsNotDir.Match)) { | ||
159 | RootIsNotDir.Match other = (RootIsNotDir.Match) obj; | ||
160 | return Objects.equals(fFs, other.fFs); | ||
161 | } else { | ||
162 | // this should be infrequent | ||
163 | if (!(obj instanceof IPatternMatch)) { | ||
164 | return false; | ||
165 | } | ||
166 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
167 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
168 | } | ||
169 | } | ||
170 | |||
171 | @Override | ||
172 | public RootIsNotDir specification() { | ||
173 | return RootIsNotDir.instance(); | ||
174 | } | ||
175 | |||
176 | /** | ||
177 | * Returns an empty, mutable match. | ||
178 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
179 | * | ||
180 | * @return the empty match. | ||
181 | * | ||
182 | */ | ||
183 | public static RootIsNotDir.Match newEmptyMatch() { | ||
184 | return new Mutable(null); | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * Returns a mutable (partial) match. | ||
189 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
190 | * | ||
191 | * @param pFs the fixed value of pattern parameter fs, or null if not bound. | ||
192 | * @return the new, mutable (partial) match object. | ||
193 | * | ||
194 | */ | ||
195 | public static RootIsNotDir.Match newMutableMatch(final FileSystem pFs) { | ||
196 | return new Mutable(pFs); | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * Returns a new (partial) match. | ||
201 | * This can be used e.g. to call the matcher with a partial match. | ||
202 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
203 | * @param pFs the fixed value of pattern parameter fs, or null if not bound. | ||
204 | * @return the (partial) match object. | ||
205 | * | ||
206 | */ | ||
207 | public static RootIsNotDir.Match newMatch(final FileSystem pFs) { | ||
208 | return new Immutable(pFs); | ||
209 | } | ||
210 | |||
211 | private static final class Mutable extends RootIsNotDir.Match { | ||
212 | Mutable(final FileSystem pFs) { | ||
213 | super(pFs); | ||
214 | } | ||
215 | |||
216 | @Override | ||
217 | public boolean isMutable() { | ||
218 | return true; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | private static final class Immutable extends RootIsNotDir.Match { | ||
223 | Immutable(final FileSystem pFs) { | ||
224 | super(pFs); | ||
225 | } | ||
226 | |||
227 | @Override | ||
228 | public boolean isMutable() { | ||
229 | return false; | ||
230 | } | ||
231 | } | ||
232 | } | ||
233 | |||
234 | /** | ||
235 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.rootIsNotDir pattern, | ||
236 | * providing pattern-specific query methods. | ||
237 | * | ||
238 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
239 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
240 | * | ||
241 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
242 | * | ||
243 | * <p>Original source: | ||
244 | * <code><pre> | ||
245 | * {@literal @}Constraint(key={fs}, severity="error", message="error") | ||
246 | * pattern rootIsNotDir(fs: FileSystem) { | ||
247 | * FileSystem.root(fs, root); | ||
248 | * neg find dir(root); | ||
249 | * } | ||
250 | * </pre></code> | ||
251 | * | ||
252 | * @see Match | ||
253 | * @see RootIsNotDir | ||
254 | * | ||
255 | */ | ||
256 | public static class Matcher extends BaseMatcher<RootIsNotDir.Match> { | ||
257 | /** | ||
258 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
259 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
260 | * | ||
261 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
262 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
263 | * | ||
264 | */ | ||
265 | public static RootIsNotDir.Matcher on(final ViatraQueryEngine engine) { | ||
266 | // check if matcher already exists | ||
267 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
268 | if (matcher == null) { | ||
269 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
270 | } | ||
271 | return matcher; | ||
272 | } | ||
273 | |||
274 | /** | ||
275 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
276 | * @return an initialized matcher | ||
277 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
278 | * | ||
279 | */ | ||
280 | public static RootIsNotDir.Matcher create() { | ||
281 | return new Matcher(); | ||
282 | } | ||
283 | |||
284 | private static final int POSITION_FS = 0; | ||
285 | |||
286 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(RootIsNotDir.Matcher.class); | ||
287 | |||
288 | /** | ||
289 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
290 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
291 | * | ||
292 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
293 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
294 | * | ||
295 | */ | ||
296 | private Matcher() { | ||
297 | super(querySpecification()); | ||
298 | } | ||
299 | |||
300 | /** | ||
301 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
302 | * @param pFs the fixed value of pattern parameter fs, or null if not bound. | ||
303 | * @return matches represented as a Match object. | ||
304 | * | ||
305 | */ | ||
306 | public Collection<RootIsNotDir.Match> getAllMatches(final FileSystem pFs) { | ||
307 | return rawStreamAllMatches(new Object[]{pFs}).collect(Collectors.toSet()); | ||
308 | } | ||
309 | |||
310 | /** | ||
311 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
312 | * </p> | ||
313 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
314 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
315 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
316 | * @param pFs the fixed value of pattern parameter fs, or null if not bound. | ||
317 | * @return a stream of matches represented as a Match object. | ||
318 | * | ||
319 | */ | ||
320 | public Stream<RootIsNotDir.Match> streamAllMatches(final FileSystem pFs) { | ||
321 | return rawStreamAllMatches(new Object[]{pFs}); | ||
322 | } | ||
323 | |||
324 | /** | ||
325 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
326 | * Neither determinism nor randomness of selection is guaranteed. | ||
327 | * @param pFs the fixed value of pattern parameter fs, or null if not bound. | ||
328 | * @return a match represented as a Match object, or null if no match is found. | ||
329 | * | ||
330 | */ | ||
331 | public Optional<RootIsNotDir.Match> getOneArbitraryMatch(final FileSystem pFs) { | ||
332 | return rawGetOneArbitraryMatch(new Object[]{pFs}); | ||
333 | } | ||
334 | |||
335 | /** | ||
336 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
337 | * under any possible substitution of the unspecified parameters (if any). | ||
338 | * @param pFs the fixed value of pattern parameter fs, or null if not bound. | ||
339 | * @return true if the input is a valid (partial) match of the pattern. | ||
340 | * | ||
341 | */ | ||
342 | public boolean hasMatch(final FileSystem pFs) { | ||
343 | return rawHasMatch(new Object[]{pFs}); | ||
344 | } | ||
345 | |||
346 | /** | ||
347 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
348 | * @param pFs the fixed value of pattern parameter fs, or null if not bound. | ||
349 | * @return the number of pattern matches found. | ||
350 | * | ||
351 | */ | ||
352 | public int countMatches(final FileSystem pFs) { | ||
353 | return rawCountMatches(new Object[]{pFs}); | ||
354 | } | ||
355 | |||
356 | /** | ||
357 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
358 | * Neither determinism nor randomness of selection is guaranteed. | ||
359 | * @param pFs the fixed value of pattern parameter fs, or null if not bound. | ||
360 | * @param processor the action that will process the selected match. | ||
361 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
362 | * | ||
363 | */ | ||
364 | public boolean forOneArbitraryMatch(final FileSystem pFs, final Consumer<? super RootIsNotDir.Match> processor) { | ||
365 | return rawForOneArbitraryMatch(new Object[]{pFs}, processor); | ||
366 | } | ||
367 | |||
368 | /** | ||
369 | * Returns a new (partial) match. | ||
370 | * This can be used e.g. to call the matcher with a partial match. | ||
371 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
372 | * @param pFs the fixed value of pattern parameter fs, or null if not bound. | ||
373 | * @return the (partial) match object. | ||
374 | * | ||
375 | */ | ||
376 | public RootIsNotDir.Match newMatch(final FileSystem pFs) { | ||
377 | return RootIsNotDir.Match.newMatch(pFs); | ||
378 | } | ||
379 | |||
380 | /** | ||
381 | * Retrieve the set of values that occur in matches for fs. | ||
382 | * @return the Set of all values or empty set if there are no matches | ||
383 | * | ||
384 | */ | ||
385 | protected Stream<FileSystem> rawStreamAllValuesOffs(final Object[] parameters) { | ||
386 | return rawStreamAllValues(POSITION_FS, parameters).map(FileSystem.class::cast); | ||
387 | } | ||
388 | |||
389 | /** | ||
390 | * Retrieve the set of values that occur in matches for fs. | ||
391 | * @return the Set of all values or empty set if there are no matches | ||
392 | * | ||
393 | */ | ||
394 | public Set<FileSystem> getAllValuesOffs() { | ||
395 | return rawStreamAllValuesOffs(emptyArray()).collect(Collectors.toSet()); | ||
396 | } | ||
397 | |||
398 | /** | ||
399 | * Retrieve the set of values that occur in matches for fs. | ||
400 | * @return the Set of all values or empty set if there are no matches | ||
401 | * | ||
402 | */ | ||
403 | public Stream<FileSystem> streamAllValuesOffs() { | ||
404 | return rawStreamAllValuesOffs(emptyArray()); | ||
405 | } | ||
406 | |||
407 | @Override | ||
408 | protected RootIsNotDir.Match tupleToMatch(final Tuple t) { | ||
409 | try { | ||
410 | return RootIsNotDir.Match.newMatch((FileSystem) t.get(POSITION_FS)); | ||
411 | } catch(ClassCastException e) { | ||
412 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
413 | return null; | ||
414 | } | ||
415 | } | ||
416 | |||
417 | @Override | ||
418 | protected RootIsNotDir.Match arrayToMatch(final Object[] match) { | ||
419 | try { | ||
420 | return RootIsNotDir.Match.newMatch((FileSystem) match[POSITION_FS]); | ||
421 | } catch(ClassCastException e) { | ||
422 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
423 | return null; | ||
424 | } | ||
425 | } | ||
426 | |||
427 | @Override | ||
428 | protected RootIsNotDir.Match arrayToMatchMutable(final Object[] match) { | ||
429 | try { | ||
430 | return RootIsNotDir.Match.newMutableMatch((FileSystem) match[POSITION_FS]); | ||
431 | } catch(ClassCastException e) { | ||
432 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
433 | return null; | ||
434 | } | ||
435 | } | ||
436 | |||
437 | /** | ||
438 | * @return the singleton instance of the query specification of this pattern | ||
439 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
440 | * | ||
441 | */ | ||
442 | public static IQuerySpecification<RootIsNotDir.Matcher> querySpecification() { | ||
443 | return RootIsNotDir.instance(); | ||
444 | } | ||
445 | } | ||
446 | |||
447 | private RootIsNotDir() { | ||
448 | super(GeneratedPQuery.INSTANCE); | ||
449 | } | ||
450 | |||
451 | /** | ||
452 | * @return the singleton instance of the query specification | ||
453 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
454 | * | ||
455 | */ | ||
456 | public static RootIsNotDir instance() { | ||
457 | try{ | ||
458 | return LazyHolder.INSTANCE; | ||
459 | } catch (ExceptionInInitializerError err) { | ||
460 | throw processInitializerError(err); | ||
461 | } | ||
462 | } | ||
463 | |||
464 | @Override | ||
465 | protected RootIsNotDir.Matcher instantiate(final ViatraQueryEngine engine) { | ||
466 | return RootIsNotDir.Matcher.on(engine); | ||
467 | } | ||
468 | |||
469 | @Override | ||
470 | public RootIsNotDir.Matcher instantiate() { | ||
471 | return RootIsNotDir.Matcher.create(); | ||
472 | } | ||
473 | |||
474 | @Override | ||
475 | public RootIsNotDir.Match newEmptyMatch() { | ||
476 | return RootIsNotDir.Match.newEmptyMatch(); | ||
477 | } | ||
478 | |||
479 | @Override | ||
480 | public RootIsNotDir.Match newMatch(final Object... parameters) { | ||
481 | return RootIsNotDir.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FileSystem) parameters[0]); | ||
482 | } | ||
483 | |||
484 | /** | ||
485 | * Inner class allowing the singleton instance of {@link RootIsNotDir} to be created | ||
486 | * <b>not</b> at the class load time of the outer class, | ||
487 | * but rather at the first call to {@link RootIsNotDir#instance()}. | ||
488 | * | ||
489 | * <p> This workaround is required e.g. to support recursion. | ||
490 | * | ||
491 | */ | ||
492 | private static class LazyHolder { | ||
493 | private static final RootIsNotDir INSTANCE = new RootIsNotDir(); | ||
494 | |||
495 | /** | ||
496 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
497 | * This initialization order is required to support indirect recursion. | ||
498 | * | ||
499 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
500 | * | ||
501 | */ | ||
502 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
503 | |||
504 | public static Object ensureInitialized() { | ||
505 | INSTANCE.ensureInitializedInternal(); | ||
506 | return null; | ||
507 | } | ||
508 | } | ||
509 | |||
510 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
511 | private static final RootIsNotDir.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
512 | |||
513 | private final PParameter parameter_fs = new PParameter("fs", "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FileSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("FS", "FileSystem")), PParameterDirection.INOUT); | ||
514 | |||
515 | private final List<PParameter> parameters = Arrays.asList(parameter_fs); | ||
516 | |||
517 | private GeneratedPQuery() { | ||
518 | super(PVisibility.PUBLIC); | ||
519 | } | ||
520 | |||
521 | @Override | ||
522 | public String getFullyQualifiedName() { | ||
523 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.rootIsNotDir"; | ||
524 | } | ||
525 | |||
526 | @Override | ||
527 | public List<String> getParameterNames() { | ||
528 | return Arrays.asList("fs"); | ||
529 | } | ||
530 | |||
531 | @Override | ||
532 | public List<PParameter> getParameters() { | ||
533 | return parameters; | ||
534 | } | ||
535 | |||
536 | @Override | ||
537 | public Set<PBody> doGetContainedBodies() { | ||
538 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
539 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
540 | { | ||
541 | PBody body = new PBody(this); | ||
542 | PVariable var_fs = body.getOrCreateVariableByName("fs"); | ||
543 | PVariable var_root = body.getOrCreateVariableByName("root"); | ||
544 | new TypeConstraint(body, Tuples.flatTupleOf(var_fs), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FileSystem"))); | ||
545 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
546 | new ExportedParameter(body, var_fs, parameter_fs) | ||
547 | )); | ||
548 | // FileSystem.root(fs, root) | ||
549 | new TypeConstraint(body, Tuples.flatTupleOf(var_fs), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FileSystem"))); | ||
550 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
551 | new TypeConstraint(body, Tuples.flatTupleOf(var_fs, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("FS", "FileSystem", "root"))); | ||
552 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FSObject"))); | ||
553 | new Equality(body, var__virtual_0_, var_root); | ||
554 | // neg find dir(root) | ||
555 | new NegativePatternCall(body, Tuples.flatTupleOf(var_root), Dir.instance().getInternalQueryRepresentation()); | ||
556 | bodies.add(body); | ||
557 | } | ||
558 | { | ||
559 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
560 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
561 | new ParameterReference("fs") | ||
562 | })); | ||
563 | annotation.addAttribute("severity", "error"); | ||
564 | annotation.addAttribute("message", "error"); | ||
565 | addAnnotation(annotation); | ||
566 | } | ||
567 | return bodies; | ||
568 | } | ||
569 | } | ||
570 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Unsat_loopInInheritance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Unsat_loopInInheritance.java new file mode 100644 index 00000000..83bd0f66 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Unsat_loopInInheritance.java | |||
@@ -0,0 +1,566 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Ecore.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.alloyexamples; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.LoopInInheritence; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Unsat_subpackage; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.emf.ecore.EPackage; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
42 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
43 | |||
44 | /** | ||
45 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
46 | * | ||
47 | * <p>Original source: | ||
48 | * <code><pre> | ||
49 | * {@literal @}Constraint(key={p}, severity="error", message="error") | ||
50 | * pattern unsat_loopInInheritance(p: EPackage) { | ||
51 | * neg find unsat_subpackage(_, p); | ||
52 | * neg find loopInInheritence(_); | ||
53 | * } | ||
54 | * </pre></code> | ||
55 | * | ||
56 | * @see Matcher | ||
57 | * @see Match | ||
58 | * | ||
59 | */ | ||
60 | @SuppressWarnings("all") | ||
61 | public final class Unsat_loopInInheritance extends BaseGeneratedEMFQuerySpecification<Unsat_loopInInheritance.Matcher> { | ||
62 | /** | ||
63 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_loopInInheritance pattern, | ||
64 | * to be used in conjunction with {@link Matcher}. | ||
65 | * | ||
66 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
67 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
68 | * usable to represent a match of the pattern in the result of a query, | ||
69 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
70 | * | ||
71 | * @see Matcher | ||
72 | * | ||
73 | */ | ||
74 | public static abstract class Match extends BasePatternMatch { | ||
75 | private EPackage fP; | ||
76 | |||
77 | private static List<String> parameterNames = makeImmutableList("p"); | ||
78 | |||
79 | private Match(final EPackage pP) { | ||
80 | this.fP = pP; | ||
81 | } | ||
82 | |||
83 | @Override | ||
84 | public Object get(final String parameterName) { | ||
85 | switch(parameterName) { | ||
86 | case "p": return this.fP; | ||
87 | default: return null; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | @Override | ||
92 | public Object get(final int index) { | ||
93 | switch(index) { | ||
94 | case 0: return this.fP; | ||
95 | default: return null; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | public EPackage getP() { | ||
100 | return this.fP; | ||
101 | } | ||
102 | |||
103 | @Override | ||
104 | public boolean set(final String parameterName, final Object newValue) { | ||
105 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
106 | if ("p".equals(parameterName) ) { | ||
107 | this.fP = (EPackage) newValue; | ||
108 | return true; | ||
109 | } | ||
110 | return false; | ||
111 | } | ||
112 | |||
113 | public void setP(final EPackage pP) { | ||
114 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
115 | this.fP = pP; | ||
116 | } | ||
117 | |||
118 | @Override | ||
119 | public String patternName() { | ||
120 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_loopInInheritance"; | ||
121 | } | ||
122 | |||
123 | @Override | ||
124 | public List<String> parameterNames() { | ||
125 | return Unsat_loopInInheritance.Match.parameterNames; | ||
126 | } | ||
127 | |||
128 | @Override | ||
129 | public Object[] toArray() { | ||
130 | return new Object[]{fP}; | ||
131 | } | ||
132 | |||
133 | @Override | ||
134 | public Unsat_loopInInheritance.Match toImmutable() { | ||
135 | return isMutable() ? newMatch(fP) : this; | ||
136 | } | ||
137 | |||
138 | @Override | ||
139 | public String prettyPrint() { | ||
140 | StringBuilder result = new StringBuilder(); | ||
141 | result.append("\"p\"=" + prettyPrintValue(fP)); | ||
142 | return result.toString(); | ||
143 | } | ||
144 | |||
145 | @Override | ||
146 | public int hashCode() { | ||
147 | return Objects.hash(fP); | ||
148 | } | ||
149 | |||
150 | @Override | ||
151 | public boolean equals(final Object obj) { | ||
152 | if (this == obj) | ||
153 | return true; | ||
154 | if (obj == null) { | ||
155 | return false; | ||
156 | } | ||
157 | if ((obj instanceof Unsat_loopInInheritance.Match)) { | ||
158 | Unsat_loopInInheritance.Match other = (Unsat_loopInInheritance.Match) obj; | ||
159 | return Objects.equals(fP, other.fP); | ||
160 | } else { | ||
161 | // this should be infrequent | ||
162 | if (!(obj instanceof IPatternMatch)) { | ||
163 | return false; | ||
164 | } | ||
165 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
166 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
167 | } | ||
168 | } | ||
169 | |||
170 | @Override | ||
171 | public Unsat_loopInInheritance specification() { | ||
172 | return Unsat_loopInInheritance.instance(); | ||
173 | } | ||
174 | |||
175 | /** | ||
176 | * Returns an empty, mutable match. | ||
177 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
178 | * | ||
179 | * @return the empty match. | ||
180 | * | ||
181 | */ | ||
182 | public static Unsat_loopInInheritance.Match newEmptyMatch() { | ||
183 | return new Mutable(null); | ||
184 | } | ||
185 | |||
186 | /** | ||
187 | * Returns a mutable (partial) match. | ||
188 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
189 | * | ||
190 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
191 | * @return the new, mutable (partial) match object. | ||
192 | * | ||
193 | */ | ||
194 | public static Unsat_loopInInheritance.Match newMutableMatch(final EPackage pP) { | ||
195 | return new Mutable(pP); | ||
196 | } | ||
197 | |||
198 | /** | ||
199 | * Returns a new (partial) match. | ||
200 | * This can be used e.g. to call the matcher with a partial match. | ||
201 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
202 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
203 | * @return the (partial) match object. | ||
204 | * | ||
205 | */ | ||
206 | public static Unsat_loopInInheritance.Match newMatch(final EPackage pP) { | ||
207 | return new Immutable(pP); | ||
208 | } | ||
209 | |||
210 | private static final class Mutable extends Unsat_loopInInheritance.Match { | ||
211 | Mutable(final EPackage pP) { | ||
212 | super(pP); | ||
213 | } | ||
214 | |||
215 | @Override | ||
216 | public boolean isMutable() { | ||
217 | return true; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | private static final class Immutable extends Unsat_loopInInheritance.Match { | ||
222 | Immutable(final EPackage pP) { | ||
223 | super(pP); | ||
224 | } | ||
225 | |||
226 | @Override | ||
227 | public boolean isMutable() { | ||
228 | return false; | ||
229 | } | ||
230 | } | ||
231 | } | ||
232 | |||
233 | /** | ||
234 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_loopInInheritance pattern, | ||
235 | * providing pattern-specific query methods. | ||
236 | * | ||
237 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
238 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
239 | * | ||
240 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
241 | * | ||
242 | * <p>Original source: | ||
243 | * <code><pre> | ||
244 | * {@literal @}Constraint(key={p}, severity="error", message="error") | ||
245 | * pattern unsat_loopInInheritance(p: EPackage) { | ||
246 | * neg find unsat_subpackage(_, p); | ||
247 | * neg find loopInInheritence(_); | ||
248 | * } | ||
249 | * </pre></code> | ||
250 | * | ||
251 | * @see Match | ||
252 | * @see Unsat_loopInInheritance | ||
253 | * | ||
254 | */ | ||
255 | public static class Matcher extends BaseMatcher<Unsat_loopInInheritance.Match> { | ||
256 | /** | ||
257 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
258 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
259 | * | ||
260 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
261 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
262 | * | ||
263 | */ | ||
264 | public static Unsat_loopInInheritance.Matcher on(final ViatraQueryEngine engine) { | ||
265 | // check if matcher already exists | ||
266 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
267 | if (matcher == null) { | ||
268 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
269 | } | ||
270 | return matcher; | ||
271 | } | ||
272 | |||
273 | /** | ||
274 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
275 | * @return an initialized matcher | ||
276 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
277 | * | ||
278 | */ | ||
279 | public static Unsat_loopInInheritance.Matcher create() { | ||
280 | return new Matcher(); | ||
281 | } | ||
282 | |||
283 | private static final int POSITION_P = 0; | ||
284 | |||
285 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Unsat_loopInInheritance.Matcher.class); | ||
286 | |||
287 | /** | ||
288 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
289 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
290 | * | ||
291 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
292 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
293 | * | ||
294 | */ | ||
295 | private Matcher() { | ||
296 | super(querySpecification()); | ||
297 | } | ||
298 | |||
299 | /** | ||
300 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
301 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
302 | * @return matches represented as a Match object. | ||
303 | * | ||
304 | */ | ||
305 | public Collection<Unsat_loopInInheritance.Match> getAllMatches(final EPackage pP) { | ||
306 | return rawStreamAllMatches(new Object[]{pP}).collect(Collectors.toSet()); | ||
307 | } | ||
308 | |||
309 | /** | ||
310 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
311 | * </p> | ||
312 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
313 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
314 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
315 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
316 | * @return a stream of matches represented as a Match object. | ||
317 | * | ||
318 | */ | ||
319 | public Stream<Unsat_loopInInheritance.Match> streamAllMatches(final EPackage pP) { | ||
320 | return rawStreamAllMatches(new Object[]{pP}); | ||
321 | } | ||
322 | |||
323 | /** | ||
324 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
325 | * Neither determinism nor randomness of selection is guaranteed. | ||
326 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
327 | * @return a match represented as a Match object, or null if no match is found. | ||
328 | * | ||
329 | */ | ||
330 | public Optional<Unsat_loopInInheritance.Match> getOneArbitraryMatch(final EPackage pP) { | ||
331 | return rawGetOneArbitraryMatch(new Object[]{pP}); | ||
332 | } | ||
333 | |||
334 | /** | ||
335 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
336 | * under any possible substitution of the unspecified parameters (if any). | ||
337 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
338 | * @return true if the input is a valid (partial) match of the pattern. | ||
339 | * | ||
340 | */ | ||
341 | public boolean hasMatch(final EPackage pP) { | ||
342 | return rawHasMatch(new Object[]{pP}); | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
347 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
348 | * @return the number of pattern matches found. | ||
349 | * | ||
350 | */ | ||
351 | public int countMatches(final EPackage pP) { | ||
352 | return rawCountMatches(new Object[]{pP}); | ||
353 | } | ||
354 | |||
355 | /** | ||
356 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
357 | * Neither determinism nor randomness of selection is guaranteed. | ||
358 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
359 | * @param processor the action that will process the selected match. | ||
360 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
361 | * | ||
362 | */ | ||
363 | public boolean forOneArbitraryMatch(final EPackage pP, final Consumer<? super Unsat_loopInInheritance.Match> processor) { | ||
364 | return rawForOneArbitraryMatch(new Object[]{pP}, processor); | ||
365 | } | ||
366 | |||
367 | /** | ||
368 | * Returns a new (partial) match. | ||
369 | * This can be used e.g. to call the matcher with a partial match. | ||
370 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
371 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
372 | * @return the (partial) match object. | ||
373 | * | ||
374 | */ | ||
375 | public Unsat_loopInInheritance.Match newMatch(final EPackage pP) { | ||
376 | return Unsat_loopInInheritance.Match.newMatch(pP); | ||
377 | } | ||
378 | |||
379 | /** | ||
380 | * Retrieve the set of values that occur in matches for p. | ||
381 | * @return the Set of all values or empty set if there are no matches | ||
382 | * | ||
383 | */ | ||
384 | protected Stream<EPackage> rawStreamAllValuesOfp(final Object[] parameters) { | ||
385 | return rawStreamAllValues(POSITION_P, parameters).map(EPackage.class::cast); | ||
386 | } | ||
387 | |||
388 | /** | ||
389 | * Retrieve the set of values that occur in matches for p. | ||
390 | * @return the Set of all values or empty set if there are no matches | ||
391 | * | ||
392 | */ | ||
393 | public Set<EPackage> getAllValuesOfp() { | ||
394 | return rawStreamAllValuesOfp(emptyArray()).collect(Collectors.toSet()); | ||
395 | } | ||
396 | |||
397 | /** | ||
398 | * Retrieve the set of values that occur in matches for p. | ||
399 | * @return the Set of all values or empty set if there are no matches | ||
400 | * | ||
401 | */ | ||
402 | public Stream<EPackage> streamAllValuesOfp() { | ||
403 | return rawStreamAllValuesOfp(emptyArray()); | ||
404 | } | ||
405 | |||
406 | @Override | ||
407 | protected Unsat_loopInInheritance.Match tupleToMatch(final Tuple t) { | ||
408 | try { | ||
409 | return Unsat_loopInInheritance.Match.newMatch((EPackage) t.get(POSITION_P)); | ||
410 | } catch(ClassCastException e) { | ||
411 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
412 | return null; | ||
413 | } | ||
414 | } | ||
415 | |||
416 | @Override | ||
417 | protected Unsat_loopInInheritance.Match arrayToMatch(final Object[] match) { | ||
418 | try { | ||
419 | return Unsat_loopInInheritance.Match.newMatch((EPackage) match[POSITION_P]); | ||
420 | } catch(ClassCastException e) { | ||
421 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
422 | return null; | ||
423 | } | ||
424 | } | ||
425 | |||
426 | @Override | ||
427 | protected Unsat_loopInInheritance.Match arrayToMatchMutable(final Object[] match) { | ||
428 | try { | ||
429 | return Unsat_loopInInheritance.Match.newMutableMatch((EPackage) match[POSITION_P]); | ||
430 | } catch(ClassCastException e) { | ||
431 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
432 | return null; | ||
433 | } | ||
434 | } | ||
435 | |||
436 | /** | ||
437 | * @return the singleton instance of the query specification of this pattern | ||
438 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
439 | * | ||
440 | */ | ||
441 | public static IQuerySpecification<Unsat_loopInInheritance.Matcher> querySpecification() { | ||
442 | return Unsat_loopInInheritance.instance(); | ||
443 | } | ||
444 | } | ||
445 | |||
446 | private Unsat_loopInInheritance() { | ||
447 | super(GeneratedPQuery.INSTANCE); | ||
448 | } | ||
449 | |||
450 | /** | ||
451 | * @return the singleton instance of the query specification | ||
452 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
453 | * | ||
454 | */ | ||
455 | public static Unsat_loopInInheritance instance() { | ||
456 | try{ | ||
457 | return LazyHolder.INSTANCE; | ||
458 | } catch (ExceptionInInitializerError err) { | ||
459 | throw processInitializerError(err); | ||
460 | } | ||
461 | } | ||
462 | |||
463 | @Override | ||
464 | protected Unsat_loopInInheritance.Matcher instantiate(final ViatraQueryEngine engine) { | ||
465 | return Unsat_loopInInheritance.Matcher.on(engine); | ||
466 | } | ||
467 | |||
468 | @Override | ||
469 | public Unsat_loopInInheritance.Matcher instantiate() { | ||
470 | return Unsat_loopInInheritance.Matcher.create(); | ||
471 | } | ||
472 | |||
473 | @Override | ||
474 | public Unsat_loopInInheritance.Match newEmptyMatch() { | ||
475 | return Unsat_loopInInheritance.Match.newEmptyMatch(); | ||
476 | } | ||
477 | |||
478 | @Override | ||
479 | public Unsat_loopInInheritance.Match newMatch(final Object... parameters) { | ||
480 | return Unsat_loopInInheritance.Match.newMatch((org.eclipse.emf.ecore.EPackage) parameters[0]); | ||
481 | } | ||
482 | |||
483 | /** | ||
484 | * Inner class allowing the singleton instance of {@link Unsat_loopInInheritance} to be created | ||
485 | * <b>not</b> at the class load time of the outer class, | ||
486 | * but rather at the first call to {@link Unsat_loopInInheritance#instance()}. | ||
487 | * | ||
488 | * <p> This workaround is required e.g. to support recursion. | ||
489 | * | ||
490 | */ | ||
491 | private static class LazyHolder { | ||
492 | private static final Unsat_loopInInheritance INSTANCE = new Unsat_loopInInheritance(); | ||
493 | |||
494 | /** | ||
495 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
496 | * This initialization order is required to support indirect recursion. | ||
497 | * | ||
498 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
499 | * | ||
500 | */ | ||
501 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
502 | |||
503 | public static Object ensureInitialized() { | ||
504 | INSTANCE.ensureInitializedInternal(); | ||
505 | return null; | ||
506 | } | ||
507 | } | ||
508 | |||
509 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
510 | private static final Unsat_loopInInheritance.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
511 | |||
512 | private final PParameter parameter_p = new PParameter("p", "org.eclipse.emf.ecore.EPackage", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EPackage")), PParameterDirection.INOUT); | ||
513 | |||
514 | private final List<PParameter> parameters = Arrays.asList(parameter_p); | ||
515 | |||
516 | private GeneratedPQuery() { | ||
517 | super(PVisibility.PUBLIC); | ||
518 | } | ||
519 | |||
520 | @Override | ||
521 | public String getFullyQualifiedName() { | ||
522 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_loopInInheritance"; | ||
523 | } | ||
524 | |||
525 | @Override | ||
526 | public List<String> getParameterNames() { | ||
527 | return Arrays.asList("p"); | ||
528 | } | ||
529 | |||
530 | @Override | ||
531 | public List<PParameter> getParameters() { | ||
532 | return parameters; | ||
533 | } | ||
534 | |||
535 | @Override | ||
536 | public Set<PBody> doGetContainedBodies() { | ||
537 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
538 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
539 | { | ||
540 | PBody body = new PBody(this); | ||
541 | PVariable var_p = body.getOrCreateVariableByName("p"); | ||
542 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
543 | PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); | ||
544 | new TypeConstraint(body, Tuples.flatTupleOf(var_p), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); | ||
545 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
546 | new ExportedParameter(body, var_p, parameter_p) | ||
547 | )); | ||
548 | // neg find unsat_subpackage(_, p) | ||
549 | new NegativePatternCall(body, Tuples.flatTupleOf(var___0_, var_p), Unsat_subpackage.instance().getInternalQueryRepresentation()); | ||
550 | // neg find loopInInheritence(_) | ||
551 | new NegativePatternCall(body, Tuples.flatTupleOf(var___1_), LoopInInheritence.instance().getInternalQueryRepresentation()); | ||
552 | bodies.add(body); | ||
553 | } | ||
554 | { | ||
555 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
556 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
557 | new ParameterReference("p") | ||
558 | })); | ||
559 | annotation.addAttribute("severity", "error"); | ||
560 | annotation.addAttribute("message", "error"); | ||
561 | addAnnotation(annotation); | ||
562 | } | ||
563 | return bodies; | ||
564 | } | ||
565 | } | ||
566 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Unsat_subpackage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Unsat_subpackage.java new file mode 100644 index 00000000..a9c8aed8 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Unsat_subpackage.java | |||
@@ -0,0 +1,704 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Ecore.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.alloyexamples; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import org.apache.log4j.Logger; | ||
17 | import org.eclipse.emf.ecore.EClass; | ||
18 | import org.eclipse.emf.ecore.EPackage; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
40 | |||
41 | /** | ||
42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
43 | * | ||
44 | * <p>Original source: | ||
45 | * <code><pre> | ||
46 | * pattern unsat_subpackage(a: EPackage, b: EPackage) { | ||
47 | * EPackage.eSubpackages(a, b); | ||
48 | * } | ||
49 | * </pre></code> | ||
50 | * | ||
51 | * @see Matcher | ||
52 | * @see Match | ||
53 | * | ||
54 | */ | ||
55 | @SuppressWarnings("all") | ||
56 | public final class Unsat_subpackage extends BaseGeneratedEMFQuerySpecification<Unsat_subpackage.Matcher> { | ||
57 | /** | ||
58 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_subpackage pattern, | ||
59 | * to be used in conjunction with {@link Matcher}. | ||
60 | * | ||
61 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
62 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
63 | * usable to represent a match of the pattern in the result of a query, | ||
64 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
65 | * | ||
66 | * @see Matcher | ||
67 | * | ||
68 | */ | ||
69 | public static abstract class Match extends BasePatternMatch { | ||
70 | private EPackage fA; | ||
71 | |||
72 | private EPackage fB; | ||
73 | |||
74 | private static List<String> parameterNames = makeImmutableList("a", "b"); | ||
75 | |||
76 | private Match(final EPackage pA, final EPackage pB) { | ||
77 | this.fA = pA; | ||
78 | this.fB = pB; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "a": return this.fA; | ||
85 | case "b": return this.fB; | ||
86 | default: return null; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | @Override | ||
91 | public Object get(final int index) { | ||
92 | switch(index) { | ||
93 | case 0: return this.fA; | ||
94 | case 1: return this.fB; | ||
95 | default: return null; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | public EPackage getA() { | ||
100 | return this.fA; | ||
101 | } | ||
102 | |||
103 | public EPackage getB() { | ||
104 | return this.fB; | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public boolean set(final String parameterName, final Object newValue) { | ||
109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
110 | if ("a".equals(parameterName) ) { | ||
111 | this.fA = (EPackage) newValue; | ||
112 | return true; | ||
113 | } | ||
114 | if ("b".equals(parameterName) ) { | ||
115 | this.fB = (EPackage) newValue; | ||
116 | return true; | ||
117 | } | ||
118 | return false; | ||
119 | } | ||
120 | |||
121 | public void setA(final EPackage pA) { | ||
122 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
123 | this.fA = pA; | ||
124 | } | ||
125 | |||
126 | public void setB(final EPackage pB) { | ||
127 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
128 | this.fB = pB; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public String patternName() { | ||
133 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_subpackage"; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public List<String> parameterNames() { | ||
138 | return Unsat_subpackage.Match.parameterNames; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public Object[] toArray() { | ||
143 | return new Object[]{fA, fB}; | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public Unsat_subpackage.Match toImmutable() { | ||
148 | return isMutable() ? newMatch(fA, fB) : this; | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public String prettyPrint() { | ||
153 | StringBuilder result = new StringBuilder(); | ||
154 | result.append("\"a\"=" + prettyPrintValue(fA) + ", "); | ||
155 | result.append("\"b\"=" + prettyPrintValue(fB)); | ||
156 | return result.toString(); | ||
157 | } | ||
158 | |||
159 | @Override | ||
160 | public int hashCode() { | ||
161 | return Objects.hash(fA, fB); | ||
162 | } | ||
163 | |||
164 | @Override | ||
165 | public boolean equals(final Object obj) { | ||
166 | if (this == obj) | ||
167 | return true; | ||
168 | if (obj == null) { | ||
169 | return false; | ||
170 | } | ||
171 | if ((obj instanceof Unsat_subpackage.Match)) { | ||
172 | Unsat_subpackage.Match other = (Unsat_subpackage.Match) obj; | ||
173 | return Objects.equals(fA, other.fA) && Objects.equals(fB, other.fB); | ||
174 | } else { | ||
175 | // this should be infrequent | ||
176 | if (!(obj instanceof IPatternMatch)) { | ||
177 | return false; | ||
178 | } | ||
179 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
180 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | @Override | ||
185 | public Unsat_subpackage specification() { | ||
186 | return Unsat_subpackage.instance(); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * Returns an empty, mutable match. | ||
191 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
192 | * | ||
193 | * @return the empty match. | ||
194 | * | ||
195 | */ | ||
196 | public static Unsat_subpackage.Match newEmptyMatch() { | ||
197 | return new Mutable(null, null); | ||
198 | } | ||
199 | |||
200 | /** | ||
201 | * Returns a mutable (partial) match. | ||
202 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
203 | * | ||
204 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
205 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
206 | * @return the new, mutable (partial) match object. | ||
207 | * | ||
208 | */ | ||
209 | public static Unsat_subpackage.Match newMutableMatch(final EPackage pA, final EPackage pB) { | ||
210 | return new Mutable(pA, pB); | ||
211 | } | ||
212 | |||
213 | /** | ||
214 | * Returns a new (partial) match. | ||
215 | * This can be used e.g. to call the matcher with a partial match. | ||
216 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
217 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
218 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
219 | * @return the (partial) match object. | ||
220 | * | ||
221 | */ | ||
222 | public static Unsat_subpackage.Match newMatch(final EPackage pA, final EPackage pB) { | ||
223 | return new Immutable(pA, pB); | ||
224 | } | ||
225 | |||
226 | private static final class Mutable extends Unsat_subpackage.Match { | ||
227 | Mutable(final EPackage pA, final EPackage pB) { | ||
228 | super(pA, pB); | ||
229 | } | ||
230 | |||
231 | @Override | ||
232 | public boolean isMutable() { | ||
233 | return true; | ||
234 | } | ||
235 | } | ||
236 | |||
237 | private static final class Immutable extends Unsat_subpackage.Match { | ||
238 | Immutable(final EPackage pA, final EPackage pB) { | ||
239 | super(pA, pB); | ||
240 | } | ||
241 | |||
242 | @Override | ||
243 | public boolean isMutable() { | ||
244 | return false; | ||
245 | } | ||
246 | } | ||
247 | } | ||
248 | |||
249 | /** | ||
250 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_subpackage pattern, | ||
251 | * providing pattern-specific query methods. | ||
252 | * | ||
253 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
254 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
255 | * | ||
256 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
257 | * | ||
258 | * <p>Original source: | ||
259 | * <code><pre> | ||
260 | * pattern unsat_subpackage(a: EPackage, b: EPackage) { | ||
261 | * EPackage.eSubpackages(a, b); | ||
262 | * } | ||
263 | * </pre></code> | ||
264 | * | ||
265 | * @see Match | ||
266 | * @see Unsat_subpackage | ||
267 | * | ||
268 | */ | ||
269 | public static class Matcher extends BaseMatcher<Unsat_subpackage.Match> { | ||
270 | /** | ||
271 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
272 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
273 | * | ||
274 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
275 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
276 | * | ||
277 | */ | ||
278 | public static Unsat_subpackage.Matcher on(final ViatraQueryEngine engine) { | ||
279 | // check if matcher already exists | ||
280 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
281 | if (matcher == null) { | ||
282 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
283 | } | ||
284 | return matcher; | ||
285 | } | ||
286 | |||
287 | /** | ||
288 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
289 | * @return an initialized matcher | ||
290 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
291 | * | ||
292 | */ | ||
293 | public static Unsat_subpackage.Matcher create() { | ||
294 | return new Matcher(); | ||
295 | } | ||
296 | |||
297 | private static final int POSITION_A = 0; | ||
298 | |||
299 | private static final int POSITION_B = 1; | ||
300 | |||
301 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Unsat_subpackage.Matcher.class); | ||
302 | |||
303 | /** | ||
304 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
305 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
306 | * | ||
307 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
308 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
309 | * | ||
310 | */ | ||
311 | private Matcher() { | ||
312 | super(querySpecification()); | ||
313 | } | ||
314 | |||
315 | /** | ||
316 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
317 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
318 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
319 | * @return matches represented as a Match object. | ||
320 | * | ||
321 | */ | ||
322 | public Collection<Unsat_subpackage.Match> getAllMatches(final EPackage pA, final EPackage pB) { | ||
323 | return rawStreamAllMatches(new Object[]{pA, pB}).collect(Collectors.toSet()); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
328 | * </p> | ||
329 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
330 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
331 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
332 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
333 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
334 | * @return a stream of matches represented as a Match object. | ||
335 | * | ||
336 | */ | ||
337 | public Stream<Unsat_subpackage.Match> streamAllMatches(final EPackage pA, final EPackage pB) { | ||
338 | return rawStreamAllMatches(new Object[]{pA, pB}); | ||
339 | } | ||
340 | |||
341 | /** | ||
342 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
343 | * Neither determinism nor randomness of selection is guaranteed. | ||
344 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
345 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
346 | * @return a match represented as a Match object, or null if no match is found. | ||
347 | * | ||
348 | */ | ||
349 | public Optional<Unsat_subpackage.Match> getOneArbitraryMatch(final EPackage pA, final EPackage pB) { | ||
350 | return rawGetOneArbitraryMatch(new Object[]{pA, pB}); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
355 | * under any possible substitution of the unspecified parameters (if any). | ||
356 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
357 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
358 | * @return true if the input is a valid (partial) match of the pattern. | ||
359 | * | ||
360 | */ | ||
361 | public boolean hasMatch(final EPackage pA, final EPackage pB) { | ||
362 | return rawHasMatch(new Object[]{pA, pB}); | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
367 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
368 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
369 | * @return the number of pattern matches found. | ||
370 | * | ||
371 | */ | ||
372 | public int countMatches(final EPackage pA, final EPackage pB) { | ||
373 | return rawCountMatches(new Object[]{pA, pB}); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
378 | * Neither determinism nor randomness of selection is guaranteed. | ||
379 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
380 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
381 | * @param processor the action that will process the selected match. | ||
382 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
383 | * | ||
384 | */ | ||
385 | public boolean forOneArbitraryMatch(final EPackage pA, final EPackage pB, final Consumer<? super Unsat_subpackage.Match> processor) { | ||
386 | return rawForOneArbitraryMatch(new Object[]{pA, pB}, processor); | ||
387 | } | ||
388 | |||
389 | /** | ||
390 | * Returns a new (partial) match. | ||
391 | * This can be used e.g. to call the matcher with a partial match. | ||
392 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
393 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
394 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
395 | * @return the (partial) match object. | ||
396 | * | ||
397 | */ | ||
398 | public Unsat_subpackage.Match newMatch(final EPackage pA, final EPackage pB) { | ||
399 | return Unsat_subpackage.Match.newMatch(pA, pB); | ||
400 | } | ||
401 | |||
402 | /** | ||
403 | * Retrieve the set of values that occur in matches for a. | ||
404 | * @return the Set of all values or empty set if there are no matches | ||
405 | * | ||
406 | */ | ||
407 | protected Stream<EPackage> rawStreamAllValuesOfa(final Object[] parameters) { | ||
408 | return rawStreamAllValues(POSITION_A, parameters).map(EPackage.class::cast); | ||
409 | } | ||
410 | |||
411 | /** | ||
412 | * Retrieve the set of values that occur in matches for a. | ||
413 | * @return the Set of all values or empty set if there are no matches | ||
414 | * | ||
415 | */ | ||
416 | public Set<EPackage> getAllValuesOfa() { | ||
417 | return rawStreamAllValuesOfa(emptyArray()).collect(Collectors.toSet()); | ||
418 | } | ||
419 | |||
420 | /** | ||
421 | * Retrieve the set of values that occur in matches for a. | ||
422 | * @return the Set of all values or empty set if there are no matches | ||
423 | * | ||
424 | */ | ||
425 | public Stream<EPackage> streamAllValuesOfa() { | ||
426 | return rawStreamAllValuesOfa(emptyArray()); | ||
427 | } | ||
428 | |||
429 | /** | ||
430 | * Retrieve the set of values that occur in matches for a. | ||
431 | * </p> | ||
432 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
433 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
434 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
435 | * | ||
436 | * @return the Stream of all values or empty set if there are no matches | ||
437 | * | ||
438 | */ | ||
439 | public Stream<EPackage> streamAllValuesOfa(final Unsat_subpackage.Match partialMatch) { | ||
440 | return rawStreamAllValuesOfa(partialMatch.toArray()); | ||
441 | } | ||
442 | |||
443 | /** | ||
444 | * Retrieve the set of values that occur in matches for a. | ||
445 | * </p> | ||
446 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
447 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
448 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
449 | * | ||
450 | * @return the Stream of all values or empty set if there are no matches | ||
451 | * | ||
452 | */ | ||
453 | public Stream<EPackage> streamAllValuesOfa(final EPackage pB) { | ||
454 | return rawStreamAllValuesOfa(new Object[]{null, pB}); | ||
455 | } | ||
456 | |||
457 | /** | ||
458 | * Retrieve the set of values that occur in matches for a. | ||
459 | * @return the Set of all values or empty set if there are no matches | ||
460 | * | ||
461 | */ | ||
462 | public Set<EPackage> getAllValuesOfa(final Unsat_subpackage.Match partialMatch) { | ||
463 | return rawStreamAllValuesOfa(partialMatch.toArray()).collect(Collectors.toSet()); | ||
464 | } | ||
465 | |||
466 | /** | ||
467 | * Retrieve the set of values that occur in matches for a. | ||
468 | * @return the Set of all values or empty set if there are no matches | ||
469 | * | ||
470 | */ | ||
471 | public Set<EPackage> getAllValuesOfa(final EPackage pB) { | ||
472 | return rawStreamAllValuesOfa(new Object[]{null, pB}).collect(Collectors.toSet()); | ||
473 | } | ||
474 | |||
475 | /** | ||
476 | * Retrieve the set of values that occur in matches for b. | ||
477 | * @return the Set of all values or empty set if there are no matches | ||
478 | * | ||
479 | */ | ||
480 | protected Stream<EPackage> rawStreamAllValuesOfb(final Object[] parameters) { | ||
481 | return rawStreamAllValues(POSITION_B, parameters).map(EPackage.class::cast); | ||
482 | } | ||
483 | |||
484 | /** | ||
485 | * Retrieve the set of values that occur in matches for b. | ||
486 | * @return the Set of all values or empty set if there are no matches | ||
487 | * | ||
488 | */ | ||
489 | public Set<EPackage> getAllValuesOfb() { | ||
490 | return rawStreamAllValuesOfb(emptyArray()).collect(Collectors.toSet()); | ||
491 | } | ||
492 | |||
493 | /** | ||
494 | * Retrieve the set of values that occur in matches for b. | ||
495 | * @return the Set of all values or empty set if there are no matches | ||
496 | * | ||
497 | */ | ||
498 | public Stream<EPackage> streamAllValuesOfb() { | ||
499 | return rawStreamAllValuesOfb(emptyArray()); | ||
500 | } | ||
501 | |||
502 | /** | ||
503 | * Retrieve the set of values that occur in matches for b. | ||
504 | * </p> | ||
505 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
506 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
507 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
508 | * | ||
509 | * @return the Stream of all values or empty set if there are no matches | ||
510 | * | ||
511 | */ | ||
512 | public Stream<EPackage> streamAllValuesOfb(final Unsat_subpackage.Match partialMatch) { | ||
513 | return rawStreamAllValuesOfb(partialMatch.toArray()); | ||
514 | } | ||
515 | |||
516 | /** | ||
517 | * Retrieve the set of values that occur in matches for b. | ||
518 | * </p> | ||
519 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
520 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
521 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
522 | * | ||
523 | * @return the Stream of all values or empty set if there are no matches | ||
524 | * | ||
525 | */ | ||
526 | public Stream<EPackage> streamAllValuesOfb(final EPackage pA) { | ||
527 | return rawStreamAllValuesOfb(new Object[]{pA, null}); | ||
528 | } | ||
529 | |||
530 | /** | ||
531 | * Retrieve the set of values that occur in matches for b. | ||
532 | * @return the Set of all values or empty set if there are no matches | ||
533 | * | ||
534 | */ | ||
535 | public Set<EPackage> getAllValuesOfb(final Unsat_subpackage.Match partialMatch) { | ||
536 | return rawStreamAllValuesOfb(partialMatch.toArray()).collect(Collectors.toSet()); | ||
537 | } | ||
538 | |||
539 | /** | ||
540 | * Retrieve the set of values that occur in matches for b. | ||
541 | * @return the Set of all values or empty set if there are no matches | ||
542 | * | ||
543 | */ | ||
544 | public Set<EPackage> getAllValuesOfb(final EPackage pA) { | ||
545 | return rawStreamAllValuesOfb(new Object[]{pA, null}).collect(Collectors.toSet()); | ||
546 | } | ||
547 | |||
548 | @Override | ||
549 | protected Unsat_subpackage.Match tupleToMatch(final Tuple t) { | ||
550 | try { | ||
551 | return Unsat_subpackage.Match.newMatch((EPackage) t.get(POSITION_A), (EPackage) t.get(POSITION_B)); | ||
552 | } catch(ClassCastException e) { | ||
553 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
554 | return null; | ||
555 | } | ||
556 | } | ||
557 | |||
558 | @Override | ||
559 | protected Unsat_subpackage.Match arrayToMatch(final Object[] match) { | ||
560 | try { | ||
561 | return Unsat_subpackage.Match.newMatch((EPackage) match[POSITION_A], (EPackage) match[POSITION_B]); | ||
562 | } catch(ClassCastException e) { | ||
563 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
564 | return null; | ||
565 | } | ||
566 | } | ||
567 | |||
568 | @Override | ||
569 | protected Unsat_subpackage.Match arrayToMatchMutable(final Object[] match) { | ||
570 | try { | ||
571 | return Unsat_subpackage.Match.newMutableMatch((EPackage) match[POSITION_A], (EPackage) match[POSITION_B]); | ||
572 | } catch(ClassCastException e) { | ||
573 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
574 | return null; | ||
575 | } | ||
576 | } | ||
577 | |||
578 | /** | ||
579 | * @return the singleton instance of the query specification of this pattern | ||
580 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
581 | * | ||
582 | */ | ||
583 | public static IQuerySpecification<Unsat_subpackage.Matcher> querySpecification() { | ||
584 | return Unsat_subpackage.instance(); | ||
585 | } | ||
586 | } | ||
587 | |||
588 | private Unsat_subpackage() { | ||
589 | super(GeneratedPQuery.INSTANCE); | ||
590 | } | ||
591 | |||
592 | /** | ||
593 | * @return the singleton instance of the query specification | ||
594 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
595 | * | ||
596 | */ | ||
597 | public static Unsat_subpackage instance() { | ||
598 | try{ | ||
599 | return LazyHolder.INSTANCE; | ||
600 | } catch (ExceptionInInitializerError err) { | ||
601 | throw processInitializerError(err); | ||
602 | } | ||
603 | } | ||
604 | |||
605 | @Override | ||
606 | protected Unsat_subpackage.Matcher instantiate(final ViatraQueryEngine engine) { | ||
607 | return Unsat_subpackage.Matcher.on(engine); | ||
608 | } | ||
609 | |||
610 | @Override | ||
611 | public Unsat_subpackage.Matcher instantiate() { | ||
612 | return Unsat_subpackage.Matcher.create(); | ||
613 | } | ||
614 | |||
615 | @Override | ||
616 | public Unsat_subpackage.Match newEmptyMatch() { | ||
617 | return Unsat_subpackage.Match.newEmptyMatch(); | ||
618 | } | ||
619 | |||
620 | @Override | ||
621 | public Unsat_subpackage.Match newMatch(final Object... parameters) { | ||
622 | return Unsat_subpackage.Match.newMatch((org.eclipse.emf.ecore.EPackage) parameters[0], (org.eclipse.emf.ecore.EPackage) parameters[1]); | ||
623 | } | ||
624 | |||
625 | /** | ||
626 | * Inner class allowing the singleton instance of {@link Unsat_subpackage} to be created | ||
627 | * <b>not</b> at the class load time of the outer class, | ||
628 | * but rather at the first call to {@link Unsat_subpackage#instance()}. | ||
629 | * | ||
630 | * <p> This workaround is required e.g. to support recursion. | ||
631 | * | ||
632 | */ | ||
633 | private static class LazyHolder { | ||
634 | private static final Unsat_subpackage INSTANCE = new Unsat_subpackage(); | ||
635 | |||
636 | /** | ||
637 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
638 | * This initialization order is required to support indirect recursion. | ||
639 | * | ||
640 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
641 | * | ||
642 | */ | ||
643 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
644 | |||
645 | public static Object ensureInitialized() { | ||
646 | INSTANCE.ensureInitializedInternal(); | ||
647 | return null; | ||
648 | } | ||
649 | } | ||
650 | |||
651 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
652 | private static final Unsat_subpackage.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
653 | |||
654 | private final PParameter parameter_a = new PParameter("a", "org.eclipse.emf.ecore.EPackage", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EPackage")), PParameterDirection.INOUT); | ||
655 | |||
656 | private final PParameter parameter_b = new PParameter("b", "org.eclipse.emf.ecore.EPackage", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EPackage")), PParameterDirection.INOUT); | ||
657 | |||
658 | private final List<PParameter> parameters = Arrays.asList(parameter_a, parameter_b); | ||
659 | |||
660 | private GeneratedPQuery() { | ||
661 | super(PVisibility.PUBLIC); | ||
662 | } | ||
663 | |||
664 | @Override | ||
665 | public String getFullyQualifiedName() { | ||
666 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_subpackage"; | ||
667 | } | ||
668 | |||
669 | @Override | ||
670 | public List<String> getParameterNames() { | ||
671 | return Arrays.asList("a","b"); | ||
672 | } | ||
673 | |||
674 | @Override | ||
675 | public List<PParameter> getParameters() { | ||
676 | return parameters; | ||
677 | } | ||
678 | |||
679 | @Override | ||
680 | public Set<PBody> doGetContainedBodies() { | ||
681 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
682 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
683 | { | ||
684 | PBody body = new PBody(this); | ||
685 | PVariable var_a = body.getOrCreateVariableByName("a"); | ||
686 | PVariable var_b = body.getOrCreateVariableByName("b"); | ||
687 | new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); | ||
688 | new TypeConstraint(body, Tuples.flatTupleOf(var_b), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); | ||
689 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
690 | new ExportedParameter(body, var_a, parameter_a), | ||
691 | new ExportedParameter(body, var_b, parameter_b) | ||
692 | )); | ||
693 | // EPackage.eSubpackages(a, b) | ||
694 | new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); | ||
695 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
696 | new TypeConstraint(body, Tuples.flatTupleOf(var_a, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage", "eSubpackages"))); | ||
697 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); | ||
698 | new Equality(body, var__virtual_0_, var_b); | ||
699 | bodies.add(body); | ||
700 | } | ||
701 | return bodies; | ||
702 | } | ||
703 | } | ||
704 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/internal/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/internal/.gitignore new file mode 100644 index 00000000..995169ff --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/internal/.gitignore | |||
@@ -0,0 +1,4 @@ | |||
1 | /.EcoreAll.java._trace | ||
2 | /.SubpackageOrSelf.java._trace | ||
3 | /.Subpackage.java._trace | ||
4 | /.TopLevelPackageWithLoop.java._trace | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.classpath b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.classpath new file mode 100644 index 00000000..faa51b1d --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.classpath | |||
@@ -0,0 +1,15 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <classpath> | ||
3 | <classpathentry kind="src" path="ecore-gen"/> | ||
4 | <classpathentry kind="src" path="xtend-gen"/> | ||
5 | <classpathentry kind="src" path="src"/> | ||
6 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> | ||
7 | <attributes> | ||
8 | <attribute name="module" value="true"/> | ||
9 | </attributes> | ||
10 | </classpathentry> | ||
11 | <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
12 | <classpathentry kind="src" path="src-gen"/> | ||
13 | <classpathentry kind="con" path="uk.ac.kcl.inf.mdeoptimiser.languages.ui.Mopt.MDEO_CONTAINER/dsl"/> | ||
14 | <classpathentry kind="output" path="bin"/> | ||
15 | </classpath> | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.gitignore new file mode 100644 index 00000000..2affc42f --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.gitignore | |||
@@ -0,0 +1,7 @@ | |||
1 | /bin/ | ||
2 | /xtend-gen/ | ||
3 | /problem.lp | ||
4 | /solution.txt | ||
5 | /model/cps_fixup.henshin | ||
6 | /model/problem.xmi | ||
7 | /mdeo-results | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project new file mode 100644 index 00000000..41867b27 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project | |||
@@ -0,0 +1,40 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <projectDescription> | ||
3 | <name>hu.bme.mit.inf.dslreasoner.domains.cps</name> | ||
4 | <comment></comment> | ||
5 | <projects> | ||
6 | </projects> | ||
7 | <buildSpec> | ||
8 | <buildCommand> | ||
9 | <name>org.eclipse.viatra.query.tooling.ui.projectbuilder</name> | ||
10 | <arguments> | ||
11 | </arguments> | ||
12 | </buildCommand> | ||
13 | <buildCommand> | ||
14 | <name>org.eclipse.xtext.ui.shared.xtextBuilder</name> | ||
15 | <arguments> | ||
16 | </arguments> | ||
17 | </buildCommand> | ||
18 | <buildCommand> | ||
19 | <name>org.eclipse.jdt.core.javabuilder</name> | ||
20 | <arguments> | ||
21 | </arguments> | ||
22 | </buildCommand> | ||
23 | <buildCommand> | ||
24 | <name>org.eclipse.pde.ManifestBuilder</name> | ||
25 | <arguments> | ||
26 | </arguments> | ||
27 | </buildCommand> | ||
28 | <buildCommand> | ||
29 | <name>org.eclipse.pde.SchemaBuilder</name> | ||
30 | <arguments> | ||
31 | </arguments> | ||
32 | </buildCommand> | ||
33 | </buildSpec> | ||
34 | <natures> | ||
35 | <nature>org.eclipse.jdt.core.javanature</nature> | ||
36 | <nature>org.eclipse.pde.PluginNature</nature> | ||
37 | <nature>org.eclipse.viatra.query.projectnature</nature> | ||
38 | <nature>org.eclipse.xtext.ui.shared.xtextNature</nature> | ||
39 | </natures> | ||
40 | </projectDescription> | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.settings/org.eclipse.core.resources.prefs b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..6d3062d3 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.settings/org.eclipse.core.resources.prefs | |||
@@ -0,0 +1,3 @@ | |||
1 | eclipse.preferences.version=1 | ||
2 | encoding//model/cps.henshin=UTF-8 | ||
3 | encoding//model/cps.henshin_diagram=UTF-8 | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF new file mode 100644 index 00000000..275a988a --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF | |||
@@ -0,0 +1,30 @@ | |||
1 | Manifest-Version: 1.0 | ||
2 | Bundle-ManifestVersion: 2 | ||
3 | Bundle-Name: %pluginName | ||
4 | Bundle-SymbolicName: hu.bme.mit.inf.dslreasoner.domains.cps;singleton:=true | ||
5 | Bundle-Version: 0.1.0.qualifier | ||
6 | Bundle-ClassPath: . | ||
7 | Bundle-Vendor: %providerName | ||
8 | Bundle-Localization: plugin | ||
9 | Export-Package: hu.bme.mit.inf.dslreasoner.domains.cps, | ||
10 | hu.bme.mit.inf.dslreasoner.domains.cps.impl, | ||
11 | hu.bme.mit.inf.dslreasoner.domains.cps.queries, | ||
12 | hu.bme.mit.inf.dslreasoner.domains.cps.util | ||
13 | Require-Bundle: org.eclipse.viatra.addon.querybasedfeatures.runtime, | ||
14 | org.eclipse.viatra.query.runtime, | ||
15 | org.eclipse.viatra.query.runtime.rete, | ||
16 | org.eclipse.viatra.query.runtime.localsearch, | ||
17 | org.eclipse.xtext.xbase.lib, | ||
18 | org.eclipse.emf.ecore;visibility:=reexport, | ||
19 | org.eclipse.core.runtime, | ||
20 | org.eclipse.xtend.lib;bundle-version="2.16.0", | ||
21 | org.eclipse.xtend.lib.macro;bundle-version="2.16.0", | ||
22 | hu.bme.mit.inf.dslreasoner.application;bundle-version="1.0.0", | ||
23 | org.eclipse.viatra.dse, | ||
24 | org.eclipse.viatra.dse.genetic, | ||
25 | hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner;bundle-version="1.0.0", | ||
26 | org.eclipse.emf.ecore.xmi;bundle-version="2.15.0" | ||
27 | Import-Package: org.apache.log4j | ||
28 | Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.domains.cps | ||
29 | Bundle-ActivationPolicy: lazy | ||
30 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/README.md b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/README.md new file mode 100644 index 00000000..986663fd --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/README.md | |||
@@ -0,0 +1,7 @@ | |||
1 | # Cyber Physical System case study for VIATRA Solver | ||
2 | |||
3 | ## Modifications to the metamodel | ||
4 | |||
5 | * Removed the `State` enumeration and the `ApplicationInstance.state` attribute, as we are only optimizing static configurations of applications instead of deployment strategies. | ||
6 | * Added `ApplicationInstance.requirement` as an opposite reference of `Requirement.instances` with multiplicity `[1..1]` to ensure that each `ApplicationInstance` satisfies exactly one `Requirement`. | ||
7 | * Marked `HostInstance.availableMemory`, `availableHdd`, `totalMemory`, `totalHdd` as derived. The values of `availableMemory` and `availableHdd` can be computed from `totalMemory`, `totalHdd` and the `ResourceRequirement`s associated with the `ApplicationInstances` allocated to the `HostInstance`, while `totalMemory` and `totalHdd` are always equal to `HostType.defaultMemory` and `defaultHdd`. \ No newline at end of file | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/build.properties b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/build.properties new file mode 100644 index 00000000..37a7e53b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/build.properties | |||
@@ -0,0 +1,9 @@ | |||
1 | bin.includes = .,\ | ||
2 | model/,\ | ||
3 | META-INF/,\ | ||
4 | plugin.xml,\ | ||
5 | plugin.properties | ||
6 | jars.compile.order = . | ||
7 | source.. = ecore-gen/,\ | ||
8 | src-gen/ | ||
9 | output.. = bin/ | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationInstance.java new file mode 100644 index 00000000..dc9426f2 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationInstance.java | |||
@@ -0,0 +1,110 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps; | ||
4 | |||
5 | import org.eclipse.emf.ecore.EObject; | ||
6 | |||
7 | /** | ||
8 | * <!-- begin-user-doc --> | ||
9 | * A representation of the model object '<em><b>Application Instance</b></em>'. | ||
10 | * <!-- end-user-doc --> | ||
11 | * | ||
12 | * <p> | ||
13 | * The following features are supported: | ||
14 | * </p> | ||
15 | * <ul> | ||
16 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement <em>Requirement</em>}</li> | ||
17 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType <em>Type</em>}</li> | ||
18 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo <em>Allocated To</em>}</li> | ||
19 | * </ul> | ||
20 | * | ||
21 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationInstance() | ||
22 | * @model | ||
23 | * @generated | ||
24 | */ | ||
25 | public interface ApplicationInstance extends EObject { | ||
26 | /** | ||
27 | * Returns the value of the '<em><b>Requirement</b></em>' reference. | ||
28 | * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances <em>Instances</em>}'. | ||
29 | * <!-- begin-user-doc --> | ||
30 | * <p> | ||
31 | * If the meaning of the '<em>Requirement</em>' reference isn't clear, | ||
32 | * there really should be more of a description here... | ||
33 | * </p> | ||
34 | * <!-- end-user-doc --> | ||
35 | * @return the value of the '<em>Requirement</em>' reference. | ||
36 | * @see #setRequirement(Requirement) | ||
37 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationInstance_Requirement() | ||
38 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances | ||
39 | * @model opposite="instances" | ||
40 | * @generated | ||
41 | */ | ||
42 | Requirement getRequirement(); | ||
43 | |||
44 | /** | ||
45 | * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement <em>Requirement</em>}' reference. | ||
46 | * <!-- begin-user-doc --> | ||
47 | * <!-- end-user-doc --> | ||
48 | * @param value the new value of the '<em>Requirement</em>' reference. | ||
49 | * @see #getRequirement() | ||
50 | * @generated | ||
51 | */ | ||
52 | void setRequirement(Requirement value); | ||
53 | |||
54 | /** | ||
55 | * Returns the value of the '<em><b>Type</b></em>' container reference. | ||
56 | * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances <em>Instances</em>}'. | ||
57 | * <!-- begin-user-doc --> | ||
58 | * <p> | ||
59 | * If the meaning of the '<em>Type</em>' container reference isn't clear, | ||
60 | * there really should be more of a description here... | ||
61 | * </p> | ||
62 | * <!-- end-user-doc --> | ||
63 | * @return the value of the '<em>Type</em>' container reference. | ||
64 | * @see #setType(ApplicationType) | ||
65 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationInstance_Type() | ||
66 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances | ||
67 | * @model opposite="instances" required="true" transient="false" | ||
68 | * @generated | ||
69 | */ | ||
70 | ApplicationType getType(); | ||
71 | |||
72 | /** | ||
73 | * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType <em>Type</em>}' container reference. | ||
74 | * <!-- begin-user-doc --> | ||
75 | * <!-- end-user-doc --> | ||
76 | * @param value the new value of the '<em>Type</em>' container reference. | ||
77 | * @see #getType() | ||
78 | * @generated | ||
79 | */ | ||
80 | void setType(ApplicationType value); | ||
81 | |||
82 | /** | ||
83 | * Returns the value of the '<em><b>Allocated To</b></em>' reference. | ||
84 | * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications <em>Applications</em>}'. | ||
85 | * <!-- begin-user-doc --> | ||
86 | * <p> | ||
87 | * If the meaning of the '<em>Allocated To</em>' reference isn't clear, | ||
88 | * there really should be more of a description here... | ||
89 | * </p> | ||
90 | * <!-- end-user-doc --> | ||
91 | * @return the value of the '<em>Allocated To</em>' reference. | ||
92 | * @see #setAllocatedTo(HostInstance) | ||
93 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationInstance_AllocatedTo() | ||
94 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications | ||
95 | * @model opposite="applications" required="true" | ||
96 | * @generated | ||
97 | */ | ||
98 | HostInstance getAllocatedTo(); | ||
99 | |||
100 | /** | ||
101 | * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo <em>Allocated To</em>}' reference. | ||
102 | * <!-- begin-user-doc --> | ||
103 | * <!-- end-user-doc --> | ||
104 | * @param value the new value of the '<em>Allocated To</em>' reference. | ||
105 | * @see #getAllocatedTo() | ||
106 | * @generated | ||
107 | */ | ||
108 | void setAllocatedTo(HostInstance value); | ||
109 | |||
110 | } // ApplicationInstance | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationType.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationType.java new file mode 100644 index 00000000..f44287ae --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationType.java | |||
@@ -0,0 +1,61 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps; | ||
4 | |||
5 | import org.eclipse.emf.common.util.EList; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | |||
9 | /** | ||
10 | * <!-- begin-user-doc --> | ||
11 | * A representation of the model object '<em><b>Application Type</b></em>'. | ||
12 | * <!-- end-user-doc --> | ||
13 | * | ||
14 | * <p> | ||
15 | * The following features are supported: | ||
16 | * </p> | ||
17 | * <ul> | ||
18 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances <em>Instances</em>}</li> | ||
19 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getRequirements <em>Requirements</em>}</li> | ||
20 | * </ul> | ||
21 | * | ||
22 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationType() | ||
23 | * @model | ||
24 | * @generated | ||
25 | */ | ||
26 | public interface ApplicationType extends EObject { | ||
27 | /** | ||
28 | * Returns the value of the '<em><b>Instances</b></em>' containment reference list. | ||
29 | * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance}. | ||
30 | * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType <em>Type</em>}'. | ||
31 | * <!-- begin-user-doc --> | ||
32 | * <p> | ||
33 | * If the meaning of the '<em>Instances</em>' containment reference list isn't clear, | ||
34 | * there really should be more of a description here... | ||
35 | * </p> | ||
36 | * <!-- end-user-doc --> | ||
37 | * @return the value of the '<em>Instances</em>' containment reference list. | ||
38 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationType_Instances() | ||
39 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType | ||
40 | * @model opposite="type" containment="true" | ||
41 | * @generated | ||
42 | */ | ||
43 | EList<ApplicationInstance> getInstances(); | ||
44 | |||
45 | /** | ||
46 | * Returns the value of the '<em><b>Requirements</b></em>' containment reference list. | ||
47 | * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement}. | ||
48 | * <!-- begin-user-doc --> | ||
49 | * <p> | ||
50 | * If the meaning of the '<em>Requirements</em>' containment reference list isn't clear, | ||
51 | * there really should be more of a description here... | ||
52 | * </p> | ||
53 | * <!-- end-user-doc --> | ||
54 | * @return the value of the '<em>Requirements</em>' containment reference list. | ||
55 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationType_Requirements() | ||
56 | * @model containment="true" | ||
57 | * @generated | ||
58 | */ | ||
59 | EList<ResourceRequirement> getRequirements(); | ||
60 | |||
61 | } // ApplicationType | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsFactory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsFactory.java new file mode 100644 index 00000000..93a5fc95 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsFactory.java | |||
@@ -0,0 +1,105 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps; | ||
4 | |||
5 | import org.eclipse.emf.ecore.EFactory; | ||
6 | |||
7 | /** | ||
8 | * <!-- begin-user-doc --> | ||
9 | * The <b>Factory</b> for the model. | ||
10 | * It provides a create method for each non-abstract class of the model. | ||
11 | * <!-- end-user-doc --> | ||
12 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage | ||
13 | * @generated | ||
14 | */ | ||
15 | public interface CpsFactory extends EFactory { | ||
16 | /** | ||
17 | * The singleton instance of the factory. | ||
18 | * <!-- begin-user-doc --> | ||
19 | * <!-- end-user-doc --> | ||
20 | * @generated | ||
21 | */ | ||
22 | CpsFactory eINSTANCE = hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsFactoryImpl.init(); | ||
23 | |||
24 | /** | ||
25 | * Returns a new object of class '<em>Cyber Physical System</em>'. | ||
26 | * <!-- begin-user-doc --> | ||
27 | * <!-- end-user-doc --> | ||
28 | * @return a new object of class '<em>Cyber Physical System</em>'. | ||
29 | * @generated | ||
30 | */ | ||
31 | CyberPhysicalSystem createCyberPhysicalSystem(); | ||
32 | |||
33 | /** | ||
34 | * Returns a new object of class '<em>Application Type</em>'. | ||
35 | * <!-- begin-user-doc --> | ||
36 | * <!-- end-user-doc --> | ||
37 | * @return a new object of class '<em>Application Type</em>'. | ||
38 | * @generated | ||
39 | */ | ||
40 | ApplicationType createApplicationType(); | ||
41 | |||
42 | /** | ||
43 | * Returns a new object of class '<em>Host Type</em>'. | ||
44 | * <!-- begin-user-doc --> | ||
45 | * <!-- end-user-doc --> | ||
46 | * @return a new object of class '<em>Host Type</em>'. | ||
47 | * @generated | ||
48 | */ | ||
49 | HostType createHostType(); | ||
50 | |||
51 | /** | ||
52 | * Returns a new object of class '<em>Request</em>'. | ||
53 | * <!-- begin-user-doc --> | ||
54 | * <!-- end-user-doc --> | ||
55 | * @return a new object of class '<em>Request</em>'. | ||
56 | * @generated | ||
57 | */ | ||
58 | Request createRequest(); | ||
59 | |||
60 | /** | ||
61 | * Returns a new object of class '<em>Requirement</em>'. | ||
62 | * <!-- begin-user-doc --> | ||
63 | * <!-- end-user-doc --> | ||
64 | * @return a new object of class '<em>Requirement</em>'. | ||
65 | * @generated | ||
66 | */ | ||
67 | Requirement createRequirement(); | ||
68 | |||
69 | /** | ||
70 | * Returns a new object of class '<em>Application Instance</em>'. | ||
71 | * <!-- begin-user-doc --> | ||
72 | * <!-- end-user-doc --> | ||
73 | * @return a new object of class '<em>Application Instance</em>'. | ||
74 | * @generated | ||
75 | */ | ||
76 | ApplicationInstance createApplicationInstance(); | ||
77 | |||
78 | /** | ||
79 | * Returns a new object of class '<em>Resource Requirement</em>'. | ||
80 | * <!-- begin-user-doc --> | ||
81 | * <!-- end-user-doc --> | ||
82 | * @return a new object of class '<em>Resource Requirement</em>'. | ||
83 | * @generated | ||
84 | */ | ||
85 | ResourceRequirement createResourceRequirement(); | ||
86 | |||
87 | /** | ||
88 | * Returns a new object of class '<em>Host Instance</em>'. | ||
89 | * <!-- begin-user-doc --> | ||
90 | * <!-- end-user-doc --> | ||
91 | * @return a new object of class '<em>Host Instance</em>'. | ||
92 | * @generated | ||
93 | */ | ||
94 | HostInstance createHostInstance(); | ||
95 | |||
96 | /** | ||
97 | * Returns the package supported by this factory. | ||
98 | * <!-- begin-user-doc --> | ||
99 | * <!-- end-user-doc --> | ||
100 | * @return the package supported by this factory. | ||
101 | * @generated | ||
102 | */ | ||
103 | CpsPackage getCpsPackage(); | ||
104 | |||
105 | } //CpsFactory | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java new file mode 100644 index 00000000..b0c69786 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java | |||
@@ -0,0 +1,1084 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps; | ||
4 | |||
5 | import org.eclipse.emf.ecore.EAttribute; | ||
6 | import org.eclipse.emf.ecore.EClass; | ||
7 | import org.eclipse.emf.ecore.EPackage; | ||
8 | import org.eclipse.emf.ecore.EReference; | ||
9 | |||
10 | /** | ||
11 | * <!-- begin-user-doc --> | ||
12 | * The <b>Package</b> for the model. | ||
13 | * It contains accessors for the meta objects to represent | ||
14 | * <ul> | ||
15 | * <li>each class,</li> | ||
16 | * <li>each feature of each class,</li> | ||
17 | * <li>each operation of each class,</li> | ||
18 | * <li>each enum,</li> | ||
19 | * <li>and each data type</li> | ||
20 | * </ul> | ||
21 | * <!-- end-user-doc --> | ||
22 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory | ||
23 | * @model kind="package" | ||
24 | * @generated | ||
25 | */ | ||
26 | public interface CpsPackage extends EPackage { | ||
27 | /** | ||
28 | * The package name. | ||
29 | * <!-- begin-user-doc --> | ||
30 | * <!-- end-user-doc --> | ||
31 | * @generated | ||
32 | */ | ||
33 | String eNAME = "cps"; | ||
34 | |||
35 | /** | ||
36 | * The package namespace URI. | ||
37 | * <!-- begin-user-doc --> | ||
38 | * <!-- end-user-doc --> | ||
39 | * @generated | ||
40 | */ | ||
41 | String eNS_URI = "http://www.example.org/cps"; | ||
42 | |||
43 | /** | ||
44 | * The package namespace name. | ||
45 | * <!-- begin-user-doc --> | ||
46 | * <!-- end-user-doc --> | ||
47 | * @generated | ||
48 | */ | ||
49 | String eNS_PREFIX = "cps"; | ||
50 | |||
51 | /** | ||
52 | * The singleton instance of the package. | ||
53 | * <!-- begin-user-doc --> | ||
54 | * <!-- end-user-doc --> | ||
55 | * @generated | ||
56 | */ | ||
57 | CpsPackage eINSTANCE = hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl.init(); | ||
58 | |||
59 | /** | ||
60 | * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl <em>Cyber Physical System</em>}' class. | ||
61 | * <!-- begin-user-doc --> | ||
62 | * <!-- end-user-doc --> | ||
63 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl | ||
64 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getCyberPhysicalSystem() | ||
65 | * @generated | ||
66 | */ | ||
67 | int CYBER_PHYSICAL_SYSTEM = 0; | ||
68 | |||
69 | /** | ||
70 | * The feature id for the '<em><b>Requests</b></em>' containment reference list. | ||
71 | * <!-- begin-user-doc --> | ||
72 | * <!-- end-user-doc --> | ||
73 | * @generated | ||
74 | * @ordered | ||
75 | */ | ||
76 | int CYBER_PHYSICAL_SYSTEM__REQUESTS = 0; | ||
77 | |||
78 | /** | ||
79 | * The feature id for the '<em><b>Application Types</b></em>' containment reference list. | ||
80 | * <!-- begin-user-doc --> | ||
81 | * <!-- end-user-doc --> | ||
82 | * @generated | ||
83 | * @ordered | ||
84 | */ | ||
85 | int CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES = 1; | ||
86 | |||
87 | /** | ||
88 | * The feature id for the '<em><b>Host Types</b></em>' containment reference list. | ||
89 | * <!-- begin-user-doc --> | ||
90 | * <!-- end-user-doc --> | ||
91 | * @generated | ||
92 | * @ordered | ||
93 | */ | ||
94 | int CYBER_PHYSICAL_SYSTEM__HOST_TYPES = 2; | ||
95 | |||
96 | /** | ||
97 | * The number of structural features of the '<em>Cyber Physical System</em>' class. | ||
98 | * <!-- begin-user-doc --> | ||
99 | * <!-- end-user-doc --> | ||
100 | * @generated | ||
101 | * @ordered | ||
102 | */ | ||
103 | int CYBER_PHYSICAL_SYSTEM_FEATURE_COUNT = 3; | ||
104 | |||
105 | /** | ||
106 | * The number of operations of the '<em>Cyber Physical System</em>' class. | ||
107 | * <!-- begin-user-doc --> | ||
108 | * <!-- end-user-doc --> | ||
109 | * @generated | ||
110 | * @ordered | ||
111 | */ | ||
112 | int CYBER_PHYSICAL_SYSTEM_OPERATION_COUNT = 0; | ||
113 | |||
114 | /** | ||
115 | * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl <em>Application Type</em>}' class. | ||
116 | * <!-- begin-user-doc --> | ||
117 | * <!-- end-user-doc --> | ||
118 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl | ||
119 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getApplicationType() | ||
120 | * @generated | ||
121 | */ | ||
122 | int APPLICATION_TYPE = 1; | ||
123 | |||
124 | /** | ||
125 | * The feature id for the '<em><b>Instances</b></em>' containment reference list. | ||
126 | * <!-- begin-user-doc --> | ||
127 | * <!-- end-user-doc --> | ||
128 | * @generated | ||
129 | * @ordered | ||
130 | */ | ||
131 | int APPLICATION_TYPE__INSTANCES = 0; | ||
132 | |||
133 | /** | ||
134 | * The feature id for the '<em><b>Requirements</b></em>' containment reference list. | ||
135 | * <!-- begin-user-doc --> | ||
136 | * <!-- end-user-doc --> | ||
137 | * @generated | ||
138 | * @ordered | ||
139 | */ | ||
140 | int APPLICATION_TYPE__REQUIREMENTS = 1; | ||
141 | |||
142 | /** | ||
143 | * The number of structural features of the '<em>Application Type</em>' class. | ||
144 | * <!-- begin-user-doc --> | ||
145 | * <!-- end-user-doc --> | ||
146 | * @generated | ||
147 | * @ordered | ||
148 | */ | ||
149 | int APPLICATION_TYPE_FEATURE_COUNT = 2; | ||
150 | |||
151 | /** | ||
152 | * The number of operations of the '<em>Application Type</em>' class. | ||
153 | * <!-- begin-user-doc --> | ||
154 | * <!-- end-user-doc --> | ||
155 | * @generated | ||
156 | * @ordered | ||
157 | */ | ||
158 | int APPLICATION_TYPE_OPERATION_COUNT = 0; | ||
159 | |||
160 | /** | ||
161 | * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl <em>Host Type</em>}' class. | ||
162 | * <!-- begin-user-doc --> | ||
163 | * <!-- end-user-doc --> | ||
164 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl | ||
165 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getHostType() | ||
166 | * @generated | ||
167 | */ | ||
168 | int HOST_TYPE = 2; | ||
169 | |||
170 | /** | ||
171 | * The feature id for the '<em><b>Default Memory</b></em>' attribute. | ||
172 | * <!-- begin-user-doc --> | ||
173 | * <!-- end-user-doc --> | ||
174 | * @generated | ||
175 | * @ordered | ||
176 | */ | ||
177 | int HOST_TYPE__DEFAULT_MEMORY = 0; | ||
178 | |||
179 | /** | ||
180 | * The feature id for the '<em><b>Default Hdd</b></em>' attribute. | ||
181 | * <!-- begin-user-doc --> | ||
182 | * <!-- end-user-doc --> | ||
183 | * @generated | ||
184 | * @ordered | ||
185 | */ | ||
186 | int HOST_TYPE__DEFAULT_HDD = 1; | ||
187 | |||
188 | /** | ||
189 | * The feature id for the '<em><b>Instances</b></em>' containment reference list. | ||
190 | * <!-- begin-user-doc --> | ||
191 | * <!-- end-user-doc --> | ||
192 | * @generated | ||
193 | * @ordered | ||
194 | */ | ||
195 | int HOST_TYPE__INSTANCES = 2; | ||
196 | |||
197 | /** | ||
198 | * The feature id for the '<em><b>Cost</b></em>' attribute. | ||
199 | * <!-- begin-user-doc --> | ||
200 | * <!-- end-user-doc --> | ||
201 | * @generated | ||
202 | * @ordered | ||
203 | */ | ||
204 | int HOST_TYPE__COST = 3; | ||
205 | |||
206 | /** | ||
207 | * The number of structural features of the '<em>Host Type</em>' class. | ||
208 | * <!-- begin-user-doc --> | ||
209 | * <!-- end-user-doc --> | ||
210 | * @generated | ||
211 | * @ordered | ||
212 | */ | ||
213 | int HOST_TYPE_FEATURE_COUNT = 4; | ||
214 | |||
215 | /** | ||
216 | * The number of operations of the '<em>Host Type</em>' class. | ||
217 | * <!-- begin-user-doc --> | ||
218 | * <!-- end-user-doc --> | ||
219 | * @generated | ||
220 | * @ordered | ||
221 | */ | ||
222 | int HOST_TYPE_OPERATION_COUNT = 0; | ||
223 | |||
224 | /** | ||
225 | * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl <em>Request</em>}' class. | ||
226 | * <!-- begin-user-doc --> | ||
227 | * <!-- end-user-doc --> | ||
228 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl | ||
229 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getRequest() | ||
230 | * @generated | ||
231 | */ | ||
232 | int REQUEST = 3; | ||
233 | |||
234 | /** | ||
235 | * The feature id for the '<em><b>Requirements</b></em>' containment reference list. | ||
236 | * <!-- begin-user-doc --> | ||
237 | * <!-- end-user-doc --> | ||
238 | * @generated | ||
239 | * @ordered | ||
240 | */ | ||
241 | int REQUEST__REQUIREMENTS = 0; | ||
242 | |||
243 | /** | ||
244 | * The number of structural features of the '<em>Request</em>' class. | ||
245 | * <!-- begin-user-doc --> | ||
246 | * <!-- end-user-doc --> | ||
247 | * @generated | ||
248 | * @ordered | ||
249 | */ | ||
250 | int REQUEST_FEATURE_COUNT = 1; | ||
251 | |||
252 | /** | ||
253 | * The number of operations of the '<em>Request</em>' class. | ||
254 | * <!-- begin-user-doc --> | ||
255 | * <!-- end-user-doc --> | ||
256 | * @generated | ||
257 | * @ordered | ||
258 | */ | ||
259 | int REQUEST_OPERATION_COUNT = 0; | ||
260 | |||
261 | /** | ||
262 | * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl <em>Requirement</em>}' class. | ||
263 | * <!-- begin-user-doc --> | ||
264 | * <!-- end-user-doc --> | ||
265 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl | ||
266 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getRequirement() | ||
267 | * @generated | ||
268 | */ | ||
269 | int REQUIREMENT = 4; | ||
270 | |||
271 | /** | ||
272 | * The feature id for the '<em><b>Request</b></em>' container reference. | ||
273 | * <!-- begin-user-doc --> | ||
274 | * <!-- end-user-doc --> | ||
275 | * @generated | ||
276 | * @ordered | ||
277 | */ | ||
278 | int REQUIREMENT__REQUEST = 0; | ||
279 | |||
280 | /** | ||
281 | * The feature id for the '<em><b>Count</b></em>' attribute. | ||
282 | * <!-- begin-user-doc --> | ||
283 | * <!-- end-user-doc --> | ||
284 | * @generated | ||
285 | * @ordered | ||
286 | */ | ||
287 | int REQUIREMENT__COUNT = 1; | ||
288 | |||
289 | /** | ||
290 | * The feature id for the '<em><b>Type</b></em>' reference. | ||
291 | * <!-- begin-user-doc --> | ||
292 | * <!-- end-user-doc --> | ||
293 | * @generated | ||
294 | * @ordered | ||
295 | */ | ||
296 | int REQUIREMENT__TYPE = 2; | ||
297 | |||
298 | /** | ||
299 | * The feature id for the '<em><b>Instances</b></em>' reference list. | ||
300 | * <!-- begin-user-doc --> | ||
301 | * <!-- end-user-doc --> | ||
302 | * @generated | ||
303 | * @ordered | ||
304 | */ | ||
305 | int REQUIREMENT__INSTANCES = 3; | ||
306 | |||
307 | /** | ||
308 | * The number of structural features of the '<em>Requirement</em>' class. | ||
309 | * <!-- begin-user-doc --> | ||
310 | * <!-- end-user-doc --> | ||
311 | * @generated | ||
312 | * @ordered | ||
313 | */ | ||
314 | int REQUIREMENT_FEATURE_COUNT = 4; | ||
315 | |||
316 | /** | ||
317 | * The number of operations of the '<em>Requirement</em>' class. | ||
318 | * <!-- begin-user-doc --> | ||
319 | * <!-- end-user-doc --> | ||
320 | * @generated | ||
321 | * @ordered | ||
322 | */ | ||
323 | int REQUIREMENT_OPERATION_COUNT = 0; | ||
324 | |||
325 | /** | ||
326 | * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl <em>Application Instance</em>}' class. | ||
327 | * <!-- begin-user-doc --> | ||
328 | * <!-- end-user-doc --> | ||
329 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl | ||
330 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getApplicationInstance() | ||
331 | * @generated | ||
332 | */ | ||
333 | int APPLICATION_INSTANCE = 5; | ||
334 | |||
335 | /** | ||
336 | * The feature id for the '<em><b>Requirement</b></em>' reference. | ||
337 | * <!-- begin-user-doc --> | ||
338 | * <!-- end-user-doc --> | ||
339 | * @generated | ||
340 | * @ordered | ||
341 | */ | ||
342 | int APPLICATION_INSTANCE__REQUIREMENT = 0; | ||
343 | |||
344 | /** | ||
345 | * The feature id for the '<em><b>Type</b></em>' container reference. | ||
346 | * <!-- begin-user-doc --> | ||
347 | * <!-- end-user-doc --> | ||
348 | * @generated | ||
349 | * @ordered | ||
350 | */ | ||
351 | int APPLICATION_INSTANCE__TYPE = 1; | ||
352 | |||
353 | /** | ||
354 | * The feature id for the '<em><b>Allocated To</b></em>' reference. | ||
355 | * <!-- begin-user-doc --> | ||
356 | * <!-- end-user-doc --> | ||
357 | * @generated | ||
358 | * @ordered | ||
359 | */ | ||
360 | int APPLICATION_INSTANCE__ALLOCATED_TO = 2; | ||
361 | |||
362 | /** | ||
363 | * The number of structural features of the '<em>Application Instance</em>' class. | ||
364 | * <!-- begin-user-doc --> | ||
365 | * <!-- end-user-doc --> | ||
366 | * @generated | ||
367 | * @ordered | ||
368 | */ | ||
369 | int APPLICATION_INSTANCE_FEATURE_COUNT = 3; | ||
370 | |||
371 | /** | ||
372 | * The number of operations of the '<em>Application Instance</em>' class. | ||
373 | * <!-- begin-user-doc --> | ||
374 | * <!-- end-user-doc --> | ||
375 | * @generated | ||
376 | * @ordered | ||
377 | */ | ||
378 | int APPLICATION_INSTANCE_OPERATION_COUNT = 0; | ||
379 | |||
380 | /** | ||
381 | * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl <em>Resource Requirement</em>}' class. | ||
382 | * <!-- begin-user-doc --> | ||
383 | * <!-- end-user-doc --> | ||
384 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl | ||
385 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getResourceRequirement() | ||
386 | * @generated | ||
387 | */ | ||
388 | int RESOURCE_REQUIREMENT = 6; | ||
389 | |||
390 | /** | ||
391 | * The feature id for the '<em><b>Required Memory</b></em>' attribute. | ||
392 | * <!-- begin-user-doc --> | ||
393 | * <!-- end-user-doc --> | ||
394 | * @generated | ||
395 | * @ordered | ||
396 | */ | ||
397 | int RESOURCE_REQUIREMENT__REQUIRED_MEMORY = 0; | ||
398 | |||
399 | /** | ||
400 | * The feature id for the '<em><b>Required Hdd</b></em>' attribute. | ||
401 | * <!-- begin-user-doc --> | ||
402 | * <!-- end-user-doc --> | ||
403 | * @generated | ||
404 | * @ordered | ||
405 | */ | ||
406 | int RESOURCE_REQUIREMENT__REQUIRED_HDD = 1; | ||
407 | |||
408 | /** | ||
409 | * The feature id for the '<em><b>Host Type</b></em>' reference. | ||
410 | * <!-- begin-user-doc --> | ||
411 | * <!-- end-user-doc --> | ||
412 | * @generated | ||
413 | * @ordered | ||
414 | */ | ||
415 | int RESOURCE_REQUIREMENT__HOST_TYPE = 2; | ||
416 | |||
417 | /** | ||
418 | * The number of structural features of the '<em>Resource Requirement</em>' class. | ||
419 | * <!-- begin-user-doc --> | ||
420 | * <!-- end-user-doc --> | ||
421 | * @generated | ||
422 | * @ordered | ||
423 | */ | ||
424 | int RESOURCE_REQUIREMENT_FEATURE_COUNT = 3; | ||
425 | |||
426 | /** | ||
427 | * The number of operations of the '<em>Resource Requirement</em>' class. | ||
428 | * <!-- begin-user-doc --> | ||
429 | * <!-- end-user-doc --> | ||
430 | * @generated | ||
431 | * @ordered | ||
432 | */ | ||
433 | int RESOURCE_REQUIREMENT_OPERATION_COUNT = 0; | ||
434 | |||
435 | /** | ||
436 | * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl <em>Host Instance</em>}' class. | ||
437 | * <!-- begin-user-doc --> | ||
438 | * <!-- end-user-doc --> | ||
439 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl | ||
440 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getHostInstance() | ||
441 | * @generated | ||
442 | */ | ||
443 | int HOST_INSTANCE = 7; | ||
444 | |||
445 | /** | ||
446 | * The feature id for the '<em><b>Type</b></em>' container reference. | ||
447 | * <!-- begin-user-doc --> | ||
448 | * <!-- end-user-doc --> | ||
449 | * @generated | ||
450 | * @ordered | ||
451 | */ | ||
452 | int HOST_INSTANCE__TYPE = 0; | ||
453 | |||
454 | /** | ||
455 | * The feature id for the '<em><b>Applications</b></em>' reference list. | ||
456 | * <!-- begin-user-doc --> | ||
457 | * <!-- end-user-doc --> | ||
458 | * @generated | ||
459 | * @ordered | ||
460 | */ | ||
461 | int HOST_INSTANCE__APPLICATIONS = 1; | ||
462 | |||
463 | /** | ||
464 | * The number of structural features of the '<em>Host Instance</em>' class. | ||
465 | * <!-- begin-user-doc --> | ||
466 | * <!-- end-user-doc --> | ||
467 | * @generated | ||
468 | * @ordered | ||
469 | */ | ||
470 | int HOST_INSTANCE_FEATURE_COUNT = 2; | ||
471 | |||
472 | /** | ||
473 | * The number of operations of the '<em>Host Instance</em>' class. | ||
474 | * <!-- begin-user-doc --> | ||
475 | * <!-- end-user-doc --> | ||
476 | * @generated | ||
477 | * @ordered | ||
478 | */ | ||
479 | int HOST_INSTANCE_OPERATION_COUNT = 0; | ||
480 | |||
481 | /** | ||
482 | * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem <em>Cyber Physical System</em>}'. | ||
483 | * <!-- begin-user-doc --> | ||
484 | * <!-- end-user-doc --> | ||
485 | * @return the meta object for class '<em>Cyber Physical System</em>'. | ||
486 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem | ||
487 | * @generated | ||
488 | */ | ||
489 | EClass getCyberPhysicalSystem(); | ||
490 | |||
491 | /** | ||
492 | * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getRequests <em>Requests</em>}'. | ||
493 | * <!-- begin-user-doc --> | ||
494 | * <!-- end-user-doc --> | ||
495 | * @return the meta object for the containment reference list '<em>Requests</em>'. | ||
496 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getRequests() | ||
497 | * @see #getCyberPhysicalSystem() | ||
498 | * @generated | ||
499 | */ | ||
500 | EReference getCyberPhysicalSystem_Requests(); | ||
501 | |||
502 | /** | ||
503 | * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplicationTypes <em>Application Types</em>}'. | ||
504 | * <!-- begin-user-doc --> | ||
505 | * <!-- end-user-doc --> | ||
506 | * @return the meta object for the containment reference list '<em>Application Types</em>'. | ||
507 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplicationTypes() | ||
508 | * @see #getCyberPhysicalSystem() | ||
509 | * @generated | ||
510 | */ | ||
511 | EReference getCyberPhysicalSystem_ApplicationTypes(); | ||
512 | |||
513 | /** | ||
514 | * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHostTypes <em>Host Types</em>}'. | ||
515 | * <!-- begin-user-doc --> | ||
516 | * <!-- end-user-doc --> | ||
517 | * @return the meta object for the containment reference list '<em>Host Types</em>'. | ||
518 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHostTypes() | ||
519 | * @see #getCyberPhysicalSystem() | ||
520 | * @generated | ||
521 | */ | ||
522 | EReference getCyberPhysicalSystem_HostTypes(); | ||
523 | |||
524 | /** | ||
525 | * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType <em>Application Type</em>}'. | ||
526 | * <!-- begin-user-doc --> | ||
527 | * <!-- end-user-doc --> | ||
528 | * @return the meta object for class '<em>Application Type</em>'. | ||
529 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType | ||
530 | * @generated | ||
531 | */ | ||
532 | EClass getApplicationType(); | ||
533 | |||
534 | /** | ||
535 | * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances <em>Instances</em>}'. | ||
536 | * <!-- begin-user-doc --> | ||
537 | * <!-- end-user-doc --> | ||
538 | * @return the meta object for the containment reference list '<em>Instances</em>'. | ||
539 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances() | ||
540 | * @see #getApplicationType() | ||
541 | * @generated | ||
542 | */ | ||
543 | EReference getApplicationType_Instances(); | ||
544 | |||
545 | /** | ||
546 | * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getRequirements <em>Requirements</em>}'. | ||
547 | * <!-- begin-user-doc --> | ||
548 | * <!-- end-user-doc --> | ||
549 | * @return the meta object for the containment reference list '<em>Requirements</em>'. | ||
550 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getRequirements() | ||
551 | * @see #getApplicationType() | ||
552 | * @generated | ||
553 | */ | ||
554 | EReference getApplicationType_Requirements(); | ||
555 | |||
556 | /** | ||
557 | * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType <em>Host Type</em>}'. | ||
558 | * <!-- begin-user-doc --> | ||
559 | * <!-- end-user-doc --> | ||
560 | * @return the meta object for class '<em>Host Type</em>'. | ||
561 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType | ||
562 | * @generated | ||
563 | */ | ||
564 | EClass getHostType(); | ||
565 | |||
566 | /** | ||
567 | * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultMemory <em>Default Memory</em>}'. | ||
568 | * <!-- begin-user-doc --> | ||
569 | * <!-- end-user-doc --> | ||
570 | * @return the meta object for the attribute '<em>Default Memory</em>'. | ||
571 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultMemory() | ||
572 | * @see #getHostType() | ||
573 | * @generated | ||
574 | */ | ||
575 | EAttribute getHostType_DefaultMemory(); | ||
576 | |||
577 | /** | ||
578 | * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultHdd <em>Default Hdd</em>}'. | ||
579 | * <!-- begin-user-doc --> | ||
580 | * <!-- end-user-doc --> | ||
581 | * @return the meta object for the attribute '<em>Default Hdd</em>'. | ||
582 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultHdd() | ||
583 | * @see #getHostType() | ||
584 | * @generated | ||
585 | */ | ||
586 | EAttribute getHostType_DefaultHdd(); | ||
587 | |||
588 | /** | ||
589 | * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances <em>Instances</em>}'. | ||
590 | * <!-- begin-user-doc --> | ||
591 | * <!-- end-user-doc --> | ||
592 | * @return the meta object for the containment reference list '<em>Instances</em>'. | ||
593 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances() | ||
594 | * @see #getHostType() | ||
595 | * @generated | ||
596 | */ | ||
597 | EReference getHostType_Instances(); | ||
598 | |||
599 | /** | ||
600 | * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getCost <em>Cost</em>}'. | ||
601 | * <!-- begin-user-doc --> | ||
602 | * <!-- end-user-doc --> | ||
603 | * @return the meta object for the attribute '<em>Cost</em>'. | ||
604 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getCost() | ||
605 | * @see #getHostType() | ||
606 | * @generated | ||
607 | */ | ||
608 | EAttribute getHostType_Cost(); | ||
609 | |||
610 | /** | ||
611 | * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Request <em>Request</em>}'. | ||
612 | * <!-- begin-user-doc --> | ||
613 | * <!-- end-user-doc --> | ||
614 | * @return the meta object for class '<em>Request</em>'. | ||
615 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.Request | ||
616 | * @generated | ||
617 | */ | ||
618 | EClass getRequest(); | ||
619 | |||
620 | /** | ||
621 | * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements <em>Requirements</em>}'. | ||
622 | * <!-- begin-user-doc --> | ||
623 | * <!-- end-user-doc --> | ||
624 | * @return the meta object for the containment reference list '<em>Requirements</em>'. | ||
625 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements() | ||
626 | * @see #getRequest() | ||
627 | * @generated | ||
628 | */ | ||
629 | EReference getRequest_Requirements(); | ||
630 | |||
631 | /** | ||
632 | * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement <em>Requirement</em>}'. | ||
633 | * <!-- begin-user-doc --> | ||
634 | * <!-- end-user-doc --> | ||
635 | * @return the meta object for class '<em>Requirement</em>'. | ||
636 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement | ||
637 | * @generated | ||
638 | */ | ||
639 | EClass getRequirement(); | ||
640 | |||
641 | /** | ||
642 | * Returns the meta object for the container reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest <em>Request</em>}'. | ||
643 | * <!-- begin-user-doc --> | ||
644 | * <!-- end-user-doc --> | ||
645 | * @return the meta object for the container reference '<em>Request</em>'. | ||
646 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest() | ||
647 | * @see #getRequirement() | ||
648 | * @generated | ||
649 | */ | ||
650 | EReference getRequirement_Request(); | ||
651 | |||
652 | /** | ||
653 | * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getCount <em>Count</em>}'. | ||
654 | * <!-- begin-user-doc --> | ||
655 | * <!-- end-user-doc --> | ||
656 | * @return the meta object for the attribute '<em>Count</em>'. | ||
657 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getCount() | ||
658 | * @see #getRequirement() | ||
659 | * @generated | ||
660 | */ | ||
661 | EAttribute getRequirement_Count(); | ||
662 | |||
663 | /** | ||
664 | * Returns the meta object for the reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getType <em>Type</em>}'. | ||
665 | * <!-- begin-user-doc --> | ||
666 | * <!-- end-user-doc --> | ||
667 | * @return the meta object for the reference '<em>Type</em>'. | ||
668 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getType() | ||
669 | * @see #getRequirement() | ||
670 | * @generated | ||
671 | */ | ||
672 | EReference getRequirement_Type(); | ||
673 | |||
674 | /** | ||
675 | * Returns the meta object for the reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances <em>Instances</em>}'. | ||
676 | * <!-- begin-user-doc --> | ||
677 | * <!-- end-user-doc --> | ||
678 | * @return the meta object for the reference list '<em>Instances</em>'. | ||
679 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances() | ||
680 | * @see #getRequirement() | ||
681 | * @generated | ||
682 | */ | ||
683 | EReference getRequirement_Instances(); | ||
684 | |||
685 | /** | ||
686 | * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance <em>Application Instance</em>}'. | ||
687 | * <!-- begin-user-doc --> | ||
688 | * <!-- end-user-doc --> | ||
689 | * @return the meta object for class '<em>Application Instance</em>'. | ||
690 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance | ||
691 | * @generated | ||
692 | */ | ||
693 | EClass getApplicationInstance(); | ||
694 | |||
695 | /** | ||
696 | * Returns the meta object for the reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement <em>Requirement</em>}'. | ||
697 | * <!-- begin-user-doc --> | ||
698 | * <!-- end-user-doc --> | ||
699 | * @return the meta object for the reference '<em>Requirement</em>'. | ||
700 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement() | ||
701 | * @see #getApplicationInstance() | ||
702 | * @generated | ||
703 | */ | ||
704 | EReference getApplicationInstance_Requirement(); | ||
705 | |||
706 | /** | ||
707 | * Returns the meta object for the container reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType <em>Type</em>}'. | ||
708 | * <!-- begin-user-doc --> | ||
709 | * <!-- end-user-doc --> | ||
710 | * @return the meta object for the container reference '<em>Type</em>'. | ||
711 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType() | ||
712 | * @see #getApplicationInstance() | ||
713 | * @generated | ||
714 | */ | ||
715 | EReference getApplicationInstance_Type(); | ||
716 | |||
717 | /** | ||
718 | * Returns the meta object for the reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo <em>Allocated To</em>}'. | ||
719 | * <!-- begin-user-doc --> | ||
720 | * <!-- end-user-doc --> | ||
721 | * @return the meta object for the reference '<em>Allocated To</em>'. | ||
722 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo() | ||
723 | * @see #getApplicationInstance() | ||
724 | * @generated | ||
725 | */ | ||
726 | EReference getApplicationInstance_AllocatedTo(); | ||
727 | |||
728 | /** | ||
729 | * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement <em>Resource Requirement</em>}'. | ||
730 | * <!-- begin-user-doc --> | ||
731 | * <!-- end-user-doc --> | ||
732 | * @return the meta object for class '<em>Resource Requirement</em>'. | ||
733 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement | ||
734 | * @generated | ||
735 | */ | ||
736 | EClass getResourceRequirement(); | ||
737 | |||
738 | /** | ||
739 | * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredMemory <em>Required Memory</em>}'. | ||
740 | * <!-- begin-user-doc --> | ||
741 | * <!-- end-user-doc --> | ||
742 | * @return the meta object for the attribute '<em>Required Memory</em>'. | ||
743 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredMemory() | ||
744 | * @see #getResourceRequirement() | ||
745 | * @generated | ||
746 | */ | ||
747 | EAttribute getResourceRequirement_RequiredMemory(); | ||
748 | |||
749 | /** | ||
750 | * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredHdd <em>Required Hdd</em>}'. | ||
751 | * <!-- begin-user-doc --> | ||
752 | * <!-- end-user-doc --> | ||
753 | * @return the meta object for the attribute '<em>Required Hdd</em>'. | ||
754 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredHdd() | ||
755 | * @see #getResourceRequirement() | ||
756 | * @generated | ||
757 | */ | ||
758 | EAttribute getResourceRequirement_RequiredHdd(); | ||
759 | |||
760 | /** | ||
761 | * Returns the meta object for the reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getHostType <em>Host Type</em>}'. | ||
762 | * <!-- begin-user-doc --> | ||
763 | * <!-- end-user-doc --> | ||
764 | * @return the meta object for the reference '<em>Host Type</em>'. | ||
765 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getHostType() | ||
766 | * @see #getResourceRequirement() | ||
767 | * @generated | ||
768 | */ | ||
769 | EReference getResourceRequirement_HostType(); | ||
770 | |||
771 | /** | ||
772 | * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance <em>Host Instance</em>}'. | ||
773 | * <!-- begin-user-doc --> | ||
774 | * <!-- end-user-doc --> | ||
775 | * @return the meta object for class '<em>Host Instance</em>'. | ||
776 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance | ||
777 | * @generated | ||
778 | */ | ||
779 | EClass getHostInstance(); | ||
780 | |||
781 | /** | ||
782 | * Returns the meta object for the container reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType <em>Type</em>}'. | ||
783 | * <!-- begin-user-doc --> | ||
784 | * <!-- end-user-doc --> | ||
785 | * @return the meta object for the container reference '<em>Type</em>'. | ||
786 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType() | ||
787 | * @see #getHostInstance() | ||
788 | * @generated | ||
789 | */ | ||
790 | EReference getHostInstance_Type(); | ||
791 | |||
792 | /** | ||
793 | * Returns the meta object for the reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications <em>Applications</em>}'. | ||
794 | * <!-- begin-user-doc --> | ||
795 | * <!-- end-user-doc --> | ||
796 | * @return the meta object for the reference list '<em>Applications</em>'. | ||
797 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications() | ||
798 | * @see #getHostInstance() | ||
799 | * @generated | ||
800 | */ | ||
801 | EReference getHostInstance_Applications(); | ||
802 | |||
803 | /** | ||
804 | * Returns the factory that creates the instances of the model. | ||
805 | * <!-- begin-user-doc --> | ||
806 | * <!-- end-user-doc --> | ||
807 | * @return the factory that creates the instances of the model. | ||
808 | * @generated | ||
809 | */ | ||
810 | CpsFactory getCpsFactory(); | ||
811 | |||
812 | /** | ||
813 | * <!-- begin-user-doc --> | ||
814 | * Defines literals for the meta objects that represent | ||
815 | * <ul> | ||
816 | * <li>each class,</li> | ||
817 | * <li>each feature of each class,</li> | ||
818 | * <li>each operation of each class,</li> | ||
819 | * <li>each enum,</li> | ||
820 | * <li>and each data type</li> | ||
821 | * </ul> | ||
822 | * <!-- end-user-doc --> | ||
823 | * @generated | ||
824 | */ | ||
825 | interface Literals { | ||
826 | /** | ||
827 | * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl <em>Cyber Physical System</em>}' class. | ||
828 | * <!-- begin-user-doc --> | ||
829 | * <!-- end-user-doc --> | ||
830 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl | ||
831 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getCyberPhysicalSystem() | ||
832 | * @generated | ||
833 | */ | ||
834 | EClass CYBER_PHYSICAL_SYSTEM = eINSTANCE.getCyberPhysicalSystem(); | ||
835 | |||
836 | /** | ||
837 | * The meta object literal for the '<em><b>Requests</b></em>' containment reference list feature. | ||
838 | * <!-- begin-user-doc --> | ||
839 | * <!-- end-user-doc --> | ||
840 | * @generated | ||
841 | */ | ||
842 | EReference CYBER_PHYSICAL_SYSTEM__REQUESTS = eINSTANCE.getCyberPhysicalSystem_Requests(); | ||
843 | |||
844 | /** | ||
845 | * The meta object literal for the '<em><b>Application Types</b></em>' containment reference list feature. | ||
846 | * <!-- begin-user-doc --> | ||
847 | * <!-- end-user-doc --> | ||
848 | * @generated | ||
849 | */ | ||
850 | EReference CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES = eINSTANCE.getCyberPhysicalSystem_ApplicationTypes(); | ||
851 | |||
852 | /** | ||
853 | * The meta object literal for the '<em><b>Host Types</b></em>' containment reference list feature. | ||
854 | * <!-- begin-user-doc --> | ||
855 | * <!-- end-user-doc --> | ||
856 | * @generated | ||
857 | */ | ||
858 | EReference CYBER_PHYSICAL_SYSTEM__HOST_TYPES = eINSTANCE.getCyberPhysicalSystem_HostTypes(); | ||
859 | |||
860 | /** | ||
861 | * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl <em>Application Type</em>}' class. | ||
862 | * <!-- begin-user-doc --> | ||
863 | * <!-- end-user-doc --> | ||
864 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl | ||
865 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getApplicationType() | ||
866 | * @generated | ||
867 | */ | ||
868 | EClass APPLICATION_TYPE = eINSTANCE.getApplicationType(); | ||
869 | |||
870 | /** | ||
871 | * The meta object literal for the '<em><b>Instances</b></em>' containment reference list feature. | ||
872 | * <!-- begin-user-doc --> | ||
873 | * <!-- end-user-doc --> | ||
874 | * @generated | ||
875 | */ | ||
876 | EReference APPLICATION_TYPE__INSTANCES = eINSTANCE.getApplicationType_Instances(); | ||
877 | |||
878 | /** | ||
879 | * The meta object literal for the '<em><b>Requirements</b></em>' containment reference list feature. | ||
880 | * <!-- begin-user-doc --> | ||
881 | * <!-- end-user-doc --> | ||
882 | * @generated | ||
883 | */ | ||
884 | EReference APPLICATION_TYPE__REQUIREMENTS = eINSTANCE.getApplicationType_Requirements(); | ||
885 | |||
886 | /** | ||
887 | * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl <em>Host Type</em>}' class. | ||
888 | * <!-- begin-user-doc --> | ||
889 | * <!-- end-user-doc --> | ||
890 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl | ||
891 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getHostType() | ||
892 | * @generated | ||
893 | */ | ||
894 | EClass HOST_TYPE = eINSTANCE.getHostType(); | ||
895 | |||
896 | /** | ||
897 | * The meta object literal for the '<em><b>Default Memory</b></em>' attribute feature. | ||
898 | * <!-- begin-user-doc --> | ||
899 | * <!-- end-user-doc --> | ||
900 | * @generated | ||
901 | */ | ||
902 | EAttribute HOST_TYPE__DEFAULT_MEMORY = eINSTANCE.getHostType_DefaultMemory(); | ||
903 | |||
904 | /** | ||
905 | * The meta object literal for the '<em><b>Default Hdd</b></em>' attribute feature. | ||
906 | * <!-- begin-user-doc --> | ||
907 | * <!-- end-user-doc --> | ||
908 | * @generated | ||
909 | */ | ||
910 | EAttribute HOST_TYPE__DEFAULT_HDD = eINSTANCE.getHostType_DefaultHdd(); | ||
911 | |||
912 | /** | ||
913 | * The meta object literal for the '<em><b>Instances</b></em>' containment reference list feature. | ||
914 | * <!-- begin-user-doc --> | ||
915 | * <!-- end-user-doc --> | ||
916 | * @generated | ||
917 | */ | ||
918 | EReference HOST_TYPE__INSTANCES = eINSTANCE.getHostType_Instances(); | ||
919 | |||
920 | /** | ||
921 | * The meta object literal for the '<em><b>Cost</b></em>' attribute feature. | ||
922 | * <!-- begin-user-doc --> | ||
923 | * <!-- end-user-doc --> | ||
924 | * @generated | ||
925 | */ | ||
926 | EAttribute HOST_TYPE__COST = eINSTANCE.getHostType_Cost(); | ||
927 | |||
928 | /** | ||
929 | * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl <em>Request</em>}' class. | ||
930 | * <!-- begin-user-doc --> | ||
931 | * <!-- end-user-doc --> | ||
932 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl | ||
933 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getRequest() | ||
934 | * @generated | ||
935 | */ | ||
936 | EClass REQUEST = eINSTANCE.getRequest(); | ||
937 | |||
938 | /** | ||
939 | * The meta object literal for the '<em><b>Requirements</b></em>' containment reference list feature. | ||
940 | * <!-- begin-user-doc --> | ||
941 | * <!-- end-user-doc --> | ||
942 | * @generated | ||
943 | */ | ||
944 | EReference REQUEST__REQUIREMENTS = eINSTANCE.getRequest_Requirements(); | ||
945 | |||
946 | /** | ||
947 | * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl <em>Requirement</em>}' class. | ||
948 | * <!-- begin-user-doc --> | ||
949 | * <!-- end-user-doc --> | ||
950 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl | ||
951 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getRequirement() | ||
952 | * @generated | ||
953 | */ | ||
954 | EClass REQUIREMENT = eINSTANCE.getRequirement(); | ||
955 | |||
956 | /** | ||
957 | * The meta object literal for the '<em><b>Request</b></em>' container reference feature. | ||
958 | * <!-- begin-user-doc --> | ||
959 | * <!-- end-user-doc --> | ||
960 | * @generated | ||
961 | */ | ||
962 | EReference REQUIREMENT__REQUEST = eINSTANCE.getRequirement_Request(); | ||
963 | |||
964 | /** | ||
965 | * The meta object literal for the '<em><b>Count</b></em>' attribute feature. | ||
966 | * <!-- begin-user-doc --> | ||
967 | * <!-- end-user-doc --> | ||
968 | * @generated | ||
969 | */ | ||
970 | EAttribute REQUIREMENT__COUNT = eINSTANCE.getRequirement_Count(); | ||
971 | |||
972 | /** | ||
973 | * The meta object literal for the '<em><b>Type</b></em>' reference feature. | ||
974 | * <!-- begin-user-doc --> | ||
975 | * <!-- end-user-doc --> | ||
976 | * @generated | ||
977 | */ | ||
978 | EReference REQUIREMENT__TYPE = eINSTANCE.getRequirement_Type(); | ||
979 | |||
980 | /** | ||
981 | * The meta object literal for the '<em><b>Instances</b></em>' reference list feature. | ||
982 | * <!-- begin-user-doc --> | ||
983 | * <!-- end-user-doc --> | ||
984 | * @generated | ||
985 | */ | ||
986 | EReference REQUIREMENT__INSTANCES = eINSTANCE.getRequirement_Instances(); | ||
987 | |||
988 | /** | ||
989 | * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl <em>Application Instance</em>}' class. | ||
990 | * <!-- begin-user-doc --> | ||
991 | * <!-- end-user-doc --> | ||
992 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl | ||
993 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getApplicationInstance() | ||
994 | * @generated | ||
995 | */ | ||
996 | EClass APPLICATION_INSTANCE = eINSTANCE.getApplicationInstance(); | ||
997 | |||
998 | /** | ||
999 | * The meta object literal for the '<em><b>Requirement</b></em>' reference feature. | ||
1000 | * <!-- begin-user-doc --> | ||
1001 | * <!-- end-user-doc --> | ||
1002 | * @generated | ||
1003 | */ | ||
1004 | EReference APPLICATION_INSTANCE__REQUIREMENT = eINSTANCE.getApplicationInstance_Requirement(); | ||
1005 | |||
1006 | /** | ||
1007 | * The meta object literal for the '<em><b>Type</b></em>' container reference feature. | ||
1008 | * <!-- begin-user-doc --> | ||
1009 | * <!-- end-user-doc --> | ||
1010 | * @generated | ||
1011 | */ | ||
1012 | EReference APPLICATION_INSTANCE__TYPE = eINSTANCE.getApplicationInstance_Type(); | ||
1013 | |||
1014 | /** | ||
1015 | * The meta object literal for the '<em><b>Allocated To</b></em>' reference feature. | ||
1016 | * <!-- begin-user-doc --> | ||
1017 | * <!-- end-user-doc --> | ||
1018 | * @generated | ||
1019 | */ | ||
1020 | EReference APPLICATION_INSTANCE__ALLOCATED_TO = eINSTANCE.getApplicationInstance_AllocatedTo(); | ||
1021 | |||
1022 | /** | ||
1023 | * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl <em>Resource Requirement</em>}' class. | ||
1024 | * <!-- begin-user-doc --> | ||
1025 | * <!-- end-user-doc --> | ||
1026 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl | ||
1027 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getResourceRequirement() | ||
1028 | * @generated | ||
1029 | */ | ||
1030 | EClass RESOURCE_REQUIREMENT = eINSTANCE.getResourceRequirement(); | ||
1031 | |||
1032 | /** | ||
1033 | * The meta object literal for the '<em><b>Required Memory</b></em>' attribute feature. | ||
1034 | * <!-- begin-user-doc --> | ||
1035 | * <!-- end-user-doc --> | ||
1036 | * @generated | ||
1037 | */ | ||
1038 | EAttribute RESOURCE_REQUIREMENT__REQUIRED_MEMORY = eINSTANCE.getResourceRequirement_RequiredMemory(); | ||
1039 | |||
1040 | /** | ||
1041 | * The meta object literal for the '<em><b>Required Hdd</b></em>' attribute feature. | ||
1042 | * <!-- begin-user-doc --> | ||
1043 | * <!-- end-user-doc --> | ||
1044 | * @generated | ||
1045 | */ | ||
1046 | EAttribute RESOURCE_REQUIREMENT__REQUIRED_HDD = eINSTANCE.getResourceRequirement_RequiredHdd(); | ||
1047 | |||
1048 | /** | ||
1049 | * The meta object literal for the '<em><b>Host Type</b></em>' reference feature. | ||
1050 | * <!-- begin-user-doc --> | ||
1051 | * <!-- end-user-doc --> | ||
1052 | * @generated | ||
1053 | */ | ||
1054 | EReference RESOURCE_REQUIREMENT__HOST_TYPE = eINSTANCE.getResourceRequirement_HostType(); | ||
1055 | |||
1056 | /** | ||
1057 | * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl <em>Host Instance</em>}' class. | ||
1058 | * <!-- begin-user-doc --> | ||
1059 | * <!-- end-user-doc --> | ||
1060 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl | ||
1061 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getHostInstance() | ||
1062 | * @generated | ||
1063 | */ | ||
1064 | EClass HOST_INSTANCE = eINSTANCE.getHostInstance(); | ||
1065 | |||
1066 | /** | ||
1067 | * The meta object literal for the '<em><b>Type</b></em>' container reference feature. | ||
1068 | * <!-- begin-user-doc --> | ||
1069 | * <!-- end-user-doc --> | ||
1070 | * @generated | ||
1071 | */ | ||
1072 | EReference HOST_INSTANCE__TYPE = eINSTANCE.getHostInstance_Type(); | ||
1073 | |||
1074 | /** | ||
1075 | * The meta object literal for the '<em><b>Applications</b></em>' reference list feature. | ||
1076 | * <!-- begin-user-doc --> | ||
1077 | * <!-- end-user-doc --> | ||
1078 | * @generated | ||
1079 | */ | ||
1080 | EReference HOST_INSTANCE__APPLICATIONS = eINSTANCE.getHostInstance_Applications(); | ||
1081 | |||
1082 | } | ||
1083 | |||
1084 | } //CpsPackage | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java new file mode 100644 index 00000000..fbf4ce0d --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java | |||
@@ -0,0 +1,76 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps; | ||
4 | |||
5 | import org.eclipse.emf.common.util.EList; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | |||
9 | /** | ||
10 | * <!-- begin-user-doc --> | ||
11 | * A representation of the model object '<em><b>Cyber Physical System</b></em>'. | ||
12 | * <!-- end-user-doc --> | ||
13 | * | ||
14 | * <p> | ||
15 | * The following features are supported: | ||
16 | * </p> | ||
17 | * <ul> | ||
18 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getRequests <em>Requests</em>}</li> | ||
19 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplicationTypes <em>Application Types</em>}</li> | ||
20 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHostTypes <em>Host Types</em>}</li> | ||
21 | * </ul> | ||
22 | * | ||
23 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem() | ||
24 | * @model | ||
25 | * @generated | ||
26 | */ | ||
27 | public interface CyberPhysicalSystem extends EObject { | ||
28 | /** | ||
29 | * Returns the value of the '<em><b>Requests</b></em>' containment reference list. | ||
30 | * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.Request}. | ||
31 | * <!-- begin-user-doc --> | ||
32 | * <p> | ||
33 | * If the meaning of the '<em>Requests</em>' containment reference list isn't clear, | ||
34 | * there really should be more of a description here... | ||
35 | * </p> | ||
36 | * <!-- end-user-doc --> | ||
37 | * @return the value of the '<em>Requests</em>' containment reference list. | ||
38 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_Requests() | ||
39 | * @model containment="true" | ||
40 | * @generated | ||
41 | */ | ||
42 | EList<Request> getRequests(); | ||
43 | |||
44 | /** | ||
45 | * Returns the value of the '<em><b>Application Types</b></em>' containment reference list. | ||
46 | * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType}. | ||
47 | * <!-- begin-user-doc --> | ||
48 | * <p> | ||
49 | * If the meaning of the '<em>Application Types</em>' containment reference list isn't clear, | ||
50 | * there really should be more of a description here... | ||
51 | * </p> | ||
52 | * <!-- end-user-doc --> | ||
53 | * @return the value of the '<em>Application Types</em>' containment reference list. | ||
54 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_ApplicationTypes() | ||
55 | * @model containment="true" | ||
56 | * @generated | ||
57 | */ | ||
58 | EList<ApplicationType> getApplicationTypes(); | ||
59 | |||
60 | /** | ||
61 | * Returns the value of the '<em><b>Host Types</b></em>' containment reference list. | ||
62 | * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType}. | ||
63 | * <!-- begin-user-doc --> | ||
64 | * <p> | ||
65 | * If the meaning of the '<em>Host Types</em>' containment reference list isn't clear, | ||
66 | * there really should be more of a description here... | ||
67 | * </p> | ||
68 | * <!-- end-user-doc --> | ||
69 | * @return the value of the '<em>Host Types</em>' containment reference list. | ||
70 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_HostTypes() | ||
71 | * @model containment="true" | ||
72 | * @generated | ||
73 | */ | ||
74 | EList<HostType> getHostTypes(); | ||
75 | |||
76 | } // CyberPhysicalSystem | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java new file mode 100644 index 00000000..b4721842 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java | |||
@@ -0,0 +1,73 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps; | ||
4 | |||
5 | import org.eclipse.emf.common.util.EList; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | |||
9 | /** | ||
10 | * <!-- begin-user-doc --> | ||
11 | * A representation of the model object '<em><b>Host Instance</b></em>'. | ||
12 | * <!-- end-user-doc --> | ||
13 | * | ||
14 | * <p> | ||
15 | * The following features are supported: | ||
16 | * </p> | ||
17 | * <ul> | ||
18 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType <em>Type</em>}</li> | ||
19 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications <em>Applications</em>}</li> | ||
20 | * </ul> | ||
21 | * | ||
22 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance() | ||
23 | * @model | ||
24 | * @generated | ||
25 | */ | ||
26 | public interface HostInstance extends EObject { | ||
27 | /** | ||
28 | * Returns the value of the '<em><b>Type</b></em>' container reference. | ||
29 | * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances <em>Instances</em>}'. | ||
30 | * <!-- begin-user-doc --> | ||
31 | * <p> | ||
32 | * If the meaning of the '<em>Type</em>' container reference isn't clear, | ||
33 | * there really should be more of a description here... | ||
34 | * </p> | ||
35 | * <!-- end-user-doc --> | ||
36 | * @return the value of the '<em>Type</em>' container reference. | ||
37 | * @see #setType(HostType) | ||
38 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_Type() | ||
39 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances | ||
40 | * @model opposite="instances" required="true" transient="false" | ||
41 | * @generated | ||
42 | */ | ||
43 | HostType getType(); | ||
44 | |||
45 | /** | ||
46 | * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType <em>Type</em>}' container reference. | ||
47 | * <!-- begin-user-doc --> | ||
48 | * <!-- end-user-doc --> | ||
49 | * @param value the new value of the '<em>Type</em>' container reference. | ||
50 | * @see #getType() | ||
51 | * @generated | ||
52 | */ | ||
53 | void setType(HostType value); | ||
54 | |||
55 | /** | ||
56 | * Returns the value of the '<em><b>Applications</b></em>' reference list. | ||
57 | * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance}. | ||
58 | * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo <em>Allocated To</em>}'. | ||
59 | * <!-- begin-user-doc --> | ||
60 | * <p> | ||
61 | * If the meaning of the '<em>Applications</em>' reference list isn't clear, | ||
62 | * there really should be more of a description here... | ||
63 | * </p> | ||
64 | * <!-- end-user-doc --> | ||
65 | * @return the value of the '<em>Applications</em>' reference list. | ||
66 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_Applications() | ||
67 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo | ||
68 | * @model opposite="allocatedTo" | ||
69 | * @generated | ||
70 | */ | ||
71 | EList<ApplicationInstance> getApplications(); | ||
72 | |||
73 | } // HostInstance | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostType.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostType.java new file mode 100644 index 00000000..45201930 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostType.java | |||
@@ -0,0 +1,125 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps; | ||
4 | |||
5 | import org.eclipse.emf.common.util.EList; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | |||
9 | /** | ||
10 | * <!-- begin-user-doc --> | ||
11 | * A representation of the model object '<em><b>Host Type</b></em>'. | ||
12 | * <!-- end-user-doc --> | ||
13 | * | ||
14 | * <p> | ||
15 | * The following features are supported: | ||
16 | * </p> | ||
17 | * <ul> | ||
18 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultMemory <em>Default Memory</em>}</li> | ||
19 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultHdd <em>Default Hdd</em>}</li> | ||
20 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances <em>Instances</em>}</li> | ||
21 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getCost <em>Cost</em>}</li> | ||
22 | * </ul> | ||
23 | * | ||
24 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType() | ||
25 | * @model | ||
26 | * @generated | ||
27 | */ | ||
28 | public interface HostType extends EObject { | ||
29 | /** | ||
30 | * Returns the value of the '<em><b>Default Memory</b></em>' attribute. | ||
31 | * <!-- begin-user-doc --> | ||
32 | * <p> | ||
33 | * If the meaning of the '<em>Default Memory</em>' attribute isn't clear, | ||
34 | * there really should be more of a description here... | ||
35 | * </p> | ||
36 | * <!-- end-user-doc --> | ||
37 | * @return the value of the '<em>Default Memory</em>' attribute. | ||
38 | * @see #setDefaultMemory(int) | ||
39 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType_DefaultMemory() | ||
40 | * @model required="true" | ||
41 | * @generated | ||
42 | */ | ||
43 | int getDefaultMemory(); | ||
44 | |||
45 | /** | ||
46 | * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultMemory <em>Default Memory</em>}' attribute. | ||
47 | * <!-- begin-user-doc --> | ||
48 | * <!-- end-user-doc --> | ||
49 | * @param value the new value of the '<em>Default Memory</em>' attribute. | ||
50 | * @see #getDefaultMemory() | ||
51 | * @generated | ||
52 | */ | ||
53 | void setDefaultMemory(int value); | ||
54 | |||
55 | /** | ||
56 | * Returns the value of the '<em><b>Default Hdd</b></em>' attribute. | ||
57 | * <!-- begin-user-doc --> | ||
58 | * <p> | ||
59 | * If the meaning of the '<em>Default Hdd</em>' attribute isn't clear, | ||
60 | * there really should be more of a description here... | ||
61 | * </p> | ||
62 | * <!-- end-user-doc --> | ||
63 | * @return the value of the '<em>Default Hdd</em>' attribute. | ||
64 | * @see #setDefaultHdd(int) | ||
65 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType_DefaultHdd() | ||
66 | * @model required="true" | ||
67 | * @generated | ||
68 | */ | ||
69 | int getDefaultHdd(); | ||
70 | |||
71 | /** | ||
72 | * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultHdd <em>Default Hdd</em>}' attribute. | ||
73 | * <!-- begin-user-doc --> | ||
74 | * <!-- end-user-doc --> | ||
75 | * @param value the new value of the '<em>Default Hdd</em>' attribute. | ||
76 | * @see #getDefaultHdd() | ||
77 | * @generated | ||
78 | */ | ||
79 | void setDefaultHdd(int value); | ||
80 | |||
81 | /** | ||
82 | * Returns the value of the '<em><b>Instances</b></em>' containment reference list. | ||
83 | * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance}. | ||
84 | * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType <em>Type</em>}'. | ||
85 | * <!-- begin-user-doc --> | ||
86 | * <p> | ||
87 | * If the meaning of the '<em>Instances</em>' containment reference list isn't clear, | ||
88 | * there really should be more of a description here... | ||
89 | * </p> | ||
90 | * <!-- end-user-doc --> | ||
91 | * @return the value of the '<em>Instances</em>' containment reference list. | ||
92 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType_Instances() | ||
93 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType | ||
94 | * @model opposite="type" containment="true" | ||
95 | * @generated | ||
96 | */ | ||
97 | EList<HostInstance> getInstances(); | ||
98 | |||
99 | /** | ||
100 | * Returns the value of the '<em><b>Cost</b></em>' attribute. | ||
101 | * <!-- begin-user-doc --> | ||
102 | * <p> | ||
103 | * If the meaning of the '<em>Cost</em>' attribute isn't clear, | ||
104 | * there really should be more of a description here... | ||
105 | * </p> | ||
106 | * <!-- end-user-doc --> | ||
107 | * @return the value of the '<em>Cost</em>' attribute. | ||
108 | * @see #setCost(int) | ||
109 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType_Cost() | ||
110 | * @model required="true" | ||
111 | * @generated | ||
112 | */ | ||
113 | int getCost(); | ||
114 | |||
115 | /** | ||
116 | * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getCost <em>Cost</em>}' attribute. | ||
117 | * <!-- begin-user-doc --> | ||
118 | * <!-- end-user-doc --> | ||
119 | * @param value the new value of the '<em>Cost</em>' attribute. | ||
120 | * @see #getCost() | ||
121 | * @generated | ||
122 | */ | ||
123 | void setCost(int value); | ||
124 | |||
125 | } // HostType | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Request.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Request.java new file mode 100644 index 00000000..261562a0 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Request.java | |||
@@ -0,0 +1,44 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps; | ||
4 | |||
5 | import org.eclipse.emf.common.util.EList; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | |||
9 | /** | ||
10 | * <!-- begin-user-doc --> | ||
11 | * A representation of the model object '<em><b>Request</b></em>'. | ||
12 | * <!-- end-user-doc --> | ||
13 | * | ||
14 | * <p> | ||
15 | * The following features are supported: | ||
16 | * </p> | ||
17 | * <ul> | ||
18 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements <em>Requirements</em>}</li> | ||
19 | * </ul> | ||
20 | * | ||
21 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequest() | ||
22 | * @model | ||
23 | * @generated | ||
24 | */ | ||
25 | public interface Request extends EObject { | ||
26 | /** | ||
27 | * Returns the value of the '<em><b>Requirements</b></em>' containment reference list. | ||
28 | * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement}. | ||
29 | * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest <em>Request</em>}'. | ||
30 | * <!-- begin-user-doc --> | ||
31 | * <p> | ||
32 | * If the meaning of the '<em>Requirements</em>' containment reference list isn't clear, | ||
33 | * there really should be more of a description here... | ||
34 | * </p> | ||
35 | * <!-- end-user-doc --> | ||
36 | * @return the value of the '<em>Requirements</em>' containment reference list. | ||
37 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequest_Requirements() | ||
38 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest | ||
39 | * @model opposite="request" containment="true" | ||
40 | * @generated | ||
41 | */ | ||
42 | EList<Requirement> getRequirements(); | ||
43 | |||
44 | } // Request | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Requirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Requirement.java new file mode 100644 index 00000000..a1d494e4 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Requirement.java | |||
@@ -0,0 +1,127 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps; | ||
4 | |||
5 | import org.eclipse.emf.common.util.EList; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | |||
9 | /** | ||
10 | * <!-- begin-user-doc --> | ||
11 | * A representation of the model object '<em><b>Requirement</b></em>'. | ||
12 | * <!-- end-user-doc --> | ||
13 | * | ||
14 | * <p> | ||
15 | * The following features are supported: | ||
16 | * </p> | ||
17 | * <ul> | ||
18 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest <em>Request</em>}</li> | ||
19 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getCount <em>Count</em>}</li> | ||
20 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getType <em>Type</em>}</li> | ||
21 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances <em>Instances</em>}</li> | ||
22 | * </ul> | ||
23 | * | ||
24 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement() | ||
25 | * @model | ||
26 | * @generated | ||
27 | */ | ||
28 | public interface Requirement extends EObject { | ||
29 | /** | ||
30 | * Returns the value of the '<em><b>Request</b></em>' container reference. | ||
31 | * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements <em>Requirements</em>}'. | ||
32 | * <!-- begin-user-doc --> | ||
33 | * <p> | ||
34 | * If the meaning of the '<em>Request</em>' container reference isn't clear, | ||
35 | * there really should be more of a description here... | ||
36 | * </p> | ||
37 | * <!-- end-user-doc --> | ||
38 | * @return the value of the '<em>Request</em>' container reference. | ||
39 | * @see #setRequest(Request) | ||
40 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement_Request() | ||
41 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements | ||
42 | * @model opposite="requirements" required="true" transient="false" | ||
43 | * @generated | ||
44 | */ | ||
45 | Request getRequest(); | ||
46 | |||
47 | /** | ||
48 | * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest <em>Request</em>}' container reference. | ||
49 | * <!-- begin-user-doc --> | ||
50 | * <!-- end-user-doc --> | ||
51 | * @param value the new value of the '<em>Request</em>' container reference. | ||
52 | * @see #getRequest() | ||
53 | * @generated | ||
54 | */ | ||
55 | void setRequest(Request value); | ||
56 | |||
57 | /** | ||
58 | * Returns the value of the '<em><b>Count</b></em>' attribute. | ||
59 | * <!-- begin-user-doc --> | ||
60 | * <p> | ||
61 | * If the meaning of the '<em>Count</em>' attribute isn't clear, | ||
62 | * there really should be more of a description here... | ||
63 | * </p> | ||
64 | * <!-- end-user-doc --> | ||
65 | * @return the value of the '<em>Count</em>' attribute. | ||
66 | * @see #setCount(int) | ||
67 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement_Count() | ||
68 | * @model required="true" | ||
69 | * @generated | ||
70 | */ | ||
71 | int getCount(); | ||
72 | |||
73 | /** | ||
74 | * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getCount <em>Count</em>}' attribute. | ||
75 | * <!-- begin-user-doc --> | ||
76 | * <!-- end-user-doc --> | ||
77 | * @param value the new value of the '<em>Count</em>' attribute. | ||
78 | * @see #getCount() | ||
79 | * @generated | ||
80 | */ | ||
81 | void setCount(int value); | ||
82 | |||
83 | /** | ||
84 | * Returns the value of the '<em><b>Type</b></em>' reference. | ||
85 | * <!-- begin-user-doc --> | ||
86 | * <p> | ||
87 | * If the meaning of the '<em>Type</em>' reference isn't clear, | ||
88 | * there really should be more of a description here... | ||
89 | * </p> | ||
90 | * <!-- end-user-doc --> | ||
91 | * @return the value of the '<em>Type</em>' reference. | ||
92 | * @see #setType(ApplicationType) | ||
93 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement_Type() | ||
94 | * @model | ||
95 | * @generated | ||
96 | */ | ||
97 | ApplicationType getType(); | ||
98 | |||
99 | /** | ||
100 | * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getType <em>Type</em>}' reference. | ||
101 | * <!-- begin-user-doc --> | ||
102 | * <!-- end-user-doc --> | ||
103 | * @param value the new value of the '<em>Type</em>' reference. | ||
104 | * @see #getType() | ||
105 | * @generated | ||
106 | */ | ||
107 | void setType(ApplicationType value); | ||
108 | |||
109 | /** | ||
110 | * Returns the value of the '<em><b>Instances</b></em>' reference list. | ||
111 | * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance}. | ||
112 | * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement <em>Requirement</em>}'. | ||
113 | * <!-- begin-user-doc --> | ||
114 | * <p> | ||
115 | * If the meaning of the '<em>Instances</em>' reference list isn't clear, | ||
116 | * there really should be more of a description here... | ||
117 | * </p> | ||
118 | * <!-- end-user-doc --> | ||
119 | * @return the value of the '<em>Instances</em>' reference list. | ||
120 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement_Instances() | ||
121 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement | ||
122 | * @model opposite="requirement" | ||
123 | * @generated | ||
124 | */ | ||
125 | EList<ApplicationInstance> getInstances(); | ||
126 | |||
127 | } // Requirement | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ResourceRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ResourceRequirement.java new file mode 100644 index 00000000..a99cc12e --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ResourceRequirement.java | |||
@@ -0,0 +1,104 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps; | ||
4 | |||
5 | import org.eclipse.emf.ecore.EObject; | ||
6 | |||
7 | /** | ||
8 | * <!-- begin-user-doc --> | ||
9 | * A representation of the model object '<em><b>Resource Requirement</b></em>'. | ||
10 | * <!-- end-user-doc --> | ||
11 | * | ||
12 | * <p> | ||
13 | * The following features are supported: | ||
14 | * </p> | ||
15 | * <ul> | ||
16 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredMemory <em>Required Memory</em>}</li> | ||
17 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredHdd <em>Required Hdd</em>}</li> | ||
18 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getHostType <em>Host Type</em>}</li> | ||
19 | * </ul> | ||
20 | * | ||
21 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getResourceRequirement() | ||
22 | * @model | ||
23 | * @generated | ||
24 | */ | ||
25 | public interface ResourceRequirement extends EObject { | ||
26 | /** | ||
27 | * Returns the value of the '<em><b>Required Memory</b></em>' attribute. | ||
28 | * <!-- begin-user-doc --> | ||
29 | * <p> | ||
30 | * If the meaning of the '<em>Required Memory</em>' attribute isn't clear, | ||
31 | * there really should be more of a description here... | ||
32 | * </p> | ||
33 | * <!-- end-user-doc --> | ||
34 | * @return the value of the '<em>Required Memory</em>' attribute. | ||
35 | * @see #setRequiredMemory(int) | ||
36 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getResourceRequirement_RequiredMemory() | ||
37 | * @model required="true" | ||
38 | * @generated | ||
39 | */ | ||
40 | int getRequiredMemory(); | ||
41 | |||
42 | /** | ||
43 | * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredMemory <em>Required Memory</em>}' attribute. | ||
44 | * <!-- begin-user-doc --> | ||
45 | * <!-- end-user-doc --> | ||
46 | * @param value the new value of the '<em>Required Memory</em>' attribute. | ||
47 | * @see #getRequiredMemory() | ||
48 | * @generated | ||
49 | */ | ||
50 | void setRequiredMemory(int value); | ||
51 | |||
52 | /** | ||
53 | * Returns the value of the '<em><b>Required Hdd</b></em>' attribute. | ||
54 | * <!-- begin-user-doc --> | ||
55 | * <p> | ||
56 | * If the meaning of the '<em>Required Hdd</em>' attribute isn't clear, | ||
57 | * there really should be more of a description here... | ||
58 | * </p> | ||
59 | * <!-- end-user-doc --> | ||
60 | * @return the value of the '<em>Required Hdd</em>' attribute. | ||
61 | * @see #setRequiredHdd(int) | ||
62 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getResourceRequirement_RequiredHdd() | ||
63 | * @model required="true" | ||
64 | * @generated | ||
65 | */ | ||
66 | int getRequiredHdd(); | ||
67 | |||
68 | /** | ||
69 | * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredHdd <em>Required Hdd</em>}' attribute. | ||
70 | * <!-- begin-user-doc --> | ||
71 | * <!-- end-user-doc --> | ||
72 | * @param value the new value of the '<em>Required Hdd</em>' attribute. | ||
73 | * @see #getRequiredHdd() | ||
74 | * @generated | ||
75 | */ | ||
76 | void setRequiredHdd(int value); | ||
77 | |||
78 | /** | ||
79 | * Returns the value of the '<em><b>Host Type</b></em>' reference. | ||
80 | * <!-- begin-user-doc --> | ||
81 | * <p> | ||
82 | * If the meaning of the '<em>Host Type</em>' reference isn't clear, | ||
83 | * there really should be more of a description here... | ||
84 | * </p> | ||
85 | * <!-- end-user-doc --> | ||
86 | * @return the value of the '<em>Host Type</em>' reference. | ||
87 | * @see #setHostType(HostType) | ||
88 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getResourceRequirement_HostType() | ||
89 | * @model required="true" | ||
90 | * @generated | ||
91 | */ | ||
92 | HostType getHostType(); | ||
93 | |||
94 | /** | ||
95 | * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getHostType <em>Host Type</em>}' reference. | ||
96 | * <!-- begin-user-doc --> | ||
97 | * <!-- end-user-doc --> | ||
98 | * @param value the new value of the '<em>Host Type</em>' reference. | ||
99 | * @see #getHostType() | ||
100 | * @generated | ||
101 | */ | ||
102 | void setHostType(HostType value); | ||
103 | |||
104 | } // ResourceRequirement | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationInstanceImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationInstanceImpl.java new file mode 100644 index 00000000..cea2d6f4 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationInstanceImpl.java | |||
@@ -0,0 +1,405 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps.impl; | ||
4 | |||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; | ||
10 | |||
11 | import org.eclipse.emf.common.notify.Notification; | ||
12 | import org.eclipse.emf.common.notify.NotificationChain; | ||
13 | |||
14 | import org.eclipse.emf.ecore.EClass; | ||
15 | import org.eclipse.emf.ecore.InternalEObject; | ||
16 | |||
17 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
18 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; | ||
19 | |||
20 | import org.eclipse.emf.ecore.util.EcoreUtil; | ||
21 | |||
22 | /** | ||
23 | * <!-- begin-user-doc --> | ||
24 | * An implementation of the model object '<em><b>Application Instance</b></em>'. | ||
25 | * <!-- end-user-doc --> | ||
26 | * <p> | ||
27 | * The following features are implemented: | ||
28 | * </p> | ||
29 | * <ul> | ||
30 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl#getRequirement <em>Requirement</em>}</li> | ||
31 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl#getType <em>Type</em>}</li> | ||
32 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl#getAllocatedTo <em>Allocated To</em>}</li> | ||
33 | * </ul> | ||
34 | * | ||
35 | * @generated | ||
36 | */ | ||
37 | public class ApplicationInstanceImpl extends MinimalEObjectImpl.Container implements ApplicationInstance { | ||
38 | /** | ||
39 | * The cached value of the '{@link #getRequirement() <em>Requirement</em>}' reference. | ||
40 | * <!-- begin-user-doc --> | ||
41 | * <!-- end-user-doc --> | ||
42 | * @see #getRequirement() | ||
43 | * @generated | ||
44 | * @ordered | ||
45 | */ | ||
46 | protected Requirement requirement; | ||
47 | |||
48 | /** | ||
49 | * The cached value of the '{@link #getAllocatedTo() <em>Allocated To</em>}' reference. | ||
50 | * <!-- begin-user-doc --> | ||
51 | * <!-- end-user-doc --> | ||
52 | * @see #getAllocatedTo() | ||
53 | * @generated | ||
54 | * @ordered | ||
55 | */ | ||
56 | protected HostInstance allocatedTo; | ||
57 | |||
58 | /** | ||
59 | * <!-- begin-user-doc --> | ||
60 | * <!-- end-user-doc --> | ||
61 | * @generated | ||
62 | */ | ||
63 | protected ApplicationInstanceImpl() { | ||
64 | super(); | ||
65 | } | ||
66 | |||
67 | /** | ||
68 | * <!-- begin-user-doc --> | ||
69 | * <!-- end-user-doc --> | ||
70 | * @generated | ||
71 | */ | ||
72 | @Override | ||
73 | protected EClass eStaticClass() { | ||
74 | return CpsPackage.Literals.APPLICATION_INSTANCE; | ||
75 | } | ||
76 | |||
77 | /** | ||
78 | * <!-- begin-user-doc --> | ||
79 | * <!-- end-user-doc --> | ||
80 | * @generated | ||
81 | */ | ||
82 | @Override | ||
83 | public Requirement getRequirement() { | ||
84 | if (requirement != null && requirement.eIsProxy()) { | ||
85 | InternalEObject oldRequirement = (InternalEObject) requirement; | ||
86 | requirement = (Requirement) eResolveProxy(oldRequirement); | ||
87 | if (requirement != oldRequirement) { | ||
88 | if (eNotificationRequired()) | ||
89 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, | ||
90 | CpsPackage.APPLICATION_INSTANCE__REQUIREMENT, oldRequirement, requirement)); | ||
91 | } | ||
92 | } | ||
93 | return requirement; | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * <!-- begin-user-doc --> | ||
98 | * <!-- end-user-doc --> | ||
99 | * @generated | ||
100 | */ | ||
101 | public Requirement basicGetRequirement() { | ||
102 | return requirement; | ||
103 | } | ||
104 | |||
105 | /** | ||
106 | * <!-- begin-user-doc --> | ||
107 | * <!-- end-user-doc --> | ||
108 | * @generated | ||
109 | */ | ||
110 | public NotificationChain basicSetRequirement(Requirement newRequirement, NotificationChain msgs) { | ||
111 | Requirement oldRequirement = requirement; | ||
112 | requirement = newRequirement; | ||
113 | if (eNotificationRequired()) { | ||
114 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, | ||
115 | CpsPackage.APPLICATION_INSTANCE__REQUIREMENT, oldRequirement, newRequirement); | ||
116 | if (msgs == null) | ||
117 | msgs = notification; | ||
118 | else | ||
119 | msgs.add(notification); | ||
120 | } | ||
121 | return msgs; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * <!-- begin-user-doc --> | ||
126 | * <!-- end-user-doc --> | ||
127 | * @generated | ||
128 | */ | ||
129 | @Override | ||
130 | public void setRequirement(Requirement newRequirement) { | ||
131 | if (newRequirement != requirement) { | ||
132 | NotificationChain msgs = null; | ||
133 | if (requirement != null) | ||
134 | msgs = ((InternalEObject) requirement).eInverseRemove(this, CpsPackage.REQUIREMENT__INSTANCES, | ||
135 | Requirement.class, msgs); | ||
136 | if (newRequirement != null) | ||
137 | msgs = ((InternalEObject) newRequirement).eInverseAdd(this, CpsPackage.REQUIREMENT__INSTANCES, | ||
138 | Requirement.class, msgs); | ||
139 | msgs = basicSetRequirement(newRequirement, msgs); | ||
140 | if (msgs != null) | ||
141 | msgs.dispatch(); | ||
142 | } else if (eNotificationRequired()) | ||
143 | eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.APPLICATION_INSTANCE__REQUIREMENT, | ||
144 | newRequirement, newRequirement)); | ||
145 | } | ||
146 | |||
147 | /** | ||
148 | * <!-- begin-user-doc --> | ||
149 | * <!-- end-user-doc --> | ||
150 | * @generated | ||
151 | */ | ||
152 | @Override | ||
153 | public ApplicationType getType() { | ||
154 | if (eContainerFeatureID() != CpsPackage.APPLICATION_INSTANCE__TYPE) | ||
155 | return null; | ||
156 | return (ApplicationType) eInternalContainer(); | ||
157 | } | ||
158 | |||
159 | /** | ||
160 | * <!-- begin-user-doc --> | ||
161 | * <!-- end-user-doc --> | ||
162 | * @generated | ||
163 | */ | ||
164 | public NotificationChain basicSetType(ApplicationType newType, NotificationChain msgs) { | ||
165 | msgs = eBasicSetContainer((InternalEObject) newType, CpsPackage.APPLICATION_INSTANCE__TYPE, msgs); | ||
166 | return msgs; | ||
167 | } | ||
168 | |||
169 | /** | ||
170 | * <!-- begin-user-doc --> | ||
171 | * <!-- end-user-doc --> | ||
172 | * @generated | ||
173 | */ | ||
174 | @Override | ||
175 | public void setType(ApplicationType newType) { | ||
176 | if (newType != eInternalContainer() | ||
177 | || (eContainerFeatureID() != CpsPackage.APPLICATION_INSTANCE__TYPE && newType != null)) { | ||
178 | if (EcoreUtil.isAncestor(this, newType)) | ||
179 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); | ||
180 | NotificationChain msgs = null; | ||
181 | if (eInternalContainer() != null) | ||
182 | msgs = eBasicRemoveFromContainer(msgs); | ||
183 | if (newType != null) | ||
184 | msgs = ((InternalEObject) newType).eInverseAdd(this, CpsPackage.APPLICATION_TYPE__INSTANCES, | ||
185 | ApplicationType.class, msgs); | ||
186 | msgs = basicSetType(newType, msgs); | ||
187 | if (msgs != null) | ||
188 | msgs.dispatch(); | ||
189 | } else if (eNotificationRequired()) | ||
190 | eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.APPLICATION_INSTANCE__TYPE, newType, | ||
191 | newType)); | ||
192 | } | ||
193 | |||
194 | /** | ||
195 | * <!-- begin-user-doc --> | ||
196 | * <!-- end-user-doc --> | ||
197 | * @generated | ||
198 | */ | ||
199 | @Override | ||
200 | public HostInstance getAllocatedTo() { | ||
201 | if (allocatedTo != null && allocatedTo.eIsProxy()) { | ||
202 | InternalEObject oldAllocatedTo = (InternalEObject) allocatedTo; | ||
203 | allocatedTo = (HostInstance) eResolveProxy(oldAllocatedTo); | ||
204 | if (allocatedTo != oldAllocatedTo) { | ||
205 | if (eNotificationRequired()) | ||
206 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, | ||
207 | CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO, oldAllocatedTo, allocatedTo)); | ||
208 | } | ||
209 | } | ||
210 | return allocatedTo; | ||
211 | } | ||
212 | |||
213 | /** | ||
214 | * <!-- begin-user-doc --> | ||
215 | * <!-- end-user-doc --> | ||
216 | * @generated | ||
217 | */ | ||
218 | public HostInstance basicGetAllocatedTo() { | ||
219 | return allocatedTo; | ||
220 | } | ||
221 | |||
222 | /** | ||
223 | * <!-- begin-user-doc --> | ||
224 | * <!-- end-user-doc --> | ||
225 | * @generated | ||
226 | */ | ||
227 | public NotificationChain basicSetAllocatedTo(HostInstance newAllocatedTo, NotificationChain msgs) { | ||
228 | HostInstance oldAllocatedTo = allocatedTo; | ||
229 | allocatedTo = newAllocatedTo; | ||
230 | if (eNotificationRequired()) { | ||
231 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, | ||
232 | CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO, oldAllocatedTo, newAllocatedTo); | ||
233 | if (msgs == null) | ||
234 | msgs = notification; | ||
235 | else | ||
236 | msgs.add(notification); | ||
237 | } | ||
238 | return msgs; | ||
239 | } | ||
240 | |||
241 | /** | ||
242 | * <!-- begin-user-doc --> | ||
243 | * <!-- end-user-doc --> | ||
244 | * @generated | ||
245 | */ | ||
246 | @Override | ||
247 | public void setAllocatedTo(HostInstance newAllocatedTo) { | ||
248 | if (newAllocatedTo != allocatedTo) { | ||
249 | NotificationChain msgs = null; | ||
250 | if (allocatedTo != null) | ||
251 | msgs = ((InternalEObject) allocatedTo).eInverseRemove(this, CpsPackage.HOST_INSTANCE__APPLICATIONS, | ||
252 | HostInstance.class, msgs); | ||
253 | if (newAllocatedTo != null) | ||
254 | msgs = ((InternalEObject) newAllocatedTo).eInverseAdd(this, CpsPackage.HOST_INSTANCE__APPLICATIONS, | ||
255 | HostInstance.class, msgs); | ||
256 | msgs = basicSetAllocatedTo(newAllocatedTo, msgs); | ||
257 | if (msgs != null) | ||
258 | msgs.dispatch(); | ||
259 | } else if (eNotificationRequired()) | ||
260 | eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO, | ||
261 | newAllocatedTo, newAllocatedTo)); | ||
262 | } | ||
263 | |||
264 | /** | ||
265 | * <!-- begin-user-doc --> | ||
266 | * <!-- end-user-doc --> | ||
267 | * @generated | ||
268 | */ | ||
269 | @Override | ||
270 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
271 | switch (featureID) { | ||
272 | case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: | ||
273 | if (requirement != null) | ||
274 | msgs = ((InternalEObject) requirement).eInverseRemove(this, CpsPackage.REQUIREMENT__INSTANCES, | ||
275 | Requirement.class, msgs); | ||
276 | return basicSetRequirement((Requirement) otherEnd, msgs); | ||
277 | case CpsPackage.APPLICATION_INSTANCE__TYPE: | ||
278 | if (eInternalContainer() != null) | ||
279 | msgs = eBasicRemoveFromContainer(msgs); | ||
280 | return basicSetType((ApplicationType) otherEnd, msgs); | ||
281 | case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: | ||
282 | if (allocatedTo != null) | ||
283 | msgs = ((InternalEObject) allocatedTo).eInverseRemove(this, CpsPackage.HOST_INSTANCE__APPLICATIONS, | ||
284 | HostInstance.class, msgs); | ||
285 | return basicSetAllocatedTo((HostInstance) otherEnd, msgs); | ||
286 | } | ||
287 | return super.eInverseAdd(otherEnd, featureID, msgs); | ||
288 | } | ||
289 | |||
290 | /** | ||
291 | * <!-- begin-user-doc --> | ||
292 | * <!-- end-user-doc --> | ||
293 | * @generated | ||
294 | */ | ||
295 | @Override | ||
296 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
297 | switch (featureID) { | ||
298 | case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: | ||
299 | return basicSetRequirement(null, msgs); | ||
300 | case CpsPackage.APPLICATION_INSTANCE__TYPE: | ||
301 | return basicSetType(null, msgs); | ||
302 | case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: | ||
303 | return basicSetAllocatedTo(null, msgs); | ||
304 | } | ||
305 | return super.eInverseRemove(otherEnd, featureID, msgs); | ||
306 | } | ||
307 | |||
308 | /** | ||
309 | * <!-- begin-user-doc --> | ||
310 | * <!-- end-user-doc --> | ||
311 | * @generated | ||
312 | */ | ||
313 | @Override | ||
314 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { | ||
315 | switch (eContainerFeatureID()) { | ||
316 | case CpsPackage.APPLICATION_INSTANCE__TYPE: | ||
317 | return eInternalContainer().eInverseRemove(this, CpsPackage.APPLICATION_TYPE__INSTANCES, | ||
318 | ApplicationType.class, msgs); | ||
319 | } | ||
320 | return super.eBasicRemoveFromContainerFeature(msgs); | ||
321 | } | ||
322 | |||
323 | /** | ||
324 | * <!-- begin-user-doc --> | ||
325 | * <!-- end-user-doc --> | ||
326 | * @generated | ||
327 | */ | ||
328 | @Override | ||
329 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
330 | switch (featureID) { | ||
331 | case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: | ||
332 | if (resolve) | ||
333 | return getRequirement(); | ||
334 | return basicGetRequirement(); | ||
335 | case CpsPackage.APPLICATION_INSTANCE__TYPE: | ||
336 | return getType(); | ||
337 | case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: | ||
338 | if (resolve) | ||
339 | return getAllocatedTo(); | ||
340 | return basicGetAllocatedTo(); | ||
341 | } | ||
342 | return super.eGet(featureID, resolve, coreType); | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * <!-- begin-user-doc --> | ||
347 | * <!-- end-user-doc --> | ||
348 | * @generated | ||
349 | */ | ||
350 | @Override | ||
351 | public void eSet(int featureID, Object newValue) { | ||
352 | switch (featureID) { | ||
353 | case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: | ||
354 | setRequirement((Requirement) newValue); | ||
355 | return; | ||
356 | case CpsPackage.APPLICATION_INSTANCE__TYPE: | ||
357 | setType((ApplicationType) newValue); | ||
358 | return; | ||
359 | case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: | ||
360 | setAllocatedTo((HostInstance) newValue); | ||
361 | return; | ||
362 | } | ||
363 | super.eSet(featureID, newValue); | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * <!-- begin-user-doc --> | ||
368 | * <!-- end-user-doc --> | ||
369 | * @generated | ||
370 | */ | ||
371 | @Override | ||
372 | public void eUnset(int featureID) { | ||
373 | switch (featureID) { | ||
374 | case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: | ||
375 | setRequirement((Requirement) null); | ||
376 | return; | ||
377 | case CpsPackage.APPLICATION_INSTANCE__TYPE: | ||
378 | setType((ApplicationType) null); | ||
379 | return; | ||
380 | case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: | ||
381 | setAllocatedTo((HostInstance) null); | ||
382 | return; | ||
383 | } | ||
384 | super.eUnset(featureID); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * <!-- begin-user-doc --> | ||
389 | * <!-- end-user-doc --> | ||
390 | * @generated | ||
391 | */ | ||
392 | @Override | ||
393 | public boolean eIsSet(int featureID) { | ||
394 | switch (featureID) { | ||
395 | case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: | ||
396 | return requirement != null; | ||
397 | case CpsPackage.APPLICATION_INSTANCE__TYPE: | ||
398 | return getType() != null; | ||
399 | case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: | ||
400 | return allocatedTo != null; | ||
401 | } | ||
402 | return super.eIsSet(featureID); | ||
403 | } | ||
404 | |||
405 | } //ApplicationInstanceImpl | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationTypeImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationTypeImpl.java new file mode 100644 index 00000000..f8793e30 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationTypeImpl.java | |||
@@ -0,0 +1,209 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps.impl; | ||
4 | |||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; | ||
9 | |||
10 | import java.util.Collection; | ||
11 | |||
12 | import org.eclipse.emf.common.notify.NotificationChain; | ||
13 | |||
14 | import org.eclipse.emf.common.util.EList; | ||
15 | |||
16 | import org.eclipse.emf.ecore.EClass; | ||
17 | import org.eclipse.emf.ecore.InternalEObject; | ||
18 | |||
19 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; | ||
20 | |||
21 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; | ||
22 | import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; | ||
23 | import org.eclipse.emf.ecore.util.InternalEList; | ||
24 | |||
25 | /** | ||
26 | * <!-- begin-user-doc --> | ||
27 | * An implementation of the model object '<em><b>Application Type</b></em>'. | ||
28 | * <!-- end-user-doc --> | ||
29 | * <p> | ||
30 | * The following features are implemented: | ||
31 | * </p> | ||
32 | * <ul> | ||
33 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl#getInstances <em>Instances</em>}</li> | ||
34 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl#getRequirements <em>Requirements</em>}</li> | ||
35 | * </ul> | ||
36 | * | ||
37 | * @generated | ||
38 | */ | ||
39 | public class ApplicationTypeImpl extends MinimalEObjectImpl.Container implements ApplicationType { | ||
40 | /** | ||
41 | * The cached value of the '{@link #getInstances() <em>Instances</em>}' containment reference list. | ||
42 | * <!-- begin-user-doc --> | ||
43 | * <!-- end-user-doc --> | ||
44 | * @see #getInstances() | ||
45 | * @generated | ||
46 | * @ordered | ||
47 | */ | ||
48 | protected EList<ApplicationInstance> instances; | ||
49 | |||
50 | /** | ||
51 | * The cached value of the '{@link #getRequirements() <em>Requirements</em>}' containment reference list. | ||
52 | * <!-- begin-user-doc --> | ||
53 | * <!-- end-user-doc --> | ||
54 | * @see #getRequirements() | ||
55 | * @generated | ||
56 | * @ordered | ||
57 | */ | ||
58 | protected EList<ResourceRequirement> requirements; | ||
59 | |||
60 | /** | ||
61 | * <!-- begin-user-doc --> | ||
62 | * <!-- end-user-doc --> | ||
63 | * @generated | ||
64 | */ | ||
65 | protected ApplicationTypeImpl() { | ||
66 | super(); | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * <!-- begin-user-doc --> | ||
71 | * <!-- end-user-doc --> | ||
72 | * @generated | ||
73 | */ | ||
74 | @Override | ||
75 | protected EClass eStaticClass() { | ||
76 | return CpsPackage.Literals.APPLICATION_TYPE; | ||
77 | } | ||
78 | |||
79 | /** | ||
80 | * <!-- begin-user-doc --> | ||
81 | * <!-- end-user-doc --> | ||
82 | * @generated | ||
83 | */ | ||
84 | @Override | ||
85 | public EList<ApplicationInstance> getInstances() { | ||
86 | if (instances == null) { | ||
87 | instances = new EObjectContainmentWithInverseEList<ApplicationInstance>(ApplicationInstance.class, this, | ||
88 | CpsPackage.APPLICATION_TYPE__INSTANCES, CpsPackage.APPLICATION_INSTANCE__TYPE); | ||
89 | } | ||
90 | return instances; | ||
91 | } | ||
92 | |||
93 | /** | ||
94 | * <!-- begin-user-doc --> | ||
95 | * <!-- end-user-doc --> | ||
96 | * @generated | ||
97 | */ | ||
98 | @Override | ||
99 | public EList<ResourceRequirement> getRequirements() { | ||
100 | if (requirements == null) { | ||
101 | requirements = new EObjectContainmentEList<ResourceRequirement>(ResourceRequirement.class, this, | ||
102 | CpsPackage.APPLICATION_TYPE__REQUIREMENTS); | ||
103 | } | ||
104 | return requirements; | ||
105 | } | ||
106 | |||
107 | /** | ||
108 | * <!-- begin-user-doc --> | ||
109 | * <!-- end-user-doc --> | ||
110 | * @generated | ||
111 | */ | ||
112 | @SuppressWarnings("unchecked") | ||
113 | @Override | ||
114 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
115 | switch (featureID) { | ||
116 | case CpsPackage.APPLICATION_TYPE__INSTANCES: | ||
117 | return ((InternalEList<InternalEObject>) (InternalEList<?>) getInstances()).basicAdd(otherEnd, msgs); | ||
118 | } | ||
119 | return super.eInverseAdd(otherEnd, featureID, msgs); | ||
120 | } | ||
121 | |||
122 | /** | ||
123 | * <!-- begin-user-doc --> | ||
124 | * <!-- end-user-doc --> | ||
125 | * @generated | ||
126 | */ | ||
127 | @Override | ||
128 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
129 | switch (featureID) { | ||
130 | case CpsPackage.APPLICATION_TYPE__INSTANCES: | ||
131 | return ((InternalEList<?>) getInstances()).basicRemove(otherEnd, msgs); | ||
132 | case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: | ||
133 | return ((InternalEList<?>) getRequirements()).basicRemove(otherEnd, msgs); | ||
134 | } | ||
135 | return super.eInverseRemove(otherEnd, featureID, msgs); | ||
136 | } | ||
137 | |||
138 | /** | ||
139 | * <!-- begin-user-doc --> | ||
140 | * <!-- end-user-doc --> | ||
141 | * @generated | ||
142 | */ | ||
143 | @Override | ||
144 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
145 | switch (featureID) { | ||
146 | case CpsPackage.APPLICATION_TYPE__INSTANCES: | ||
147 | return getInstances(); | ||
148 | case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: | ||
149 | return getRequirements(); | ||
150 | } | ||
151 | return super.eGet(featureID, resolve, coreType); | ||
152 | } | ||
153 | |||
154 | /** | ||
155 | * <!-- begin-user-doc --> | ||
156 | * <!-- end-user-doc --> | ||
157 | * @generated | ||
158 | */ | ||
159 | @SuppressWarnings("unchecked") | ||
160 | @Override | ||
161 | public void eSet(int featureID, Object newValue) { | ||
162 | switch (featureID) { | ||
163 | case CpsPackage.APPLICATION_TYPE__INSTANCES: | ||
164 | getInstances().clear(); | ||
165 | getInstances().addAll((Collection<? extends ApplicationInstance>) newValue); | ||
166 | return; | ||
167 | case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: | ||
168 | getRequirements().clear(); | ||
169 | getRequirements().addAll((Collection<? extends ResourceRequirement>) newValue); | ||
170 | return; | ||
171 | } | ||
172 | super.eSet(featureID, newValue); | ||
173 | } | ||
174 | |||
175 | /** | ||
176 | * <!-- begin-user-doc --> | ||
177 | * <!-- end-user-doc --> | ||
178 | * @generated | ||
179 | */ | ||
180 | @Override | ||
181 | public void eUnset(int featureID) { | ||
182 | switch (featureID) { | ||
183 | case CpsPackage.APPLICATION_TYPE__INSTANCES: | ||
184 | getInstances().clear(); | ||
185 | return; | ||
186 | case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: | ||
187 | getRequirements().clear(); | ||
188 | return; | ||
189 | } | ||
190 | super.eUnset(featureID); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * <!-- begin-user-doc --> | ||
195 | * <!-- end-user-doc --> | ||
196 | * @generated | ||
197 | */ | ||
198 | @Override | ||
199 | public boolean eIsSet(int featureID) { | ||
200 | switch (featureID) { | ||
201 | case CpsPackage.APPLICATION_TYPE__INSTANCES: | ||
202 | return instances != null && !instances.isEmpty(); | ||
203 | case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: | ||
204 | return requirements != null && !requirements.isEmpty(); | ||
205 | } | ||
206 | return super.eIsSet(featureID); | ||
207 | } | ||
208 | |||
209 | } //ApplicationTypeImpl | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsFactoryImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsFactoryImpl.java new file mode 100644 index 00000000..110f5abb --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsFactoryImpl.java | |||
@@ -0,0 +1,188 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps.impl; | ||
4 | |||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.*; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EClass; | ||
8 | import org.eclipse.emf.ecore.EObject; | ||
9 | import org.eclipse.emf.ecore.EPackage; | ||
10 | |||
11 | import org.eclipse.emf.ecore.impl.EFactoryImpl; | ||
12 | |||
13 | import org.eclipse.emf.ecore.plugin.EcorePlugin; | ||
14 | |||
15 | /** | ||
16 | * <!-- begin-user-doc --> | ||
17 | * An implementation of the model <b>Factory</b>. | ||
18 | * <!-- end-user-doc --> | ||
19 | * @generated | ||
20 | */ | ||
21 | public class CpsFactoryImpl extends EFactoryImpl implements CpsFactory { | ||
22 | /** | ||
23 | * Creates the default factory implementation. | ||
24 | * <!-- begin-user-doc --> | ||
25 | * <!-- end-user-doc --> | ||
26 | * @generated | ||
27 | */ | ||
28 | public static CpsFactory init() { | ||
29 | try { | ||
30 | CpsFactory theCpsFactory = (CpsFactory) EPackage.Registry.INSTANCE.getEFactory(CpsPackage.eNS_URI); | ||
31 | if (theCpsFactory != null) { | ||
32 | return theCpsFactory; | ||
33 | } | ||
34 | } catch (Exception exception) { | ||
35 | EcorePlugin.INSTANCE.log(exception); | ||
36 | } | ||
37 | return new CpsFactoryImpl(); | ||
38 | } | ||
39 | |||
40 | /** | ||
41 | * Creates an instance of the factory. | ||
42 | * <!-- begin-user-doc --> | ||
43 | * <!-- end-user-doc --> | ||
44 | * @generated | ||
45 | */ | ||
46 | public CpsFactoryImpl() { | ||
47 | super(); | ||
48 | } | ||
49 | |||
50 | /** | ||
51 | * <!-- begin-user-doc --> | ||
52 | * <!-- end-user-doc --> | ||
53 | * @generated | ||
54 | */ | ||
55 | @Override | ||
56 | public EObject create(EClass eClass) { | ||
57 | switch (eClass.getClassifierID()) { | ||
58 | case CpsPackage.CYBER_PHYSICAL_SYSTEM: | ||
59 | return createCyberPhysicalSystem(); | ||
60 | case CpsPackage.APPLICATION_TYPE: | ||
61 | return createApplicationType(); | ||
62 | case CpsPackage.HOST_TYPE: | ||
63 | return createHostType(); | ||
64 | case CpsPackage.REQUEST: | ||
65 | return createRequest(); | ||
66 | case CpsPackage.REQUIREMENT: | ||
67 | return createRequirement(); | ||
68 | case CpsPackage.APPLICATION_INSTANCE: | ||
69 | return createApplicationInstance(); | ||
70 | case CpsPackage.RESOURCE_REQUIREMENT: | ||
71 | return createResourceRequirement(); | ||
72 | case CpsPackage.HOST_INSTANCE: | ||
73 | return createHostInstance(); | ||
74 | default: | ||
75 | throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | /** | ||
80 | * <!-- begin-user-doc --> | ||
81 | * <!-- end-user-doc --> | ||
82 | * @generated | ||
83 | */ | ||
84 | @Override | ||
85 | public CyberPhysicalSystem createCyberPhysicalSystem() { | ||
86 | CyberPhysicalSystemImpl cyberPhysicalSystem = new CyberPhysicalSystemImpl(); | ||
87 | return cyberPhysicalSystem; | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * <!-- begin-user-doc --> | ||
92 | * <!-- end-user-doc --> | ||
93 | * @generated | ||
94 | */ | ||
95 | @Override | ||
96 | public ApplicationType createApplicationType() { | ||
97 | ApplicationTypeImpl applicationType = new ApplicationTypeImpl(); | ||
98 | return applicationType; | ||
99 | } | ||
100 | |||
101 | /** | ||
102 | * <!-- begin-user-doc --> | ||
103 | * <!-- end-user-doc --> | ||
104 | * @generated | ||
105 | */ | ||
106 | @Override | ||
107 | public HostType createHostType() { | ||
108 | HostTypeImpl hostType = new HostTypeImpl(); | ||
109 | return hostType; | ||
110 | } | ||
111 | |||
112 | /** | ||
113 | * <!-- begin-user-doc --> | ||
114 | * <!-- end-user-doc --> | ||
115 | * @generated | ||
116 | */ | ||
117 | @Override | ||
118 | public Request createRequest() { | ||
119 | RequestImpl request = new RequestImpl(); | ||
120 | return request; | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * <!-- begin-user-doc --> | ||
125 | * <!-- end-user-doc --> | ||
126 | * @generated | ||
127 | */ | ||
128 | @Override | ||
129 | public Requirement createRequirement() { | ||
130 | RequirementImpl requirement = new RequirementImpl(); | ||
131 | return requirement; | ||
132 | } | ||
133 | |||
134 | /** | ||
135 | * <!-- begin-user-doc --> | ||
136 | * <!-- end-user-doc --> | ||
137 | * @generated | ||
138 | */ | ||
139 | @Override | ||
140 | public ApplicationInstance createApplicationInstance() { | ||
141 | ApplicationInstanceImpl applicationInstance = new ApplicationInstanceImpl(); | ||
142 | return applicationInstance; | ||
143 | } | ||
144 | |||
145 | /** | ||
146 | * <!-- begin-user-doc --> | ||
147 | * <!-- end-user-doc --> | ||
148 | * @generated | ||
149 | */ | ||
150 | @Override | ||
151 | public ResourceRequirement createResourceRequirement() { | ||
152 | ResourceRequirementImpl resourceRequirement = new ResourceRequirementImpl(); | ||
153 | return resourceRequirement; | ||
154 | } | ||
155 | |||
156 | /** | ||
157 | * <!-- begin-user-doc --> | ||
158 | * <!-- end-user-doc --> | ||
159 | * @generated | ||
160 | */ | ||
161 | @Override | ||
162 | public HostInstance createHostInstance() { | ||
163 | HostInstanceImpl hostInstance = new HostInstanceImpl(); | ||
164 | return hostInstance; | ||
165 | } | ||
166 | |||
167 | /** | ||
168 | * <!-- begin-user-doc --> | ||
169 | * <!-- end-user-doc --> | ||
170 | * @generated | ||
171 | */ | ||
172 | @Override | ||
173 | public CpsPackage getCpsPackage() { | ||
174 | return (CpsPackage) getEPackage(); | ||
175 | } | ||
176 | |||
177 | /** | ||
178 | * <!-- begin-user-doc --> | ||
179 | * <!-- end-user-doc --> | ||
180 | * @deprecated | ||
181 | * @generated | ||
182 | */ | ||
183 | @Deprecated | ||
184 | public static CpsPackage getPackage() { | ||
185 | return CpsPackage.eINSTANCE; | ||
186 | } | ||
187 | |||
188 | } //CpsFactoryImpl | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java new file mode 100644 index 00000000..e29ccccd --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java | |||
@@ -0,0 +1,643 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps.impl; | ||
4 | |||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
10 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
11 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
12 | import hu.bme.mit.inf.dslreasoner.domains.cps.Request; | ||
13 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; | ||
14 | import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; | ||
15 | |||
16 | import org.eclipse.emf.ecore.EAttribute; | ||
17 | import org.eclipse.emf.ecore.EClass; | ||
18 | import org.eclipse.emf.ecore.EPackage; | ||
19 | import org.eclipse.emf.ecore.EReference; | ||
20 | |||
21 | import org.eclipse.emf.ecore.impl.EPackageImpl; | ||
22 | |||
23 | /** | ||
24 | * <!-- begin-user-doc --> | ||
25 | * An implementation of the model <b>Package</b>. | ||
26 | * <!-- end-user-doc --> | ||
27 | * @generated | ||
28 | */ | ||
29 | public class CpsPackageImpl extends EPackageImpl implements CpsPackage { | ||
30 | /** | ||
31 | * <!-- begin-user-doc --> | ||
32 | * <!-- end-user-doc --> | ||
33 | * @generated | ||
34 | */ | ||
35 | private EClass cyberPhysicalSystemEClass = null; | ||
36 | |||
37 | /** | ||
38 | * <!-- begin-user-doc --> | ||
39 | * <!-- end-user-doc --> | ||
40 | * @generated | ||
41 | */ | ||
42 | private EClass applicationTypeEClass = null; | ||
43 | |||
44 | /** | ||
45 | * <!-- begin-user-doc --> | ||
46 | * <!-- end-user-doc --> | ||
47 | * @generated | ||
48 | */ | ||
49 | private EClass hostTypeEClass = null; | ||
50 | |||
51 | /** | ||
52 | * <!-- begin-user-doc --> | ||
53 | * <!-- end-user-doc --> | ||
54 | * @generated | ||
55 | */ | ||
56 | private EClass requestEClass = null; | ||
57 | |||
58 | /** | ||
59 | * <!-- begin-user-doc --> | ||
60 | * <!-- end-user-doc --> | ||
61 | * @generated | ||
62 | */ | ||
63 | private EClass requirementEClass = null; | ||
64 | |||
65 | /** | ||
66 | * <!-- begin-user-doc --> | ||
67 | * <!-- end-user-doc --> | ||
68 | * @generated | ||
69 | */ | ||
70 | private EClass applicationInstanceEClass = null; | ||
71 | |||
72 | /** | ||
73 | * <!-- begin-user-doc --> | ||
74 | * <!-- end-user-doc --> | ||
75 | * @generated | ||
76 | */ | ||
77 | private EClass resourceRequirementEClass = null; | ||
78 | |||
79 | /** | ||
80 | * <!-- begin-user-doc --> | ||
81 | * <!-- end-user-doc --> | ||
82 | * @generated | ||
83 | */ | ||
84 | private EClass hostInstanceEClass = null; | ||
85 | |||
86 | /** | ||
87 | * Creates an instance of the model <b>Package</b>, registered with | ||
88 | * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package | ||
89 | * package URI value. | ||
90 | * <p>Note: the correct way to create the package is via the static | ||
91 | * factory method {@link #init init()}, which also performs | ||
92 | * initialization of the package, or returns the registered package, | ||
93 | * if one already exists. | ||
94 | * <!-- begin-user-doc --> | ||
95 | * <!-- end-user-doc --> | ||
96 | * @see org.eclipse.emf.ecore.EPackage.Registry | ||
97 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#eNS_URI | ||
98 | * @see #init() | ||
99 | * @generated | ||
100 | */ | ||
101 | private CpsPackageImpl() { | ||
102 | super(eNS_URI, CpsFactory.eINSTANCE); | ||
103 | } | ||
104 | |||
105 | /** | ||
106 | * <!-- begin-user-doc --> | ||
107 | * <!-- end-user-doc --> | ||
108 | * @generated | ||
109 | */ | ||
110 | private static boolean isInited = false; | ||
111 | |||
112 | /** | ||
113 | * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. | ||
114 | * | ||
115 | * <p>This method is used to initialize {@link CpsPackage#eINSTANCE} when that field is accessed. | ||
116 | * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. | ||
117 | * <!-- begin-user-doc --> | ||
118 | * <!-- end-user-doc --> | ||
119 | * @see #eNS_URI | ||
120 | * @see #createPackageContents() | ||
121 | * @see #initializePackageContents() | ||
122 | * @generated | ||
123 | */ | ||
124 | public static CpsPackage init() { | ||
125 | if (isInited) | ||
126 | return (CpsPackage) EPackage.Registry.INSTANCE.getEPackage(CpsPackage.eNS_URI); | ||
127 | |||
128 | // Obtain or create and register package | ||
129 | Object registeredCpsPackage = EPackage.Registry.INSTANCE.get(eNS_URI); | ||
130 | CpsPackageImpl theCpsPackage = registeredCpsPackage instanceof CpsPackageImpl | ||
131 | ? (CpsPackageImpl) registeredCpsPackage | ||
132 | : new CpsPackageImpl(); | ||
133 | |||
134 | isInited = true; | ||
135 | |||
136 | // Create package meta-data objects | ||
137 | theCpsPackage.createPackageContents(); | ||
138 | |||
139 | // Initialize created meta-data | ||
140 | theCpsPackage.initializePackageContents(); | ||
141 | |||
142 | // Mark meta-data to indicate it can't be changed | ||
143 | theCpsPackage.freeze(); | ||
144 | |||
145 | // Update the registry and return the package | ||
146 | EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, theCpsPackage); | ||
147 | return theCpsPackage; | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * <!-- begin-user-doc --> | ||
152 | * <!-- end-user-doc --> | ||
153 | * @generated | ||
154 | */ | ||
155 | @Override | ||
156 | public EClass getCyberPhysicalSystem() { | ||
157 | return cyberPhysicalSystemEClass; | ||
158 | } | ||
159 | |||
160 | /** | ||
161 | * <!-- begin-user-doc --> | ||
162 | * <!-- end-user-doc --> | ||
163 | * @generated | ||
164 | */ | ||
165 | @Override | ||
166 | public EReference getCyberPhysicalSystem_Requests() { | ||
167 | return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(0); | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * <!-- begin-user-doc --> | ||
172 | * <!-- end-user-doc --> | ||
173 | * @generated | ||
174 | */ | ||
175 | @Override | ||
176 | public EReference getCyberPhysicalSystem_ApplicationTypes() { | ||
177 | return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(1); | ||
178 | } | ||
179 | |||
180 | /** | ||
181 | * <!-- begin-user-doc --> | ||
182 | * <!-- end-user-doc --> | ||
183 | * @generated | ||
184 | */ | ||
185 | @Override | ||
186 | public EReference getCyberPhysicalSystem_HostTypes() { | ||
187 | return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(2); | ||
188 | } | ||
189 | |||
190 | /** | ||
191 | * <!-- begin-user-doc --> | ||
192 | * <!-- end-user-doc --> | ||
193 | * @generated | ||
194 | */ | ||
195 | @Override | ||
196 | public EClass getApplicationType() { | ||
197 | return applicationTypeEClass; | ||
198 | } | ||
199 | |||
200 | /** | ||
201 | * <!-- begin-user-doc --> | ||
202 | * <!-- end-user-doc --> | ||
203 | * @generated | ||
204 | */ | ||
205 | @Override | ||
206 | public EReference getApplicationType_Instances() { | ||
207 | return (EReference) applicationTypeEClass.getEStructuralFeatures().get(0); | ||
208 | } | ||
209 | |||
210 | /** | ||
211 | * <!-- begin-user-doc --> | ||
212 | * <!-- end-user-doc --> | ||
213 | * @generated | ||
214 | */ | ||
215 | @Override | ||
216 | public EReference getApplicationType_Requirements() { | ||
217 | return (EReference) applicationTypeEClass.getEStructuralFeatures().get(1); | ||
218 | } | ||
219 | |||
220 | /** | ||
221 | * <!-- begin-user-doc --> | ||
222 | * <!-- end-user-doc --> | ||
223 | * @generated | ||
224 | */ | ||
225 | @Override | ||
226 | public EClass getHostType() { | ||
227 | return hostTypeEClass; | ||
228 | } | ||
229 | |||
230 | /** | ||
231 | * <!-- begin-user-doc --> | ||
232 | * <!-- end-user-doc --> | ||
233 | * @generated | ||
234 | */ | ||
235 | @Override | ||
236 | public EAttribute getHostType_DefaultMemory() { | ||
237 | return (EAttribute) hostTypeEClass.getEStructuralFeatures().get(0); | ||
238 | } | ||
239 | |||
240 | /** | ||
241 | * <!-- begin-user-doc --> | ||
242 | * <!-- end-user-doc --> | ||
243 | * @generated | ||
244 | */ | ||
245 | @Override | ||
246 | public EAttribute getHostType_DefaultHdd() { | ||
247 | return (EAttribute) hostTypeEClass.getEStructuralFeatures().get(1); | ||
248 | } | ||
249 | |||
250 | /** | ||
251 | * <!-- begin-user-doc --> | ||
252 | * <!-- end-user-doc --> | ||
253 | * @generated | ||
254 | */ | ||
255 | @Override | ||
256 | public EReference getHostType_Instances() { | ||
257 | return (EReference) hostTypeEClass.getEStructuralFeatures().get(2); | ||
258 | } | ||
259 | |||
260 | /** | ||
261 | * <!-- begin-user-doc --> | ||
262 | * <!-- end-user-doc --> | ||
263 | * @generated | ||
264 | */ | ||
265 | @Override | ||
266 | public EAttribute getHostType_Cost() { | ||
267 | return (EAttribute) hostTypeEClass.getEStructuralFeatures().get(3); | ||
268 | } | ||
269 | |||
270 | /** | ||
271 | * <!-- begin-user-doc --> | ||
272 | * <!-- end-user-doc --> | ||
273 | * @generated | ||
274 | */ | ||
275 | @Override | ||
276 | public EClass getRequest() { | ||
277 | return requestEClass; | ||
278 | } | ||
279 | |||
280 | /** | ||
281 | * <!-- begin-user-doc --> | ||
282 | * <!-- end-user-doc --> | ||
283 | * @generated | ||
284 | */ | ||
285 | @Override | ||
286 | public EReference getRequest_Requirements() { | ||
287 | return (EReference) requestEClass.getEStructuralFeatures().get(0); | ||
288 | } | ||
289 | |||
290 | /** | ||
291 | * <!-- begin-user-doc --> | ||
292 | * <!-- end-user-doc --> | ||
293 | * @generated | ||
294 | */ | ||
295 | @Override | ||
296 | public EClass getRequirement() { | ||
297 | return requirementEClass; | ||
298 | } | ||
299 | |||
300 | /** | ||
301 | * <!-- begin-user-doc --> | ||
302 | * <!-- end-user-doc --> | ||
303 | * @generated | ||
304 | */ | ||
305 | @Override | ||
306 | public EReference getRequirement_Request() { | ||
307 | return (EReference) requirementEClass.getEStructuralFeatures().get(0); | ||
308 | } | ||
309 | |||
310 | /** | ||
311 | * <!-- begin-user-doc --> | ||
312 | * <!-- end-user-doc --> | ||
313 | * @generated | ||
314 | */ | ||
315 | @Override | ||
316 | public EAttribute getRequirement_Count() { | ||
317 | return (EAttribute) requirementEClass.getEStructuralFeatures().get(1); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * <!-- begin-user-doc --> | ||
322 | * <!-- end-user-doc --> | ||
323 | * @generated | ||
324 | */ | ||
325 | @Override | ||
326 | public EReference getRequirement_Type() { | ||
327 | return (EReference) requirementEClass.getEStructuralFeatures().get(2); | ||
328 | } | ||
329 | |||
330 | /** | ||
331 | * <!-- begin-user-doc --> | ||
332 | * <!-- end-user-doc --> | ||
333 | * @generated | ||
334 | */ | ||
335 | @Override | ||
336 | public EReference getRequirement_Instances() { | ||
337 | return (EReference) requirementEClass.getEStructuralFeatures().get(3); | ||
338 | } | ||
339 | |||
340 | /** | ||
341 | * <!-- begin-user-doc --> | ||
342 | * <!-- end-user-doc --> | ||
343 | * @generated | ||
344 | */ | ||
345 | @Override | ||
346 | public EClass getApplicationInstance() { | ||
347 | return applicationInstanceEClass; | ||
348 | } | ||
349 | |||
350 | /** | ||
351 | * <!-- begin-user-doc --> | ||
352 | * <!-- end-user-doc --> | ||
353 | * @generated | ||
354 | */ | ||
355 | @Override | ||
356 | public EReference getApplicationInstance_Requirement() { | ||
357 | return (EReference) applicationInstanceEClass.getEStructuralFeatures().get(0); | ||
358 | } | ||
359 | |||
360 | /** | ||
361 | * <!-- begin-user-doc --> | ||
362 | * <!-- end-user-doc --> | ||
363 | * @generated | ||
364 | */ | ||
365 | @Override | ||
366 | public EReference getApplicationInstance_Type() { | ||
367 | return (EReference) applicationInstanceEClass.getEStructuralFeatures().get(1); | ||
368 | } | ||
369 | |||
370 | /** | ||
371 | * <!-- begin-user-doc --> | ||
372 | * <!-- end-user-doc --> | ||
373 | * @generated | ||
374 | */ | ||
375 | @Override | ||
376 | public EReference getApplicationInstance_AllocatedTo() { | ||
377 | return (EReference) applicationInstanceEClass.getEStructuralFeatures().get(2); | ||
378 | } | ||
379 | |||
380 | /** | ||
381 | * <!-- begin-user-doc --> | ||
382 | * <!-- end-user-doc --> | ||
383 | * @generated | ||
384 | */ | ||
385 | @Override | ||
386 | public EClass getResourceRequirement() { | ||
387 | return resourceRequirementEClass; | ||
388 | } | ||
389 | |||
390 | /** | ||
391 | * <!-- begin-user-doc --> | ||
392 | * <!-- end-user-doc --> | ||
393 | * @generated | ||
394 | */ | ||
395 | @Override | ||
396 | public EAttribute getResourceRequirement_RequiredMemory() { | ||
397 | return (EAttribute) resourceRequirementEClass.getEStructuralFeatures().get(0); | ||
398 | } | ||
399 | |||
400 | /** | ||
401 | * <!-- begin-user-doc --> | ||
402 | * <!-- end-user-doc --> | ||
403 | * @generated | ||
404 | */ | ||
405 | @Override | ||
406 | public EAttribute getResourceRequirement_RequiredHdd() { | ||
407 | return (EAttribute) resourceRequirementEClass.getEStructuralFeatures().get(1); | ||
408 | } | ||
409 | |||
410 | /** | ||
411 | * <!-- begin-user-doc --> | ||
412 | * <!-- end-user-doc --> | ||
413 | * @generated | ||
414 | */ | ||
415 | @Override | ||
416 | public EReference getResourceRequirement_HostType() { | ||
417 | return (EReference) resourceRequirementEClass.getEStructuralFeatures().get(2); | ||
418 | } | ||
419 | |||
420 | /** | ||
421 | * <!-- begin-user-doc --> | ||
422 | * <!-- end-user-doc --> | ||
423 | * @generated | ||
424 | */ | ||
425 | @Override | ||
426 | public EClass getHostInstance() { | ||
427 | return hostInstanceEClass; | ||
428 | } | ||
429 | |||
430 | /** | ||
431 | * <!-- begin-user-doc --> | ||
432 | * <!-- end-user-doc --> | ||
433 | * @generated | ||
434 | */ | ||
435 | @Override | ||
436 | public EReference getHostInstance_Type() { | ||
437 | return (EReference) hostInstanceEClass.getEStructuralFeatures().get(0); | ||
438 | } | ||
439 | |||
440 | /** | ||
441 | * <!-- begin-user-doc --> | ||
442 | * <!-- end-user-doc --> | ||
443 | * @generated | ||
444 | */ | ||
445 | @Override | ||
446 | public EReference getHostInstance_Applications() { | ||
447 | return (EReference) hostInstanceEClass.getEStructuralFeatures().get(1); | ||
448 | } | ||
449 | |||
450 | /** | ||
451 | * <!-- begin-user-doc --> | ||
452 | * <!-- end-user-doc --> | ||
453 | * @generated | ||
454 | */ | ||
455 | @Override | ||
456 | public CpsFactory getCpsFactory() { | ||
457 | return (CpsFactory) getEFactoryInstance(); | ||
458 | } | ||
459 | |||
460 | /** | ||
461 | * <!-- begin-user-doc --> | ||
462 | * <!-- end-user-doc --> | ||
463 | * @generated | ||
464 | */ | ||
465 | private boolean isCreated = false; | ||
466 | |||
467 | /** | ||
468 | * Creates the meta-model objects for the package. This method is | ||
469 | * guarded to have no affect on any invocation but its first. | ||
470 | * <!-- begin-user-doc --> | ||
471 | * <!-- end-user-doc --> | ||
472 | * @generated | ||
473 | */ | ||
474 | public void createPackageContents() { | ||
475 | if (isCreated) | ||
476 | return; | ||
477 | isCreated = true; | ||
478 | |||
479 | // Create classes and their features | ||
480 | cyberPhysicalSystemEClass = createEClass(CYBER_PHYSICAL_SYSTEM); | ||
481 | createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__REQUESTS); | ||
482 | createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES); | ||
483 | createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__HOST_TYPES); | ||
484 | |||
485 | applicationTypeEClass = createEClass(APPLICATION_TYPE); | ||
486 | createEReference(applicationTypeEClass, APPLICATION_TYPE__INSTANCES); | ||
487 | createEReference(applicationTypeEClass, APPLICATION_TYPE__REQUIREMENTS); | ||
488 | |||
489 | hostTypeEClass = createEClass(HOST_TYPE); | ||
490 | createEAttribute(hostTypeEClass, HOST_TYPE__DEFAULT_MEMORY); | ||
491 | createEAttribute(hostTypeEClass, HOST_TYPE__DEFAULT_HDD); | ||
492 | createEReference(hostTypeEClass, HOST_TYPE__INSTANCES); | ||
493 | createEAttribute(hostTypeEClass, HOST_TYPE__COST); | ||
494 | |||
495 | requestEClass = createEClass(REQUEST); | ||
496 | createEReference(requestEClass, REQUEST__REQUIREMENTS); | ||
497 | |||
498 | requirementEClass = createEClass(REQUIREMENT); | ||
499 | createEReference(requirementEClass, REQUIREMENT__REQUEST); | ||
500 | createEAttribute(requirementEClass, REQUIREMENT__COUNT); | ||
501 | createEReference(requirementEClass, REQUIREMENT__TYPE); | ||
502 | createEReference(requirementEClass, REQUIREMENT__INSTANCES); | ||
503 | |||
504 | applicationInstanceEClass = createEClass(APPLICATION_INSTANCE); | ||
505 | createEReference(applicationInstanceEClass, APPLICATION_INSTANCE__REQUIREMENT); | ||
506 | createEReference(applicationInstanceEClass, APPLICATION_INSTANCE__TYPE); | ||
507 | createEReference(applicationInstanceEClass, APPLICATION_INSTANCE__ALLOCATED_TO); | ||
508 | |||
509 | resourceRequirementEClass = createEClass(RESOURCE_REQUIREMENT); | ||
510 | createEAttribute(resourceRequirementEClass, RESOURCE_REQUIREMENT__REQUIRED_MEMORY); | ||
511 | createEAttribute(resourceRequirementEClass, RESOURCE_REQUIREMENT__REQUIRED_HDD); | ||
512 | createEReference(resourceRequirementEClass, RESOURCE_REQUIREMENT__HOST_TYPE); | ||
513 | |||
514 | hostInstanceEClass = createEClass(HOST_INSTANCE); | ||
515 | createEReference(hostInstanceEClass, HOST_INSTANCE__TYPE); | ||
516 | createEReference(hostInstanceEClass, HOST_INSTANCE__APPLICATIONS); | ||
517 | } | ||
518 | |||
519 | /** | ||
520 | * <!-- begin-user-doc --> | ||
521 | * <!-- end-user-doc --> | ||
522 | * @generated | ||
523 | */ | ||
524 | private boolean isInitialized = false; | ||
525 | |||
526 | /** | ||
527 | * Complete the initialization of the package and its meta-model. This | ||
528 | * method is guarded to have no affect on any invocation but its first. | ||
529 | * <!-- begin-user-doc --> | ||
530 | * <!-- end-user-doc --> | ||
531 | * @generated | ||
532 | */ | ||
533 | public void initializePackageContents() { | ||
534 | if (isInitialized) | ||
535 | return; | ||
536 | isInitialized = true; | ||
537 | |||
538 | // Initialize package | ||
539 | setName(eNAME); | ||
540 | setNsPrefix(eNS_PREFIX); | ||
541 | setNsURI(eNS_URI); | ||
542 | |||
543 | // Create type parameters | ||
544 | |||
545 | // Set bounds for type parameters | ||
546 | |||
547 | // Add supertypes to classes | ||
548 | |||
549 | // Initialize classes, features, and operations; add parameters | ||
550 | initEClass(cyberPhysicalSystemEClass, CyberPhysicalSystem.class, "CyberPhysicalSystem", !IS_ABSTRACT, | ||
551 | !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | ||
552 | initEReference(getCyberPhysicalSystem_Requests(), this.getRequest(), null, "requests", null, 0, -1, | ||
553 | CyberPhysicalSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, | ||
554 | !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
555 | initEReference(getCyberPhysicalSystem_ApplicationTypes(), this.getApplicationType(), null, "applicationTypes", | ||
556 | null, 0, -1, CyberPhysicalSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, | ||
557 | !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
558 | initEReference(getCyberPhysicalSystem_HostTypes(), this.getHostType(), null, "hostTypes", null, 0, -1, | ||
559 | CyberPhysicalSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, | ||
560 | !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
561 | |||
562 | initEClass(applicationTypeEClass, ApplicationType.class, "ApplicationType", !IS_ABSTRACT, !IS_INTERFACE, | ||
563 | IS_GENERATED_INSTANCE_CLASS); | ||
564 | initEReference(getApplicationType_Instances(), this.getApplicationInstance(), | ||
565 | this.getApplicationInstance_Type(), "instances", null, 0, -1, ApplicationType.class, !IS_TRANSIENT, | ||
566 | !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, | ||
567 | IS_ORDERED); | ||
568 | initEReference(getApplicationType_Requirements(), this.getResourceRequirement(), null, "requirements", null, 0, | ||
569 | -1, ApplicationType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, | ||
570 | !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
571 | |||
572 | initEClass(hostTypeEClass, HostType.class, "HostType", !IS_ABSTRACT, !IS_INTERFACE, | ||
573 | IS_GENERATED_INSTANCE_CLASS); | ||
574 | initEAttribute(getHostType_DefaultMemory(), ecorePackage.getEInt(), "defaultMemory", null, 1, 1, HostType.class, | ||
575 | !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
576 | initEAttribute(getHostType_DefaultHdd(), ecorePackage.getEInt(), "defaultHdd", null, 1, 1, HostType.class, | ||
577 | !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
578 | initEReference(getHostType_Instances(), this.getHostInstance(), this.getHostInstance_Type(), "instances", null, | ||
579 | 0, -1, HostType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, | ||
580 | !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
581 | initEAttribute(getHostType_Cost(), ecorePackage.getEInt(), "cost", null, 1, 1, HostType.class, !IS_TRANSIENT, | ||
582 | !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
583 | |||
584 | initEClass(requestEClass, Request.class, "Request", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | ||
585 | initEReference(getRequest_Requirements(), this.getRequirement(), this.getRequirement_Request(), "requirements", | ||
586 | null, 0, -1, Request.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, | ||
587 | !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
588 | |||
589 | initEClass(requirementEClass, Requirement.class, "Requirement", !IS_ABSTRACT, !IS_INTERFACE, | ||
590 | IS_GENERATED_INSTANCE_CLASS); | ||
591 | initEReference(getRequirement_Request(), this.getRequest(), this.getRequest_Requirements(), "request", null, 1, | ||
592 | 1, Requirement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, | ||
593 | !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
594 | initEAttribute(getRequirement_Count(), ecorePackage.getEInt(), "count", null, 1, 1, Requirement.class, | ||
595 | !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
596 | initEReference(getRequirement_Type(), this.getApplicationType(), null, "type", null, 0, 1, Requirement.class, | ||
597 | !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, | ||
598 | IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
599 | initEReference(getRequirement_Instances(), this.getApplicationInstance(), | ||
600 | this.getApplicationInstance_Requirement(), "instances", null, 0, -1, Requirement.class, !IS_TRANSIENT, | ||
601 | !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, | ||
602 | IS_ORDERED); | ||
603 | |||
604 | initEClass(applicationInstanceEClass, ApplicationInstance.class, "ApplicationInstance", !IS_ABSTRACT, | ||
605 | !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | ||
606 | initEReference(getApplicationInstance_Requirement(), this.getRequirement(), this.getRequirement_Instances(), | ||
607 | "requirement", null, 0, 1, ApplicationInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, | ||
608 | !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
609 | initEReference(getApplicationInstance_Type(), this.getApplicationType(), this.getApplicationType_Instances(), | ||
610 | "type", null, 1, 1, ApplicationInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, | ||
611 | !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
612 | initEReference(getApplicationInstance_AllocatedTo(), this.getHostInstance(), | ||
613 | this.getHostInstance_Applications(), "allocatedTo", null, 1, 1, ApplicationInstance.class, | ||
614 | !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, | ||
615 | IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
616 | |||
617 | initEClass(resourceRequirementEClass, ResourceRequirement.class, "ResourceRequirement", !IS_ABSTRACT, | ||
618 | !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | ||
619 | initEAttribute(getResourceRequirement_RequiredMemory(), ecorePackage.getEInt(), "requiredMemory", null, 1, 1, | ||
620 | ResourceRequirement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, | ||
621 | IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
622 | initEAttribute(getResourceRequirement_RequiredHdd(), ecorePackage.getEInt(), "requiredHdd", null, 1, 1, | ||
623 | ResourceRequirement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, | ||
624 | IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
625 | initEReference(getResourceRequirement_HostType(), this.getHostType(), null, "hostType", null, 1, 1, | ||
626 | ResourceRequirement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, | ||
627 | IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
628 | |||
629 | initEClass(hostInstanceEClass, HostInstance.class, "HostInstance", !IS_ABSTRACT, !IS_INTERFACE, | ||
630 | IS_GENERATED_INSTANCE_CLASS); | ||
631 | initEReference(getHostInstance_Type(), this.getHostType(), this.getHostType_Instances(), "type", null, 1, 1, | ||
632 | HostInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, | ||
633 | !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
634 | initEReference(getHostInstance_Applications(), this.getApplicationInstance(), | ||
635 | this.getApplicationInstance_AllocatedTo(), "applications", null, 0, -1, HostInstance.class, | ||
636 | !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, | ||
637 | IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
638 | |||
639 | // Create resource | ||
640 | createResource(eNS_URI); | ||
641 | } | ||
642 | |||
643 | } //CpsPackageImpl | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java new file mode 100644 index 00000000..3ba111af --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java | |||
@@ -0,0 +1,232 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps.impl; | ||
4 | |||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.cps.Request; | ||
10 | |||
11 | import java.util.Collection; | ||
12 | |||
13 | import org.eclipse.emf.common.notify.NotificationChain; | ||
14 | |||
15 | import org.eclipse.emf.common.util.EList; | ||
16 | |||
17 | import org.eclipse.emf.ecore.EClass; | ||
18 | import org.eclipse.emf.ecore.InternalEObject; | ||
19 | |||
20 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; | ||
21 | |||
22 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; | ||
23 | import org.eclipse.emf.ecore.util.InternalEList; | ||
24 | |||
25 | /** | ||
26 | * <!-- begin-user-doc --> | ||
27 | * An implementation of the model object '<em><b>Cyber Physical System</b></em>'. | ||
28 | * <!-- end-user-doc --> | ||
29 | * <p> | ||
30 | * The following features are implemented: | ||
31 | * </p> | ||
32 | * <ul> | ||
33 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getRequests <em>Requests</em>}</li> | ||
34 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getApplicationTypes <em>Application Types</em>}</li> | ||
35 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getHostTypes <em>Host Types</em>}</li> | ||
36 | * </ul> | ||
37 | * | ||
38 | * @generated | ||
39 | */ | ||
40 | public class CyberPhysicalSystemImpl extends MinimalEObjectImpl.Container implements CyberPhysicalSystem { | ||
41 | /** | ||
42 | * The cached value of the '{@link #getRequests() <em>Requests</em>}' containment reference list. | ||
43 | * <!-- begin-user-doc --> | ||
44 | * <!-- end-user-doc --> | ||
45 | * @see #getRequests() | ||
46 | * @generated | ||
47 | * @ordered | ||
48 | */ | ||
49 | protected EList<Request> requests; | ||
50 | |||
51 | /** | ||
52 | * The cached value of the '{@link #getApplicationTypes() <em>Application Types</em>}' containment reference list. | ||
53 | * <!-- begin-user-doc --> | ||
54 | * <!-- end-user-doc --> | ||
55 | * @see #getApplicationTypes() | ||
56 | * @generated | ||
57 | * @ordered | ||
58 | */ | ||
59 | protected EList<ApplicationType> applicationTypes; | ||
60 | |||
61 | /** | ||
62 | * The cached value of the '{@link #getHostTypes() <em>Host Types</em>}' containment reference list. | ||
63 | * <!-- begin-user-doc --> | ||
64 | * <!-- end-user-doc --> | ||
65 | * @see #getHostTypes() | ||
66 | * @generated | ||
67 | * @ordered | ||
68 | */ | ||
69 | protected EList<HostType> hostTypes; | ||
70 | |||
71 | /** | ||
72 | * <!-- begin-user-doc --> | ||
73 | * <!-- end-user-doc --> | ||
74 | * @generated | ||
75 | */ | ||
76 | protected CyberPhysicalSystemImpl() { | ||
77 | super(); | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * <!-- begin-user-doc --> | ||
82 | * <!-- end-user-doc --> | ||
83 | * @generated | ||
84 | */ | ||
85 | @Override | ||
86 | protected EClass eStaticClass() { | ||
87 | return CpsPackage.Literals.CYBER_PHYSICAL_SYSTEM; | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * <!-- begin-user-doc --> | ||
92 | * <!-- end-user-doc --> | ||
93 | * @generated | ||
94 | */ | ||
95 | @Override | ||
96 | public EList<Request> getRequests() { | ||
97 | if (requests == null) { | ||
98 | requests = new EObjectContainmentEList<Request>(Request.class, this, | ||
99 | CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS); | ||
100 | } | ||
101 | return requests; | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * <!-- begin-user-doc --> | ||
106 | * <!-- end-user-doc --> | ||
107 | * @generated | ||
108 | */ | ||
109 | @Override | ||
110 | public EList<ApplicationType> getApplicationTypes() { | ||
111 | if (applicationTypes == null) { | ||
112 | applicationTypes = new EObjectContainmentEList<ApplicationType>(ApplicationType.class, this, | ||
113 | CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES); | ||
114 | } | ||
115 | return applicationTypes; | ||
116 | } | ||
117 | |||
118 | /** | ||
119 | * <!-- begin-user-doc --> | ||
120 | * <!-- end-user-doc --> | ||
121 | * @generated | ||
122 | */ | ||
123 | @Override | ||
124 | public EList<HostType> getHostTypes() { | ||
125 | if (hostTypes == null) { | ||
126 | hostTypes = new EObjectContainmentEList<HostType>(HostType.class, this, | ||
127 | CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES); | ||
128 | } | ||
129 | return hostTypes; | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * <!-- begin-user-doc --> | ||
134 | * <!-- end-user-doc --> | ||
135 | * @generated | ||
136 | */ | ||
137 | @Override | ||
138 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
139 | switch (featureID) { | ||
140 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: | ||
141 | return ((InternalEList<?>) getRequests()).basicRemove(otherEnd, msgs); | ||
142 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: | ||
143 | return ((InternalEList<?>) getApplicationTypes()).basicRemove(otherEnd, msgs); | ||
144 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: | ||
145 | return ((InternalEList<?>) getHostTypes()).basicRemove(otherEnd, msgs); | ||
146 | } | ||
147 | return super.eInverseRemove(otherEnd, featureID, msgs); | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * <!-- begin-user-doc --> | ||
152 | * <!-- end-user-doc --> | ||
153 | * @generated | ||
154 | */ | ||
155 | @Override | ||
156 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
157 | switch (featureID) { | ||
158 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: | ||
159 | return getRequests(); | ||
160 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: | ||
161 | return getApplicationTypes(); | ||
162 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: | ||
163 | return getHostTypes(); | ||
164 | } | ||
165 | return super.eGet(featureID, resolve, coreType); | ||
166 | } | ||
167 | |||
168 | /** | ||
169 | * <!-- begin-user-doc --> | ||
170 | * <!-- end-user-doc --> | ||
171 | * @generated | ||
172 | */ | ||
173 | @SuppressWarnings("unchecked") | ||
174 | @Override | ||
175 | public void eSet(int featureID, Object newValue) { | ||
176 | switch (featureID) { | ||
177 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: | ||
178 | getRequests().clear(); | ||
179 | getRequests().addAll((Collection<? extends Request>) newValue); | ||
180 | return; | ||
181 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: | ||
182 | getApplicationTypes().clear(); | ||
183 | getApplicationTypes().addAll((Collection<? extends ApplicationType>) newValue); | ||
184 | return; | ||
185 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: | ||
186 | getHostTypes().clear(); | ||
187 | getHostTypes().addAll((Collection<? extends HostType>) newValue); | ||
188 | return; | ||
189 | } | ||
190 | super.eSet(featureID, newValue); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * <!-- begin-user-doc --> | ||
195 | * <!-- end-user-doc --> | ||
196 | * @generated | ||
197 | */ | ||
198 | @Override | ||
199 | public void eUnset(int featureID) { | ||
200 | switch (featureID) { | ||
201 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: | ||
202 | getRequests().clear(); | ||
203 | return; | ||
204 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: | ||
205 | getApplicationTypes().clear(); | ||
206 | return; | ||
207 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: | ||
208 | getHostTypes().clear(); | ||
209 | return; | ||
210 | } | ||
211 | super.eUnset(featureID); | ||
212 | } | ||
213 | |||
214 | /** | ||
215 | * <!-- begin-user-doc --> | ||
216 | * <!-- end-user-doc --> | ||
217 | * @generated | ||
218 | */ | ||
219 | @Override | ||
220 | public boolean eIsSet(int featureID) { | ||
221 | switch (featureID) { | ||
222 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: | ||
223 | return requests != null && !requests.isEmpty(); | ||
224 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: | ||
225 | return applicationTypes != null && !applicationTypes.isEmpty(); | ||
226 | case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: | ||
227 | return hostTypes != null && !hostTypes.isEmpty(); | ||
228 | } | ||
229 | return super.eIsSet(featureID); | ||
230 | } | ||
231 | |||
232 | } //CyberPhysicalSystemImpl | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java new file mode 100644 index 00000000..551f2ed6 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java | |||
@@ -0,0 +1,250 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps.impl; | ||
4 | |||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
9 | |||
10 | import java.util.Collection; | ||
11 | |||
12 | import org.eclipse.emf.common.notify.Notification; | ||
13 | import org.eclipse.emf.common.notify.NotificationChain; | ||
14 | |||
15 | import org.eclipse.emf.common.util.EList; | ||
16 | |||
17 | import org.eclipse.emf.ecore.EClass; | ||
18 | import org.eclipse.emf.ecore.InternalEObject; | ||
19 | |||
20 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
21 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; | ||
22 | |||
23 | import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; | ||
24 | import org.eclipse.emf.ecore.util.EcoreUtil; | ||
25 | import org.eclipse.emf.ecore.util.InternalEList; | ||
26 | |||
27 | /** | ||
28 | * <!-- begin-user-doc --> | ||
29 | * An implementation of the model object '<em><b>Host Instance</b></em>'. | ||
30 | * <!-- end-user-doc --> | ||
31 | * <p> | ||
32 | * The following features are implemented: | ||
33 | * </p> | ||
34 | * <ul> | ||
35 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getType <em>Type</em>}</li> | ||
36 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getApplications <em>Applications</em>}</li> | ||
37 | * </ul> | ||
38 | * | ||
39 | * @generated | ||
40 | */ | ||
41 | public class HostInstanceImpl extends MinimalEObjectImpl.Container implements HostInstance { | ||
42 | /** | ||
43 | * The cached value of the '{@link #getApplications() <em>Applications</em>}' reference list. | ||
44 | * <!-- begin-user-doc --> | ||
45 | * <!-- end-user-doc --> | ||
46 | * @see #getApplications() | ||
47 | * @generated | ||
48 | * @ordered | ||
49 | */ | ||
50 | protected EList<ApplicationInstance> applications; | ||
51 | |||
52 | /** | ||
53 | * <!-- begin-user-doc --> | ||
54 | * <!-- end-user-doc --> | ||
55 | * @generated | ||
56 | */ | ||
57 | protected HostInstanceImpl() { | ||
58 | super(); | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * <!-- begin-user-doc --> | ||
63 | * <!-- end-user-doc --> | ||
64 | * @generated | ||
65 | */ | ||
66 | @Override | ||
67 | protected EClass eStaticClass() { | ||
68 | return CpsPackage.Literals.HOST_INSTANCE; | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * <!-- begin-user-doc --> | ||
73 | * <!-- end-user-doc --> | ||
74 | * @generated | ||
75 | */ | ||
76 | @Override | ||
77 | public HostType getType() { | ||
78 | if (eContainerFeatureID() != CpsPackage.HOST_INSTANCE__TYPE) | ||
79 | return null; | ||
80 | return (HostType) eInternalContainer(); | ||
81 | } | ||
82 | |||
83 | /** | ||
84 | * <!-- begin-user-doc --> | ||
85 | * <!-- end-user-doc --> | ||
86 | * @generated | ||
87 | */ | ||
88 | public NotificationChain basicSetType(HostType newType, NotificationChain msgs) { | ||
89 | msgs = eBasicSetContainer((InternalEObject) newType, CpsPackage.HOST_INSTANCE__TYPE, msgs); | ||
90 | return msgs; | ||
91 | } | ||
92 | |||
93 | /** | ||
94 | * <!-- begin-user-doc --> | ||
95 | * <!-- end-user-doc --> | ||
96 | * @generated | ||
97 | */ | ||
98 | @Override | ||
99 | public void setType(HostType newType) { | ||
100 | if (newType != eInternalContainer() | ||
101 | || (eContainerFeatureID() != CpsPackage.HOST_INSTANCE__TYPE && newType != null)) { | ||
102 | if (EcoreUtil.isAncestor(this, newType)) | ||
103 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); | ||
104 | NotificationChain msgs = null; | ||
105 | if (eInternalContainer() != null) | ||
106 | msgs = eBasicRemoveFromContainer(msgs); | ||
107 | if (newType != null) | ||
108 | msgs = ((InternalEObject) newType).eInverseAdd(this, CpsPackage.HOST_TYPE__INSTANCES, HostType.class, | ||
109 | msgs); | ||
110 | msgs = basicSetType(newType, msgs); | ||
111 | if (msgs != null) | ||
112 | msgs.dispatch(); | ||
113 | } else if (eNotificationRequired()) | ||
114 | eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.HOST_INSTANCE__TYPE, newType, newType)); | ||
115 | } | ||
116 | |||
117 | /** | ||
118 | * <!-- begin-user-doc --> | ||
119 | * <!-- end-user-doc --> | ||
120 | * @generated | ||
121 | */ | ||
122 | @Override | ||
123 | public EList<ApplicationInstance> getApplications() { | ||
124 | if (applications == null) { | ||
125 | applications = new EObjectWithInverseResolvingEList<ApplicationInstance>(ApplicationInstance.class, this, | ||
126 | CpsPackage.HOST_INSTANCE__APPLICATIONS, CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO); | ||
127 | } | ||
128 | return applications; | ||
129 | } | ||
130 | |||
131 | /** | ||
132 | * <!-- begin-user-doc --> | ||
133 | * <!-- end-user-doc --> | ||
134 | * @generated | ||
135 | */ | ||
136 | @SuppressWarnings("unchecked") | ||
137 | @Override | ||
138 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
139 | switch (featureID) { | ||
140 | case CpsPackage.HOST_INSTANCE__TYPE: | ||
141 | if (eInternalContainer() != null) | ||
142 | msgs = eBasicRemoveFromContainer(msgs); | ||
143 | return basicSetType((HostType) otherEnd, msgs); | ||
144 | case CpsPackage.HOST_INSTANCE__APPLICATIONS: | ||
145 | return ((InternalEList<InternalEObject>) (InternalEList<?>) getApplications()).basicAdd(otherEnd, msgs); | ||
146 | } | ||
147 | return super.eInverseAdd(otherEnd, featureID, msgs); | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * <!-- begin-user-doc --> | ||
152 | * <!-- end-user-doc --> | ||
153 | * @generated | ||
154 | */ | ||
155 | @Override | ||
156 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
157 | switch (featureID) { | ||
158 | case CpsPackage.HOST_INSTANCE__TYPE: | ||
159 | return basicSetType(null, msgs); | ||
160 | case CpsPackage.HOST_INSTANCE__APPLICATIONS: | ||
161 | return ((InternalEList<?>) getApplications()).basicRemove(otherEnd, msgs); | ||
162 | } | ||
163 | return super.eInverseRemove(otherEnd, featureID, msgs); | ||
164 | } | ||
165 | |||
166 | /** | ||
167 | * <!-- begin-user-doc --> | ||
168 | * <!-- end-user-doc --> | ||
169 | * @generated | ||
170 | */ | ||
171 | @Override | ||
172 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { | ||
173 | switch (eContainerFeatureID()) { | ||
174 | case CpsPackage.HOST_INSTANCE__TYPE: | ||
175 | return eInternalContainer().eInverseRemove(this, CpsPackage.HOST_TYPE__INSTANCES, HostType.class, msgs); | ||
176 | } | ||
177 | return super.eBasicRemoveFromContainerFeature(msgs); | ||
178 | } | ||
179 | |||
180 | /** | ||
181 | * <!-- begin-user-doc --> | ||
182 | * <!-- end-user-doc --> | ||
183 | * @generated | ||
184 | */ | ||
185 | @Override | ||
186 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
187 | switch (featureID) { | ||
188 | case CpsPackage.HOST_INSTANCE__TYPE: | ||
189 | return getType(); | ||
190 | case CpsPackage.HOST_INSTANCE__APPLICATIONS: | ||
191 | return getApplications(); | ||
192 | } | ||
193 | return super.eGet(featureID, resolve, coreType); | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * <!-- begin-user-doc --> | ||
198 | * <!-- end-user-doc --> | ||
199 | * @generated | ||
200 | */ | ||
201 | @SuppressWarnings("unchecked") | ||
202 | @Override | ||
203 | public void eSet(int featureID, Object newValue) { | ||
204 | switch (featureID) { | ||
205 | case CpsPackage.HOST_INSTANCE__TYPE: | ||
206 | setType((HostType) newValue); | ||
207 | return; | ||
208 | case CpsPackage.HOST_INSTANCE__APPLICATIONS: | ||
209 | getApplications().clear(); | ||
210 | getApplications().addAll((Collection<? extends ApplicationInstance>) newValue); | ||
211 | return; | ||
212 | } | ||
213 | super.eSet(featureID, newValue); | ||
214 | } | ||
215 | |||
216 | /** | ||
217 | * <!-- begin-user-doc --> | ||
218 | * <!-- end-user-doc --> | ||
219 | * @generated | ||
220 | */ | ||
221 | @Override | ||
222 | public void eUnset(int featureID) { | ||
223 | switch (featureID) { | ||
224 | case CpsPackage.HOST_INSTANCE__TYPE: | ||
225 | setType((HostType) null); | ||
226 | return; | ||
227 | case CpsPackage.HOST_INSTANCE__APPLICATIONS: | ||
228 | getApplications().clear(); | ||
229 | return; | ||
230 | } | ||
231 | super.eUnset(featureID); | ||
232 | } | ||
233 | |||
234 | /** | ||
235 | * <!-- begin-user-doc --> | ||
236 | * <!-- end-user-doc --> | ||
237 | * @generated | ||
238 | */ | ||
239 | @Override | ||
240 | public boolean eIsSet(int featureID) { | ||
241 | switch (featureID) { | ||
242 | case CpsPackage.HOST_INSTANCE__TYPE: | ||
243 | return getType() != null; | ||
244 | case CpsPackage.HOST_INSTANCE__APPLICATIONS: | ||
245 | return applications != null && !applications.isEmpty(); | ||
246 | } | ||
247 | return super.eIsSet(featureID); | ||
248 | } | ||
249 | |||
250 | } //HostInstanceImpl | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostTypeImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostTypeImpl.java new file mode 100644 index 00000000..c3d5b3dc --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostTypeImpl.java | |||
@@ -0,0 +1,356 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps.impl; | ||
4 | |||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
8 | |||
9 | import java.util.Collection; | ||
10 | |||
11 | import org.eclipse.emf.common.notify.Notification; | ||
12 | import org.eclipse.emf.common.notify.NotificationChain; | ||
13 | |||
14 | import org.eclipse.emf.common.util.EList; | ||
15 | |||
16 | import org.eclipse.emf.ecore.EClass; | ||
17 | import org.eclipse.emf.ecore.InternalEObject; | ||
18 | |||
19 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
20 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; | ||
21 | |||
22 | import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; | ||
23 | import org.eclipse.emf.ecore.util.InternalEList; | ||
24 | |||
25 | /** | ||
26 | * <!-- begin-user-doc --> | ||
27 | * An implementation of the model object '<em><b>Host Type</b></em>'. | ||
28 | * <!-- end-user-doc --> | ||
29 | * <p> | ||
30 | * The following features are implemented: | ||
31 | * </p> | ||
32 | * <ul> | ||
33 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl#getDefaultMemory <em>Default Memory</em>}</li> | ||
34 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl#getDefaultHdd <em>Default Hdd</em>}</li> | ||
35 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl#getInstances <em>Instances</em>}</li> | ||
36 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl#getCost <em>Cost</em>}</li> | ||
37 | * </ul> | ||
38 | * | ||
39 | * @generated | ||
40 | */ | ||
41 | public class HostTypeImpl extends MinimalEObjectImpl.Container implements HostType { | ||
42 | /** | ||
43 | * The default value of the '{@link #getDefaultMemory() <em>Default Memory</em>}' attribute. | ||
44 | * <!-- begin-user-doc --> | ||
45 | * <!-- end-user-doc --> | ||
46 | * @see #getDefaultMemory() | ||
47 | * @generated | ||
48 | * @ordered | ||
49 | */ | ||
50 | protected static final int DEFAULT_MEMORY_EDEFAULT = 0; | ||
51 | |||
52 | /** | ||
53 | * The cached value of the '{@link #getDefaultMemory() <em>Default Memory</em>}' attribute. | ||
54 | * <!-- begin-user-doc --> | ||
55 | * <!-- end-user-doc --> | ||
56 | * @see #getDefaultMemory() | ||
57 | * @generated | ||
58 | * @ordered | ||
59 | */ | ||
60 | protected int defaultMemory = DEFAULT_MEMORY_EDEFAULT; | ||
61 | |||
62 | /** | ||
63 | * The default value of the '{@link #getDefaultHdd() <em>Default Hdd</em>}' attribute. | ||
64 | * <!-- begin-user-doc --> | ||
65 | * <!-- end-user-doc --> | ||
66 | * @see #getDefaultHdd() | ||
67 | * @generated | ||
68 | * @ordered | ||
69 | */ | ||
70 | protected static final int DEFAULT_HDD_EDEFAULT = 0; | ||
71 | |||
72 | /** | ||
73 | * The cached value of the '{@link #getDefaultHdd() <em>Default Hdd</em>}' attribute. | ||
74 | * <!-- begin-user-doc --> | ||
75 | * <!-- end-user-doc --> | ||
76 | * @see #getDefaultHdd() | ||
77 | * @generated | ||
78 | * @ordered | ||
79 | */ | ||
80 | protected int defaultHdd = DEFAULT_HDD_EDEFAULT; | ||
81 | |||
82 | /** | ||
83 | * The cached value of the '{@link #getInstances() <em>Instances</em>}' containment reference list. | ||
84 | * <!-- begin-user-doc --> | ||
85 | * <!-- end-user-doc --> | ||
86 | * @see #getInstances() | ||
87 | * @generated | ||
88 | * @ordered | ||
89 | */ | ||
90 | protected EList<HostInstance> instances; | ||
91 | |||
92 | /** | ||
93 | * The default value of the '{@link #getCost() <em>Cost</em>}' attribute. | ||
94 | * <!-- begin-user-doc --> | ||
95 | * <!-- end-user-doc --> | ||
96 | * @see #getCost() | ||
97 | * @generated | ||
98 | * @ordered | ||
99 | */ | ||
100 | protected static final int COST_EDEFAULT = 0; | ||
101 | |||
102 | /** | ||
103 | * The cached value of the '{@link #getCost() <em>Cost</em>}' attribute. | ||
104 | * <!-- begin-user-doc --> | ||
105 | * <!-- end-user-doc --> | ||
106 | * @see #getCost() | ||
107 | * @generated | ||
108 | * @ordered | ||
109 | */ | ||
110 | protected int cost = COST_EDEFAULT; | ||
111 | |||
112 | /** | ||
113 | * <!-- begin-user-doc --> | ||
114 | * <!-- end-user-doc --> | ||
115 | * @generated | ||
116 | */ | ||
117 | protected HostTypeImpl() { | ||
118 | super(); | ||
119 | } | ||
120 | |||
121 | /** | ||
122 | * <!-- begin-user-doc --> | ||
123 | * <!-- end-user-doc --> | ||
124 | * @generated | ||
125 | */ | ||
126 | @Override | ||
127 | protected EClass eStaticClass() { | ||
128 | return CpsPackage.Literals.HOST_TYPE; | ||
129 | } | ||
130 | |||
131 | /** | ||
132 | * <!-- begin-user-doc --> | ||
133 | * <!-- end-user-doc --> | ||
134 | * @generated | ||
135 | */ | ||
136 | @Override | ||
137 | public int getDefaultMemory() { | ||
138 | return defaultMemory; | ||
139 | } | ||
140 | |||
141 | /** | ||
142 | * <!-- begin-user-doc --> | ||
143 | * <!-- end-user-doc --> | ||
144 | * @generated | ||
145 | */ | ||
146 | @Override | ||
147 | public void setDefaultMemory(int newDefaultMemory) { | ||
148 | int oldDefaultMemory = defaultMemory; | ||
149 | defaultMemory = newDefaultMemory; | ||
150 | if (eNotificationRequired()) | ||
151 | eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.HOST_TYPE__DEFAULT_MEMORY, | ||
152 | oldDefaultMemory, defaultMemory)); | ||
153 | } | ||
154 | |||
155 | /** | ||
156 | * <!-- begin-user-doc --> | ||
157 | * <!-- end-user-doc --> | ||
158 | * @generated | ||
159 | */ | ||
160 | @Override | ||
161 | public int getDefaultHdd() { | ||
162 | return defaultHdd; | ||
163 | } | ||
164 | |||
165 | /** | ||
166 | * <!-- begin-user-doc --> | ||
167 | * <!-- end-user-doc --> | ||
168 | * @generated | ||
169 | */ | ||
170 | @Override | ||
171 | public void setDefaultHdd(int newDefaultHdd) { | ||
172 | int oldDefaultHdd = defaultHdd; | ||
173 | defaultHdd = newDefaultHdd; | ||
174 | if (eNotificationRequired()) | ||
175 | eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.HOST_TYPE__DEFAULT_HDD, oldDefaultHdd, | ||
176 | defaultHdd)); | ||
177 | } | ||
178 | |||
179 | /** | ||
180 | * <!-- begin-user-doc --> | ||
181 | * <!-- end-user-doc --> | ||
182 | * @generated | ||
183 | */ | ||
184 | @Override | ||
185 | public EList<HostInstance> getInstances() { | ||
186 | if (instances == null) { | ||
187 | instances = new EObjectContainmentWithInverseEList<HostInstance>(HostInstance.class, this, | ||
188 | CpsPackage.HOST_TYPE__INSTANCES, CpsPackage.HOST_INSTANCE__TYPE); | ||
189 | } | ||
190 | return instances; | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * <!-- begin-user-doc --> | ||
195 | * <!-- end-user-doc --> | ||
196 | * @generated | ||
197 | */ | ||
198 | @Override | ||
199 | public int getCost() { | ||
200 | return cost; | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * <!-- begin-user-doc --> | ||
205 | * <!-- end-user-doc --> | ||
206 | * @generated | ||
207 | */ | ||
208 | @Override | ||
209 | public void setCost(int newCost) { | ||
210 | int oldCost = cost; | ||
211 | cost = newCost; | ||
212 | if (eNotificationRequired()) | ||
213 | eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.HOST_TYPE__COST, oldCost, cost)); | ||
214 | } | ||
215 | |||
216 | /** | ||
217 | * <!-- begin-user-doc --> | ||
218 | * <!-- end-user-doc --> | ||
219 | * @generated | ||
220 | */ | ||
221 | @SuppressWarnings("unchecked") | ||
222 | @Override | ||
223 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
224 | switch (featureID) { | ||
225 | case CpsPackage.HOST_TYPE__INSTANCES: | ||
226 | return ((InternalEList<InternalEObject>) (InternalEList<?>) getInstances()).basicAdd(otherEnd, msgs); | ||
227 | } | ||
228 | return super.eInverseAdd(otherEnd, featureID, msgs); | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * <!-- begin-user-doc --> | ||
233 | * <!-- end-user-doc --> | ||
234 | * @generated | ||
235 | */ | ||
236 | @Override | ||
237 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
238 | switch (featureID) { | ||
239 | case CpsPackage.HOST_TYPE__INSTANCES: | ||
240 | return ((InternalEList<?>) getInstances()).basicRemove(otherEnd, msgs); | ||
241 | } | ||
242 | return super.eInverseRemove(otherEnd, featureID, msgs); | ||
243 | } | ||
244 | |||
245 | /** | ||
246 | * <!-- begin-user-doc --> | ||
247 | * <!-- end-user-doc --> | ||
248 | * @generated | ||
249 | */ | ||
250 | @Override | ||
251 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
252 | switch (featureID) { | ||
253 | case CpsPackage.HOST_TYPE__DEFAULT_MEMORY: | ||
254 | return getDefaultMemory(); | ||
255 | case CpsPackage.HOST_TYPE__DEFAULT_HDD: | ||
256 | return getDefaultHdd(); | ||
257 | case CpsPackage.HOST_TYPE__INSTANCES: | ||
258 | return getInstances(); | ||
259 | case CpsPackage.HOST_TYPE__COST: | ||
260 | return getCost(); | ||
261 | } | ||
262 | return super.eGet(featureID, resolve, coreType); | ||
263 | } | ||
264 | |||
265 | /** | ||
266 | * <!-- begin-user-doc --> | ||
267 | * <!-- end-user-doc --> | ||
268 | * @generated | ||
269 | */ | ||
270 | @SuppressWarnings("unchecked") | ||
271 | @Override | ||
272 | public void eSet(int featureID, Object newValue) { | ||
273 | switch (featureID) { | ||
274 | case CpsPackage.HOST_TYPE__DEFAULT_MEMORY: | ||
275 | setDefaultMemory((Integer) newValue); | ||
276 | return; | ||
277 | case CpsPackage.HOST_TYPE__DEFAULT_HDD: | ||
278 | setDefaultHdd((Integer) newValue); | ||
279 | return; | ||
280 | case CpsPackage.HOST_TYPE__INSTANCES: | ||
281 | getInstances().clear(); | ||
282 | getInstances().addAll((Collection<? extends HostInstance>) newValue); | ||
283 | return; | ||
284 | case CpsPackage.HOST_TYPE__COST: | ||
285 | setCost((Integer) newValue); | ||
286 | return; | ||
287 | } | ||
288 | super.eSet(featureID, newValue); | ||
289 | } | ||
290 | |||
291 | /** | ||
292 | * <!-- begin-user-doc --> | ||
293 | * <!-- end-user-doc --> | ||
294 | * @generated | ||
295 | */ | ||
296 | @Override | ||
297 | public void eUnset(int featureID) { | ||
298 | switch (featureID) { | ||
299 | case CpsPackage.HOST_TYPE__DEFAULT_MEMORY: | ||
300 | setDefaultMemory(DEFAULT_MEMORY_EDEFAULT); | ||
301 | return; | ||
302 | case CpsPackage.HOST_TYPE__DEFAULT_HDD: | ||
303 | setDefaultHdd(DEFAULT_HDD_EDEFAULT); | ||
304 | return; | ||
305 | case CpsPackage.HOST_TYPE__INSTANCES: | ||
306 | getInstances().clear(); | ||
307 | return; | ||
308 | case CpsPackage.HOST_TYPE__COST: | ||
309 | setCost(COST_EDEFAULT); | ||
310 | return; | ||
311 | } | ||
312 | super.eUnset(featureID); | ||
313 | } | ||
314 | |||
315 | /** | ||
316 | * <!-- begin-user-doc --> | ||
317 | * <!-- end-user-doc --> | ||
318 | * @generated | ||
319 | */ | ||
320 | @Override | ||
321 | public boolean eIsSet(int featureID) { | ||
322 | switch (featureID) { | ||
323 | case CpsPackage.HOST_TYPE__DEFAULT_MEMORY: | ||
324 | return defaultMemory != DEFAULT_MEMORY_EDEFAULT; | ||
325 | case CpsPackage.HOST_TYPE__DEFAULT_HDD: | ||
326 | return defaultHdd != DEFAULT_HDD_EDEFAULT; | ||
327 | case CpsPackage.HOST_TYPE__INSTANCES: | ||
328 | return instances != null && !instances.isEmpty(); | ||
329 | case CpsPackage.HOST_TYPE__COST: | ||
330 | return cost != COST_EDEFAULT; | ||
331 | } | ||
332 | return super.eIsSet(featureID); | ||
333 | } | ||
334 | |||
335 | /** | ||
336 | * <!-- begin-user-doc --> | ||
337 | * <!-- end-user-doc --> | ||
338 | * @generated | ||
339 | */ | ||
340 | @Override | ||
341 | public String toString() { | ||
342 | if (eIsProxy()) | ||
343 | return super.toString(); | ||
344 | |||
345 | StringBuilder result = new StringBuilder(super.toString()); | ||
346 | result.append(" (defaultMemory: "); | ||
347 | result.append(defaultMemory); | ||
348 | result.append(", defaultHdd: "); | ||
349 | result.append(defaultHdd); | ||
350 | result.append(", cost: "); | ||
351 | result.append(cost); | ||
352 | result.append(')'); | ||
353 | return result.toString(); | ||
354 | } | ||
355 | |||
356 | } //HostTypeImpl | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequestImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequestImpl.java new file mode 100644 index 00000000..72b4c732 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequestImpl.java | |||
@@ -0,0 +1,169 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps.impl; | ||
4 | |||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.Request; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; | ||
8 | |||
9 | import java.util.Collection; | ||
10 | |||
11 | import org.eclipse.emf.common.notify.NotificationChain; | ||
12 | |||
13 | import org.eclipse.emf.common.util.EList; | ||
14 | |||
15 | import org.eclipse.emf.ecore.EClass; | ||
16 | import org.eclipse.emf.ecore.InternalEObject; | ||
17 | |||
18 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; | ||
19 | |||
20 | import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; | ||
21 | import org.eclipse.emf.ecore.util.InternalEList; | ||
22 | |||
23 | /** | ||
24 | * <!-- begin-user-doc --> | ||
25 | * An implementation of the model object '<em><b>Request</b></em>'. | ||
26 | * <!-- end-user-doc --> | ||
27 | * <p> | ||
28 | * The following features are implemented: | ||
29 | * </p> | ||
30 | * <ul> | ||
31 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl#getRequirements <em>Requirements</em>}</li> | ||
32 | * </ul> | ||
33 | * | ||
34 | * @generated | ||
35 | */ | ||
36 | public class RequestImpl extends MinimalEObjectImpl.Container implements Request { | ||
37 | /** | ||
38 | * The cached value of the '{@link #getRequirements() <em>Requirements</em>}' containment reference list. | ||
39 | * <!-- begin-user-doc --> | ||
40 | * <!-- end-user-doc --> | ||
41 | * @see #getRequirements() | ||
42 | * @generated | ||
43 | * @ordered | ||
44 | */ | ||
45 | protected EList<Requirement> requirements; | ||
46 | |||
47 | /** | ||
48 | * <!-- begin-user-doc --> | ||
49 | * <!-- end-user-doc --> | ||
50 | * @generated | ||
51 | */ | ||
52 | protected RequestImpl() { | ||
53 | super(); | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * <!-- begin-user-doc --> | ||
58 | * <!-- end-user-doc --> | ||
59 | * @generated | ||
60 | */ | ||
61 | @Override | ||
62 | protected EClass eStaticClass() { | ||
63 | return CpsPackage.Literals.REQUEST; | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * <!-- begin-user-doc --> | ||
68 | * <!-- end-user-doc --> | ||
69 | * @generated | ||
70 | */ | ||
71 | @Override | ||
72 | public EList<Requirement> getRequirements() { | ||
73 | if (requirements == null) { | ||
74 | requirements = new EObjectContainmentWithInverseEList<Requirement>(Requirement.class, this, | ||
75 | CpsPackage.REQUEST__REQUIREMENTS, CpsPackage.REQUIREMENT__REQUEST); | ||
76 | } | ||
77 | return requirements; | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * <!-- begin-user-doc --> | ||
82 | * <!-- end-user-doc --> | ||
83 | * @generated | ||
84 | */ | ||
85 | @SuppressWarnings("unchecked") | ||
86 | @Override | ||
87 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
88 | switch (featureID) { | ||
89 | case CpsPackage.REQUEST__REQUIREMENTS: | ||
90 | return ((InternalEList<InternalEObject>) (InternalEList<?>) getRequirements()).basicAdd(otherEnd, msgs); | ||
91 | } | ||
92 | return super.eInverseAdd(otherEnd, featureID, msgs); | ||
93 | } | ||
94 | |||
95 | /** | ||
96 | * <!-- begin-user-doc --> | ||
97 | * <!-- end-user-doc --> | ||
98 | * @generated | ||
99 | */ | ||
100 | @Override | ||
101 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
102 | switch (featureID) { | ||
103 | case CpsPackage.REQUEST__REQUIREMENTS: | ||
104 | return ((InternalEList<?>) getRequirements()).basicRemove(otherEnd, msgs); | ||
105 | } | ||
106 | return super.eInverseRemove(otherEnd, featureID, msgs); | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * <!-- begin-user-doc --> | ||
111 | * <!-- end-user-doc --> | ||
112 | * @generated | ||
113 | */ | ||
114 | @Override | ||
115 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
116 | switch (featureID) { | ||
117 | case CpsPackage.REQUEST__REQUIREMENTS: | ||
118 | return getRequirements(); | ||
119 | } | ||
120 | return super.eGet(featureID, resolve, coreType); | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * <!-- begin-user-doc --> | ||
125 | * <!-- end-user-doc --> | ||
126 | * @generated | ||
127 | */ | ||
128 | @SuppressWarnings("unchecked") | ||
129 | @Override | ||
130 | public void eSet(int featureID, Object newValue) { | ||
131 | switch (featureID) { | ||
132 | case CpsPackage.REQUEST__REQUIREMENTS: | ||
133 | getRequirements().clear(); | ||
134 | getRequirements().addAll((Collection<? extends Requirement>) newValue); | ||
135 | return; | ||
136 | } | ||
137 | super.eSet(featureID, newValue); | ||
138 | } | ||
139 | |||
140 | /** | ||
141 | * <!-- begin-user-doc --> | ||
142 | * <!-- end-user-doc --> | ||
143 | * @generated | ||
144 | */ | ||
145 | @Override | ||
146 | public void eUnset(int featureID) { | ||
147 | switch (featureID) { | ||
148 | case CpsPackage.REQUEST__REQUIREMENTS: | ||
149 | getRequirements().clear(); | ||
150 | return; | ||
151 | } | ||
152 | super.eUnset(featureID); | ||
153 | } | ||
154 | |||
155 | /** | ||
156 | * <!-- begin-user-doc --> | ||
157 | * <!-- end-user-doc --> | ||
158 | * @generated | ||
159 | */ | ||
160 | @Override | ||
161 | public boolean eIsSet(int featureID) { | ||
162 | switch (featureID) { | ||
163 | case CpsPackage.REQUEST__REQUIREMENTS: | ||
164 | return requirements != null && !requirements.isEmpty(); | ||
165 | } | ||
166 | return super.eIsSet(featureID); | ||
167 | } | ||
168 | |||
169 | } //RequestImpl | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequirementImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequirementImpl.java new file mode 100644 index 00000000..79dc4f62 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequirementImpl.java | |||
@@ -0,0 +1,387 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps.impl; | ||
4 | |||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.Request; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; | ||
10 | |||
11 | import java.util.Collection; | ||
12 | |||
13 | import org.eclipse.emf.common.notify.Notification; | ||
14 | import org.eclipse.emf.common.notify.NotificationChain; | ||
15 | |||
16 | import org.eclipse.emf.common.util.EList; | ||
17 | |||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.emf.ecore.InternalEObject; | ||
20 | |||
21 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
22 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; | ||
23 | |||
24 | import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; | ||
25 | import org.eclipse.emf.ecore.util.EcoreUtil; | ||
26 | import org.eclipse.emf.ecore.util.InternalEList; | ||
27 | |||
28 | /** | ||
29 | * <!-- begin-user-doc --> | ||
30 | * An implementation of the model object '<em><b>Requirement</b></em>'. | ||
31 | * <!-- end-user-doc --> | ||
32 | * <p> | ||
33 | * The following features are implemented: | ||
34 | * </p> | ||
35 | * <ul> | ||
36 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl#getRequest <em>Request</em>}</li> | ||
37 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl#getCount <em>Count</em>}</li> | ||
38 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl#getType <em>Type</em>}</li> | ||
39 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl#getInstances <em>Instances</em>}</li> | ||
40 | * </ul> | ||
41 | * | ||
42 | * @generated | ||
43 | */ | ||
44 | public class RequirementImpl extends MinimalEObjectImpl.Container implements Requirement { | ||
45 | /** | ||
46 | * The default value of the '{@link #getCount() <em>Count</em>}' attribute. | ||
47 | * <!-- begin-user-doc --> | ||
48 | * <!-- end-user-doc --> | ||
49 | * @see #getCount() | ||
50 | * @generated | ||
51 | * @ordered | ||
52 | */ | ||
53 | protected static final int COUNT_EDEFAULT = 0; | ||
54 | |||
55 | /** | ||
56 | * The cached value of the '{@link #getCount() <em>Count</em>}' attribute. | ||
57 | * <!-- begin-user-doc --> | ||
58 | * <!-- end-user-doc --> | ||
59 | * @see #getCount() | ||
60 | * @generated | ||
61 | * @ordered | ||
62 | */ | ||
63 | protected int count = COUNT_EDEFAULT; | ||
64 | |||
65 | /** | ||
66 | * The cached value of the '{@link #getType() <em>Type</em>}' reference. | ||
67 | * <!-- begin-user-doc --> | ||
68 | * <!-- end-user-doc --> | ||
69 | * @see #getType() | ||
70 | * @generated | ||
71 | * @ordered | ||
72 | */ | ||
73 | protected ApplicationType type; | ||
74 | |||
75 | /** | ||
76 | * The cached value of the '{@link #getInstances() <em>Instances</em>}' reference list. | ||
77 | * <!-- begin-user-doc --> | ||
78 | * <!-- end-user-doc --> | ||
79 | * @see #getInstances() | ||
80 | * @generated | ||
81 | * @ordered | ||
82 | */ | ||
83 | protected EList<ApplicationInstance> instances; | ||
84 | |||
85 | /** | ||
86 | * <!-- begin-user-doc --> | ||
87 | * <!-- end-user-doc --> | ||
88 | * @generated | ||
89 | */ | ||
90 | protected RequirementImpl() { | ||
91 | super(); | ||
92 | } | ||
93 | |||
94 | /** | ||
95 | * <!-- begin-user-doc --> | ||
96 | * <!-- end-user-doc --> | ||
97 | * @generated | ||
98 | */ | ||
99 | @Override | ||
100 | protected EClass eStaticClass() { | ||
101 | return CpsPackage.Literals.REQUIREMENT; | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * <!-- begin-user-doc --> | ||
106 | * <!-- end-user-doc --> | ||
107 | * @generated | ||
108 | */ | ||
109 | @Override | ||
110 | public Request getRequest() { | ||
111 | if (eContainerFeatureID() != CpsPackage.REQUIREMENT__REQUEST) | ||
112 | return null; | ||
113 | return (Request) eInternalContainer(); | ||
114 | } | ||
115 | |||
116 | /** | ||
117 | * <!-- begin-user-doc --> | ||
118 | * <!-- end-user-doc --> | ||
119 | * @generated | ||
120 | */ | ||
121 | public NotificationChain basicSetRequest(Request newRequest, NotificationChain msgs) { | ||
122 | msgs = eBasicSetContainer((InternalEObject) newRequest, CpsPackage.REQUIREMENT__REQUEST, msgs); | ||
123 | return msgs; | ||
124 | } | ||
125 | |||
126 | /** | ||
127 | * <!-- begin-user-doc --> | ||
128 | * <!-- end-user-doc --> | ||
129 | * @generated | ||
130 | */ | ||
131 | @Override | ||
132 | public void setRequest(Request newRequest) { | ||
133 | if (newRequest != eInternalContainer() | ||
134 | || (eContainerFeatureID() != CpsPackage.REQUIREMENT__REQUEST && newRequest != null)) { | ||
135 | if (EcoreUtil.isAncestor(this, newRequest)) | ||
136 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); | ||
137 | NotificationChain msgs = null; | ||
138 | if (eInternalContainer() != null) | ||
139 | msgs = eBasicRemoveFromContainer(msgs); | ||
140 | if (newRequest != null) | ||
141 | msgs = ((InternalEObject) newRequest).eInverseAdd(this, CpsPackage.REQUEST__REQUIREMENTS, Request.class, | ||
142 | msgs); | ||
143 | msgs = basicSetRequest(newRequest, msgs); | ||
144 | if (msgs != null) | ||
145 | msgs.dispatch(); | ||
146 | } else if (eNotificationRequired()) | ||
147 | eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.REQUIREMENT__REQUEST, newRequest, | ||
148 | newRequest)); | ||
149 | } | ||
150 | |||
151 | /** | ||
152 | * <!-- begin-user-doc --> | ||
153 | * <!-- end-user-doc --> | ||
154 | * @generated | ||
155 | */ | ||
156 | @Override | ||
157 | public int getCount() { | ||
158 | return count; | ||
159 | } | ||
160 | |||
161 | /** | ||
162 | * <!-- begin-user-doc --> | ||
163 | * <!-- end-user-doc --> | ||
164 | * @generated | ||
165 | */ | ||
166 | @Override | ||
167 | public void setCount(int newCount) { | ||
168 | int oldCount = count; | ||
169 | count = newCount; | ||
170 | if (eNotificationRequired()) | ||
171 | eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.REQUIREMENT__COUNT, oldCount, count)); | ||
172 | } | ||
173 | |||
174 | /** | ||
175 | * <!-- begin-user-doc --> | ||
176 | * <!-- end-user-doc --> | ||
177 | * @generated | ||
178 | */ | ||
179 | @Override | ||
180 | public ApplicationType getType() { | ||
181 | if (type != null && type.eIsProxy()) { | ||
182 | InternalEObject oldType = (InternalEObject) type; | ||
183 | type = (ApplicationType) eResolveProxy(oldType); | ||
184 | if (type != oldType) { | ||
185 | if (eNotificationRequired()) | ||
186 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, CpsPackage.REQUIREMENT__TYPE, oldType, | ||
187 | type)); | ||
188 | } | ||
189 | } | ||
190 | return type; | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * <!-- begin-user-doc --> | ||
195 | * <!-- end-user-doc --> | ||
196 | * @generated | ||
197 | */ | ||
198 | public ApplicationType basicGetType() { | ||
199 | return type; | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * <!-- begin-user-doc --> | ||
204 | * <!-- end-user-doc --> | ||
205 | * @generated | ||
206 | */ | ||
207 | @Override | ||
208 | public void setType(ApplicationType newType) { | ||
209 | ApplicationType oldType = type; | ||
210 | type = newType; | ||
211 | if (eNotificationRequired()) | ||
212 | eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.REQUIREMENT__TYPE, oldType, type)); | ||
213 | } | ||
214 | |||
215 | /** | ||
216 | * <!-- begin-user-doc --> | ||
217 | * <!-- end-user-doc --> | ||
218 | * @generated | ||
219 | */ | ||
220 | @Override | ||
221 | public EList<ApplicationInstance> getInstances() { | ||
222 | if (instances == null) { | ||
223 | instances = new EObjectWithInverseResolvingEList<ApplicationInstance>(ApplicationInstance.class, this, | ||
224 | CpsPackage.REQUIREMENT__INSTANCES, CpsPackage.APPLICATION_INSTANCE__REQUIREMENT); | ||
225 | } | ||
226 | return instances; | ||
227 | } | ||
228 | |||
229 | /** | ||
230 | * <!-- begin-user-doc --> | ||
231 | * <!-- end-user-doc --> | ||
232 | * @generated | ||
233 | */ | ||
234 | @SuppressWarnings("unchecked") | ||
235 | @Override | ||
236 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
237 | switch (featureID) { | ||
238 | case CpsPackage.REQUIREMENT__REQUEST: | ||
239 | if (eInternalContainer() != null) | ||
240 | msgs = eBasicRemoveFromContainer(msgs); | ||
241 | return basicSetRequest((Request) otherEnd, msgs); | ||
242 | case CpsPackage.REQUIREMENT__INSTANCES: | ||
243 | return ((InternalEList<InternalEObject>) (InternalEList<?>) getInstances()).basicAdd(otherEnd, msgs); | ||
244 | } | ||
245 | return super.eInverseAdd(otherEnd, featureID, msgs); | ||
246 | } | ||
247 | |||
248 | /** | ||
249 | * <!-- begin-user-doc --> | ||
250 | * <!-- end-user-doc --> | ||
251 | * @generated | ||
252 | */ | ||
253 | @Override | ||
254 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
255 | switch (featureID) { | ||
256 | case CpsPackage.REQUIREMENT__REQUEST: | ||
257 | return basicSetRequest(null, msgs); | ||
258 | case CpsPackage.REQUIREMENT__INSTANCES: | ||
259 | return ((InternalEList<?>) getInstances()).basicRemove(otherEnd, msgs); | ||
260 | } | ||
261 | return super.eInverseRemove(otherEnd, featureID, msgs); | ||
262 | } | ||
263 | |||
264 | /** | ||
265 | * <!-- begin-user-doc --> | ||
266 | * <!-- end-user-doc --> | ||
267 | * @generated | ||
268 | */ | ||
269 | @Override | ||
270 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { | ||
271 | switch (eContainerFeatureID()) { | ||
272 | case CpsPackage.REQUIREMENT__REQUEST: | ||
273 | return eInternalContainer().eInverseRemove(this, CpsPackage.REQUEST__REQUIREMENTS, Request.class, msgs); | ||
274 | } | ||
275 | return super.eBasicRemoveFromContainerFeature(msgs); | ||
276 | } | ||
277 | |||
278 | /** | ||
279 | * <!-- begin-user-doc --> | ||
280 | * <!-- end-user-doc --> | ||
281 | * @generated | ||
282 | */ | ||
283 | @Override | ||
284 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
285 | switch (featureID) { | ||
286 | case CpsPackage.REQUIREMENT__REQUEST: | ||
287 | return getRequest(); | ||
288 | case CpsPackage.REQUIREMENT__COUNT: | ||
289 | return getCount(); | ||
290 | case CpsPackage.REQUIREMENT__TYPE: | ||
291 | if (resolve) | ||
292 | return getType(); | ||
293 | return basicGetType(); | ||
294 | case CpsPackage.REQUIREMENT__INSTANCES: | ||
295 | return getInstances(); | ||
296 | } | ||
297 | return super.eGet(featureID, resolve, coreType); | ||
298 | } | ||
299 | |||
300 | /** | ||
301 | * <!-- begin-user-doc --> | ||
302 | * <!-- end-user-doc --> | ||
303 | * @generated | ||
304 | */ | ||
305 | @SuppressWarnings("unchecked") | ||
306 | @Override | ||
307 | public void eSet(int featureID, Object newValue) { | ||
308 | switch (featureID) { | ||
309 | case CpsPackage.REQUIREMENT__REQUEST: | ||
310 | setRequest((Request) newValue); | ||
311 | return; | ||
312 | case CpsPackage.REQUIREMENT__COUNT: | ||
313 | setCount((Integer) newValue); | ||
314 | return; | ||
315 | case CpsPackage.REQUIREMENT__TYPE: | ||
316 | setType((ApplicationType) newValue); | ||
317 | return; | ||
318 | case CpsPackage.REQUIREMENT__INSTANCES: | ||
319 | getInstances().clear(); | ||
320 | getInstances().addAll((Collection<? extends ApplicationInstance>) newValue); | ||
321 | return; | ||
322 | } | ||
323 | super.eSet(featureID, newValue); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * <!-- begin-user-doc --> | ||
328 | * <!-- end-user-doc --> | ||
329 | * @generated | ||
330 | */ | ||
331 | @Override | ||
332 | public void eUnset(int featureID) { | ||
333 | switch (featureID) { | ||
334 | case CpsPackage.REQUIREMENT__REQUEST: | ||
335 | setRequest((Request) null); | ||
336 | return; | ||
337 | case CpsPackage.REQUIREMENT__COUNT: | ||
338 | setCount(COUNT_EDEFAULT); | ||
339 | return; | ||
340 | case CpsPackage.REQUIREMENT__TYPE: | ||
341 | setType((ApplicationType) null); | ||
342 | return; | ||
343 | case CpsPackage.REQUIREMENT__INSTANCES: | ||
344 | getInstances().clear(); | ||
345 | return; | ||
346 | } | ||
347 | super.eUnset(featureID); | ||
348 | } | ||
349 | |||
350 | /** | ||
351 | * <!-- begin-user-doc --> | ||
352 | * <!-- end-user-doc --> | ||
353 | * @generated | ||
354 | */ | ||
355 | @Override | ||
356 | public boolean eIsSet(int featureID) { | ||
357 | switch (featureID) { | ||
358 | case CpsPackage.REQUIREMENT__REQUEST: | ||
359 | return getRequest() != null; | ||
360 | case CpsPackage.REQUIREMENT__COUNT: | ||
361 | return count != COUNT_EDEFAULT; | ||
362 | case CpsPackage.REQUIREMENT__TYPE: | ||
363 | return type != null; | ||
364 | case CpsPackage.REQUIREMENT__INSTANCES: | ||
365 | return instances != null && !instances.isEmpty(); | ||
366 | } | ||
367 | return super.eIsSet(featureID); | ||
368 | } | ||
369 | |||
370 | /** | ||
371 | * <!-- begin-user-doc --> | ||
372 | * <!-- end-user-doc --> | ||
373 | * @generated | ||
374 | */ | ||
375 | @Override | ||
376 | public String toString() { | ||
377 | if (eIsProxy()) | ||
378 | return super.toString(); | ||
379 | |||
380 | StringBuilder result = new StringBuilder(super.toString()); | ||
381 | result.append(" (count: "); | ||
382 | result.append(count); | ||
383 | result.append(')'); | ||
384 | return result.toString(); | ||
385 | } | ||
386 | |||
387 | } //RequirementImpl | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ResourceRequirementImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ResourceRequirementImpl.java new file mode 100644 index 00000000..f4deb575 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ResourceRequirementImpl.java | |||
@@ -0,0 +1,291 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps.impl; | ||
4 | |||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; | ||
8 | |||
9 | import org.eclipse.emf.common.notify.Notification; | ||
10 | |||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.emf.ecore.InternalEObject; | ||
13 | |||
14 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
15 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; | ||
16 | |||
17 | /** | ||
18 | * <!-- begin-user-doc --> | ||
19 | * An implementation of the model object '<em><b>Resource Requirement</b></em>'. | ||
20 | * <!-- end-user-doc --> | ||
21 | * <p> | ||
22 | * The following features are implemented: | ||
23 | * </p> | ||
24 | * <ul> | ||
25 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl#getRequiredMemory <em>Required Memory</em>}</li> | ||
26 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl#getRequiredHdd <em>Required Hdd</em>}</li> | ||
27 | * <li>{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl#getHostType <em>Host Type</em>}</li> | ||
28 | * </ul> | ||
29 | * | ||
30 | * @generated | ||
31 | */ | ||
32 | public class ResourceRequirementImpl extends MinimalEObjectImpl.Container implements ResourceRequirement { | ||
33 | /** | ||
34 | * The default value of the '{@link #getRequiredMemory() <em>Required Memory</em>}' attribute. | ||
35 | * <!-- begin-user-doc --> | ||
36 | * <!-- end-user-doc --> | ||
37 | * @see #getRequiredMemory() | ||
38 | * @generated | ||
39 | * @ordered | ||
40 | */ | ||
41 | protected static final int REQUIRED_MEMORY_EDEFAULT = 0; | ||
42 | |||
43 | /** | ||
44 | * The cached value of the '{@link #getRequiredMemory() <em>Required Memory</em>}' attribute. | ||
45 | * <!-- begin-user-doc --> | ||
46 | * <!-- end-user-doc --> | ||
47 | * @see #getRequiredMemory() | ||
48 | * @generated | ||
49 | * @ordered | ||
50 | */ | ||
51 | protected int requiredMemory = REQUIRED_MEMORY_EDEFAULT; | ||
52 | |||
53 | /** | ||
54 | * The default value of the '{@link #getRequiredHdd() <em>Required Hdd</em>}' attribute. | ||
55 | * <!-- begin-user-doc --> | ||
56 | * <!-- end-user-doc --> | ||
57 | * @see #getRequiredHdd() | ||
58 | * @generated | ||
59 | * @ordered | ||
60 | */ | ||
61 | protected static final int REQUIRED_HDD_EDEFAULT = 0; | ||
62 | |||
63 | /** | ||
64 | * The cached value of the '{@link #getRequiredHdd() <em>Required Hdd</em>}' attribute. | ||
65 | * <!-- begin-user-doc --> | ||
66 | * <!-- end-user-doc --> | ||
67 | * @see #getRequiredHdd() | ||
68 | * @generated | ||
69 | * @ordered | ||
70 | */ | ||
71 | protected int requiredHdd = REQUIRED_HDD_EDEFAULT; | ||
72 | |||
73 | /** | ||
74 | * The cached value of the '{@link #getHostType() <em>Host Type</em>}' reference. | ||
75 | * <!-- begin-user-doc --> | ||
76 | * <!-- end-user-doc --> | ||
77 | * @see #getHostType() | ||
78 | * @generated | ||
79 | * @ordered | ||
80 | */ | ||
81 | protected HostType hostType; | ||
82 | |||
83 | /** | ||
84 | * <!-- begin-user-doc --> | ||
85 | * <!-- end-user-doc --> | ||
86 | * @generated | ||
87 | */ | ||
88 | protected ResourceRequirementImpl() { | ||
89 | super(); | ||
90 | } | ||
91 | |||
92 | /** | ||
93 | * <!-- begin-user-doc --> | ||
94 | * <!-- end-user-doc --> | ||
95 | * @generated | ||
96 | */ | ||
97 | @Override | ||
98 | protected EClass eStaticClass() { | ||
99 | return CpsPackage.Literals.RESOURCE_REQUIREMENT; | ||
100 | } | ||
101 | |||
102 | /** | ||
103 | * <!-- begin-user-doc --> | ||
104 | * <!-- end-user-doc --> | ||
105 | * @generated | ||
106 | */ | ||
107 | @Override | ||
108 | public int getRequiredMemory() { | ||
109 | return requiredMemory; | ||
110 | } | ||
111 | |||
112 | /** | ||
113 | * <!-- begin-user-doc --> | ||
114 | * <!-- end-user-doc --> | ||
115 | * @generated | ||
116 | */ | ||
117 | @Override | ||
118 | public void setRequiredMemory(int newRequiredMemory) { | ||
119 | int oldRequiredMemory = requiredMemory; | ||
120 | requiredMemory = newRequiredMemory; | ||
121 | if (eNotificationRequired()) | ||
122 | eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY, | ||
123 | oldRequiredMemory, requiredMemory)); | ||
124 | } | ||
125 | |||
126 | /** | ||
127 | * <!-- begin-user-doc --> | ||
128 | * <!-- end-user-doc --> | ||
129 | * @generated | ||
130 | */ | ||
131 | @Override | ||
132 | public int getRequiredHdd() { | ||
133 | return requiredHdd; | ||
134 | } | ||
135 | |||
136 | /** | ||
137 | * <!-- begin-user-doc --> | ||
138 | * <!-- end-user-doc --> | ||
139 | * @generated | ||
140 | */ | ||
141 | @Override | ||
142 | public void setRequiredHdd(int newRequiredHdd) { | ||
143 | int oldRequiredHdd = requiredHdd; | ||
144 | requiredHdd = newRequiredHdd; | ||
145 | if (eNotificationRequired()) | ||
146 | eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD, | ||
147 | oldRequiredHdd, requiredHdd)); | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * <!-- begin-user-doc --> | ||
152 | * <!-- end-user-doc --> | ||
153 | * @generated | ||
154 | */ | ||
155 | @Override | ||
156 | public HostType getHostType() { | ||
157 | if (hostType != null && hostType.eIsProxy()) { | ||
158 | InternalEObject oldHostType = (InternalEObject) hostType; | ||
159 | hostType = (HostType) eResolveProxy(oldHostType); | ||
160 | if (hostType != oldHostType) { | ||
161 | if (eNotificationRequired()) | ||
162 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, | ||
163 | CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE, oldHostType, hostType)); | ||
164 | } | ||
165 | } | ||
166 | return hostType; | ||
167 | } | ||
168 | |||
169 | /** | ||
170 | * <!-- begin-user-doc --> | ||
171 | * <!-- end-user-doc --> | ||
172 | * @generated | ||
173 | */ | ||
174 | public HostType basicGetHostType() { | ||
175 | return hostType; | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * <!-- begin-user-doc --> | ||
180 | * <!-- end-user-doc --> | ||
181 | * @generated | ||
182 | */ | ||
183 | @Override | ||
184 | public void setHostType(HostType newHostType) { | ||
185 | HostType oldHostType = hostType; | ||
186 | hostType = newHostType; | ||
187 | if (eNotificationRequired()) | ||
188 | eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE, | ||
189 | oldHostType, hostType)); | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * <!-- begin-user-doc --> | ||
194 | * <!-- end-user-doc --> | ||
195 | * @generated | ||
196 | */ | ||
197 | @Override | ||
198 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
199 | switch (featureID) { | ||
200 | case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY: | ||
201 | return getRequiredMemory(); | ||
202 | case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD: | ||
203 | return getRequiredHdd(); | ||
204 | case CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE: | ||
205 | if (resolve) | ||
206 | return getHostType(); | ||
207 | return basicGetHostType(); | ||
208 | } | ||
209 | return super.eGet(featureID, resolve, coreType); | ||
210 | } | ||
211 | |||
212 | /** | ||
213 | * <!-- begin-user-doc --> | ||
214 | * <!-- end-user-doc --> | ||
215 | * @generated | ||
216 | */ | ||
217 | @Override | ||
218 | public void eSet(int featureID, Object newValue) { | ||
219 | switch (featureID) { | ||
220 | case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY: | ||
221 | setRequiredMemory((Integer) newValue); | ||
222 | return; | ||
223 | case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD: | ||
224 | setRequiredHdd((Integer) newValue); | ||
225 | return; | ||
226 | case CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE: | ||
227 | setHostType((HostType) newValue); | ||
228 | return; | ||
229 | } | ||
230 | super.eSet(featureID, newValue); | ||
231 | } | ||
232 | |||
233 | /** | ||
234 | * <!-- begin-user-doc --> | ||
235 | * <!-- end-user-doc --> | ||
236 | * @generated | ||
237 | */ | ||
238 | @Override | ||
239 | public void eUnset(int featureID) { | ||
240 | switch (featureID) { | ||
241 | case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY: | ||
242 | setRequiredMemory(REQUIRED_MEMORY_EDEFAULT); | ||
243 | return; | ||
244 | case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD: | ||
245 | setRequiredHdd(REQUIRED_HDD_EDEFAULT); | ||
246 | return; | ||
247 | case CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE: | ||
248 | setHostType((HostType) null); | ||
249 | return; | ||
250 | } | ||
251 | super.eUnset(featureID); | ||
252 | } | ||
253 | |||
254 | /** | ||
255 | * <!-- begin-user-doc --> | ||
256 | * <!-- end-user-doc --> | ||
257 | * @generated | ||
258 | */ | ||
259 | @Override | ||
260 | public boolean eIsSet(int featureID) { | ||
261 | switch (featureID) { | ||
262 | case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY: | ||
263 | return requiredMemory != REQUIRED_MEMORY_EDEFAULT; | ||
264 | case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD: | ||
265 | return requiredHdd != REQUIRED_HDD_EDEFAULT; | ||
266 | case CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE: | ||
267 | return hostType != null; | ||
268 | } | ||
269 | return super.eIsSet(featureID); | ||
270 | } | ||
271 | |||
272 | /** | ||
273 | * <!-- begin-user-doc --> | ||
274 | * <!-- end-user-doc --> | ||
275 | * @generated | ||
276 | */ | ||
277 | @Override | ||
278 | public String toString() { | ||
279 | if (eIsProxy()) | ||
280 | return super.toString(); | ||
281 | |||
282 | StringBuilder result = new StringBuilder(super.toString()); | ||
283 | result.append(" (requiredMemory: "); | ||
284 | result.append(requiredMemory); | ||
285 | result.append(", requiredHdd: "); | ||
286 | result.append(requiredHdd); | ||
287 | result.append(')'); | ||
288 | return result.toString(); | ||
289 | } | ||
290 | |||
291 | } //ResourceRequirementImpl | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsAdapterFactory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsAdapterFactory.java new file mode 100644 index 00000000..83e984a6 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsAdapterFactory.java | |||
@@ -0,0 +1,252 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps.util; | ||
4 | |||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.*; | ||
6 | |||
7 | import org.eclipse.emf.common.notify.Adapter; | ||
8 | import org.eclipse.emf.common.notify.Notifier; | ||
9 | |||
10 | import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; | ||
11 | |||
12 | import org.eclipse.emf.ecore.EObject; | ||
13 | |||
14 | /** | ||
15 | * <!-- begin-user-doc --> | ||
16 | * The <b>Adapter Factory</b> for the model. | ||
17 | * It provides an adapter <code>createXXX</code> method for each class of the model. | ||
18 | * <!-- end-user-doc --> | ||
19 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage | ||
20 | * @generated | ||
21 | */ | ||
22 | public class CpsAdapterFactory extends AdapterFactoryImpl { | ||
23 | /** | ||
24 | * The cached model package. | ||
25 | * <!-- begin-user-doc --> | ||
26 | * <!-- end-user-doc --> | ||
27 | * @generated | ||
28 | */ | ||
29 | protected static CpsPackage modelPackage; | ||
30 | |||
31 | /** | ||
32 | * Creates an instance of the adapter factory. | ||
33 | * <!-- begin-user-doc --> | ||
34 | * <!-- end-user-doc --> | ||
35 | * @generated | ||
36 | */ | ||
37 | public CpsAdapterFactory() { | ||
38 | if (modelPackage == null) { | ||
39 | modelPackage = CpsPackage.eINSTANCE; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | * Returns whether this factory is applicable for the type of the object. | ||
45 | * <!-- begin-user-doc --> | ||
46 | * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. | ||
47 | * <!-- end-user-doc --> | ||
48 | * @return whether this factory is applicable for the type of the object. | ||
49 | * @generated | ||
50 | */ | ||
51 | @Override | ||
52 | public boolean isFactoryForType(Object object) { | ||
53 | if (object == modelPackage) { | ||
54 | return true; | ||
55 | } | ||
56 | if (object instanceof EObject) { | ||
57 | return ((EObject) object).eClass().getEPackage() == modelPackage; | ||
58 | } | ||
59 | return false; | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * The switch that delegates to the <code>createXXX</code> methods. | ||
64 | * <!-- begin-user-doc --> | ||
65 | * <!-- end-user-doc --> | ||
66 | * @generated | ||
67 | */ | ||
68 | protected CpsSwitch<Adapter> modelSwitch = new CpsSwitch<Adapter>() { | ||
69 | @Override | ||
70 | public Adapter caseCyberPhysicalSystem(CyberPhysicalSystem object) { | ||
71 | return createCyberPhysicalSystemAdapter(); | ||
72 | } | ||
73 | |||
74 | @Override | ||
75 | public Adapter caseApplicationType(ApplicationType object) { | ||
76 | return createApplicationTypeAdapter(); | ||
77 | } | ||
78 | |||
79 | @Override | ||
80 | public Adapter caseHostType(HostType object) { | ||
81 | return createHostTypeAdapter(); | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Adapter caseRequest(Request object) { | ||
86 | return createRequestAdapter(); | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Adapter caseRequirement(Requirement object) { | ||
91 | return createRequirementAdapter(); | ||
92 | } | ||
93 | |||
94 | @Override | ||
95 | public Adapter caseApplicationInstance(ApplicationInstance object) { | ||
96 | return createApplicationInstanceAdapter(); | ||
97 | } | ||
98 | |||
99 | @Override | ||
100 | public Adapter caseResourceRequirement(ResourceRequirement object) { | ||
101 | return createResourceRequirementAdapter(); | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public Adapter caseHostInstance(HostInstance object) { | ||
106 | return createHostInstanceAdapter(); | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public Adapter defaultCase(EObject object) { | ||
111 | return createEObjectAdapter(); | ||
112 | } | ||
113 | }; | ||
114 | |||
115 | /** | ||
116 | * Creates an adapter for the <code>target</code>. | ||
117 | * <!-- begin-user-doc --> | ||
118 | * <!-- end-user-doc --> | ||
119 | * @param target the object to adapt. | ||
120 | * @return the adapter for the <code>target</code>. | ||
121 | * @generated | ||
122 | */ | ||
123 | @Override | ||
124 | public Adapter createAdapter(Notifier target) { | ||
125 | return modelSwitch.doSwitch((EObject) target); | ||
126 | } | ||
127 | |||
128 | /** | ||
129 | * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem <em>Cyber Physical System</em>}'. | ||
130 | * <!-- begin-user-doc --> | ||
131 | * This default implementation returns null so that we can easily ignore cases; | ||
132 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
133 | * <!-- end-user-doc --> | ||
134 | * @return the new adapter. | ||
135 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem | ||
136 | * @generated | ||
137 | */ | ||
138 | public Adapter createCyberPhysicalSystemAdapter() { | ||
139 | return null; | ||
140 | } | ||
141 | |||
142 | /** | ||
143 | * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType <em>Application Type</em>}'. | ||
144 | * <!-- begin-user-doc --> | ||
145 | * This default implementation returns null so that we can easily ignore cases; | ||
146 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
147 | * <!-- end-user-doc --> | ||
148 | * @return the new adapter. | ||
149 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType | ||
150 | * @generated | ||
151 | */ | ||
152 | public Adapter createApplicationTypeAdapter() { | ||
153 | return null; | ||
154 | } | ||
155 | |||
156 | /** | ||
157 | * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType <em>Host Type</em>}'. | ||
158 | * <!-- begin-user-doc --> | ||
159 | * This default implementation returns null so that we can easily ignore cases; | ||
160 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
161 | * <!-- end-user-doc --> | ||
162 | * @return the new adapter. | ||
163 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType | ||
164 | * @generated | ||
165 | */ | ||
166 | public Adapter createHostTypeAdapter() { | ||
167 | return null; | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Request <em>Request</em>}'. | ||
172 | * <!-- begin-user-doc --> | ||
173 | * This default implementation returns null so that we can easily ignore cases; | ||
174 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
175 | * <!-- end-user-doc --> | ||
176 | * @return the new adapter. | ||
177 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.Request | ||
178 | * @generated | ||
179 | */ | ||
180 | public Adapter createRequestAdapter() { | ||
181 | return null; | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement <em>Requirement</em>}'. | ||
186 | * <!-- begin-user-doc --> | ||
187 | * This default implementation returns null so that we can easily ignore cases; | ||
188 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
189 | * <!-- end-user-doc --> | ||
190 | * @return the new adapter. | ||
191 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement | ||
192 | * @generated | ||
193 | */ | ||
194 | public Adapter createRequirementAdapter() { | ||
195 | return null; | ||
196 | } | ||
197 | |||
198 | /** | ||
199 | * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance <em>Application Instance</em>}'. | ||
200 | * <!-- begin-user-doc --> | ||
201 | * This default implementation returns null so that we can easily ignore cases; | ||
202 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
203 | * <!-- end-user-doc --> | ||
204 | * @return the new adapter. | ||
205 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance | ||
206 | * @generated | ||
207 | */ | ||
208 | public Adapter createApplicationInstanceAdapter() { | ||
209 | return null; | ||
210 | } | ||
211 | |||
212 | /** | ||
213 | * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement <em>Resource Requirement</em>}'. | ||
214 | * <!-- begin-user-doc --> | ||
215 | * This default implementation returns null so that we can easily ignore cases; | ||
216 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
217 | * <!-- end-user-doc --> | ||
218 | * @return the new adapter. | ||
219 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement | ||
220 | * @generated | ||
221 | */ | ||
222 | public Adapter createResourceRequirementAdapter() { | ||
223 | return null; | ||
224 | } | ||
225 | |||
226 | /** | ||
227 | * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance <em>Host Instance</em>}'. | ||
228 | * <!-- begin-user-doc --> | ||
229 | * This default implementation returns null so that we can easily ignore cases; | ||
230 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
231 | * <!-- end-user-doc --> | ||
232 | * @return the new adapter. | ||
233 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance | ||
234 | * @generated | ||
235 | */ | ||
236 | public Adapter createHostInstanceAdapter() { | ||
237 | return null; | ||
238 | } | ||
239 | |||
240 | /** | ||
241 | * Creates a new adapter for the default case. | ||
242 | * <!-- begin-user-doc --> | ||
243 | * This default implementation returns null. | ||
244 | * <!-- end-user-doc --> | ||
245 | * @return the new adapter. | ||
246 | * @generated | ||
247 | */ | ||
248 | public Adapter createEObjectAdapter() { | ||
249 | return null; | ||
250 | } | ||
251 | |||
252 | } //CpsAdapterFactory | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsSwitch.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsSwitch.java new file mode 100644 index 00000000..28b630a9 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsSwitch.java | |||
@@ -0,0 +1,266 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package hu.bme.mit.inf.dslreasoner.domains.cps.util; | ||
4 | |||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.*; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | import org.eclipse.emf.ecore.EPackage; | ||
9 | |||
10 | import org.eclipse.emf.ecore.util.Switch; | ||
11 | |||
12 | /** | ||
13 | * <!-- begin-user-doc --> | ||
14 | * The <b>Switch</b> for the model's inheritance hierarchy. | ||
15 | * It supports the call {@link #doSwitch(EObject) doSwitch(object)} | ||
16 | * to invoke the <code>caseXXX</code> method for each class of the model, | ||
17 | * starting with the actual class of the object | ||
18 | * and proceeding up the inheritance hierarchy | ||
19 | * until a non-null result is returned, | ||
20 | * which is the result of the switch. | ||
21 | * <!-- end-user-doc --> | ||
22 | * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage | ||
23 | * @generated | ||
24 | */ | ||
25 | public class CpsSwitch<T> extends Switch<T> { | ||
26 | /** | ||
27 | * The cached model package | ||
28 | * <!-- begin-user-doc --> | ||
29 | * <!-- end-user-doc --> | ||
30 | * @generated | ||
31 | */ | ||
32 | protected static CpsPackage modelPackage; | ||
33 | |||
34 | /** | ||
35 | * Creates an instance of the switch. | ||
36 | * <!-- begin-user-doc --> | ||
37 | * <!-- end-user-doc --> | ||
38 | * @generated | ||
39 | */ | ||
40 | public CpsSwitch() { | ||
41 | if (modelPackage == null) { | ||
42 | modelPackage = CpsPackage.eINSTANCE; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | /** | ||
47 | * Checks whether this is a switch for the given package. | ||
48 | * <!-- begin-user-doc --> | ||
49 | * <!-- end-user-doc --> | ||
50 | * @param ePackage the package in question. | ||
51 | * @return whether this is a switch for the given package. | ||
52 | * @generated | ||
53 | */ | ||
54 | @Override | ||
55 | protected boolean isSwitchFor(EPackage ePackage) { | ||
56 | return ePackage == modelPackage; | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. | ||
61 | * <!-- begin-user-doc --> | ||
62 | * <!-- end-user-doc --> | ||
63 | * @return the first non-null result returned by a <code>caseXXX</code> call. | ||
64 | * @generated | ||
65 | */ | ||
66 | @Override | ||
67 | protected T doSwitch(int classifierID, EObject theEObject) { | ||
68 | switch (classifierID) { | ||
69 | case CpsPackage.CYBER_PHYSICAL_SYSTEM: { | ||
70 | CyberPhysicalSystem cyberPhysicalSystem = (CyberPhysicalSystem) theEObject; | ||
71 | T result = caseCyberPhysicalSystem(cyberPhysicalSystem); | ||
72 | if (result == null) | ||
73 | result = defaultCase(theEObject); | ||
74 | return result; | ||
75 | } | ||
76 | case CpsPackage.APPLICATION_TYPE: { | ||
77 | ApplicationType applicationType = (ApplicationType) theEObject; | ||
78 | T result = caseApplicationType(applicationType); | ||
79 | if (result == null) | ||
80 | result = defaultCase(theEObject); | ||
81 | return result; | ||
82 | } | ||
83 | case CpsPackage.HOST_TYPE: { | ||
84 | HostType hostType = (HostType) theEObject; | ||
85 | T result = caseHostType(hostType); | ||
86 | if (result == null) | ||
87 | result = defaultCase(theEObject); | ||
88 | return result; | ||
89 | } | ||
90 | case CpsPackage.REQUEST: { | ||
91 | Request request = (Request) theEObject; | ||
92 | T result = caseRequest(request); | ||
93 | if (result == null) | ||
94 | result = defaultCase(theEObject); | ||
95 | return result; | ||
96 | } | ||
97 | case CpsPackage.REQUIREMENT: { | ||
98 | Requirement requirement = (Requirement) theEObject; | ||
99 | T result = caseRequirement(requirement); | ||
100 | if (result == null) | ||
101 | result = defaultCase(theEObject); | ||
102 | return result; | ||
103 | } | ||
104 | case CpsPackage.APPLICATION_INSTANCE: { | ||
105 | ApplicationInstance applicationInstance = (ApplicationInstance) theEObject; | ||
106 | T result = caseApplicationInstance(applicationInstance); | ||
107 | if (result == null) | ||
108 | result = defaultCase(theEObject); | ||
109 | return result; | ||
110 | } | ||
111 | case CpsPackage.RESOURCE_REQUIREMENT: { | ||
112 | ResourceRequirement resourceRequirement = (ResourceRequirement) theEObject; | ||
113 | T result = caseResourceRequirement(resourceRequirement); | ||
114 | if (result == null) | ||
115 | result = defaultCase(theEObject); | ||
116 | return result; | ||
117 | } | ||
118 | case CpsPackage.HOST_INSTANCE: { | ||
119 | HostInstance hostInstance = (HostInstance) theEObject; | ||
120 | T result = caseHostInstance(hostInstance); | ||
121 | if (result == null) | ||
122 | result = defaultCase(theEObject); | ||
123 | return result; | ||
124 | } | ||
125 | default: | ||
126 | return defaultCase(theEObject); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | /** | ||
131 | * Returns the result of interpreting the object as an instance of '<em>Cyber Physical System</em>'. | ||
132 | * <!-- begin-user-doc --> | ||
133 | * This implementation returns null; | ||
134 | * returning a non-null result will terminate the switch. | ||
135 | * <!-- end-user-doc --> | ||
136 | * @param object the target of the switch. | ||
137 | * @return the result of interpreting the object as an instance of '<em>Cyber Physical System</em>'. | ||
138 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
139 | * @generated | ||
140 | */ | ||
141 | public T caseCyberPhysicalSystem(CyberPhysicalSystem object) { | ||
142 | return null; | ||
143 | } | ||
144 | |||
145 | /** | ||
146 | * Returns the result of interpreting the object as an instance of '<em>Application Type</em>'. | ||
147 | * <!-- begin-user-doc --> | ||
148 | * This implementation returns null; | ||
149 | * returning a non-null result will terminate the switch. | ||
150 | * <!-- end-user-doc --> | ||
151 | * @param object the target of the switch. | ||
152 | * @return the result of interpreting the object as an instance of '<em>Application Type</em>'. | ||
153 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
154 | * @generated | ||
155 | */ | ||
156 | public T caseApplicationType(ApplicationType object) { | ||
157 | return null; | ||
158 | } | ||
159 | |||
160 | /** | ||
161 | * Returns the result of interpreting the object as an instance of '<em>Host Type</em>'. | ||
162 | * <!-- begin-user-doc --> | ||
163 | * This implementation returns null; | ||
164 | * returning a non-null result will terminate the switch. | ||
165 | * <!-- end-user-doc --> | ||
166 | * @param object the target of the switch. | ||
167 | * @return the result of interpreting the object as an instance of '<em>Host Type</em>'. | ||
168 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
169 | * @generated | ||
170 | */ | ||
171 | public T caseHostType(HostType object) { | ||
172 | return null; | ||
173 | } | ||
174 | |||
175 | /** | ||
176 | * Returns the result of interpreting the object as an instance of '<em>Request</em>'. | ||
177 | * <!-- begin-user-doc --> | ||
178 | * This implementation returns null; | ||
179 | * returning a non-null result will terminate the switch. | ||
180 | * <!-- end-user-doc --> | ||
181 | * @param object the target of the switch. | ||
182 | * @return the result of interpreting the object as an instance of '<em>Request</em>'. | ||
183 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
184 | * @generated | ||
185 | */ | ||
186 | public T caseRequest(Request object) { | ||
187 | return null; | ||
188 | } | ||
189 | |||
190 | /** | ||
191 | * Returns the result of interpreting the object as an instance of '<em>Requirement</em>'. | ||
192 | * <!-- begin-user-doc --> | ||
193 | * This implementation returns null; | ||
194 | * returning a non-null result will terminate the switch. | ||
195 | * <!-- end-user-doc --> | ||
196 | * @param object the target of the switch. | ||
197 | * @return the result of interpreting the object as an instance of '<em>Requirement</em>'. | ||
198 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
199 | * @generated | ||
200 | */ | ||
201 | public T caseRequirement(Requirement object) { | ||
202 | return null; | ||
203 | } | ||
204 | |||
205 | /** | ||
206 | * Returns the result of interpreting the object as an instance of '<em>Application Instance</em>'. | ||
207 | * <!-- begin-user-doc --> | ||
208 | * This implementation returns null; | ||
209 | * returning a non-null result will terminate the switch. | ||
210 | * <!-- end-user-doc --> | ||
211 | * @param object the target of the switch. | ||
212 | * @return the result of interpreting the object as an instance of '<em>Application Instance</em>'. | ||
213 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
214 | * @generated | ||
215 | */ | ||
216 | public T caseApplicationInstance(ApplicationInstance object) { | ||
217 | return null; | ||
218 | } | ||
219 | |||
220 | /** | ||
221 | * Returns the result of interpreting the object as an instance of '<em>Resource Requirement</em>'. | ||
222 | * <!-- begin-user-doc --> | ||
223 | * This implementation returns null; | ||
224 | * returning a non-null result will terminate the switch. | ||
225 | * <!-- end-user-doc --> | ||
226 | * @param object the target of the switch. | ||
227 | * @return the result of interpreting the object as an instance of '<em>Resource Requirement</em>'. | ||
228 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
229 | * @generated | ||
230 | */ | ||
231 | public T caseResourceRequirement(ResourceRequirement object) { | ||
232 | return null; | ||
233 | } | ||
234 | |||
235 | /** | ||
236 | * Returns the result of interpreting the object as an instance of '<em>Host Instance</em>'. | ||
237 | * <!-- begin-user-doc --> | ||
238 | * This implementation returns null; | ||
239 | * returning a non-null result will terminate the switch. | ||
240 | * <!-- end-user-doc --> | ||
241 | * @param object the target of the switch. | ||
242 | * @return the result of interpreting the object as an instance of '<em>Host Instance</em>'. | ||
243 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
244 | * @generated | ||
245 | */ | ||
246 | public T caseHostInstance(HostInstance object) { | ||
247 | return null; | ||
248 | } | ||
249 | |||
250 | /** | ||
251 | * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. | ||
252 | * <!-- begin-user-doc --> | ||
253 | * This implementation returns null; | ||
254 | * returning a non-null result will terminate the switch, but this is the last case anyway. | ||
255 | * <!-- end-user-doc --> | ||
256 | * @param object the target of the switch. | ||
257 | * @return the result of interpreting the object as an instance of '<em>EObject</em>'. | ||
258 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) | ||
259 | * @generated | ||
260 | */ | ||
261 | @Override | ||
262 | public T defaultCase(EObject object) { | ||
263 | return null; | ||
264 | } | ||
265 | |||
266 | } //CpsSwitch | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore new file mode 100644 index 00000000..0f52d8ee --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore | |||
@@ -0,0 +1,61 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="cps" nsURI="http://www.example.org/cps" nsPrefix="cps"> | ||
4 | <eClassifiers xsi:type="ecore:EClass" name="CyberPhysicalSystem"> | ||
5 | <eStructuralFeatures xsi:type="ecore:EReference" name="requests" upperBound="-1" | ||
6 | eType="#//Request" containment="true"/> | ||
7 | <eStructuralFeatures xsi:type="ecore:EReference" name="applicationTypes" upperBound="-1" | ||
8 | eType="#//ApplicationType" containment="true"/> | ||
9 | <eStructuralFeatures xsi:type="ecore:EReference" name="hostTypes" upperBound="-1" | ||
10 | eType="#//HostType" containment="true"/> | ||
11 | </eClassifiers> | ||
12 | <eClassifiers xsi:type="ecore:EClass" name="ApplicationType"> | ||
13 | <eStructuralFeatures xsi:type="ecore:EReference" name="instances" upperBound="-1" | ||
14 | eType="#//ApplicationInstance" containment="true" eOpposite="#//ApplicationInstance/type"/> | ||
15 | <eStructuralFeatures xsi:type="ecore:EReference" name="requirements" upperBound="-1" | ||
16 | eType="#//ResourceRequirement" containment="true"/> | ||
17 | </eClassifiers> | ||
18 | <eClassifiers xsi:type="ecore:EClass" name="HostType"> | ||
19 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="defaultMemory" lowerBound="1" | ||
20 | eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
21 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="defaultHdd" lowerBound="1" | ||
22 | eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
23 | <eStructuralFeatures xsi:type="ecore:EReference" name="instances" upperBound="-1" | ||
24 | eType="#//HostInstance" containment="true" eOpposite="#//HostInstance/type"/> | ||
25 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="cost" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
26 | </eClassifiers> | ||
27 | <eClassifiers xsi:type="ecore:EClass" name="Request"> | ||
28 | <eStructuralFeatures xsi:type="ecore:EReference" name="requirements" upperBound="-1" | ||
29 | eType="#//Requirement" containment="true" eOpposite="#//Requirement/request"/> | ||
30 | </eClassifiers> | ||
31 | <eClassifiers xsi:type="ecore:EClass" name="Requirement"> | ||
32 | <eStructuralFeatures xsi:type="ecore:EReference" name="request" lowerBound="1" | ||
33 | eType="#//Request" eOpposite="#//Request/requirements"/> | ||
34 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="count" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
35 | <eStructuralFeatures xsi:type="ecore:EReference" name="type" eType="#//ApplicationType"/> | ||
36 | <eStructuralFeatures xsi:type="ecore:EReference" name="instances" upperBound="-1" | ||
37 | eType="#//ApplicationInstance" eOpposite="#//ApplicationInstance/requirement"/> | ||
38 | </eClassifiers> | ||
39 | <eClassifiers xsi:type="ecore:EClass" name="ApplicationInstance"> | ||
40 | <eStructuralFeatures xsi:type="ecore:EReference" name="requirement" eType="#//Requirement" | ||
41 | eOpposite="#//Requirement/instances"/> | ||
42 | <eStructuralFeatures xsi:type="ecore:EReference" name="type" lowerBound="1" eType="#//ApplicationType" | ||
43 | eOpposite="#//ApplicationType/instances"/> | ||
44 | <eStructuralFeatures xsi:type="ecore:EReference" name="allocatedTo" lowerBound="1" | ||
45 | eType="#//HostInstance" eOpposite="#//HostInstance/applications"/> | ||
46 | </eClassifiers> | ||
47 | <eClassifiers xsi:type="ecore:EClass" name="ResourceRequirement"> | ||
48 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="requiredMemory" lowerBound="1" | ||
49 | eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
50 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="requiredHdd" lowerBound="1" | ||
51 | eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
52 | <eStructuralFeatures xsi:type="ecore:EReference" name="hostType" lowerBound="1" | ||
53 | eType="#//HostType"/> | ||
54 | </eClassifiers> | ||
55 | <eClassifiers xsi:type="ecore:EClass" name="HostInstance"> | ||
56 | <eStructuralFeatures xsi:type="ecore:EReference" name="type" lowerBound="1" eType="#//HostType" | ||
57 | eOpposite="#//HostType/instances"/> | ||
58 | <eStructuralFeatures xsi:type="ecore:EReference" name="applications" upperBound="-1" | ||
59 | eType="#//ApplicationInstance" eOpposite="#//ApplicationInstance/allocatedTo"/> | ||
60 | </eClassifiers> | ||
61 | </ecore:EPackage> | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel new file mode 100644 index 00000000..09ed2e0c --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel | |||
@@ -0,0 +1,53 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" | ||
4 | modelDirectory="/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen" | ||
5 | creationIcons="false" editDirectory="/hu.bme.mit.inf.dslreasoner.domains.cps.edit/src-gen" | ||
6 | editorDirectory="/hu.bme.mit.inf.dslreasoner.domains.cps.editor/src-gen" modelPluginID="hu.bme.mit.inf.dslreasoner.domains.cps" | ||
7 | modelName="Cps" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" | ||
8 | codeFormatting="true" importerID="org.eclipse.emf.importer.ecore" complianceLevel="8.0" | ||
9 | copyrightFields="false" operationReflection="true" importOrganizing="true"> | ||
10 | <foreignModel>cps.ecore</foreignModel> | ||
11 | <testsDirectory xsi:nil="true"/> | ||
12 | <genPackages prefix="Cps" basePackage="hu.bme.mit.inf.dslreasoner.domains" disposableProviderFactory="true" | ||
13 | ecorePackage="cps.ecore#/"> | ||
14 | <genClasses ecoreClass="cps.ecore#//CyberPhysicalSystem"> | ||
15 | <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference cps.ecore#//CyberPhysicalSystem/requests"/> | ||
16 | <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference cps.ecore#//CyberPhysicalSystem/applicationTypes"/> | ||
17 | <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference cps.ecore#//CyberPhysicalSystem/hostTypes"/> | ||
18 | </genClasses> | ||
19 | <genClasses ecoreClass="cps.ecore#//ApplicationType"> | ||
20 | <genFeatures children="true" createChild="true" propertySortChoices="true" ecoreFeature="ecore:EReference cps.ecore#//ApplicationType/instances"/> | ||
21 | <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference cps.ecore#//ApplicationType/requirements"/> | ||
22 | </genClasses> | ||
23 | <genClasses ecoreClass="cps.ecore#//HostType"> | ||
24 | <genFeatures createChild="false" ecoreFeature="ecore:EAttribute cps.ecore#//HostType/defaultMemory"/> | ||
25 | <genFeatures createChild="false" ecoreFeature="ecore:EAttribute cps.ecore#//HostType/defaultHdd"/> | ||
26 | <genFeatures children="true" createChild="true" propertySortChoices="true" ecoreFeature="ecore:EReference cps.ecore#//HostType/instances"/> | ||
27 | <genFeatures createChild="false" ecoreFeature="ecore:EAttribute cps.ecore#//HostType/cost"/> | ||
28 | </genClasses> | ||
29 | <genClasses ecoreClass="cps.ecore#//Request"> | ||
30 | <genFeatures children="true" createChild="true" propertySortChoices="true" ecoreFeature="ecore:EReference cps.ecore#//Request/requirements"/> | ||
31 | </genClasses> | ||
32 | <genClasses ecoreClass="cps.ecore#//Requirement"> | ||
33 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference cps.ecore#//Requirement/request"/> | ||
34 | <genFeatures createChild="false" ecoreFeature="ecore:EAttribute cps.ecore#//Requirement/count"/> | ||
35 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference cps.ecore#//Requirement/type"/> | ||
36 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference cps.ecore#//Requirement/instances"/> | ||
37 | </genClasses> | ||
38 | <genClasses ecoreClass="cps.ecore#//ApplicationInstance"> | ||
39 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference cps.ecore#//ApplicationInstance/requirement"/> | ||
40 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference cps.ecore#//ApplicationInstance/type"/> | ||
41 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference cps.ecore#//ApplicationInstance/allocatedTo"/> | ||
42 | </genClasses> | ||
43 | <genClasses ecoreClass="cps.ecore#//ResourceRequirement"> | ||
44 | <genFeatures createChild="false" ecoreFeature="ecore:EAttribute cps.ecore#//ResourceRequirement/requiredMemory"/> | ||
45 | <genFeatures createChild="false" ecoreFeature="ecore:EAttribute cps.ecore#//ResourceRequirement/requiredHdd"/> | ||
46 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference cps.ecore#//ResourceRequirement/hostType"/> | ||
47 | </genClasses> | ||
48 | <genClasses ecoreClass="cps.ecore#//HostInstance"> | ||
49 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference cps.ecore#//HostInstance/type"/> | ||
50 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference cps.ecore#//HostInstance/applications"/> | ||
51 | </genClasses> | ||
52 | </genPackages> | ||
53 | </genmodel:GenModel> | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.henshin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.henshin new file mode 100644 index 00000000..a4f4f576 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.henshin | |||
@@ -0,0 +1,498 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <henshin:Module xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:henshin="http://www.eclipse.org/emf/2011/Henshin" xmi:id="_rUcIgHyxEemI79hpD-o6pA"> | ||
3 | <imports href="cps.ecore#/"/> | ||
4 | <units xsi:type="henshin:Rule" xmi:id="_ttviMHyxEemI79hpD-o6pA" name="createAppInstance"> | ||
5 | <lhs xmi:id="_tuVYEHyxEemI79hpD-o6pA" name="Lhs"> | ||
6 | <nodes xmi:id="_8OoYwHyxEemI79hpD-o6pA" name="req" outgoing="_APd7gHyzEemI79hpD-o6pA"> | ||
7 | <type href="cps.ecore#//Requirement"/> | ||
8 | </nodes> | ||
9 | <nodes xmi:id="__cBFUHyyEemI79hpD-o6pA" incoming="_APd7gHyzEemI79hpD-o6pA"> | ||
10 | <type href="cps.ecore#//ApplicationType"/> | ||
11 | </nodes> | ||
12 | <edges xmi:id="_APd7gHyzEemI79hpD-o6pA" source="_8OoYwHyxEemI79hpD-o6pA" target="__cBFUHyyEemI79hpD-o6pA"> | ||
13 | <type href="cps.ecore#//Requirement/type"/> | ||
14 | </edges> | ||
15 | </lhs> | ||
16 | <rhs xmi:id="_txSlcHyxEemI79hpD-o6pA" name="Rhs"> | ||
17 | <nodes xmi:id="_8OufYHyxEemI79hpD-o6pA" name="req" outgoing="_6YaokHyyEemI79hpD-o6pA _APd7gXyzEemI79hpD-o6pA"> | ||
18 | <type href="cps.ecore#//Requirement"/> | ||
19 | </nodes> | ||
20 | <nodes xmi:id="_KIXvwHyyEemI79hpD-o6pA" incoming="_6YaokHyyEemI79hpD-o6pA _AoFP0HyzEemI79hpD-o6pA"> | ||
21 | <type href="cps.ecore#//ApplicationInstance"/> | ||
22 | </nodes> | ||
23 | <nodes xmi:id="__cBFUXyyEemI79hpD-o6pA" incoming="_APd7gXyzEemI79hpD-o6pA" outgoing="_AoFP0HyzEemI79hpD-o6pA"> | ||
24 | <type href="cps.ecore#//ApplicationType"/> | ||
25 | </nodes> | ||
26 | <edges xmi:id="_6YaokHyyEemI79hpD-o6pA" source="_8OufYHyxEemI79hpD-o6pA" target="_KIXvwHyyEemI79hpD-o6pA"> | ||
27 | <type href="cps.ecore#//Requirement/instances"/> | ||
28 | </edges> | ||
29 | <edges xmi:id="_APd7gXyzEemI79hpD-o6pA" source="_8OufYHyxEemI79hpD-o6pA" target="__cBFUXyyEemI79hpD-o6pA"> | ||
30 | <type href="cps.ecore#//Requirement/type"/> | ||
31 | </edges> | ||
32 | <edges xmi:id="_AoFP0HyzEemI79hpD-o6pA" source="__cBFUXyyEemI79hpD-o6pA" target="_KIXvwHyyEemI79hpD-o6pA"> | ||
33 | <type href="cps.ecore#//ApplicationType/instances"/> | ||
34 | </edges> | ||
35 | </rhs> | ||
36 | <mappings xmi:id="_8OufYXyxEemI79hpD-o6pA" origin="_8OoYwHyxEemI79hpD-o6pA" image="_8OufYHyxEemI79hpD-o6pA"/> | ||
37 | <mappings xmi:id="__cBsYHyyEemI79hpD-o6pA" origin="__cBFUHyyEemI79hpD-o6pA" image="__cBFUXyyEemI79hpD-o6pA"/> | ||
38 | </units> | ||
39 | <units xsi:type="henshin:Rule" xmi:id="_M36NQHy0EemI79hpD-o6pA" name="createHostInstance"> | ||
40 | <lhs xmi:id="_M4D-QHy0EemI79hpD-o6pA" name="Lhs"> | ||
41 | <nodes xmi:id="_ZpwIEHy0EemI79hpD-o6pA"> | ||
42 | <type href="cps.ecore#//HostType"/> | ||
43 | </nodes> | ||
44 | </lhs> | ||
45 | <rhs xmi:id="_M4HBkHy0EemI79hpD-o6pA" name="Rhs"> | ||
46 | <nodes xmi:id="_Zp2OsHy0EemI79hpD-o6pA" outgoing="_faZ4EHy0EemI79hpD-o6pA"> | ||
47 | <type href="cps.ecore#//HostType"/> | ||
48 | </nodes> | ||
49 | <nodes xmi:id="_bFDBYHy0EemI79hpD-o6pA" incoming="_faZ4EHy0EemI79hpD-o6pA"> | ||
50 | <type href="cps.ecore#//HostInstance"/> | ||
51 | </nodes> | ||
52 | <edges xmi:id="_faZ4EHy0EemI79hpD-o6pA" source="_Zp2OsHy0EemI79hpD-o6pA" target="_bFDBYHy0EemI79hpD-o6pA"> | ||
53 | <type href="cps.ecore#//HostType/instances"/> | ||
54 | </edges> | ||
55 | </rhs> | ||
56 | <mappings xmi:id="_Zp2OsXy0EemI79hpD-o6pA" origin="_ZpwIEHy0EemI79hpD-o6pA" image="_Zp2OsHy0EemI79hpD-o6pA"/> | ||
57 | </units> | ||
58 | <units xsi:type="henshin:Rule" xmi:id="_2yQIQHy0EemI79hpD-o6pA" name="deleteHostInstance"> | ||
59 | <lhs xmi:id="_2yTLkHy0EemI79hpD-o6pA" name="Lhs"> | ||
60 | <nodes xmi:id="_5jfg0Hy0EemI79hpD-o6pA" outgoing="_7KrhEHy0EemI79hpD-o6pA"> | ||
61 | <type href="cps.ecore#//HostType"/> | ||
62 | </nodes> | ||
63 | <nodes xmi:id="_6FqZwHy0EemI79hpD-o6pA" incoming="_7KrhEHy0EemI79hpD-o6pA"> | ||
64 | <type href="cps.ecore#//HostInstance"/> | ||
65 | </nodes> | ||
66 | <edges xmi:id="_7KrhEHy0EemI79hpD-o6pA" source="_5jfg0Hy0EemI79hpD-o6pA" target="_6FqZwHy0EemI79hpD-o6pA"> | ||
67 | <type href="cps.ecore#//HostType/instances"/> | ||
68 | </edges> | ||
69 | <formula xsi:type="henshin:Not" xmi:id="__tHxgHy0EemI79hpD-o6pA"> | ||
70 | <child xsi:type="henshin:NestedCondition" xmi:id="__tIYkHy0EemI79hpD-o6pA"> | ||
71 | <conclusion xmi:id="__tIYkXy0EemI79hpD-o6pA"> | ||
72 | <nodes xmi:id="_8lTsAHy0EemI79hpD-o6pA" outgoing="__HvMgHy0EemI79hpD-o6pA"> | ||
73 | <type href="cps.ecore#//ApplicationInstance"/> | ||
74 | </nodes> | ||
75 | <nodes xmi:id="__tI_oHy0EemI79hpD-o6pA" incoming="__HvMgHy0EemI79hpD-o6pA _AuDqEHy1EemI79hpD-o6pA"> | ||
76 | <type href="cps.ecore#//HostInstance"/> | ||
77 | </nodes> | ||
78 | <nodes xmi:id="_AuDDAHy1EemI79hpD-o6pA" outgoing="_AuDqEHy1EemI79hpD-o6pA"> | ||
79 | <type href="cps.ecore#//HostType"/> | ||
80 | </nodes> | ||
81 | <edges xmi:id="__HvMgHy0EemI79hpD-o6pA" source="_8lTsAHy0EemI79hpD-o6pA" target="__tI_oHy0EemI79hpD-o6pA"> | ||
82 | <type href="cps.ecore#//ApplicationInstance/allocatedTo"/> | ||
83 | </edges> | ||
84 | <edges xmi:id="_AuDqEHy1EemI79hpD-o6pA" source="_AuDDAHy1EemI79hpD-o6pA" target="__tI_oHy0EemI79hpD-o6pA"> | ||
85 | <type href="cps.ecore#//HostType/instances"/> | ||
86 | </edges> | ||
87 | </conclusion> | ||
88 | <mappings xmi:id="__tI_oXy0EemI79hpD-o6pA" origin="_6FqZwHy0EemI79hpD-o6pA" image="__tI_oHy0EemI79hpD-o6pA"/> | ||
89 | <mappings xmi:id="_AuDDAXy1EemI79hpD-o6pA" origin="_5jfg0Hy0EemI79hpD-o6pA" image="_AuDDAHy1EemI79hpD-o6pA"/> | ||
90 | </child> | ||
91 | </formula> | ||
92 | </lhs> | ||
93 | <rhs xmi:id="_2yUZsHy0EemI79hpD-o6pA" name="Rhs"> | ||
94 | <nodes xmi:id="_5jfg0Xy0EemI79hpD-o6pA"> | ||
95 | <type href="cps.ecore#//HostType"/> | ||
96 | </nodes> | ||
97 | </rhs> | ||
98 | <mappings xmi:id="_5jfg0ny0EemI79hpD-o6pA" origin="_5jfg0Hy0EemI79hpD-o6pA" image="_5jfg0Xy0EemI79hpD-o6pA"/> | ||
99 | </units> | ||
100 | <units xsi:type="henshin:Rule" xmi:id="_W9WPYHy4EemI79hpD-o6pA" name="allocate"> | ||
101 | <lhs xmi:id="_W9ag0Hy4EemI79hpD-o6pA" name="Lhs"> | ||
102 | <nodes xmi:id="_QzQ2QHy5EemI79hpD-o6pA" outgoing="_hW5nsHy5EemI79hpD-o6pA"> | ||
103 | <type href="cps.ecore#//Requirement"/> | ||
104 | </nodes> | ||
105 | <nodes xmi:id="_U88ocHy5EemI79hpD-o6pA" outgoing="_epK2IHy5EemI79hpD-o6pA _f_l2gHy5EemI79hpD-o6pA"> | ||
106 | <type href="cps.ecore#//ApplicationType"/> | ||
107 | </nodes> | ||
108 | <nodes xmi:id="_WEdqIHy5EemI79hpD-o6pA" incoming="_f_l2gHy5EemI79hpD-o6pA _hW5nsHy5EemI79hpD-o6pA"> | ||
109 | <type href="cps.ecore#//ApplicationInstance"/> | ||
110 | </nodes> | ||
111 | <nodes xmi:id="_XGRscHy5EemI79hpD-o6pA" incoming="_fGY9oHy5EemI79hpD-o6pA" outgoing="_fggGwHy5EemI79hpD-o6pA"> | ||
112 | <type href="cps.ecore#//HostType"/> | ||
113 | </nodes> | ||
114 | <nodes xmi:id="_XfSpYHy5EemI79hpD-o6pA" incoming="_fggGwHy5EemI79hpD-o6pA"> | ||
115 | <type href="cps.ecore#//HostInstance"/> | ||
116 | </nodes> | ||
117 | <nodes xmi:id="_YuZg0Hy5EemI79hpD-o6pA" incoming="_epK2IHy5EemI79hpD-o6pA" outgoing="_fGY9oHy5EemI79hpD-o6pA"> | ||
118 | <type href="cps.ecore#//ResourceRequirement"/> | ||
119 | </nodes> | ||
120 | <edges xmi:id="_epK2IHy5EemI79hpD-o6pA" source="_U88ocHy5EemI79hpD-o6pA" target="_YuZg0Hy5EemI79hpD-o6pA"> | ||
121 | <type href="cps.ecore#//ApplicationType/requirements"/> | ||
122 | </edges> | ||
123 | <edges xmi:id="_fGY9oHy5EemI79hpD-o6pA" source="_YuZg0Hy5EemI79hpD-o6pA" target="_XGRscHy5EemI79hpD-o6pA"> | ||
124 | <type href="cps.ecore#//ResourceRequirement/hostType"/> | ||
125 | </edges> | ||
126 | <edges xmi:id="_fggGwHy5EemI79hpD-o6pA" source="_XGRscHy5EemI79hpD-o6pA" target="_XfSpYHy5EemI79hpD-o6pA"> | ||
127 | <type href="cps.ecore#//HostType/instances"/> | ||
128 | </edges> | ||
129 | <edges xmi:id="_f_l2gHy5EemI79hpD-o6pA" source="_U88ocHy5EemI79hpD-o6pA" target="_WEdqIHy5EemI79hpD-o6pA"> | ||
130 | <type href="cps.ecore#//ApplicationType/instances"/> | ||
131 | </edges> | ||
132 | <edges xmi:id="_hW5nsHy5EemI79hpD-o6pA" source="_QzQ2QHy5EemI79hpD-o6pA" target="_WEdqIHy5EemI79hpD-o6pA"> | ||
133 | <type href="cps.ecore#//Requirement/instances"/> | ||
134 | </edges> | ||
135 | <formula xsi:type="henshin:And" xmi:id="_JNyfMH8VEemiUoPdWqOlQg"> | ||
136 | <left xsi:type="henshin:Not" xmi:id="_GpwcMX8VEemiUoPdWqOlQg"> | ||
137 | <child xsi:type="henshin:NestedCondition" xmi:id="_GpwcMn8VEemiUoPdWqOlQg"> | ||
138 | <conclusion xmi:id="_GpwcM38VEemiUoPdWqOlQg" name="2"> | ||
139 | <nodes xmi:id="_GpwcNH8VEemiUoPdWqOlQg" outgoing="_GpxDQn8VEemiUoPdWqOlQg"> | ||
140 | <type href="cps.ecore#//Requirement"/> | ||
141 | </nodes> | ||
142 | <nodes xmi:id="_GpxDQH8VEemiUoPdWqOlQg" incoming="_GpxDQn8VEemiUoPdWqOlQg _GpxDSH8VEemiUoPdWqOlQg" outgoing="_LOADcH8VEemiUoPdWqOlQg"> | ||
143 | <type href="cps.ecore#//ApplicationInstance"/> | ||
144 | </nodes> | ||
145 | <nodes xmi:id="_GpxDQ38VEemiUoPdWqOlQg" outgoing="_GpxDR38VEemiUoPdWqOlQg _GpxDSH8VEemiUoPdWqOlQg"> | ||
146 | <type href="cps.ecore#//ApplicationType"/> | ||
147 | </nodes> | ||
148 | <nodes xmi:id="_GpxDRX8VEemiUoPdWqOlQg" incoming="_GpxDR38VEemiUoPdWqOlQg" outgoing="_GpxqUH8VEemiUoPdWqOlQg"> | ||
149 | <type href="cps.ecore#//ResourceRequirement"/> | ||
150 | </nodes> | ||
151 | <nodes xmi:id="_GpxDSX8VEemiUoPdWqOlQg" incoming="_GpxqUH8VEemiUoPdWqOlQg" outgoing="_GpxqU38VEemiUoPdWqOlQg"> | ||
152 | <type href="cps.ecore#//HostType"/> | ||
153 | </nodes> | ||
154 | <nodes xmi:id="_GpxqUX8VEemiUoPdWqOlQg" incoming="_GpxqU38VEemiUoPdWqOlQg"> | ||
155 | <type href="cps.ecore#//HostInstance"/> | ||
156 | </nodes> | ||
157 | <nodes xmi:id="_DK7k4H8VEemiUoPdWqOlQg" description="" incoming="_LOADcH8VEemiUoPdWqOlQg"> | ||
158 | <type href="cps.ecore#//HostInstance"/> | ||
159 | </nodes> | ||
160 | <edges xmi:id="_GpxDQn8VEemiUoPdWqOlQg" source="_GpwcNH8VEemiUoPdWqOlQg" target="_GpxDQH8VEemiUoPdWqOlQg"> | ||
161 | <type href="cps.ecore#//Requirement/instances"/> | ||
162 | </edges> | ||
163 | <edges xmi:id="_GpxDR38VEemiUoPdWqOlQg" source="_GpxDQ38VEemiUoPdWqOlQg" target="_GpxDRX8VEemiUoPdWqOlQg"> | ||
164 | <type href="cps.ecore#//ApplicationType/requirements"/> | ||
165 | </edges> | ||
166 | <edges xmi:id="_GpxDSH8VEemiUoPdWqOlQg" source="_GpxDQ38VEemiUoPdWqOlQg" target="_GpxDQH8VEemiUoPdWqOlQg"> | ||
167 | <type href="cps.ecore#//ApplicationType/instances"/> | ||
168 | </edges> | ||
169 | <edges xmi:id="_GpxqUH8VEemiUoPdWqOlQg" source="_GpxDRX8VEemiUoPdWqOlQg" target="_GpxDSX8VEemiUoPdWqOlQg"> | ||
170 | <type href="cps.ecore#//ResourceRequirement/hostType"/> | ||
171 | </edges> | ||
172 | <edges xmi:id="_GpxqU38VEemiUoPdWqOlQg" source="_GpxDSX8VEemiUoPdWqOlQg" target="_GpxqUX8VEemiUoPdWqOlQg"> | ||
173 | <type href="cps.ecore#//HostType/instances"/> | ||
174 | </edges> | ||
175 | <edges xmi:id="_LOADcH8VEemiUoPdWqOlQg" source="_GpxDQH8VEemiUoPdWqOlQg" target="_DK7k4H8VEemiUoPdWqOlQg"> | ||
176 | <type href="cps.ecore#//ApplicationInstance/allocatedTo"/> | ||
177 | </edges> | ||
178 | </conclusion> | ||
179 | <mappings xmi:id="_GpwcNX8VEemiUoPdWqOlQg" origin="_QzQ2QHy5EemI79hpD-o6pA" image="_GpwcNH8VEemiUoPdWqOlQg"/> | ||
180 | <mappings xmi:id="_GpxDQX8VEemiUoPdWqOlQg" origin="_WEdqIHy5EemI79hpD-o6pA" image="_GpxDQH8VEemiUoPdWqOlQg"/> | ||
181 | <mappings xmi:id="_GpxDRH8VEemiUoPdWqOlQg" origin="_U88ocHy5EemI79hpD-o6pA" image="_GpxDQ38VEemiUoPdWqOlQg"/> | ||
182 | <mappings xmi:id="_GpxDRn8VEemiUoPdWqOlQg" origin="_YuZg0Hy5EemI79hpD-o6pA" image="_GpxDRX8VEemiUoPdWqOlQg"/> | ||
183 | <mappings xmi:id="_GpxDSn8VEemiUoPdWqOlQg" origin="_XGRscHy5EemI79hpD-o6pA" image="_GpxDSX8VEemiUoPdWqOlQg"/> | ||
184 | <mappings xmi:id="_GpxqUn8VEemiUoPdWqOlQg" origin="_XfSpYHy5EemI79hpD-o6pA" image="_GpxqUX8VEemiUoPdWqOlQg"/> | ||
185 | </child> | ||
186 | </left> | ||
187 | <right xsi:type="henshin:Not" xmi:id="_JNyfMX8VEemiUoPdWqOlQg"> | ||
188 | <child xsi:type="henshin:NestedCondition" xmi:id="_JNzGQH8VEemiUoPdWqOlQg"> | ||
189 | <conclusion xmi:id="_JNzGQX8VEemiUoPdWqOlQg" name="1"> | ||
190 | <nodes xmi:id="_JNzGQn8VEemiUoPdWqOlQg" outgoing="_JNztUH8VEemiUoPdWqOlQg _mLtagHy5EemI79hpD-o6pA"> | ||
191 | <type href="cps.ecore#//Requirement"/> | ||
192 | </nodes> | ||
193 | <nodes xmi:id="_JNzGRH8VEemiUoPdWqOlQg" incoming="_JNztUH8VEemiUoPdWqOlQg _JN0UY38VEemiUoPdWqOlQg"> | ||
194 | <type href="cps.ecore#//ApplicationInstance"/> | ||
195 | </nodes> | ||
196 | <nodes xmi:id="_iu3gMHy5EemI79hpD-o6pA" incoming="_mLtagHy5EemI79hpD-o6pA" outgoing="_l0ud4Hy5EemI79hpD-o6pA"> | ||
197 | <type href="cps.ecore#//ApplicationInstance"/> | ||
198 | </nodes> | ||
199 | <nodes xmi:id="_JNztVH8VEemiUoPdWqOlQg" outgoing="_JN0UYn8VEemiUoPdWqOlQg _JN0UY38VEemiUoPdWqOlQg"> | ||
200 | <type href="cps.ecore#//ApplicationType"/> | ||
201 | </nodes> | ||
202 | <nodes xmi:id="_JN0UYH8VEemiUoPdWqOlQg" incoming="_JN0UYn8VEemiUoPdWqOlQg" outgoing="_JN07cn8VEemiUoPdWqOlQg"> | ||
203 | <type href="cps.ecore#//ResourceRequirement"/> | ||
204 | </nodes> | ||
205 | <nodes xmi:id="_JN07cH8VEemiUoPdWqOlQg" incoming="_JN07cn8VEemiUoPdWqOlQg" outgoing="_JN1igX8VEemiUoPdWqOlQg"> | ||
206 | <type href="cps.ecore#//HostType"/> | ||
207 | </nodes> | ||
208 | <nodes xmi:id="_JN07c38VEemiUoPdWqOlQg" incoming="_JN1igX8VEemiUoPdWqOlQg _l0ud4Hy5EemI79hpD-o6pA"> | ||
209 | <type href="cps.ecore#//HostInstance"/> | ||
210 | </nodes> | ||
211 | <edges xmi:id="_JNztUH8VEemiUoPdWqOlQg" source="_JNzGQn8VEemiUoPdWqOlQg" target="_JNzGRH8VEemiUoPdWqOlQg"> | ||
212 | <type href="cps.ecore#//Requirement/instances"/> | ||
213 | </edges> | ||
214 | <edges xmi:id="_JN0UYn8VEemiUoPdWqOlQg" source="_JNztVH8VEemiUoPdWqOlQg" target="_JN0UYH8VEemiUoPdWqOlQg"> | ||
215 | <type href="cps.ecore#//ApplicationType/requirements"/> | ||
216 | </edges> | ||
217 | <edges xmi:id="_JN0UY38VEemiUoPdWqOlQg" source="_JNztVH8VEemiUoPdWqOlQg" target="_JNzGRH8VEemiUoPdWqOlQg"> | ||
218 | <type href="cps.ecore#//ApplicationType/instances"/> | ||
219 | </edges> | ||
220 | <edges xmi:id="_JN07cn8VEemiUoPdWqOlQg" source="_JN0UYH8VEemiUoPdWqOlQg" target="_JN07cH8VEemiUoPdWqOlQg"> | ||
221 | <type href="cps.ecore#//ResourceRequirement/hostType"/> | ||
222 | </edges> | ||
223 | <edges xmi:id="_JN1igX8VEemiUoPdWqOlQg" source="_JN07cH8VEemiUoPdWqOlQg" target="_JN07c38VEemiUoPdWqOlQg"> | ||
224 | <type href="cps.ecore#//HostType/instances"/> | ||
225 | </edges> | ||
226 | <edges xmi:id="_mLtagHy5EemI79hpD-o6pA" source="_JNzGQn8VEemiUoPdWqOlQg" target="_iu3gMHy5EemI79hpD-o6pA"> | ||
227 | <type href="cps.ecore#//Requirement/instances"/> | ||
228 | </edges> | ||
229 | <edges xmi:id="_l0ud4Hy5EemI79hpD-o6pA" source="_iu3gMHy5EemI79hpD-o6pA" target="_JN07c38VEemiUoPdWqOlQg"> | ||
230 | <type href="cps.ecore#//ApplicationInstance/allocatedTo"/> | ||
231 | </edges> | ||
232 | </conclusion> | ||
233 | <mappings xmi:id="_JNzGQ38VEemiUoPdWqOlQg" origin="_QzQ2QHy5EemI79hpD-o6pA" image="_JNzGQn8VEemiUoPdWqOlQg"/> | ||
234 | <mappings xmi:id="_JNzGRX8VEemiUoPdWqOlQg" origin="_WEdqIHy5EemI79hpD-o6pA" image="_JNzGRH8VEemiUoPdWqOlQg"/> | ||
235 | <mappings xmi:id="_JNztVX8VEemiUoPdWqOlQg" origin="_U88ocHy5EemI79hpD-o6pA" image="_JNztVH8VEemiUoPdWqOlQg"/> | ||
236 | <mappings xmi:id="_JN0UYX8VEemiUoPdWqOlQg" origin="_YuZg0Hy5EemI79hpD-o6pA" image="_JN0UYH8VEemiUoPdWqOlQg"/> | ||
237 | <mappings xmi:id="_JN07cX8VEemiUoPdWqOlQg" origin="_XGRscHy5EemI79hpD-o6pA" image="_JN07cH8VEemiUoPdWqOlQg"/> | ||
238 | <mappings xmi:id="_JN1igH8VEemiUoPdWqOlQg" origin="_XfSpYHy5EemI79hpD-o6pA" image="_JN07c38VEemiUoPdWqOlQg"/> | ||
239 | </child> | ||
240 | </right> | ||
241 | </formula> | ||
242 | </lhs> | ||
243 | <rhs xmi:id="_W9bH4Hy4EemI79hpD-o6pA" name="Rhs"> | ||
244 | <nodes xmi:id="_QzT5kHy5EemI79hpD-o6pA" outgoing="_hW5nsXy5EemI79hpD-o6pA"> | ||
245 | <type href="cps.ecore#//Requirement"/> | ||
246 | </nodes> | ||
247 | <nodes xmi:id="_U89PgHy5EemI79hpD-o6pA" outgoing="_epK2IXy5EemI79hpD-o6pA _f_l2gXy5EemI79hpD-o6pA"> | ||
248 | <type href="cps.ecore#//ApplicationType"/> | ||
249 | </nodes> | ||
250 | <nodes xmi:id="_WEdqIXy5EemI79hpD-o6pA" incoming="_f_l2gXy5EemI79hpD-o6pA _hW5nsXy5EemI79hpD-o6pA" outgoing="_gh0Z0Hy5EemI79hpD-o6pA"> | ||
251 | <type href="cps.ecore#//ApplicationInstance"/> | ||
252 | </nodes> | ||
253 | <nodes xmi:id="_XGRscXy5EemI79hpD-o6pA" incoming="_fGY9oXy5EemI79hpD-o6pA" outgoing="_fggGwXy5EemI79hpD-o6pA"> | ||
254 | <type href="cps.ecore#//HostType"/> | ||
255 | </nodes> | ||
256 | <nodes xmi:id="_XfSpYXy5EemI79hpD-o6pA" incoming="_fggGwXy5EemI79hpD-o6pA _gh0Z0Hy5EemI79hpD-o6pA"> | ||
257 | <type href="cps.ecore#//HostInstance"/> | ||
258 | </nodes> | ||
259 | <nodes xmi:id="_YuZg0Xy5EemI79hpD-o6pA" incoming="_epK2IXy5EemI79hpD-o6pA" outgoing="_fGY9oXy5EemI79hpD-o6pA"> | ||
260 | <type href="cps.ecore#//ResourceRequirement"/> | ||
261 | </nodes> | ||
262 | <edges xmi:id="_epK2IXy5EemI79hpD-o6pA" source="_U89PgHy5EemI79hpD-o6pA" target="_YuZg0Xy5EemI79hpD-o6pA"> | ||
263 | <type href="cps.ecore#//ApplicationType/requirements"/> | ||
264 | </edges> | ||
265 | <edges xmi:id="_fGY9oXy5EemI79hpD-o6pA" source="_YuZg0Xy5EemI79hpD-o6pA" target="_XGRscXy5EemI79hpD-o6pA"> | ||
266 | <type href="cps.ecore#//ResourceRequirement/hostType"/> | ||
267 | </edges> | ||
268 | <edges xmi:id="_fggGwXy5EemI79hpD-o6pA" source="_XGRscXy5EemI79hpD-o6pA" target="_XfSpYXy5EemI79hpD-o6pA"> | ||
269 | <type href="cps.ecore#//HostType/instances"/> | ||
270 | </edges> | ||
271 | <edges xmi:id="_f_l2gXy5EemI79hpD-o6pA" source="_U89PgHy5EemI79hpD-o6pA" target="_WEdqIXy5EemI79hpD-o6pA"> | ||
272 | <type href="cps.ecore#//ApplicationType/instances"/> | ||
273 | </edges> | ||
274 | <edges xmi:id="_gh0Z0Hy5EemI79hpD-o6pA" source="_WEdqIXy5EemI79hpD-o6pA" target="_XfSpYXy5EemI79hpD-o6pA"> | ||
275 | <type href="cps.ecore#//ApplicationInstance/allocatedTo"/> | ||
276 | </edges> | ||
277 | <edges xmi:id="_hW5nsXy5EemI79hpD-o6pA" source="_QzT5kHy5EemI79hpD-o6pA" target="_WEdqIXy5EemI79hpD-o6pA"> | ||
278 | <type href="cps.ecore#//Requirement/instances"/> | ||
279 | </edges> | ||
280 | </rhs> | ||
281 | <mappings xmi:id="_QzUgoHy5EemI79hpD-o6pA" origin="_QzQ2QHy5EemI79hpD-o6pA" image="_QzT5kHy5EemI79hpD-o6pA"/> | ||
282 | <mappings xmi:id="_U89PgXy5EemI79hpD-o6pA" origin="_U88ocHy5EemI79hpD-o6pA" image="_U89PgHy5EemI79hpD-o6pA"/> | ||
283 | <mappings xmi:id="_WEdqIny5EemI79hpD-o6pA" origin="_WEdqIHy5EemI79hpD-o6pA" image="_WEdqIXy5EemI79hpD-o6pA"/> | ||
284 | <mappings xmi:id="_XGRscny5EemI79hpD-o6pA" origin="_XGRscHy5EemI79hpD-o6pA" image="_XGRscXy5EemI79hpD-o6pA"/> | ||
285 | <mappings xmi:id="_XfSpYny5EemI79hpD-o6pA" origin="_XfSpYHy5EemI79hpD-o6pA" image="_XfSpYXy5EemI79hpD-o6pA"/> | ||
286 | <mappings xmi:id="_YuZg0ny5EemI79hpD-o6pA" origin="_YuZg0Hy5EemI79hpD-o6pA" image="_YuZg0Xy5EemI79hpD-o6pA"/> | ||
287 | </units> | ||
288 | <units xsi:type="henshin:Rule" xmi:id="_1VgrMHy5EemI79hpD-o6pA" name="unallocate"> | ||
289 | <lhs xmi:id="_1Vk8oHy5EemI79hpD-o6pA" name="Lhs"> | ||
290 | <nodes xmi:id="_OdtesHy6EemI79hpD-o6pA" outgoing="_UpBxcHy6EemI79hpD-o6pA"> | ||
291 | <type href="cps.ecore#//ApplicationInstance"/> | ||
292 | </nodes> | ||
293 | <nodes xmi:id="_PGadcHy6EemI79hpD-o6pA" incoming="_UpBxcHy6EemI79hpD-o6pA"> | ||
294 | <type href="cps.ecore#//HostInstance"/> | ||
295 | </nodes> | ||
296 | <edges xmi:id="_UpBxcHy6EemI79hpD-o6pA" source="_OdtesHy6EemI79hpD-o6pA" target="_PGadcHy6EemI79hpD-o6pA"> | ||
297 | <type href="cps.ecore#//ApplicationInstance/allocatedTo"/> | ||
298 | </edges> | ||
299 | </lhs> | ||
300 | <rhs xmi:id="_1VmKwHy5EemI79hpD-o6pA" name="Rhs"> | ||
301 | <nodes xmi:id="_OdwiAHy6EemI79hpD-o6pA"> | ||
302 | <type href="cps.ecore#//ApplicationInstance"/> | ||
303 | </nodes> | ||
304 | <nodes xmi:id="_PGadcXy6EemI79hpD-o6pA"> | ||
305 | <type href="cps.ecore#//HostInstance"/> | ||
306 | </nodes> | ||
307 | </rhs> | ||
308 | <mappings xmi:id="_OdwiAXy6EemI79hpD-o6pA" origin="_OdtesHy6EemI79hpD-o6pA" image="_OdwiAHy6EemI79hpD-o6pA"/> | ||
309 | <mappings xmi:id="_PGadcny6EemI79hpD-o6pA" origin="_PGadcHy6EemI79hpD-o6pA" image="_PGadcXy6EemI79hpD-o6pA"/> | ||
310 | </units> | ||
311 | <units xsi:type="henshin:Rule" xmi:id="_4lbl0H8UEemiUoPdWqOlQg" name="reallocate"> | ||
312 | <lhs xmi:id="_4lkvwH8UEemiUoPdWqOlQg" name="Lhs"> | ||
313 | <nodes xmi:id="_VfKxQH8VEemiUoPdWqOlQg" outgoing="_uW8jIH8VEemiUoPdWqOlQg"> | ||
314 | <type href="cps.ecore#//Requirement"/> | ||
315 | </nodes> | ||
316 | <nodes xmi:id="_WJkZIH8VEemiUoPdWqOlQg" outgoing="_4SqlYH8VEemiUoPdWqOlQg _44kHwH8VEemiUoPdWqOlQg"> | ||
317 | <type href="cps.ecore#//ApplicationType"/> | ||
318 | </nodes> | ||
319 | <nodes xmi:id="_Yz9i0H8VEemiUoPdWqOlQg" incoming="_5r5CIH8VEemiUoPdWqOlQg"> | ||
320 | <type href="cps.ecore#//HostInstance"/> | ||
321 | </nodes> | ||
322 | <nodes xmi:id="_cTchcH8VEemiUoPdWqOlQg" incoming="_uW8jIH8VEemiUoPdWqOlQg _4SqlYH8VEemiUoPdWqOlQg" outgoing="_3NH5oH8VEemiUoPdWqOlQg"> | ||
323 | <type href="cps.ecore#//ApplicationInstance"/> | ||
324 | </nodes> | ||
325 | <nodes xmi:id="_fYauUH8VEemiUoPdWqOlQg" incoming="_44kHwH8VEemiUoPdWqOlQg" outgoing="_5Rch0H8VEemiUoPdWqOlQg"> | ||
326 | <type href="cps.ecore#//ResourceRequirement"/> | ||
327 | </nodes> | ||
328 | <nodes xmi:id="_kl-_YH8VEemiUoPdWqOlQg" incoming="_5Rch0H8VEemiUoPdWqOlQg" outgoing="_5r5CIH8VEemiUoPdWqOlQg"> | ||
329 | <type href="cps.ecore#//HostType"/> | ||
330 | </nodes> | ||
331 | <nodes xmi:id="_wZrP4H8VEemiUoPdWqOlQg" incoming="_3NH5oH8VEemiUoPdWqOlQg"> | ||
332 | <type href="cps.ecore#//HostInstance"/> | ||
333 | </nodes> | ||
334 | <edges xmi:id="_uW8jIH8VEemiUoPdWqOlQg" source="_VfKxQH8VEemiUoPdWqOlQg" target="_cTchcH8VEemiUoPdWqOlQg"> | ||
335 | <type href="cps.ecore#//Requirement/instances"/> | ||
336 | </edges> | ||
337 | <edges xmi:id="_4SqlYH8VEemiUoPdWqOlQg" source="_WJkZIH8VEemiUoPdWqOlQg" target="_cTchcH8VEemiUoPdWqOlQg"> | ||
338 | <type href="cps.ecore#//ApplicationType/instances"/> | ||
339 | </edges> | ||
340 | <edges xmi:id="_44kHwH8VEemiUoPdWqOlQg" source="_WJkZIH8VEemiUoPdWqOlQg" target="_fYauUH8VEemiUoPdWqOlQg"> | ||
341 | <type href="cps.ecore#//ApplicationType/requirements"/> | ||
342 | </edges> | ||
343 | <edges xmi:id="_5Rch0H8VEemiUoPdWqOlQg" source="_fYauUH8VEemiUoPdWqOlQg" target="_kl-_YH8VEemiUoPdWqOlQg"> | ||
344 | <type href="cps.ecore#//ResourceRequirement/hostType"/> | ||
345 | </edges> | ||
346 | <edges xmi:id="_5r5CIH8VEemiUoPdWqOlQg" source="_kl-_YH8VEemiUoPdWqOlQg" target="_Yz9i0H8VEemiUoPdWqOlQg"> | ||
347 | <type href="cps.ecore#//HostType/instances"/> | ||
348 | </edges> | ||
349 | <edges xmi:id="_3NH5oH8VEemiUoPdWqOlQg" source="_cTchcH8VEemiUoPdWqOlQg" target="_wZrP4H8VEemiUoPdWqOlQg"> | ||
350 | <type href="cps.ecore#//ApplicationInstance/allocatedTo"/> | ||
351 | </edges> | ||
352 | <formula xsi:type="henshin:Not" xmi:id="_9Q-5gH8VEemiUoPdWqOlQg"> | ||
353 | <child xsi:type="henshin:NestedCondition" xmi:id="_9Q-5gX8VEemiUoPdWqOlQg"> | ||
354 | <conclusion xmi:id="_9Q-5gn8VEemiUoPdWqOlQg"> | ||
355 | <nodes xmi:id="_9Q-5g38VEemiUoPdWqOlQg" outgoing="_9Q-5h38VEemiUoPdWqOlQg _ulPd0H8VEemiUoPdWqOlQg"> | ||
356 | <type href="cps.ecore#//Requirement"/> | ||
357 | </nodes> | ||
358 | <nodes xmi:id="_9Q-5hX8VEemiUoPdWqOlQg" incoming="_9Q-5h38VEemiUoPdWqOlQg _9Q-5jX8VEemiUoPdWqOlQg" outgoing="_9Q-5mH8VEemiUoPdWqOlQg"> | ||
359 | <type href="cps.ecore#//ApplicationInstance"/> | ||
360 | </nodes> | ||
361 | <nodes xmi:id="_Xr-AAH8VEemiUoPdWqOlQg" incoming="_ulPd0H8VEemiUoPdWqOlQg" outgoing="_-vrFEH8VEemiUoPdWqOlQg"> | ||
362 | <type href="cps.ecore#//ApplicationInstance"/> | ||
363 | </nodes> | ||
364 | <nodes xmi:id="_9Q-5i38VEemiUoPdWqOlQg" outgoing="_9Q-5jX8VEemiUoPdWqOlQg _9Q-5kH8VEemiUoPdWqOlQg"> | ||
365 | <type href="cps.ecore#//ApplicationType"/> | ||
366 | </nodes> | ||
367 | <nodes xmi:id="_9Q-5jn8VEemiUoPdWqOlQg" incoming="_9Q-5kH8VEemiUoPdWqOlQg" outgoing="_9Q-5mX8VEemiUoPdWqOlQg"> | ||
368 | <type href="cps.ecore#//ResourceRequirement"/> | ||
369 | </nodes> | ||
370 | <nodes xmi:id="_9Q-5kX8VEemiUoPdWqOlQg" incoming="_9Q-5lX8VEemiUoPdWqOlQg _-vrFEH8VEemiUoPdWqOlQg"> | ||
371 | <type href="cps.ecore#//HostInstance"/> | ||
372 | </nodes> | ||
373 | <nodes xmi:id="_9Q-5k38VEemiUoPdWqOlQg" incoming="_9Q-5mX8VEemiUoPdWqOlQg" outgoing="_9Q-5lX8VEemiUoPdWqOlQg"> | ||
374 | <type href="cps.ecore#//HostType"/> | ||
375 | </nodes> | ||
376 | <nodes xmi:id="_9Q-5ln8VEemiUoPdWqOlQg" incoming="_9Q-5mH8VEemiUoPdWqOlQg"> | ||
377 | <type href="cps.ecore#//HostInstance"/> | ||
378 | </nodes> | ||
379 | <edges xmi:id="_9Q-5h38VEemiUoPdWqOlQg" source="_9Q-5g38VEemiUoPdWqOlQg" target="_9Q-5hX8VEemiUoPdWqOlQg"> | ||
380 | <type href="cps.ecore#//Requirement/instances"/> | ||
381 | </edges> | ||
382 | <edges xmi:id="_9Q-5jX8VEemiUoPdWqOlQg" source="_9Q-5i38VEemiUoPdWqOlQg" target="_9Q-5hX8VEemiUoPdWqOlQg"> | ||
383 | <type href="cps.ecore#//ApplicationType/instances"/> | ||
384 | </edges> | ||
385 | <edges xmi:id="_9Q-5kH8VEemiUoPdWqOlQg" source="_9Q-5i38VEemiUoPdWqOlQg" target="_9Q-5jn8VEemiUoPdWqOlQg"> | ||
386 | <type href="cps.ecore#//ApplicationType/requirements"/> | ||
387 | </edges> | ||
388 | <edges xmi:id="_9Q-5lX8VEemiUoPdWqOlQg" source="_9Q-5k38VEemiUoPdWqOlQg" target="_9Q-5kX8VEemiUoPdWqOlQg"> | ||
389 | <type href="cps.ecore#//HostType/instances"/> | ||
390 | </edges> | ||
391 | <edges xmi:id="_9Q-5mH8VEemiUoPdWqOlQg" source="_9Q-5hX8VEemiUoPdWqOlQg" target="_9Q-5ln8VEemiUoPdWqOlQg"> | ||
392 | <type href="cps.ecore#//ApplicationInstance/allocatedTo"/> | ||
393 | </edges> | ||
394 | <edges xmi:id="_9Q-5mX8VEemiUoPdWqOlQg" source="_9Q-5jn8VEemiUoPdWqOlQg" target="_9Q-5k38VEemiUoPdWqOlQg"> | ||
395 | <type href="cps.ecore#//ResourceRequirement/hostType"/> | ||
396 | </edges> | ||
397 | <edges xmi:id="_ulPd0H8VEemiUoPdWqOlQg" source="_9Q-5g38VEemiUoPdWqOlQg" target="_Xr-AAH8VEemiUoPdWqOlQg"> | ||
398 | <type href="cps.ecore#//Requirement/instances"/> | ||
399 | </edges> | ||
400 | <edges xmi:id="_-vrFEH8VEemiUoPdWqOlQg" source="_Xr-AAH8VEemiUoPdWqOlQg" target="_9Q-5kX8VEemiUoPdWqOlQg"> | ||
401 | <type href="cps.ecore#//ApplicationInstance/allocatedTo"/> | ||
402 | </edges> | ||
403 | </conclusion> | ||
404 | <mappings xmi:id="_9Q-5hH8VEemiUoPdWqOlQg" origin="_VfKxQH8VEemiUoPdWqOlQg" image="_9Q-5g38VEemiUoPdWqOlQg"/> | ||
405 | <mappings xmi:id="_9Q-5hn8VEemiUoPdWqOlQg" origin="_cTchcH8VEemiUoPdWqOlQg" image="_9Q-5hX8VEemiUoPdWqOlQg"/> | ||
406 | <mappings xmi:id="_9Q-5jH8VEemiUoPdWqOlQg" origin="_WJkZIH8VEemiUoPdWqOlQg" image="_9Q-5i38VEemiUoPdWqOlQg"/> | ||
407 | <mappings xmi:id="_9Q-5j38VEemiUoPdWqOlQg" origin="_fYauUH8VEemiUoPdWqOlQg" image="_9Q-5jn8VEemiUoPdWqOlQg"/> | ||
408 | <mappings xmi:id="_9Q-5kn8VEemiUoPdWqOlQg" origin="_Yz9i0H8VEemiUoPdWqOlQg" image="_9Q-5kX8VEemiUoPdWqOlQg"/> | ||
409 | <mappings xmi:id="_9Q-5lH8VEemiUoPdWqOlQg" origin="_kl-_YH8VEemiUoPdWqOlQg" image="_9Q-5k38VEemiUoPdWqOlQg"/> | ||
410 | <mappings xmi:id="_9Q-5l38VEemiUoPdWqOlQg" origin="_wZrP4H8VEemiUoPdWqOlQg" image="_9Q-5ln8VEemiUoPdWqOlQg"/> | ||
411 | </child> | ||
412 | </formula> | ||
413 | </lhs> | ||
414 | <rhs xmi:id="_4lnMAH8UEemiUoPdWqOlQg" name="Rhs"> | ||
415 | <nodes xmi:id="_VfNNgH8VEemiUoPdWqOlQg" outgoing="_uW9KMH8VEemiUoPdWqOlQg"> | ||
416 | <type href="cps.ecore#//Requirement"/> | ||
417 | </nodes> | ||
418 | <nodes xmi:id="_WJkZIX8VEemiUoPdWqOlQg" outgoing="_4SqlYX8VEemiUoPdWqOlQg _44kHwX8VEemiUoPdWqOlQg"> | ||
419 | <type href="cps.ecore#//ApplicationType"/> | ||
420 | </nodes> | ||
421 | <nodes xmi:id="_Y0DCYH8VEemiUoPdWqOlQg" incoming="_5r5CIX8VEemiUoPdWqOlQg __Te8wH8VEemiUoPdWqOlQg"> | ||
422 | <type href="cps.ecore#//HostInstance"/> | ||
423 | </nodes> | ||
424 | <nodes xmi:id="_cTchcX8VEemiUoPdWqOlQg" incoming="_uW9KMH8VEemiUoPdWqOlQg _4SqlYX8VEemiUoPdWqOlQg" outgoing="__Te8wH8VEemiUoPdWqOlQg"> | ||
425 | <type href="cps.ecore#//ApplicationInstance"/> | ||
426 | </nodes> | ||
427 | <nodes xmi:id="_fYbVYH8VEemiUoPdWqOlQg" incoming="_44kHwX8VEemiUoPdWqOlQg" outgoing="_5Rch0X8VEemiUoPdWqOlQg"> | ||
428 | <type href="cps.ecore#//ResourceRequirement"/> | ||
429 | </nodes> | ||
430 | <nodes xmi:id="_kl-_YX8VEemiUoPdWqOlQg" incoming="_5Rch0X8VEemiUoPdWqOlQg" outgoing="_5r5CIX8VEemiUoPdWqOlQg"> | ||
431 | <type href="cps.ecore#//HostType"/> | ||
432 | </nodes> | ||
433 | <nodes xmi:id="_6wB_sH8VEemiUoPdWqOlQg"> | ||
434 | <type href="cps.ecore#//HostInstance"/> | ||
435 | </nodes> | ||
436 | <edges xmi:id="_uW9KMH8VEemiUoPdWqOlQg" source="_VfNNgH8VEemiUoPdWqOlQg" target="_cTchcX8VEemiUoPdWqOlQg"> | ||
437 | <type href="cps.ecore#//Requirement/instances"/> | ||
438 | </edges> | ||
439 | <edges xmi:id="_4SqlYX8VEemiUoPdWqOlQg" source="_WJkZIX8VEemiUoPdWqOlQg" target="_cTchcX8VEemiUoPdWqOlQg"> | ||
440 | <type href="cps.ecore#//ApplicationType/instances"/> | ||
441 | </edges> | ||
442 | <edges xmi:id="_44kHwX8VEemiUoPdWqOlQg" source="_WJkZIX8VEemiUoPdWqOlQg" target="_fYbVYH8VEemiUoPdWqOlQg"> | ||
443 | <type href="cps.ecore#//ApplicationType/requirements"/> | ||
444 | </edges> | ||
445 | <edges xmi:id="_5Rch0X8VEemiUoPdWqOlQg" source="_fYbVYH8VEemiUoPdWqOlQg" target="_kl-_YX8VEemiUoPdWqOlQg"> | ||
446 | <type href="cps.ecore#//ResourceRequirement/hostType"/> | ||
447 | </edges> | ||
448 | <edges xmi:id="_5r5CIX8VEemiUoPdWqOlQg" source="_kl-_YX8VEemiUoPdWqOlQg" target="_Y0DCYH8VEemiUoPdWqOlQg"> | ||
449 | <type href="cps.ecore#//HostType/instances"/> | ||
450 | </edges> | ||
451 | <edges xmi:id="__Te8wH8VEemiUoPdWqOlQg" source="_cTchcX8VEemiUoPdWqOlQg" target="_Y0DCYH8VEemiUoPdWqOlQg"> | ||
452 | <type href="cps.ecore#//ApplicationInstance/allocatedTo"/> | ||
453 | </edges> | ||
454 | </rhs> | ||
455 | <mappings xmi:id="_VfNNgX8VEemiUoPdWqOlQg" origin="_VfKxQH8VEemiUoPdWqOlQg" image="_VfNNgH8VEemiUoPdWqOlQg"/> | ||
456 | <mappings xmi:id="_WJkZIn8VEemiUoPdWqOlQg" origin="_WJkZIH8VEemiUoPdWqOlQg" image="_WJkZIX8VEemiUoPdWqOlQg"/> | ||
457 | <mappings xmi:id="_Y0DCYX8VEemiUoPdWqOlQg" origin="_Yz9i0H8VEemiUoPdWqOlQg" image="_Y0DCYH8VEemiUoPdWqOlQg"/> | ||
458 | <mappings xmi:id="_cTchcn8VEemiUoPdWqOlQg" origin="_cTchcH8VEemiUoPdWqOlQg" image="_cTchcX8VEemiUoPdWqOlQg"/> | ||
459 | <mappings xmi:id="_fYbVYX8VEemiUoPdWqOlQg" origin="_fYauUH8VEemiUoPdWqOlQg" image="_fYbVYH8VEemiUoPdWqOlQg"/> | ||
460 | <mappings xmi:id="_kl_mcH8VEemiUoPdWqOlQg" origin="_kl-_YH8VEemiUoPdWqOlQg" image="_kl-_YX8VEemiUoPdWqOlQg"/> | ||
461 | <mappings xmi:id="_6wB_sX8VEemiUoPdWqOlQg" origin="_wZrP4H8VEemiUoPdWqOlQg" image="_6wB_sH8VEemiUoPdWqOlQg"/> | ||
462 | </units> | ||
463 | <units xsi:type="henshin:Rule" xmi:id="_7SLYkH8XEemiUoPdWqOlQg" name="deleteAppInstance"> | ||
464 | <lhs xmi:id="_7SQREH8XEemiUoPdWqOlQg" name="Lhs"> | ||
465 | <nodes xmi:id="_AUFMMH8YEemiUoPdWqOlQg" outgoing="_IR7MgH8YEemiUoPdWqOlQg _InEWEH8YEemiUoPdWqOlQg"> | ||
466 | <type href="cps.ecore#//Requirement"/> | ||
467 | </nodes> | ||
468 | <nodes xmi:id="_A8eo8H8YEemiUoPdWqOlQg" incoming="_InEWEH8YEemiUoPdWqOlQg" outgoing="_H6p8AH8YEemiUoPdWqOlQg"> | ||
469 | <type href="cps.ecore#//ApplicationType"/> | ||
470 | </nodes> | ||
471 | <nodes xmi:id="_Dova4H8YEemiUoPdWqOlQg" incoming="_H6p8AH8YEemiUoPdWqOlQg _IR7MgH8YEemiUoPdWqOlQg"> | ||
472 | <type href="cps.ecore#//ApplicationInstance"/> | ||
473 | </nodes> | ||
474 | <edges xmi:id="_H6p8AH8YEemiUoPdWqOlQg" source="_A8eo8H8YEemiUoPdWqOlQg" target="_Dova4H8YEemiUoPdWqOlQg"> | ||
475 | <type href="cps.ecore#//ApplicationType/instances"/> | ||
476 | </edges> | ||
477 | <edges xmi:id="_IR7MgH8YEemiUoPdWqOlQg" source="_AUFMMH8YEemiUoPdWqOlQg" target="_Dova4H8YEemiUoPdWqOlQg"> | ||
478 | <type href="cps.ecore#//Requirement/instances"/> | ||
479 | </edges> | ||
480 | <edges xmi:id="_InEWEH8YEemiUoPdWqOlQg" source="_AUFMMH8YEemiUoPdWqOlQg" target="_A8eo8H8YEemiUoPdWqOlQg"> | ||
481 | <type href="cps.ecore#//Requirement/type"/> | ||
482 | </edges> | ||
483 | </lhs> | ||
484 | <rhs xmi:id="_7SQ4IH8XEemiUoPdWqOlQg" name="Rhs"> | ||
485 | <nodes xmi:id="_AUFMMX8YEemiUoPdWqOlQg" outgoing="_InEWEX8YEemiUoPdWqOlQg"> | ||
486 | <type href="cps.ecore#//Requirement"/> | ||
487 | </nodes> | ||
488 | <nodes xmi:id="_A8eo8X8YEemiUoPdWqOlQg" incoming="_InEWEX8YEemiUoPdWqOlQg"> | ||
489 | <type href="cps.ecore#//ApplicationType"/> | ||
490 | </nodes> | ||
491 | <edges xmi:id="_InEWEX8YEemiUoPdWqOlQg" source="_AUFMMX8YEemiUoPdWqOlQg" target="_A8eo8X8YEemiUoPdWqOlQg"> | ||
492 | <type href="cps.ecore#//Requirement/type"/> | ||
493 | </edges> | ||
494 | </rhs> | ||
495 | <mappings xmi:id="_AUFMMn8YEemiUoPdWqOlQg" origin="_AUFMMH8YEemiUoPdWqOlQg" image="_AUFMMX8YEemiUoPdWqOlQg"/> | ||
496 | <mappings xmi:id="_A8eo8n8YEemiUoPdWqOlQg" origin="_A8eo8H8YEemiUoPdWqOlQg" image="_A8eo8X8YEemiUoPdWqOlQg"/> | ||
497 | </units> | ||
498 | </henshin:Module> | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.henshin_diagram b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.henshin_diagram new file mode 100644 index 00000000..985ff350 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.henshin_diagram | |||
@@ -0,0 +1,699 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:henshin="http://www.eclipse.org/emf/2011/Henshin" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmi:id="_rVAwQHyxEemI79hpD-o6pA" type="Henshin" name="cps.henshin_diagram" measurementUnit="Pixel"> | ||
3 | <children xmi:type="notation:Shape" xmi:id="_0PszUHyxEemI79hpD-o6pA" type="2001" fontName="Noto Sans" italic="true" lineColor="0"> | ||
4 | <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_5CPVQHyxEemI79hpD-o6pA" source="defaultAction"> | ||
5 | <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_5CP8UHyxEemI79hpD-o6pA" key="value" value="preserve"/> | ||
6 | </eAnnotations> | ||
7 | <children xmi:type="notation:DecorationNode" xmi:id="_0PszUnyxEemI79hpD-o6pA" type="5001"/> | ||
8 | <children xmi:type="notation:DecorationNode" xmi:id="_0PtaYHyxEemI79hpD-o6pA" type="7001"> | ||
9 | <children xmi:type="notation:Shape" xmi:id="_8Ow7oHyxEemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
10 | <children xmi:type="notation:DecorationNode" xmi:id="_8OxisXyxEemI79hpD-o6pA" type="5002"/> | ||
11 | <children xmi:type="notation:DecorationNode" xmi:id="_8OxisnyxEemI79hpD-o6pA" type="5003"/> | ||
12 | <children xmi:type="notation:DecorationNode" xmi:id="_8OyJwHyxEemI79hpD-o6pA" type="7002"> | ||
13 | <styles xmi:type="notation:SortingStyle" xmi:id="_8OyJwXyxEemI79hpD-o6pA"/> | ||
14 | <styles xmi:type="notation:FilteringStyle" xmi:id="_8OyJwnyxEemI79hpD-o6pA"/> | ||
15 | </children> | ||
16 | <element xmi:type="henshin:Node" href="cps.henshin#_8OoYwHyxEemI79hpD-o6pA"/> | ||
17 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8OxisHyxEemI79hpD-o6pA" x="28" y="27"/> | ||
18 | </children> | ||
19 | <children xmi:type="notation:Shape" xmi:id="_KIaMAHyyEemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
20 | <children xmi:type="notation:DecorationNode" xmi:id="_KIaMAnyyEemI79hpD-o6pA" type="5002"/> | ||
21 | <children xmi:type="notation:DecorationNode" xmi:id="_KIaMA3yyEemI79hpD-o6pA" type="5003"/> | ||
22 | <children xmi:type="notation:DecorationNode" xmi:id="_KIaMBHyyEemI79hpD-o6pA" type="7002"> | ||
23 | <styles xmi:type="notation:SortingStyle" xmi:id="_KIaMBXyyEemI79hpD-o6pA"/> | ||
24 | <styles xmi:type="notation:FilteringStyle" xmi:id="_KIaMBnyyEemI79hpD-o6pA"/> | ||
25 | </children> | ||
26 | <element xmi:type="henshin:Node" href="cps.henshin#_KIXvwHyyEemI79hpD-o6pA"/> | ||
27 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_KIaMAXyyEemI79hpD-o6pA" x="248" y="169"/> | ||
28 | </children> | ||
29 | <children xmi:type="notation:Shape" xmi:id="__cDhkHyyEemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
30 | <children xmi:type="notation:DecorationNode" xmi:id="__cEIoXyyEemI79hpD-o6pA" type="5002"/> | ||
31 | <children xmi:type="notation:DecorationNode" xmi:id="__cEIonyyEemI79hpD-o6pA" type="5003"/> | ||
32 | <children xmi:type="notation:DecorationNode" xmi:id="__cEIo3yyEemI79hpD-o6pA" type="7002"> | ||
33 | <styles xmi:type="notation:SortingStyle" xmi:id="__cEIpHyyEemI79hpD-o6pA"/> | ||
34 | <styles xmi:type="notation:FilteringStyle" xmi:id="__cEIpXyyEemI79hpD-o6pA"/> | ||
35 | </children> | ||
36 | <element xmi:type="henshin:Node" href="cps.henshin#__cBFUHyyEemI79hpD-o6pA"/> | ||
37 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="__cEIoHyyEemI79hpD-o6pA" x="259" y="17"/> | ||
38 | </children> | ||
39 | </children> | ||
40 | <element xmi:type="henshin:Rule" href="cps.henshin#_ttviMHyxEemI79hpD-o6pA"/> | ||
41 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_0PszUXyxEemI79hpD-o6pA" x="22" y="22" width="407" height="284"/> | ||
42 | </children> | ||
43 | <children xmi:type="notation:Shape" xmi:id="_M4A68Hy0EemI79hpD-o6pA" type="2001" fontName="Noto Sans" italic="true" lineColor="0"> | ||
44 | <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_Zp21wHy0EemI79hpD-o6pA" source="defaultAction"> | ||
45 | <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Zp21wXy0EemI79hpD-o6pA" key="value" value="preserve"/> | ||
46 | </eAnnotations> | ||
47 | <children xmi:type="notation:DecorationNode" xmi:id="_M4BiAHy0EemI79hpD-o6pA" type="5001"/> | ||
48 | <children xmi:type="notation:DecorationNode" xmi:id="_M4CJEHy0EemI79hpD-o6pA" type="7001"> | ||
49 | <children xmi:type="notation:Shape" xmi:id="_Zp4q8Hy0EemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
50 | <children xmi:type="notation:DecorationNode" xmi:id="_Zp4q8ny0EemI79hpD-o6pA" type="5002"/> | ||
51 | <children xmi:type="notation:DecorationNode" xmi:id="_Zp4q83y0EemI79hpD-o6pA" type="5003"/> | ||
52 | <children xmi:type="notation:DecorationNode" xmi:id="_Zp4q9Hy0EemI79hpD-o6pA" type="7002"> | ||
53 | <styles xmi:type="notation:SortingStyle" xmi:id="_Zp4q9Xy0EemI79hpD-o6pA"/> | ||
54 | <styles xmi:type="notation:FilteringStyle" xmi:id="_Zp4q9ny0EemI79hpD-o6pA"/> | ||
55 | </children> | ||
56 | <element xmi:type="henshin:Node" href="cps.henshin#_ZpwIEHy0EemI79hpD-o6pA"/> | ||
57 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Zp4q8Xy0EemI79hpD-o6pA" x="55" y="8"/> | ||
58 | </children> | ||
59 | <children xmi:type="notation:Shape" xmi:id="_bFEPgHy0EemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
60 | <children xmi:type="notation:DecorationNode" xmi:id="_bFEPgny0EemI79hpD-o6pA" type="5002"/> | ||
61 | <children xmi:type="notation:DecorationNode" xmi:id="_bFEPg3y0EemI79hpD-o6pA" type="5003"/> | ||
62 | <children xmi:type="notation:DecorationNode" xmi:id="_bFEPhHy0EemI79hpD-o6pA" type="7002"> | ||
63 | <styles xmi:type="notation:SortingStyle" xmi:id="_bFEPhXy0EemI79hpD-o6pA"/> | ||
64 | <styles xmi:type="notation:FilteringStyle" xmi:id="_bFEPhny0EemI79hpD-o6pA"/> | ||
65 | </children> | ||
66 | <element xmi:type="henshin:Node" href="cps.henshin#_bFDBYHy0EemI79hpD-o6pA"/> | ||
67 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_bFEPgXy0EemI79hpD-o6pA" x="47" y="102"/> | ||
68 | </children> | ||
69 | </children> | ||
70 | <element xmi:type="henshin:Rule" href="cps.henshin#_M36NQHy0EemI79hpD-o6pA"/> | ||
71 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_M4A68Xy0EemI79hpD-o6pA" x="22" y="327" width="191" height="199"/> | ||
72 | </children> | ||
73 | <children xmi:type="notation:Shape" xmi:id="_2ySkgHy0EemI79hpD-o6pA" type="2001" fontName="Noto Sans" italic="true" lineColor="0"> | ||
74 | <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_5jgH4Hy0EemI79hpD-o6pA" source="defaultAction"> | ||
75 | <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_5jgH4Xy0EemI79hpD-o6pA" key="value" value="preserve"/> | ||
76 | </eAnnotations> | ||
77 | <children xmi:type="notation:DecorationNode" xmi:id="_2ySkgny0EemI79hpD-o6pA" type="5001"/> | ||
78 | <children xmi:type="notation:DecorationNode" xmi:id="_2ySkg3y0EemI79hpD-o6pA" type="7001"> | ||
79 | <children xmi:type="notation:Shape" xmi:id="_5jh9EHy0EemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
80 | <children xmi:type="notation:DecorationNode" xmi:id="_5jikIHy0EemI79hpD-o6pA" type="5002"/> | ||
81 | <children xmi:type="notation:DecorationNode" xmi:id="_5jikIXy0EemI79hpD-o6pA" type="5003"/> | ||
82 | <children xmi:type="notation:DecorationNode" xmi:id="_5jikIny0EemI79hpD-o6pA" type="7002"> | ||
83 | <styles xmi:type="notation:SortingStyle" xmi:id="_5jikI3y0EemI79hpD-o6pA"/> | ||
84 | <styles xmi:type="notation:FilteringStyle" xmi:id="_5jikJHy0EemI79hpD-o6pA"/> | ||
85 | </children> | ||
86 | <element xmi:type="henshin:Node" href="cps.henshin#_5jfg0Hy0EemI79hpD-o6pA"/> | ||
87 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_5jh9EXy0EemI79hpD-o6pA" x="46" y="17"/> | ||
88 | </children> | ||
89 | <children xmi:type="notation:Shape" xmi:id="_6FsO8Hy0EemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
90 | <children xmi:type="notation:DecorationNode" xmi:id="_6Fs2AHy0EemI79hpD-o6pA" type="5002"/> | ||
91 | <children xmi:type="notation:DecorationNode" xmi:id="_6Fs2AXy0EemI79hpD-o6pA" type="5003"/> | ||
92 | <children xmi:type="notation:DecorationNode" xmi:id="_6Fs2Any0EemI79hpD-o6pA" type="7002"> | ||
93 | <styles xmi:type="notation:SortingStyle" xmi:id="_6Fs2A3y0EemI79hpD-o6pA"/> | ||
94 | <styles xmi:type="notation:FilteringStyle" xmi:id="_6Fs2BHy0EemI79hpD-o6pA"/> | ||
95 | </children> | ||
96 | <element xmi:type="henshin:Node" href="cps.henshin#_6FqZwHy0EemI79hpD-o6pA"/> | ||
97 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_6FsO8Xy0EemI79hpD-o6pA" x="47" y="102"/> | ||
98 | </children> | ||
99 | <children xmi:type="notation:Shape" xmi:id="_8lWIQHy0EemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
100 | <children xmi:type="notation:DecorationNode" xmi:id="_8lWIQny0EemI79hpD-o6pA" type="5002"/> | ||
101 | <children xmi:type="notation:DecorationNode" xmi:id="_8lWIQ3y0EemI79hpD-o6pA" type="5003"/> | ||
102 | <children xmi:type="notation:DecorationNode" xmi:id="_8lWvUHy0EemI79hpD-o6pA" type="7002"> | ||
103 | <styles xmi:type="notation:SortingStyle" xmi:id="_8lWvUXy0EemI79hpD-o6pA"/> | ||
104 | <styles xmi:type="notation:FilteringStyle" xmi:id="_8lWvUny0EemI79hpD-o6pA"/> | ||
105 | </children> | ||
106 | <element xmi:type="henshin:Node" href="cps.henshin#_8lTsAHy0EemI79hpD-o6pA"/> | ||
107 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8lWIQXy0EemI79hpD-o6pA" x="202" y="102"/> | ||
108 | </children> | ||
109 | </children> | ||
110 | <element xmi:type="henshin:Rule" href="cps.henshin#_2yQIQHy0EemI79hpD-o6pA"/> | ||
111 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_2ySkgXy0EemI79hpD-o6pA" x="236" y="327" width="345" height="199"/> | ||
112 | </children> | ||
113 | <children xmi:type="notation:Shape" xmi:id="_W9ZSsHy4EemI79hpD-o6pA" type="2001" fontName="Noto Sans" italic="true" lineColor="0"> | ||
114 | <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_QzUgoXy5EemI79hpD-o6pA" source="defaultAction"> | ||
115 | <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_QzUgony5EemI79hpD-o6pA" key="value" value="preserve"/> | ||
116 | </eAnnotations> | ||
117 | <children xmi:type="notation:DecorationNode" xmi:id="_W9ZSsny4EemI79hpD-o6pA" type="5001"/> | ||
118 | <children xmi:type="notation:DecorationNode" xmi:id="_W9ZSs3y4EemI79hpD-o6pA" type="7001"> | ||
119 | <children xmi:type="notation:Shape" xmi:id="_QzVuwHy5EemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
120 | <children xmi:type="notation:DecorationNode" xmi:id="_QzVuwny5EemI79hpD-o6pA" type="5002"/> | ||
121 | <children xmi:type="notation:DecorationNode" xmi:id="_QzVuw3y5EemI79hpD-o6pA" type="5003"/> | ||
122 | <children xmi:type="notation:DecorationNode" xmi:id="_QzVuxHy5EemI79hpD-o6pA" type="7002"> | ||
123 | <styles xmi:type="notation:SortingStyle" xmi:id="_QzVuxXy5EemI79hpD-o6pA"/> | ||
124 | <styles xmi:type="notation:FilteringStyle" xmi:id="_QzVuxny5EemI79hpD-o6pA"/> | ||
125 | </children> | ||
126 | <element xmi:type="henshin:Node" href="cps.henshin#_QzQ2QHy5EemI79hpD-o6pA"/> | ||
127 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_QzVuwXy5EemI79hpD-o6pA" x="16" y="162"/> | ||
128 | </children> | ||
129 | <children xmi:type="notation:Shape" xmi:id="_U8_rwHy5EemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
130 | <children xmi:type="notation:DecorationNode" xmi:id="_U9AS0Hy5EemI79hpD-o6pA" type="5002"/> | ||
131 | <children xmi:type="notation:DecorationNode" xmi:id="_U9AS0Xy5EemI79hpD-o6pA" type="5003"/> | ||
132 | <children xmi:type="notation:DecorationNode" xmi:id="_U9AS0ny5EemI79hpD-o6pA" type="7002"> | ||
133 | <styles xmi:type="notation:SortingStyle" xmi:id="_U9AS03y5EemI79hpD-o6pA"/> | ||
134 | <styles xmi:type="notation:FilteringStyle" xmi:id="_U9AS1Hy5EemI79hpD-o6pA"/> | ||
135 | </children> | ||
136 | <element xmi:type="henshin:Node" href="cps.henshin#_U88ocHy5EemI79hpD-o6pA"/> | ||
137 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_U8_rwXy5EemI79hpD-o6pA" x="177" y="11"/> | ||
138 | </children> | ||
139 | <children xmi:type="notation:Shape" xmi:id="_WEe4QHy5EemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
140 | <children xmi:type="notation:DecorationNode" xmi:id="_WEe4Qny5EemI79hpD-o6pA" type="5002"/> | ||
141 | <children xmi:type="notation:DecorationNode" xmi:id="_WEe4Q3y5EemI79hpD-o6pA" type="5003"/> | ||
142 | <children xmi:type="notation:DecorationNode" xmi:id="_WEe4RHy5EemI79hpD-o6pA" type="7002"> | ||
143 | <styles xmi:type="notation:SortingStyle" xmi:id="_WEe4RXy5EemI79hpD-o6pA"/> | ||
144 | <styles xmi:type="notation:FilteringStyle" xmi:id="_WEe4Rny5EemI79hpD-o6pA"/> | ||
145 | </children> | ||
146 | <element xmi:type="henshin:Node" href="cps.henshin#_WEdqIHy5EemI79hpD-o6pA"/> | ||
147 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_WEe4QXy5EemI79hpD-o6pA" x="166" y="117"/> | ||
148 | </children> | ||
149 | <children xmi:type="notation:Shape" xmi:id="_XGUIsHy5EemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
150 | <children xmi:type="notation:DecorationNode" xmi:id="_XGUIsny5EemI79hpD-o6pA" type="5002"/> | ||
151 | <children xmi:type="notation:DecorationNode" xmi:id="_XGUvwHy5EemI79hpD-o6pA" type="5003"/> | ||
152 | <children xmi:type="notation:DecorationNode" xmi:id="_XGUvwXy5EemI79hpD-o6pA" type="7002"> | ||
153 | <styles xmi:type="notation:SortingStyle" xmi:id="_XGUvwny5EemI79hpD-o6pA"/> | ||
154 | <styles xmi:type="notation:FilteringStyle" xmi:id="_XGUvw3y5EemI79hpD-o6pA"/> | ||
155 | </children> | ||
156 | <element xmi:type="henshin:Node" href="cps.henshin#_XGRscHy5EemI79hpD-o6pA"/> | ||
157 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_XGUIsXy5EemI79hpD-o6pA" x="527" y="11"/> | ||
158 | </children> | ||
159 | <children xmi:type="notation:Shape" xmi:id="_XfT3gHy5EemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
160 | <children xmi:type="notation:DecorationNode" xmi:id="_XfT3gny5EemI79hpD-o6pA" type="5002"/> | ||
161 | <children xmi:type="notation:DecorationNode" xmi:id="_XfT3g3y5EemI79hpD-o6pA" type="5003"/> | ||
162 | <children xmi:type="notation:DecorationNode" xmi:id="_XfT3hHy5EemI79hpD-o6pA" type="7002"> | ||
163 | <styles xmi:type="notation:SortingStyle" xmi:id="_XfT3hXy5EemI79hpD-o6pA"/> | ||
164 | <styles xmi:type="notation:FilteringStyle" xmi:id="_XfT3hny5EemI79hpD-o6pA"/> | ||
165 | </children> | ||
166 | <element xmi:type="henshin:Node" href="cps.henshin#_XfSpYHy5EemI79hpD-o6pA"/> | ||
167 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_XfT3gXy5EemI79hpD-o6pA" x="527" y="162"/> | ||
168 | </children> | ||
169 | <children xmi:type="notation:Shape" xmi:id="_YuaH4Hy5EemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
170 | <children xmi:type="notation:DecorationNode" xmi:id="_YuaH4ny5EemI79hpD-o6pA" type="5002"/> | ||
171 | <children xmi:type="notation:DecorationNode" xmi:id="_YuaH43y5EemI79hpD-o6pA" type="5003"/> | ||
172 | <children xmi:type="notation:DecorationNode" xmi:id="_YuaH5Hy5EemI79hpD-o6pA" type="7002"> | ||
173 | <styles xmi:type="notation:SortingStyle" xmi:id="_YuaH5Xy5EemI79hpD-o6pA"/> | ||
174 | <styles xmi:type="notation:FilteringStyle" xmi:id="_YuaH5ny5EemI79hpD-o6pA"/> | ||
175 | </children> | ||
176 | <element xmi:type="henshin:Node" href="cps.henshin#_YuZg0Hy5EemI79hpD-o6pA"/> | ||
177 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_YuaH4Xy5EemI79hpD-o6pA" x="337" y="11"/> | ||
178 | </children> | ||
179 | <children xmi:type="notation:Shape" xmi:id="_iu5VYHy5EemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
180 | <children xmi:type="notation:DecorationNode" xmi:id="_iu5VYny5EemI79hpD-o6pA" type="5002"/> | ||
181 | <children xmi:type="notation:DecorationNode" xmi:id="_iu5VY3y5EemI79hpD-o6pA" type="5003"/> | ||
182 | <children xmi:type="notation:DecorationNode" xmi:id="_iu5VZHy5EemI79hpD-o6pA" type="7002"> | ||
183 | <styles xmi:type="notation:SortingStyle" xmi:id="_iu5VZXy5EemI79hpD-o6pA"/> | ||
184 | <styles xmi:type="notation:FilteringStyle" xmi:id="_iu5VZny5EemI79hpD-o6pA"/> | ||
185 | </children> | ||
186 | <element xmi:type="henshin:Node" href="cps.henshin#_iu3gMHy5EemI79hpD-o6pA"/> | ||
187 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_iu5VYXy5EemI79hpD-o6pA" x="166" y="214"/> | ||
188 | </children> | ||
189 | <children xmi:type="notation:Shape" xmi:id="_DK8L8H8VEemiUoPdWqOlQg" type="3001" fontName="Noto Sans"> | ||
190 | <children xmi:type="notation:DecorationNode" xmi:id="_DK8zAH8VEemiUoPdWqOlQg" type="5002"/> | ||
191 | <children xmi:type="notation:DecorationNode" xmi:id="_DK8zAX8VEemiUoPdWqOlQg" type="5003"/> | ||
192 | <children xmi:type="notation:DecorationNode" xmi:id="_DK8zAn8VEemiUoPdWqOlQg" type="7002"> | ||
193 | <styles xmi:type="notation:SortingStyle" xmi:id="_DK8zA38VEemiUoPdWqOlQg"/> | ||
194 | <styles xmi:type="notation:FilteringStyle" xmi:id="_DK8zBH8VEemiUoPdWqOlQg"/> | ||
195 | </children> | ||
196 | <element xmi:type="henshin:Node" href="cps.henshin#_DK7k4H8VEemiUoPdWqOlQg"/> | ||
197 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_DK8L8X8VEemiUoPdWqOlQg" x="15" y="11"/> | ||
198 | </children> | ||
199 | </children> | ||
200 | <element xmi:type="henshin:Rule" href="cps.henshin#_W9WPYHy4EemI79hpD-o6pA"/> | ||
201 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_W9ZSsXy4EemI79hpD-o6pA" x="22" y="549" width="637" height="322"/> | ||
202 | </children> | ||
203 | <children xmi:type="notation:Shape" xmi:id="_1VkVkHy5EemI79hpD-o6pA" type="2001" fontName="Noto Sans" italic="true" lineColor="0"> | ||
204 | <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_OdwiAny6EemI79hpD-o6pA" source="defaultAction"> | ||
205 | <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_OdwiA3y6EemI79hpD-o6pA" key="value" value="preserve"/> | ||
206 | </eAnnotations> | ||
207 | <children xmi:type="notation:DecorationNode" xmi:id="_1VkVkny5EemI79hpD-o6pA" type="5001"/> | ||
208 | <children xmi:type="notation:DecorationNode" xmi:id="_1VkVk3y5EemI79hpD-o6pA" type="7001"> | ||
209 | <children xmi:type="notation:Shape" xmi:id="_OdxwIHy6EemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
210 | <children xmi:type="notation:DecorationNode" xmi:id="_OdxwIny6EemI79hpD-o6pA" type="5002"/> | ||
211 | <children xmi:type="notation:DecorationNode" xmi:id="_OdxwI3y6EemI79hpD-o6pA" type="5003"/> | ||
212 | <children xmi:type="notation:DecorationNode" xmi:id="_OdxwJHy6EemI79hpD-o6pA" type="7002"> | ||
213 | <styles xmi:type="notation:SortingStyle" xmi:id="_OdxwJXy6EemI79hpD-o6pA"/> | ||
214 | <styles xmi:type="notation:FilteringStyle" xmi:id="_OdxwJny6EemI79hpD-o6pA"/> | ||
215 | </children> | ||
216 | <element xmi:type="henshin:Node" href="cps.henshin#_OdtesHy6EemI79hpD-o6pA"/> | ||
217 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_OdxwIXy6EemI79hpD-o6pA" x="21" y="12"/> | ||
218 | </children> | ||
219 | <children xmi:type="notation:Shape" xmi:id="_PGbrkHy6EemI79hpD-o6pA" type="3001" fontName="Noto Sans"> | ||
220 | <children xmi:type="notation:DecorationNode" xmi:id="_PGcSoHy6EemI79hpD-o6pA" type="5002"/> | ||
221 | <children xmi:type="notation:DecorationNode" xmi:id="_PGcSoXy6EemI79hpD-o6pA" type="5003"/> | ||
222 | <children xmi:type="notation:DecorationNode" xmi:id="_PGcSony6EemI79hpD-o6pA" type="7002"> | ||
223 | <styles xmi:type="notation:SortingStyle" xmi:id="_PGcSo3y6EemI79hpD-o6pA"/> | ||
224 | <styles xmi:type="notation:FilteringStyle" xmi:id="_PGcSpHy6EemI79hpD-o6pA"/> | ||
225 | </children> | ||
226 | <element xmi:type="henshin:Node" href="cps.henshin#_PGadcHy6EemI79hpD-o6pA"/> | ||
227 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_PGbrkXy6EemI79hpD-o6pA" x="39" y="163"/> | ||
228 | </children> | ||
229 | </children> | ||
230 | <element xmi:type="henshin:Rule" href="cps.henshin#_1VgrMHy5EemI79hpD-o6pA"/> | ||
231 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_1VkVkXy5EemI79hpD-o6pA" x="684" y="549" width="177" height="259"/> | ||
232 | </children> | ||
233 | <children xmi:type="notation:Shape" xmi:id="_4li6kH8UEemiUoPdWqOlQg" type="2001" fontName="Noto Sans" italic="true" lineColor="0"> | ||
234 | <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_VfNNgn8VEemiUoPdWqOlQg" source="defaultAction"> | ||
235 | <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_VfNNg38VEemiUoPdWqOlQg" key="value" value="preserve"/> | ||
236 | </eAnnotations> | ||
237 | <children xmi:type="notation:DecorationNode" xmi:id="_4ljhoH8UEemiUoPdWqOlQg" type="5001"/> | ||
238 | <children xmi:type="notation:DecorationNode" xmi:id="_4ljhoX8UEemiUoPdWqOlQg" type="7001"> | ||
239 | <children xmi:type="notation:Shape" xmi:id="_VfOboH8VEemiUoPdWqOlQg" type="3001" fontName="Noto Sans"> | ||
240 | <children xmi:type="notation:DecorationNode" xmi:id="_VfPCsH8VEemiUoPdWqOlQg" type="5002"/> | ||
241 | <children xmi:type="notation:DecorationNode" xmi:id="_VfPCsX8VEemiUoPdWqOlQg" type="5003"/> | ||
242 | <children xmi:type="notation:DecorationNode" xmi:id="_VfPCsn8VEemiUoPdWqOlQg" type="7002"> | ||
243 | <styles xmi:type="notation:SortingStyle" xmi:id="_VfPCs38VEemiUoPdWqOlQg"/> | ||
244 | <styles xmi:type="notation:FilteringStyle" xmi:id="_VfPCtH8VEemiUoPdWqOlQg"/> | ||
245 | </children> | ||
246 | <element xmi:type="henshin:Node" href="cps.henshin#_VfKxQH8VEemiUoPdWqOlQg"/> | ||
247 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_VfOboX8VEemiUoPdWqOlQg" x="19" y="196"/> | ||
248 | </children> | ||
249 | <children xmi:type="notation:Shape" xmi:id="_WJm1YH8VEemiUoPdWqOlQg" type="3001" fontName="Noto Sans"> | ||
250 | <children xmi:type="notation:DecorationNode" xmi:id="_WJnccH8VEemiUoPdWqOlQg" type="5002"/> | ||
251 | <children xmi:type="notation:DecorationNode" xmi:id="_WJnccX8VEemiUoPdWqOlQg" type="5003"/> | ||
252 | <children xmi:type="notation:DecorationNode" xmi:id="_WJnccn8VEemiUoPdWqOlQg" type="7002"> | ||
253 | <styles xmi:type="notation:SortingStyle" xmi:id="_WJncc38VEemiUoPdWqOlQg"/> | ||
254 | <styles xmi:type="notation:FilteringStyle" xmi:id="_WJncdH8VEemiUoPdWqOlQg"/> | ||
255 | </children> | ||
256 | <element xmi:type="henshin:Node" href="cps.henshin#_WJkZIH8VEemiUoPdWqOlQg"/> | ||
257 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_WJm1YX8VEemiUoPdWqOlQg" x="172" y="16"/> | ||
258 | </children> | ||
259 | <children xmi:type="notation:Shape" xmi:id="_Xr_OIH8VEemiUoPdWqOlQg" type="3001" fontName="Noto Sans"> | ||
260 | <children xmi:type="notation:DecorationNode" xmi:id="_Xr_OIn8VEemiUoPdWqOlQg" type="5002"/> | ||
261 | <children xmi:type="notation:DecorationNode" xmi:id="_Xr_OI38VEemiUoPdWqOlQg" type="5003"/> | ||
262 | <children xmi:type="notation:DecorationNode" xmi:id="_Xr_OJH8VEemiUoPdWqOlQg" type="7002"> | ||
263 | <styles xmi:type="notation:SortingStyle" xmi:id="_Xr_OJX8VEemiUoPdWqOlQg"/> | ||
264 | <styles xmi:type="notation:FilteringStyle" xmi:id="_Xr_OJn8VEemiUoPdWqOlQg"/> | ||
265 | </children> | ||
266 | <element xmi:type="henshin:Node" href="cps.henshin#_Xr-AAH8VEemiUoPdWqOlQg"/> | ||
267 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Xr_OIX8VEemiUoPdWqOlQg" x="161" y="263"/> | ||
268 | </children> | ||
269 | <children xmi:type="notation:Shape" xmi:id="_Y0FeoH8VEemiUoPdWqOlQg" type="3001" fontName="Noto Sans"> | ||
270 | <children xmi:type="notation:DecorationNode" xmi:id="_Y0GFsX8VEemiUoPdWqOlQg" type="5002"/> | ||
271 | <children xmi:type="notation:DecorationNode" xmi:id="_Y0GFsn8VEemiUoPdWqOlQg" type="5003"/> | ||
272 | <children xmi:type="notation:DecorationNode" xmi:id="_Y0GFs38VEemiUoPdWqOlQg" type="7002"> | ||
273 | <styles xmi:type="notation:SortingStyle" xmi:id="_Y0GFtH8VEemiUoPdWqOlQg"/> | ||
274 | <styles xmi:type="notation:FilteringStyle" xmi:id="_Y0GFtX8VEemiUoPdWqOlQg"/> | ||
275 | </children> | ||
276 | <element xmi:type="henshin:Node" href="cps.henshin#_Yz9i0H8VEemiUoPdWqOlQg"/> | ||
277 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Y0GFsH8VEemiUoPdWqOlQg" x="533" y="196"/> | ||
278 | </children> | ||
279 | <children xmi:type="notation:Shape" xmi:id="_cTdIgH8VEemiUoPdWqOlQg" type="3001" fontName="Noto Sans"> | ||
280 | <children xmi:type="notation:DecorationNode" xmi:id="_cTdIgn8VEemiUoPdWqOlQg" type="5002"/> | ||
281 | <children xmi:type="notation:DecorationNode" xmi:id="_cTdIg38VEemiUoPdWqOlQg" type="5003"/> | ||
282 | <children xmi:type="notation:DecorationNode" xmi:id="_cTdIhH8VEemiUoPdWqOlQg" type="7002"> | ||
283 | <styles xmi:type="notation:SortingStyle" xmi:id="_cTdIhX8VEemiUoPdWqOlQg"/> | ||
284 | <styles xmi:type="notation:FilteringStyle" xmi:id="_cTdIhn8VEemiUoPdWqOlQg"/> | ||
285 | </children> | ||
286 | <element xmi:type="henshin:Node" href="cps.henshin#_cTchcH8VEemiUoPdWqOlQg"/> | ||
287 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_cTdIgX8VEemiUoPdWqOlQg" x="161" y="133"/> | ||
288 | </children> | ||
289 | <children xmi:type="notation:Shape" xmi:id="_fYb8cH8VEemiUoPdWqOlQg" type="3001" fontName="Noto Sans"> | ||
290 | <children xmi:type="notation:DecorationNode" xmi:id="_fYb8cn8VEemiUoPdWqOlQg" type="5002"/> | ||
291 | <children xmi:type="notation:DecorationNode" xmi:id="_fYb8c38VEemiUoPdWqOlQg" type="5003"/> | ||
292 | <children xmi:type="notation:DecorationNode" xmi:id="_fYb8dH8VEemiUoPdWqOlQg" type="7002"> | ||
293 | <styles xmi:type="notation:SortingStyle" xmi:id="_fYb8dX8VEemiUoPdWqOlQg"/> | ||
294 | <styles xmi:type="notation:FilteringStyle" xmi:id="_fYb8dn8VEemiUoPdWqOlQg"/> | ||
295 | </children> | ||
296 | <element xmi:type="henshin:Node" href="cps.henshin#_fYauUH8VEemiUoPdWqOlQg"/> | ||
297 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_fYb8cX8VEemiUoPdWqOlQg" x="347" y="16"/> | ||
298 | </children> | ||
299 | <children xmi:type="notation:Shape" xmi:id="_kmA0kH8VEemiUoPdWqOlQg" type="3001" fontName="Noto Sans"> | ||
300 | <children xmi:type="notation:DecorationNode" xmi:id="_kmA0kn8VEemiUoPdWqOlQg" type="5002"/> | ||
301 | <children xmi:type="notation:DecorationNode" xmi:id="_kmA0k38VEemiUoPdWqOlQg" type="5003"/> | ||
302 | <children xmi:type="notation:DecorationNode" xmi:id="_kmA0lH8VEemiUoPdWqOlQg" type="7002"> | ||
303 | <styles xmi:type="notation:SortingStyle" xmi:id="_kmA0lX8VEemiUoPdWqOlQg"/> | ||
304 | <styles xmi:type="notation:FilteringStyle" xmi:id="_kmA0ln8VEemiUoPdWqOlQg"/> | ||
305 | </children> | ||
306 | <element xmi:type="henshin:Node" href="cps.henshin#_kl-_YH8VEemiUoPdWqOlQg"/> | ||
307 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kmA0kX8VEemiUoPdWqOlQg" x="540" y="16"/> | ||
308 | </children> | ||
309 | <children xmi:type="notation:Shape" xmi:id="_wZseAH8VEemiUoPdWqOlQg" type="3001" fontName="Noto Sans"> | ||
310 | <children xmi:type="notation:DecorationNode" xmi:id="_wZseAn8VEemiUoPdWqOlQg" type="5002"/> | ||
311 | <children xmi:type="notation:DecorationNode" xmi:id="_wZseA38VEemiUoPdWqOlQg" type="5003"/> | ||
312 | <children xmi:type="notation:DecorationNode" xmi:id="_wZseBH8VEemiUoPdWqOlQg" type="7002"> | ||
313 | <styles xmi:type="notation:SortingStyle" xmi:id="_wZseBX8VEemiUoPdWqOlQg"/> | ||
314 | <styles xmi:type="notation:FilteringStyle" xmi:id="_wZseBn8VEemiUoPdWqOlQg"/> | ||
315 | </children> | ||
316 | <element xmi:type="henshin:Node" href="cps.henshin#_wZrP4H8VEemiUoPdWqOlQg"/> | ||
317 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_wZseAX8VEemiUoPdWqOlQg" x="18" y="16"/> | ||
318 | </children> | ||
319 | </children> | ||
320 | <element xmi:type="henshin:Rule" href="cps.henshin#_4lbl0H8UEemiUoPdWqOlQg"/> | ||
321 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_4li6kX8UEemiUoPdWqOlQg" x="22" y="894" width="637" height="360"/> | ||
322 | </children> | ||
323 | <children xmi:type="notation:Shape" xmi:id="_7SPC8H8XEemiUoPdWqOlQg" type="2001" fontName="Noto Sans" italic="true" lineColor="0"> | ||
324 | <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_AUFzQH8YEemiUoPdWqOlQg" source="defaultAction"> | ||
325 | <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_AUFzQX8YEemiUoPdWqOlQg" key="value" value="preserve"/> | ||
326 | </eAnnotations> | ||
327 | <children xmi:type="notation:DecorationNode" xmi:id="_7SPqAH8XEemiUoPdWqOlQg" type="5001"/> | ||
328 | <children xmi:type="notation:DecorationNode" xmi:id="_7SPqAX8XEemiUoPdWqOlQg" type="7001"> | ||
329 | <children xmi:type="notation:Shape" xmi:id="_AUGaUH8YEemiUoPdWqOlQg" type="3001" fontName="Noto Sans"> | ||
330 | <children xmi:type="notation:DecorationNode" xmi:id="_AUGaUn8YEemiUoPdWqOlQg" type="5002"/> | ||
331 | <children xmi:type="notation:DecorationNode" xmi:id="_AUGaU38YEemiUoPdWqOlQg" type="5003"/> | ||
332 | <children xmi:type="notation:DecorationNode" xmi:id="_AUGaVH8YEemiUoPdWqOlQg" type="7002"> | ||
333 | <styles xmi:type="notation:SortingStyle" xmi:id="_AUGaVX8YEemiUoPdWqOlQg"/> | ||
334 | <styles xmi:type="notation:FilteringStyle" xmi:id="_AUGaVn8YEemiUoPdWqOlQg"/> | ||
335 | </children> | ||
336 | <element xmi:type="henshin:Node" href="cps.henshin#_AUFMMH8YEemiUoPdWqOlQg"/> | ||
337 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_AUGaUX8YEemiUoPdWqOlQg" x="28" y="19"/> | ||
338 | </children> | ||
339 | <children xmi:type="notation:Shape" xmi:id="_A8fQAH8YEemiUoPdWqOlQg" type="3001" fontName="Noto Sans"> | ||
340 | <children xmi:type="notation:DecorationNode" xmi:id="_A8fQAn8YEemiUoPdWqOlQg" type="5002"/> | ||
341 | <children xmi:type="notation:DecorationNode" xmi:id="_A8fQA38YEemiUoPdWqOlQg" type="5003"/> | ||
342 | <children xmi:type="notation:DecorationNode" xmi:id="_A8fQBH8YEemiUoPdWqOlQg" type="7002"> | ||
343 | <styles xmi:type="notation:SortingStyle" xmi:id="_A8fQBX8YEemiUoPdWqOlQg"/> | ||
344 | <styles xmi:type="notation:FilteringStyle" xmi:id="_A8fQBn8YEemiUoPdWqOlQg"/> | ||
345 | </children> | ||
346 | <element xmi:type="henshin:Node" href="cps.henshin#_A8eo8H8YEemiUoPdWqOlQg"/> | ||
347 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_A8fQAX8YEemiUoPdWqOlQg" x="238" y="19"/> | ||
348 | </children> | ||
349 | <children xmi:type="notation:Shape" xmi:id="_DowB8H8YEemiUoPdWqOlQg" type="3001" fontName="Noto Sans"> | ||
350 | <children xmi:type="notation:DecorationNode" xmi:id="_DowB8n8YEemiUoPdWqOlQg" type="5002"/> | ||
351 | <children xmi:type="notation:DecorationNode" xmi:id="_DowB838YEemiUoPdWqOlQg" type="5003"/> | ||
352 | <children xmi:type="notation:DecorationNode" xmi:id="_DowB9H8YEemiUoPdWqOlQg" type="7002"> | ||
353 | <styles xmi:type="notation:SortingStyle" xmi:id="_DowB9X8YEemiUoPdWqOlQg"/> | ||
354 | <styles xmi:type="notation:FilteringStyle" xmi:id="_DowB9n8YEemiUoPdWqOlQg"/> | ||
355 | </children> | ||
356 | <element xmi:type="henshin:Node" href="cps.henshin#_Dova4H8YEemiUoPdWqOlQg"/> | ||
357 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_DowB8X8YEemiUoPdWqOlQg" x="227" y="171"/> | ||
358 | </children> | ||
359 | </children> | ||
360 | <element xmi:type="henshin:Rule" href="cps.henshin#_7SLYkH8XEemiUoPdWqOlQg"/> | ||
361 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_7SPC8X8XEemiUoPdWqOlQg" x="453" y="22" width="376" height="284"/> | ||
362 | </children> | ||
363 | <styles xmi:type="notation:DiagramStyle" xmi:id="_rVAwQXyxEemI79hpD-o6pA"/> | ||
364 | <element xmi:type="henshin:Module" href="cps.henshin#_rUcIgHyxEemI79hpD-o6pA"/> | ||
365 | <edges xmi:type="notation:Connector" xmi:id="_6Yb2sHyyEemI79hpD-o6pA" type="4001" source="_8Ow7oHyxEemI79hpD-o6pA" target="_KIaMAHyyEemI79hpD-o6pA"> | ||
366 | <children xmi:type="notation:DecorationNode" xmi:id="_6Yb2s3yyEemI79hpD-o6pA" type="6001"> | ||
367 | <layoutConstraint xmi:type="notation:Location" xmi:id="_6Yb2tHyyEemI79hpD-o6pA" y="40"/> | ||
368 | </children> | ||
369 | <children xmi:type="notation:DecorationNode" xmi:id="_6Yb2tXyyEemI79hpD-o6pA" type="6002"> | ||
370 | <layoutConstraint xmi:type="notation:Location" xmi:id="_6Yb2tnyyEemI79hpD-o6pA" y="60"/> | ||
371 | </children> | ||
372 | <styles xmi:type="notation:FontStyle" xmi:id="_6Yb2sXyyEemI79hpD-o6pA" fontName="Noto Sans"/> | ||
373 | <element xmi:type="henshin:Edge" href="cps.henshin#_6YaokHyyEemI79hpD-o6pA"/> | ||
374 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_6Yb2snyyEemI79hpD-o6pA" points="[49, -7, -165, 20]$[190, -30, -24, -3]"/> | ||
375 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_6YdE0HyyEemI79hpD-o6pA" id="(0.20512820512820512,0.41304347826086957)"/> | ||
376 | </edges> | ||
377 | <edges xmi:type="notation:Connector" xmi:id="_APeikHyzEemI79hpD-o6pA" type="4001" source="_8Ow7oHyxEemI79hpD-o6pA" target="__cDhkHyyEemI79hpD-o6pA"> | ||
378 | <children xmi:type="notation:DecorationNode" xmi:id="_APeik3yzEemI79hpD-o6pA" type="6001"> | ||
379 | <layoutConstraint xmi:type="notation:Location" xmi:id="_APeilHyzEemI79hpD-o6pA" y="40"/> | ||
380 | </children> | ||
381 | <children xmi:type="notation:DecorationNode" xmi:id="_APeilXyzEemI79hpD-o6pA" type="6002"> | ||
382 | <layoutConstraint xmi:type="notation:Location" xmi:id="_APeilnyzEemI79hpD-o6pA" y="60"/> | ||
383 | </children> | ||
384 | <styles xmi:type="notation:FontStyle" xmi:id="_APeikXyzEemI79hpD-o6pA" fontName="Noto Sans"/> | ||
385 | <element xmi:type="henshin:Edge" href="cps.henshin#_APd7gHyzEemI79hpD-o6pA"/> | ||
386 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_APeiknyzEemI79hpD-o6pA" points="[14, -1, -203, 1]$[215, -25, -2, -23]"/> | ||
387 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_APfwsHyzEemI79hpD-o6pA" id="(0.8571428571428571,0.17391304347826086)"/> | ||
388 | </edges> | ||
389 | <edges xmi:type="notation:Connector" xmi:id="_AoHFAHyzEemI79hpD-o6pA" type="4001" source="__cDhkHyyEemI79hpD-o6pA" target="_KIaMAHyyEemI79hpD-o6pA"> | ||
390 | <children xmi:type="notation:DecorationNode" xmi:id="_AoHsEHyzEemI79hpD-o6pA" type="6001"> | ||
391 | <layoutConstraint xmi:type="notation:Location" xmi:id="_AoHsEXyzEemI79hpD-o6pA" x="20" y="37"/> | ||
392 | </children> | ||
393 | <children xmi:type="notation:DecorationNode" xmi:id="_AoHsEnyzEemI79hpD-o6pA" type="6002"> | ||
394 | <layoutConstraint xmi:type="notation:Location" xmi:id="_AoHsE3yzEemI79hpD-o6pA" y="60"/> | ||
395 | </children> | ||
396 | <styles xmi:type="notation:FontStyle" xmi:id="_AoHFAXyzEemI79hpD-o6pA" fontName="Noto Sans"/> | ||
397 | <element xmi:type="henshin:Edge" href="cps.henshin#_AoFP0HyzEemI79hpD-o6pA"/> | ||
398 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_AoHFAnyzEemI79hpD-o6pA" points="[-2, 23, 10, -119]$[-9, 136, 3, -6]"/> | ||
399 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_AoMkkHyzEemI79hpD-o6pA" id="(0.5897435897435898,0.13043478260869565)"/> | ||
400 | </edges> | ||
401 | <edges xmi:type="notation:Connector" xmi:id="_fabGMHy0EemI79hpD-o6pA" type="4001" source="_Zp4q8Hy0EemI79hpD-o6pA" target="_bFEPgHy0EemI79hpD-o6pA"> | ||
402 | <children xmi:type="notation:DecorationNode" xmi:id="_fabtQHy0EemI79hpD-o6pA" type="6001"> | ||
403 | <layoutConstraint xmi:type="notation:Location" xmi:id="_fabtQXy0EemI79hpD-o6pA" y="40"/> | ||
404 | </children> | ||
405 | <children xmi:type="notation:DecorationNode" xmi:id="_fabtQny0EemI79hpD-o6pA" type="6002"> | ||
406 | <layoutConstraint xmi:type="notation:Location" xmi:id="_facUUHy0EemI79hpD-o6pA" y="60"/> | ||
407 | </children> | ||
408 | <styles xmi:type="notation:FontStyle" xmi:id="_fabGMXy0EemI79hpD-o6pA" fontName="Noto Sans"/> | ||
409 | <element xmi:type="henshin:Edge" href="cps.henshin#_faZ4EHy0EemI79hpD-o6pA"/> | ||
410 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_fabGMny0EemI79hpD-o6pA" points="[-1, 23, 0, -56]$[-2, 71, -1, -8]"/> | ||
411 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_faglwHy0EemI79hpD-o6pA" id="(0.49382716049382713,0.17391304347826086)"/> | ||
412 | </edges> | ||
413 | <edges xmi:type="notation:Connector" xmi:id="_7KsvMHy0EemI79hpD-o6pA" type="4001" source="_5jh9EHy0EemI79hpD-o6pA" target="_6FsO8Hy0EemI79hpD-o6pA"> | ||
414 | <children xmi:type="notation:DecorationNode" xmi:id="_7KtWQHy0EemI79hpD-o6pA" type="6001"> | ||
415 | <layoutConstraint xmi:type="notation:Location" xmi:id="_7KtWQXy0EemI79hpD-o6pA" y="40"/> | ||
416 | </children> | ||
417 | <children xmi:type="notation:DecorationNode" xmi:id="_7KtWQny0EemI79hpD-o6pA" type="6002"> | ||
418 | <layoutConstraint xmi:type="notation:Location" xmi:id="_7KtWQ3y0EemI79hpD-o6pA" y="60"/> | ||
419 | </children> | ||
420 | <styles xmi:type="notation:FontStyle" xmi:id="_7KsvMXy0EemI79hpD-o6pA" fontName="Noto Sans"/> | ||
421 | <element xmi:type="henshin:Edge" href="cps.henshin#_7KrhEHy0EemI79hpD-o6pA"/> | ||
422 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_7KsvMny0EemI79hpD-o6pA" points="[3, 23, -5, -62]$[11, 62, 3, -23]"/> | ||
423 | </edges> | ||
424 | <edges xmi:type="notation:Connector" xmi:id="__HxBsHy0EemI79hpD-o6pA" type="4001" source="_8lWIQHy0EemI79hpD-o6pA" target="_6FsO8Hy0EemI79hpD-o6pA"> | ||
425 | <children xmi:type="notation:DecorationNode" xmi:id="__HxBs3y0EemI79hpD-o6pA" type="6001"> | ||
426 | <layoutConstraint xmi:type="notation:Location" xmi:id="__HxBtHy0EemI79hpD-o6pA" y="40"/> | ||
427 | </children> | ||
428 | <children xmi:type="notation:DecorationNode" xmi:id="__HxowHy0EemI79hpD-o6pA" type="6002"> | ||
429 | <layoutConstraint xmi:type="notation:Location" xmi:id="__HxowXy0EemI79hpD-o6pA" y="60"/> | ||
430 | </children> | ||
431 | <styles xmi:type="notation:FontStyle" xmi:id="__HxBsXy0EemI79hpD-o6pA" fontName="Noto Sans"/> | ||
432 | <element xmi:type="henshin:Edge" href="cps.henshin#__HvMgHy0EemI79hpD-o6pA"/> | ||
433 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="__HxBsny0EemI79hpD-o6pA" points="[-24, -5, 115, -1]$[-98, -5, 41, -1]"/> | ||
434 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="__H0sEHy0EemI79hpD-o6pA" id="(0.20512820512820512,0.5869565217391305)"/> | ||
435 | </edges> | ||
436 | <edges xmi:type="notation:Connector" xmi:id="_epK2Iny5EemI79hpD-o6pA" type="4001" source="_U8_rwHy5EemI79hpD-o6pA" target="_YuaH4Hy5EemI79hpD-o6pA"> | ||
437 | <children xmi:type="notation:DecorationNode" xmi:id="_epK2JXy5EemI79hpD-o6pA" type="6001"> | ||
438 | <layoutConstraint xmi:type="notation:Location" xmi:id="_epK2Jny5EemI79hpD-o6pA" y="40"/> | ||
439 | </children> | ||
440 | <children xmi:type="notation:DecorationNode" xmi:id="_epK2J3y5EemI79hpD-o6pA" type="6002"> | ||
441 | <layoutConstraint xmi:type="notation:Location" xmi:id="_epK2KHy5EemI79hpD-o6pA" y="60"/> | ||
442 | </children> | ||
443 | <styles xmi:type="notation:FontStyle" xmi:id="_epK2I3y5EemI79hpD-o6pA" fontName="Noto Sans"/> | ||
444 | <element xmi:type="henshin:Edge" href="cps.henshin#_epK2IHy5EemI79hpD-o6pA"/> | ||
445 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_epK2JHy5EemI79hpD-o6pA" points="[15, -1, -82, 0]$[79, -3, -18, -2]"/> | ||
446 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_epMEQHy5EemI79hpD-o6pA" id="(0.84375,0.43478260869565216)"/> | ||
447 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_epMEQXy5EemI79hpD-o6pA" id="(0.13740458015267176,0.41304347826086957)"/> | ||
448 | </edges> | ||
449 | <edges xmi:type="notation:Connector" xmi:id="_fGay0Hy5EemI79hpD-o6pA" type="4001" source="_YuaH4Hy5EemI79hpD-o6pA" target="_XGUIsHy5EemI79hpD-o6pA"> | ||
450 | <children xmi:type="notation:DecorationNode" xmi:id="_fGay03y5EemI79hpD-o6pA" type="6001"> | ||
451 | <layoutConstraint xmi:type="notation:Location" xmi:id="_fGay1Hy5EemI79hpD-o6pA" y="40"/> | ||
452 | </children> | ||
453 | <children xmi:type="notation:DecorationNode" xmi:id="_fGbZ4Hy5EemI79hpD-o6pA" type="6002"> | ||
454 | <layoutConstraint xmi:type="notation:Location" xmi:id="_fGbZ4Xy5EemI79hpD-o6pA" y="60"/> | ||
455 | </children> | ||
456 | <styles xmi:type="notation:FontStyle" xmi:id="_fGay0Xy5EemI79hpD-o6pA" fontName="Noto Sans"/> | ||
457 | <element xmi:type="henshin:Edge" href="cps.henshin#_fGY9oHy5EemI79hpD-o6pA"/> | ||
458 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_fGay0ny5EemI79hpD-o6pA" points="[13, 1, -92, -3]$[106, -19, 1, -23]"/> | ||
459 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_fGfEQHy5EemI79hpD-o6pA" id="(0.9007633587786259,0.41304347826086957)"/> | ||
460 | </edges> | ||
461 | <edges xmi:type="notation:Connector" xmi:id="_fghU4Hy5EemI79hpD-o6pA" type="4001" source="_XGUIsHy5EemI79hpD-o6pA" target="_XfT3gHy5EemI79hpD-o6pA"> | ||
462 | <children xmi:type="notation:DecorationNode" xmi:id="_fgh78Hy5EemI79hpD-o6pA" type="6001"> | ||
463 | <layoutConstraint xmi:type="notation:Location" xmi:id="_fgh78Xy5EemI79hpD-o6pA" y="40"/> | ||
464 | </children> | ||
465 | <children xmi:type="notation:DecorationNode" xmi:id="_fgh78ny5EemI79hpD-o6pA" type="6002"> | ||
466 | <layoutConstraint xmi:type="notation:Location" xmi:id="_fgh783y5EemI79hpD-o6pA" y="60"/> | ||
467 | </children> | ||
468 | <styles xmi:type="notation:FontStyle" xmi:id="_fghU4Xy5EemI79hpD-o6pA" fontName="Noto Sans"/> | ||
469 | <element xmi:type="henshin:Edge" href="cps.henshin#_fggGwHy5EemI79hpD-o6pA"/> | ||
470 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_fghU4ny5EemI79hpD-o6pA" points="[8, 23, 1, -116]$[8, 116, 1, -23]"/> | ||
471 | </edges> | ||
472 | <edges xmi:type="notation:Connector" xmi:id="_f_l2gny5EemI79hpD-o6pA" type="4001" source="_U8_rwHy5EemI79hpD-o6pA" target="_WEe4QHy5EemI79hpD-o6pA"> | ||
473 | <children xmi:type="notation:DecorationNode" xmi:id="_f_mdkHy5EemI79hpD-o6pA" type="6001"> | ||
474 | <layoutConstraint xmi:type="notation:Location" xmi:id="_f_mdkXy5EemI79hpD-o6pA" y="40"/> | ||
475 | </children> | ||
476 | <children xmi:type="notation:DecorationNode" xmi:id="_f_mdkny5EemI79hpD-o6pA" type="6002"> | ||
477 | <layoutConstraint xmi:type="notation:Location" xmi:id="_f_mdk3y5EemI79hpD-o6pA" y="60"/> | ||
478 | </children> | ||
479 | <styles xmi:type="notation:FontStyle" xmi:id="_f_l2g3y5EemI79hpD-o6pA" fontName="Noto Sans"/> | ||
480 | <element xmi:type="henshin:Edge" href="cps.henshin#_f_l2gHy5EemI79hpD-o6pA"/> | ||
481 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_f_l2hHy5EemI79hpD-o6pA" points="[2, 23, 0, -69]$[3, 83, 1, -9]"/> | ||
482 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_f_nrsHy5EemI79hpD-o6pA" id="(0.5213675213675214,0.1956521739130435)"/> | ||
483 | </edges> | ||
484 | <edges xmi:type="notation:Connector" xmi:id="_gh1n8Hy5EemI79hpD-o6pA" type="4001" source="_WEe4QHy5EemI79hpD-o6pA" target="_XfT3gHy5EemI79hpD-o6pA"> | ||
485 | <children xmi:type="notation:DecorationNode" xmi:id="_gh2PAny5EemI79hpD-o6pA" type="6001"> | ||
486 | <layoutConstraint xmi:type="notation:Location" xmi:id="_gh2PA3y5EemI79hpD-o6pA" y="40"/> | ||
487 | </children> | ||
488 | <children xmi:type="notation:DecorationNode" xmi:id="_gh2PBHy5EemI79hpD-o6pA" type="6002"> | ||
489 | <layoutConstraint xmi:type="notation:Location" xmi:id="_gh2PBXy5EemI79hpD-o6pA" y="60"/> | ||
490 | </children> | ||
491 | <styles xmi:type="notation:FontStyle" xmi:id="_gh2PAHy5EemI79hpD-o6pA" fontName="Noto Sans"/> | ||
492 | <element xmi:type="henshin:Edge" href="cps.henshin#_gh0Z0Hy5EemI79hpD-o6pA"/> | ||
493 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_gh2PAXy5EemI79hpD-o6pA" points="[15, 2, -284, -45]$[299, 70, 0, 23]"/> | ||
494 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_gh55YHy5EemI79hpD-o6pA" id="(0.8717948717948718,0.1956521739130435)"/> | ||
495 | </edges> | ||
496 | <edges xmi:type="notation:Connector" xmi:id="_hW6OwHy5EemI79hpD-o6pA" type="4001" source="_QzVuwHy5EemI79hpD-o6pA" target="_WEe4QHy5EemI79hpD-o6pA"> | ||
497 | <children xmi:type="notation:DecorationNode" xmi:id="_hW6Ow3y5EemI79hpD-o6pA" type="6001"> | ||
498 | <layoutConstraint xmi:type="notation:Location" xmi:id="_hW6OxHy5EemI79hpD-o6pA" y="40"/> | ||
499 | </children> | ||
500 | <children xmi:type="notation:DecorationNode" xmi:id="_hW6OxXy5EemI79hpD-o6pA" type="6002"> | ||
501 | <layoutConstraint xmi:type="notation:Location" xmi:id="_hW6Oxny5EemI79hpD-o6pA" y="60"/> | ||
502 | </children> | ||
503 | <styles xmi:type="notation:FontStyle" xmi:id="_hW6OwXy5EemI79hpD-o6pA" fontName="Noto Sans"/> | ||
504 | <element xmi:type="henshin:Edge" href="cps.henshin#_hW5nsHy5EemI79hpD-o6pA"/> | ||
505 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_hW6Owny5EemI79hpD-o6pA" points="[1, -5, -81, 0]$[71, -6, -11, -1]"/> | ||
506 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_hW7c4Hy5EemI79hpD-o6pA" id="(0.9873417721518988,0.6739130434782609)"/> | ||
507 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_hW7c4Xy5EemI79hpD-o6pA" id="(0.09401709401709402,0.41304347826086957)"/> | ||
508 | </edges> | ||
509 | <edges xmi:type="notation:Connector" xmi:id="_l0vE8Hy5EemI79hpD-o6pA" type="4001" source="_iu5VYHy5EemI79hpD-o6pA" target="_XfT3gHy5EemI79hpD-o6pA"> | ||
510 | <children xmi:type="notation:DecorationNode" xmi:id="_l0vE83y5EemI79hpD-o6pA" type="6001"> | ||
511 | <layoutConstraint xmi:type="notation:Location" xmi:id="_l0vE9Hy5EemI79hpD-o6pA" y="40"/> | ||
512 | </children> | ||
513 | <children xmi:type="notation:DecorationNode" xmi:id="_l0vE9Xy5EemI79hpD-o6pA" type="6002"> | ||
514 | <layoutConstraint xmi:type="notation:Location" xmi:id="_l0vE9ny5EemI79hpD-o6pA" y="60"/> | ||
515 | </children> | ||
516 | <styles xmi:type="notation:FontStyle" xmi:id="_l0vE8Xy5EemI79hpD-o6pA" fontName="Noto Sans"/> | ||
517 | <element xmi:type="henshin:Edge" href="cps.henshin#_l0ud4Hy5EemI79hpD-o6pA"/> | ||
518 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_l0vE8ny5EemI79hpD-o6pA" points="[28, -5, -282, 43]$[309, -44, -1, 4]"/> | ||
519 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_l0w6IHy5EemI79hpD-o6pA" id="(0.7606837606837606,0.5652173913043478)"/> | ||
520 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_l0w6IXy5EemI79hpD-o6pA" id="(0.4691358024691358,0.9130434782608695)"/> | ||
521 | </edges> | ||
522 | <edges xmi:type="notation:Connector" xmi:id="_mLuBkHy5EemI79hpD-o6pA" type="4001" source="_QzVuwHy5EemI79hpD-o6pA" target="_iu5VYHy5EemI79hpD-o6pA"> | ||
523 | <children xmi:type="notation:DecorationNode" xmi:id="_mLuBk3y5EemI79hpD-o6pA" type="6001"> | ||
524 | <layoutConstraint xmi:type="notation:Location" xmi:id="_mLuBlHy5EemI79hpD-o6pA" y="40"/> | ||
525 | </children> | ||
526 | <children xmi:type="notation:DecorationNode" xmi:id="_mLuBlXy5EemI79hpD-o6pA" type="6002"> | ||
527 | <layoutConstraint xmi:type="notation:Location" xmi:id="_mLuBlny5EemI79hpD-o6pA" y="60"/> | ||
528 | </children> | ||
529 | <styles xmi:type="notation:FontStyle" xmi:id="_mLuBkXy5EemI79hpD-o6pA" fontName="Noto Sans"/> | ||
530 | <element xmi:type="henshin:Edge" href="cps.henshin#_mLtagHy5EemI79hpD-o6pA"/> | ||
531 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_mLuBkny5EemI79hpD-o6pA" points="[28, 23, -111, -91]$[110, 123, -29, 9]"/> | ||
532 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_mLuooHy5EemI79hpD-o6pA" id="(0.24786324786324787,0.717391304347826)"/> | ||
533 | </edges> | ||
534 | <edges xmi:type="notation:Connector" xmi:id="_UpCYgHy6EemI79hpD-o6pA" type="4001" source="_OdxwIHy6EemI79hpD-o6pA" target="_PGbrkHy6EemI79hpD-o6pA"> | ||
535 | <children xmi:type="notation:DecorationNode" xmi:id="_UpCYg3y6EemI79hpD-o6pA" type="6001"> | ||
536 | <layoutConstraint xmi:type="notation:Location" xmi:id="_UpCYhHy6EemI79hpD-o6pA" y="40"/> | ||
537 | </children> | ||
538 | <children xmi:type="notation:DecorationNode" xmi:id="_UpCYhXy6EemI79hpD-o6pA" type="6002"> | ||
539 | <layoutConstraint xmi:type="notation:Location" xmi:id="_UpCYhny6EemI79hpD-o6pA" y="60"/> | ||
540 | </children> | ||
541 | <styles xmi:type="notation:FontStyle" xmi:id="_UpCYgXy6EemI79hpD-o6pA" fontName="Noto Sans"/> | ||
542 | <element xmi:type="henshin:Edge" href="cps.henshin#_UpBxcHy6EemI79hpD-o6pA"/> | ||
543 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_UpCYgny6EemI79hpD-o6pA" points="[4, 23, 0, -114]$[6, 128, 2, -9]"/> | ||
544 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_UpDmoHy6EemI79hpD-o6pA" id="(0.5432098765432098,0.1956521739130435)"/> | ||
545 | </edges> | ||
546 | <edges xmi:type="notation:Connector" xmi:id="_LOAqgH8VEemiUoPdWqOlQg" type="4001" source="_WEe4QHy5EemI79hpD-o6pA" target="_DK8L8H8VEemiUoPdWqOlQg"> | ||
547 | <children xmi:type="notation:DecorationNode" xmi:id="_LOAqg38VEemiUoPdWqOlQg" type="6001"> | ||
548 | <layoutConstraint xmi:type="notation:Location" xmi:id="_LOAqhH8VEemiUoPdWqOlQg" y="40"/> | ||
549 | </children> | ||
550 | <children xmi:type="notation:DecorationNode" xmi:id="_LOAqhX8VEemiUoPdWqOlQg" type="6002"> | ||
551 | <layoutConstraint xmi:type="notation:Location" xmi:id="_LOAqhn8VEemiUoPdWqOlQg" y="60"/> | ||
552 | </children> | ||
553 | <styles xmi:type="notation:FontStyle" xmi:id="_LOAqgX8VEemiUoPdWqOlQg" fontName="Noto Sans"/> | ||
554 | <element xmi:type="henshin:Edge" href="cps.henshin#_LOADcH8VEemiUoPdWqOlQg"/> | ||
555 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_LOAqgn8VEemiUoPdWqOlQg" points="[27, -7, -120, 30]$[134, -46, -13, -9]"/> | ||
556 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_LOCfsH8VEemiUoPdWqOlQg" id="(0.6666666666666666,0.15217391304347827)"/> | ||
557 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_LOCfsX8VEemiUoPdWqOlQg" id="(0.25925925925925924,0.1956521739130435)"/> | ||
558 | </edges> | ||
559 | <edges xmi:type="notation:Connector" xmi:id="_uW-YUH8VEemiUoPdWqOlQg" type="4001" source="_VfOboH8VEemiUoPdWqOlQg" target="_cTdIgH8VEemiUoPdWqOlQg"> | ||
560 | <children xmi:type="notation:DecorationNode" xmi:id="_uW-_YH8VEemiUoPdWqOlQg" type="6001"> | ||
561 | <layoutConstraint xmi:type="notation:Location" xmi:id="_uW-_YX8VEemiUoPdWqOlQg" y="40"/> | ||
562 | </children> | ||
563 | <children xmi:type="notation:DecorationNode" xmi:id="_uW-_Yn8VEemiUoPdWqOlQg" type="6002"> | ||
564 | <layoutConstraint xmi:type="notation:Location" xmi:id="_uW-_Y38VEemiUoPdWqOlQg" y="60"/> | ||
565 | </children> | ||
566 | <styles xmi:type="notation:FontStyle" xmi:id="_uW-YUX8VEemiUoPdWqOlQg" fontName="Noto Sans"/> | ||
567 | <element xmi:type="henshin:Edge" href="cps.henshin#_uW8jIH8VEemiUoPdWqOlQg"/> | ||
568 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_uW-YUn8VEemiUoPdWqOlQg" points="[36, -23, -86, 55]$[108, -86, -14, -8]"/> | ||
569 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_uXCCsH8VEemiUoPdWqOlQg" id="(0.28205128205128205,0.17391304347826086)"/> | ||
570 | </edges> | ||
571 | <edges xmi:type="notation:Connector" xmi:id="_ulQE4H8VEemiUoPdWqOlQg" type="4001" source="_VfOboH8VEemiUoPdWqOlQg" target="_Xr_OIH8VEemiUoPdWqOlQg"> | ||
572 | <children xmi:type="notation:DecorationNode" xmi:id="_ulQr8H8VEemiUoPdWqOlQg" type="6001"> | ||
573 | <layoutConstraint xmi:type="notation:Location" xmi:id="_ulQr8X8VEemiUoPdWqOlQg" y="40"/> | ||
574 | </children> | ||
575 | <children xmi:type="notation:DecorationNode" xmi:id="_ulQr8n8VEemiUoPdWqOlQg" type="6002"> | ||
576 | <layoutConstraint xmi:type="notation:Location" xmi:id="_ulQr838VEemiUoPdWqOlQg" y="60"/> | ||
577 | </children> | ||
578 | <styles xmi:type="notation:FontStyle" xmi:id="_ulQE4X8VEemiUoPdWqOlQg" fontName="Noto Sans"/> | ||
579 | <element xmi:type="henshin:Edge" href="cps.henshin#_ulPd0H8VEemiUoPdWqOlQg"/> | ||
580 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_ulQE4n8VEemiUoPdWqOlQg" points="[40, 19, -76, -39]$[89, 50, -27, -8]"/> | ||
581 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_ulTvQH8VEemiUoPdWqOlQg" id="(0.23076923076923078,0.30434782608695654)"/> | ||
582 | </edges> | ||
583 | <edges xmi:type="notation:Connector" xmi:id="_3NJHwH8VEemiUoPdWqOlQg" type="4001" source="_cTdIgH8VEemiUoPdWqOlQg" target="_wZseAH8VEemiUoPdWqOlQg"> | ||
584 | <children xmi:type="notation:DecorationNode" xmi:id="_3NJHw38VEemiUoPdWqOlQg" type="6001"> | ||
585 | <layoutConstraint xmi:type="notation:Location" xmi:id="_3NJHxH8VEemiUoPdWqOlQg" y="40"/> | ||
586 | </children> | ||
587 | <children xmi:type="notation:DecorationNode" xmi:id="_3NJHxX8VEemiUoPdWqOlQg" type="6002"> | ||
588 | <layoutConstraint xmi:type="notation:Location" xmi:id="_3NJHxn8VEemiUoPdWqOlQg" y="60"/> | ||
589 | </children> | ||
590 | <styles xmi:type="notation:FontStyle" xmi:id="_3NJHwX8VEemiUoPdWqOlQg" fontName="Noto Sans"/> | ||
591 | <element xmi:type="henshin:Edge" href="cps.henshin#_3NH5oH8VEemiUoPdWqOlQg"/> | ||
592 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_3NJHwn8VEemiUoPdWqOlQg" points="[-6, -4, 131, 94]$[-141, -121, -4, -23]"/> | ||
593 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_3NK88H8VEemiUoPdWqOlQg" id="(0.2905982905982906,0.08695652173913043)"/> | ||
594 | </edges> | ||
595 | <edges xmi:type="notation:Connector" xmi:id="_4SrMcH8VEemiUoPdWqOlQg" type="4001" source="_WJm1YH8VEemiUoPdWqOlQg" target="_cTdIgH8VEemiUoPdWqOlQg"> | ||
596 | <children xmi:type="notation:DecorationNode" xmi:id="_4SrMc38VEemiUoPdWqOlQg" type="6001"> | ||
597 | <layoutConstraint xmi:type="notation:Location" xmi:id="_4SrMdH8VEemiUoPdWqOlQg" y="40"/> | ||
598 | </children> | ||
599 | <children xmi:type="notation:DecorationNode" xmi:id="_4SrMdX8VEemiUoPdWqOlQg" type="6002"> | ||
600 | <layoutConstraint xmi:type="notation:Location" xmi:id="_4SrMdn8VEemiUoPdWqOlQg" y="60"/> | ||
601 | </children> | ||
602 | <styles xmi:type="notation:FontStyle" xmi:id="_4SrMcX8VEemiUoPdWqOlQg" fontName="Noto Sans"/> | ||
603 | <element xmi:type="henshin:Edge" href="cps.henshin#_4SqlYH8VEemiUoPdWqOlQg"/> | ||
604 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_4SrMcn8VEemiUoPdWqOlQg" points="[5, 23, 6, -94]$[5, 94, 6, -23]"/> | ||
605 | </edges> | ||
606 | <edges xmi:type="notation:Connector" xmi:id="_44ku0H8VEemiUoPdWqOlQg" type="4001" source="_WJm1YH8VEemiUoPdWqOlQg" target="_fYb8cH8VEemiUoPdWqOlQg"> | ||
607 | <children xmi:type="notation:DecorationNode" xmi:id="_44ku038VEemiUoPdWqOlQg" type="6001"> | ||
608 | <layoutConstraint xmi:type="notation:Location" xmi:id="_44ku1H8VEemiUoPdWqOlQg" y="40"/> | ||
609 | </children> | ||
610 | <children xmi:type="notation:DecorationNode" xmi:id="_44ku1X8VEemiUoPdWqOlQg" type="6002"> | ||
611 | <layoutConstraint xmi:type="notation:Location" xmi:id="_44ku1n8VEemiUoPdWqOlQg" y="60"/> | ||
612 | </children> | ||
613 | <styles xmi:type="notation:FontStyle" xmi:id="_44ku0X8VEemiUoPdWqOlQg" fontName="Noto Sans"/> | ||
614 | <element xmi:type="henshin:Edge" href="cps.henshin#_44kHwH8VEemiUoPdWqOlQg"/> | ||
615 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_44ku0n8VEemiUoPdWqOlQg" points="[11, -1, -144, 2]$[90, -1, -65, 2]"/> | ||
616 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_44l88H8VEemiUoPdWqOlQg" id="(0.8854166666666666,0.5652173913043478)"/> | ||
617 | </edges> | ||
618 | <edges xmi:type="notation:Connector" xmi:id="_5ReXAH8VEemiUoPdWqOlQg" type="4001" source="_fYb8cH8VEemiUoPdWqOlQg" target="_kmA0kH8VEemiUoPdWqOlQg"> | ||
619 | <children xmi:type="notation:DecorationNode" xmi:id="_5ReXA38VEemiUoPdWqOlQg" type="6001"> | ||
620 | <layoutConstraint xmi:type="notation:Location" xmi:id="_5ReXBH8VEemiUoPdWqOlQg" y="40"/> | ||
621 | </children> | ||
622 | <children xmi:type="notation:DecorationNode" xmi:id="_5ReXBX8VEemiUoPdWqOlQg" type="6002"> | ||
623 | <layoutConstraint xmi:type="notation:Location" xmi:id="_5ReXBn8VEemiUoPdWqOlQg" y="60"/> | ||
624 | </children> | ||
625 | <styles xmi:type="notation:FontStyle" xmi:id="_5ReXAX8VEemiUoPdWqOlQg" fontName="Noto Sans"/> | ||
626 | <element xmi:type="henshin:Edge" href="cps.henshin#_5Rch0H8VEemiUoPdWqOlQg"/> | ||
627 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_5ReXAn8VEemiUoPdWqOlQg" points="[17, -2, -95, 1]$[79, -11, -33, -8]"/> | ||
628 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_5RgMMH8VEemiUoPdWqOlQg" id="(0.8702290076335878,0.5652173913043478)"/> | ||
629 | </edges> | ||
630 | <edges xmi:type="notation:Connector" xmi:id="_5r5pMH8VEemiUoPdWqOlQg" type="4001" source="_kmA0kH8VEemiUoPdWqOlQg" target="_Y0FeoH8VEemiUoPdWqOlQg"> | ||
631 | <children xmi:type="notation:DecorationNode" xmi:id="_5r5pM38VEemiUoPdWqOlQg" type="6001"> | ||
632 | <layoutConstraint xmi:type="notation:Location" xmi:id="_5r5pNH8VEemiUoPdWqOlQg" y="40"/> | ||
633 | </children> | ||
634 | <children xmi:type="notation:DecorationNode" xmi:id="_5r5pNX8VEemiUoPdWqOlQg" type="6002"> | ||
635 | <layoutConstraint xmi:type="notation:Location" xmi:id="_5r5pNn8VEemiUoPdWqOlQg" y="60"/> | ||
636 | </children> | ||
637 | <styles xmi:type="notation:FontStyle" xmi:id="_5r5pMX8VEemiUoPdWqOlQg" fontName="Noto Sans"/> | ||
638 | <element xmi:type="henshin:Edge" href="cps.henshin#_5r5CIH8VEemiUoPdWqOlQg"/> | ||
639 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_5r5pMn8VEemiUoPdWqOlQg" points="[-3, 23, -3, -157]$[-3, 157, -3, -23]"/> | ||
640 | </edges> | ||
641 | <edges xmi:type="notation:Connector" xmi:id="_-vsTMH8VEemiUoPdWqOlQg" type="4001" source="_Xr_OIH8VEemiUoPdWqOlQg" target="_Y0FeoH8VEemiUoPdWqOlQg"> | ||
642 | <children xmi:type="notation:DecorationNode" xmi:id="_-vsTM38VEemiUoPdWqOlQg" type="6001"> | ||
643 | <layoutConstraint xmi:type="notation:Location" xmi:id="_-vsTNH8VEemiUoPdWqOlQg" y="40"/> | ||
644 | </children> | ||
645 | <children xmi:type="notation:DecorationNode" xmi:id="_-vsTNX8VEemiUoPdWqOlQg" type="6002"> | ||
646 | <layoutConstraint xmi:type="notation:Location" xmi:id="_-vsTNn8VEemiUoPdWqOlQg" y="60"/> | ||
647 | </children> | ||
648 | <styles xmi:type="notation:FontStyle" xmi:id="_-vsTMX8VEemiUoPdWqOlQg" fontName="Noto Sans"/> | ||
649 | <element xmi:type="henshin:Edge" href="cps.henshin#_-vrFEH8VEemiUoPdWqOlQg"/> | ||
650 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_-vsTMn8VEemiUoPdWqOlQg" points="[59, -14, -295, 53]$[346, -90, -8, -23]"/> | ||
651 | </edges> | ||
652 | <edges xmi:type="notation:Connector" xmi:id="__Tfj0H8VEemiUoPdWqOlQg" type="4001" source="_cTdIgH8VEemiUoPdWqOlQg" target="_Y0FeoH8VEemiUoPdWqOlQg"> | ||
653 | <children xmi:type="notation:DecorationNode" xmi:id="__Tfj038VEemiUoPdWqOlQg" type="6001"> | ||
654 | <layoutConstraint xmi:type="notation:Location" xmi:id="__Tfj1H8VEemiUoPdWqOlQg" y="40"/> | ||
655 | </children> | ||
656 | <children xmi:type="notation:DecorationNode" xmi:id="__Tfj1X8VEemiUoPdWqOlQg" type="6002"> | ||
657 | <layoutConstraint xmi:type="notation:Location" xmi:id="__Tfj1n8VEemiUoPdWqOlQg" y="60"/> | ||
658 | </children> | ||
659 | <styles xmi:type="notation:FontStyle" xmi:id="__Tfj0X8VEemiUoPdWqOlQg" fontName="Noto Sans"/> | ||
660 | <element xmi:type="henshin:Edge" href="cps.henshin#__Te8wH8VEemiUoPdWqOlQg"/> | ||
661 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="__Tfj0n8VEemiUoPdWqOlQg" points="[11, 2, -295, -62]$[266, 56, -40, -8]"/> | ||
662 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="__TiAEH8VEemiUoPdWqOlQg" id="(0.905982905982906,0.4782608695652174)"/> | ||
663 | </edges> | ||
664 | <edges xmi:type="notation:Connector" xmi:id="_H6qjEH8YEemiUoPdWqOlQg" type="4001" source="_A8fQAH8YEemiUoPdWqOlQg" target="_DowB8H8YEemiUoPdWqOlQg"> | ||
665 | <children xmi:type="notation:DecorationNode" xmi:id="_H6qjE38YEemiUoPdWqOlQg" type="6001"> | ||
666 | <layoutConstraint xmi:type="notation:Location" xmi:id="_H6qjFH8YEemiUoPdWqOlQg" y="40"/> | ||
667 | </children> | ||
668 | <children xmi:type="notation:DecorationNode" xmi:id="_H6qjFX8YEemiUoPdWqOlQg" type="6002"> | ||
669 | <layoutConstraint xmi:type="notation:Location" xmi:id="_H6qjFn8YEemiUoPdWqOlQg" y="60"/> | ||
670 | </children> | ||
671 | <styles xmi:type="notation:FontStyle" xmi:id="_H6qjEX8YEemiUoPdWqOlQg" fontName="Noto Sans"/> | ||
672 | <element xmi:type="henshin:Edge" href="cps.henshin#_H6p8AH8YEemiUoPdWqOlQg"/> | ||
673 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_H6qjEn8YEemiUoPdWqOlQg" points="[-3, 23, -2, -129]$[-3, 175, -2, 23]"/> | ||
674 | </edges> | ||
675 | <edges xmi:type="notation:Connector" xmi:id="_IR7MgX8YEemiUoPdWqOlQg" type="4001" source="_AUGaUH8YEemiUoPdWqOlQg" target="_DowB8H8YEemiUoPdWqOlQg"> | ||
676 | <children xmi:type="notation:DecorationNode" xmi:id="_IR7zkH8YEemiUoPdWqOlQg" type="6001"> | ||
677 | <layoutConstraint xmi:type="notation:Location" xmi:id="_IR7zkX8YEemiUoPdWqOlQg" y="40"/> | ||
678 | </children> | ||
679 | <children xmi:type="notation:DecorationNode" xmi:id="_IR7zkn8YEemiUoPdWqOlQg" type="6002"> | ||
680 | <layoutConstraint xmi:type="notation:Location" xmi:id="_IR7zk38YEemiUoPdWqOlQg" y="60"/> | ||
681 | </children> | ||
682 | <styles xmi:type="notation:FontStyle" xmi:id="_IR7Mgn8YEemiUoPdWqOlQg" fontName="Noto Sans"/> | ||
683 | <element xmi:type="henshin:Edge" href="cps.henshin#_IR7MgH8YEemiUoPdWqOlQg"/> | ||
684 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_IR7Mg38YEemiUoPdWqOlQg" points="[29, 23, -155, -122]$[160, 140, -24, -5]"/> | ||
685 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_IR8aoH8YEemiUoPdWqOlQg" id="(0.20512820512820512,0.34782608695652173)"/> | ||
686 | </edges> | ||
687 | <edges xmi:type="notation:Connector" xmi:id="_InE9IH8YEemiUoPdWqOlQg" type="4001" source="_AUGaUH8YEemiUoPdWqOlQg" target="_A8fQAH8YEemiUoPdWqOlQg"> | ||
688 | <children xmi:type="notation:DecorationNode" xmi:id="_InE9I38YEemiUoPdWqOlQg" type="6001"> | ||
689 | <layoutConstraint xmi:type="notation:Location" xmi:id="_InE9JH8YEemiUoPdWqOlQg" y="40"/> | ||
690 | </children> | ||
691 | <children xmi:type="notation:DecorationNode" xmi:id="_InE9JX8YEemiUoPdWqOlQg" type="6002"> | ||
692 | <layoutConstraint xmi:type="notation:Location" xmi:id="_InE9Jn8YEemiUoPdWqOlQg" y="60"/> | ||
693 | </children> | ||
694 | <styles xmi:type="notation:FontStyle" xmi:id="_InE9IX8YEemiUoPdWqOlQg" fontName="Noto Sans"/> | ||
695 | <element xmi:type="henshin:Edge" href="cps.henshin#_InEWEH8YEemiUoPdWqOlQg"/> | ||
696 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_InE9In8YEemiUoPdWqOlQg" points="[16, 8, -179, 9]$[188, 22, -7, 23]"/> | ||
697 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_InGLQH8YEemiUoPdWqOlQg" id="(0.7974683544303798,0.5217391304347826)"/> | ||
698 | </edges> | ||
699 | </notation:Diagram> | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.properties b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.properties new file mode 100644 index 00000000..aa7cf04c --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.properties | |||
@@ -0,0 +1,4 @@ | |||
1 | # | ||
2 | |||
3 | pluginName = hu.bme.mit.inf.dslreasoner.domains.cps | ||
4 | providerName = www.example.org | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml new file mode 100644 index 00000000..5a0fee8d --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml | |||
@@ -0,0 +1,27 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?><?eclipse version="3.0"?><!-- | ||
2 | --><plugin> | ||
3 | <extension point="org.eclipse.emf.ecore.generated_package"> | ||
4 | <!-- @generated cps --> | ||
5 | <package class="hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage" genModel="model/cps.genmodel" uri="http://www.example.org/cps"/> | ||
6 | </extension> | ||
7 | <extension id="hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsQueries" point="org.eclipse.viatra.query.runtime.queryspecification"> | ||
8 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsQueries" id="hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsQueries"> | ||
9 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement"/> | ||
10 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocationWithoutResourceRequirement"/> | ||
11 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory"/> | ||
12 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableHdd"/> | ||
13 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.instanceDoesNotSatisfyRequirement"/> | ||
14 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.requirementNotSatisfied"/> | ||
15 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.redundantInstancesOnSameHost"/> | ||
16 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeMemoryMetric"/> | ||
17 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric"/> | ||
18 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.costMetric"/> | ||
19 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsCost"/> | ||
20 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocate"/> | ||
21 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.unallocateAppInstance"/> | ||
22 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.createHostInstance"/> | ||
23 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.removeHostInstance"/> | ||
24 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.cps.queries.guidanceObjective"/> | ||
25 | </group> | ||
26 | </extension> | ||
27 | </plugin> | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/representations.aird b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/representations.aird new file mode 100644 index 00000000..dbaf9f8c --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/representations.aird | |||
@@ -0,0 +1,600 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:diagram="http://www.eclipse.org/sirius/diagram/1.1.0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:viewpoint="http://www.eclipse.org/sirius/1.1.0" xsi:schemaLocation="http://www.eclipse.org/sirius/description/1.1.0 http://www.eclipse.org/sirius/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/style/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description/style"> | ||
3 | <viewpoint:DAnalysis uid="_hQ-pEHpMEem6LP4EDiey6Q" selectedViews="_jsELcHpMEem6LP4EDiey6Q" version="14.1.0.201810161215"> | ||
4 | <semanticResources>model/cps.ecore</semanticResources> | ||
5 | <semanticResources>http://www.eclipse.org/emf/2002/Ecore</semanticResources> | ||
6 | <semanticResources>model/cps.genmodel</semanticResources> | ||
7 | <semanticResources>src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.xtend</semanticResources> | ||
8 | <semanticResources>src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend</semanticResources> | ||
9 | <semanticResources>src/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.xtend</semanticResources> | ||
10 | <semanticResources>src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql</semanticResources> | ||
11 | <semanticResources>src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.xtend</semanticResources> | ||
12 | <ownedViews xmi:type="viewpoint:DView" uid="_jsELcHpMEem6LP4EDiey6Q"> | ||
13 | <viewpoint xmi:type="description:Viewpoint" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']"/> | ||
14 | <ownedRepresentationDescriptors xmi:type="viewpoint:DRepresentationDescriptor" uid="_kBjTQHpMEem6LP4EDiey6Q" name="cps class diagram" repPath="#_kAPrsHpMEem6LP4EDiey6Q"> | ||
15 | <description xmi:type="description_1:DiagramDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']"/> | ||
16 | <target xmi:type="ecore:EPackage" href="model/cps.ecore#/"/> | ||
17 | </ownedRepresentationDescriptors> | ||
18 | </ownedViews> | ||
19 | </viewpoint:DAnalysis> | ||
20 | <diagram:DSemanticDiagram uid="_kAPrsHpMEem6LP4EDiey6Q" name="cps class diagram"> | ||
21 | <ownedAnnotationEntries xmi:type="description:AnnotationEntry" uid="_kBb-gHpMEem6LP4EDiey6Q" source="DANNOTATION_CUSTOMIZATION_KEY"> | ||
22 | <data xmi:type="diagram:ComputedStyleDescriptionRegistry" uid="_kBclkHpMEem6LP4EDiey6Q"> | ||
23 | <computedStyleDescriptions xmi:type="style:BundledImageDescription" xmi:id="_kku40HpMEem6LP4EDiey6Q" labelExpression="service:render" labelAlignment="LEFT" tooltipExpression="service:renderTooltip" sizeComputationExpression="1"> | ||
24 | <borderColor xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> | ||
25 | <labelFormat>bold</labelFormat> | ||
26 | <labelColor xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> | ||
27 | <color xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> | ||
28 | </computedStyleDescriptions> | ||
29 | <computedStyleDescriptions xmi:type="style:EdgeStyleDescription" xmi:id="_kk538HpMEem6LP4EDiey6Q" sourceArrow="FillDiamond" routingStyle="manhattan"> | ||
30 | <strokeColor xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> | ||
31 | <centerLabelStyleDescription xmi:type="style:CenterLabelStyleDescription" xmi:id="_kk538XpMEem6LP4EDiey6Q" showIcon="false" labelExpression="service:render"> | ||
32 | <labelColor xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> | ||
33 | </centerLabelStyleDescription> | ||
34 | <endLabelStyleDescription xmi:type="style:EndLabelStyleDescription" xmi:id="_kk538npMEem6LP4EDiey6Q" labelSize="6" showIcon="false" labelExpression="service:eKeysLabel"> | ||
35 | <labelColor xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='dark_blue']"/> | ||
36 | </endLabelStyleDescription> | ||
37 | </computedStyleDescriptions> | ||
38 | <computedStyleDescriptions xmi:type="style:EdgeStyleDescription" xmi:id="_kk_-kHpMEem6LP4EDiey6Q" routingStyle="manhattan"> | ||
39 | <strokeColor xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> | ||
40 | <centerLabelStyleDescription xmi:type="style:CenterLabelStyleDescription" xmi:id="_kk_-kXpMEem6LP4EDiey6Q" showIcon="false" labelExpression="service:render"> | ||
41 | <labelFormat>bold</labelFormat> | ||
42 | <labelColor xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> | ||
43 | </centerLabelStyleDescription> | ||
44 | <endLabelStyleDescription xmi:type="style:EndLabelStyleDescription" xmi:id="_kk_-knpMEem6LP4EDiey6Q" labelSize="6" showIcon="false" labelExpression="service:eKeysLabel"> | ||
45 | <labelColor xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='dark_blue']"/> | ||
46 | </endLabelStyleDescription> | ||
47 | </computedStyleDescriptions> | ||
48 | <computedStyleDescriptions xmi:type="style:EdgeStyleDescription" xmi:id="_klBzwHpMEem6LP4EDiey6Q" sourceArrow="InputArrow" routingStyle="manhattan"> | ||
49 | <strokeColor xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> | ||
50 | <beginLabelStyleDescription xmi:type="style:BeginLabelStyleDescription" xmi:id="_klBzwXpMEem6LP4EDiey6Q" showIcon="false" labelExpression="service:renderEOpposite"> | ||
51 | <labelFormat>bold</labelFormat> | ||
52 | <labelColor xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> | ||
53 | </beginLabelStyleDescription> | ||
54 | <endLabelStyleDescription xmi:type="style:EndLabelStyleDescription" xmi:id="_klBzwnpMEem6LP4EDiey6Q" showIcon="false" labelExpression="service:render"> | ||
55 | <labelFormat>bold</labelFormat> | ||
56 | <labelColor xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> | ||
57 | </endLabelStyleDescription> | ||
58 | </computedStyleDescriptions> | ||
59 | <computedStyleDescriptions xmi:type="style:EdgeStyleDescription" xmi:id="_klDo8HpMEem6LP4EDiey6Q" sourceArrow="FillDiamond" routingStyle="manhattan"> | ||
60 | <strokeColor xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> | ||
61 | <beginLabelStyleDescription xmi:type="style:BeginLabelStyleDescription" xmi:id="_klDo8XpMEem6LP4EDiey6Q" showIcon="false" labelExpression="service:renderEOpposite"> | ||
62 | <labelColor xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> | ||
63 | </beginLabelStyleDescription> | ||
64 | <endLabelStyleDescription xmi:type="style:EndLabelStyleDescription" xmi:id="_klDo8npMEem6LP4EDiey6Q" showIcon="false" labelExpression="service:render"> | ||
65 | <labelColor xmi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> | ||
66 | </endLabelStyleDescription> | ||
67 | </computedStyleDescriptions> | ||
68 | </data> | ||
69 | </ownedAnnotationEntries> | ||
70 | <ownedAnnotationEntries xmi:type="description:AnnotationEntry" uid="_kCIiEHpMEem6LP4EDiey6Q" source="GMF_DIAGRAMS"> | ||
71 | <data xmi:type="notation:Diagram" xmi:id="_kCIiEXpMEem6LP4EDiey6Q" type="Sirius" element="_kAPrsHpMEem6LP4EDiey6Q" measurementUnit="Pixel"> | ||
72 | <children xmi:type="notation:Node" xmi:id="_klH6YHpMEem6LP4EDiey6Q" type="2003" element="_kkaIsHpMEem6LP4EDiey6Q"> | ||
73 | <children xmi:type="notation:Node" xmi:id="_klIhcHpMEem6LP4EDiey6Q" type="5007"/> | ||
74 | <children xmi:type="notation:Node" xmi:id="_klKWoHpMEem6LP4EDiey6Q" type="7004"> | ||
75 | <styles xmi:type="notation:SortingStyle" xmi:id="_klKWoXpMEem6LP4EDiey6Q"/> | ||
76 | <styles xmi:type="notation:FilteringStyle" xmi:id="_klKWonpMEem6LP4EDiey6Q"/> | ||
77 | </children> | ||
78 | <styles xmi:type="notation:ShapeStyle" xmi:id="_klH6YXpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8"/> | ||
79 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klH6YnpMEem6LP4EDiey6Q" x="200" y="960"/> | ||
80 | </children> | ||
81 | <children xmi:type="notation:Node" xmi:id="_klK9sHpMEem6LP4EDiey6Q" type="2003" element="_kkeaIHpMEem6LP4EDiey6Q"> | ||
82 | <children xmi:type="notation:Node" xmi:id="_klK9s3pMEem6LP4EDiey6Q" type="5007"/> | ||
83 | <children xmi:type="notation:Node" xmi:id="_klK9tHpMEem6LP4EDiey6Q" type="7004"> | ||
84 | <styles xmi:type="notation:SortingStyle" xmi:id="_klK9tXpMEem6LP4EDiey6Q"/> | ||
85 | <styles xmi:type="notation:FilteringStyle" xmi:id="_klK9tnpMEem6LP4EDiey6Q"/> | ||
86 | </children> | ||
87 | <styles xmi:type="notation:ShapeStyle" xmi:id="_klK9sXpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8"/> | ||
88 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klK9snpMEem6LP4EDiey6Q" x="200" y="480"/> | ||
89 | </children> | ||
90 | <children xmi:type="notation:Node" xmi:id="_klK9t3pMEem6LP4EDiey6Q" type="2003" element="_kkfoQXpMEem6LP4EDiey6Q"> | ||
91 | <children xmi:type="notation:Node" xmi:id="_klLkwHpMEem6LP4EDiey6Q" type="5007"/> | ||
92 | <children xmi:type="notation:Node" xmi:id="_klLkwXpMEem6LP4EDiey6Q" type="7004"> | ||
93 | <children xmi:type="notation:Node" xmi:id="_klOoEHpMEem6LP4EDiey6Q" type="3010" element="_kktqsHpMEem6LP4EDiey6Q"> | ||
94 | <styles xmi:type="notation:FontStyle" xmi:id="_klOoEXpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8" bold="true"/> | ||
95 | <layoutConstraint xmi:type="notation:Location" xmi:id="_klOoEnpMEem6LP4EDiey6Q"/> | ||
96 | </children> | ||
97 | <children xmi:type="notation:Node" xmi:id="_klPPIHpMEem6LP4EDiey6Q" type="3010" element="_kkxVEHpMEem6LP4EDiey6Q"> | ||
98 | <styles xmi:type="notation:FontStyle" xmi:id="_klPPIXpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8" bold="true"/> | ||
99 | <layoutConstraint xmi:type="notation:Location" xmi:id="_klPPInpMEem6LP4EDiey6Q"/> | ||
100 | </children> | ||
101 | <children xmi:type="notation:Node" xmi:id="_klPPI3pMEem6LP4EDiey6Q" type="3010" element="_kkxVEnpMEem6LP4EDiey6Q"> | ||
102 | <styles xmi:type="notation:FontStyle" xmi:id="_klPPJHpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8" bold="true"/> | ||
103 | <layoutConstraint xmi:type="notation:Location" xmi:id="_klPPJXpMEem6LP4EDiey6Q"/> | ||
104 | </children> | ||
105 | <styles xmi:type="notation:SortingStyle" xmi:id="_klLkwnpMEem6LP4EDiey6Q"/> | ||
106 | <styles xmi:type="notation:FilteringStyle" xmi:id="_klLkw3pMEem6LP4EDiey6Q"/> | ||
107 | </children> | ||
108 | <styles xmi:type="notation:ShapeStyle" xmi:id="_klK9uHpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8"/> | ||
109 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klK9uXpMEem6LP4EDiey6Q" x="140" y="160"/> | ||
110 | </children> | ||
111 | <children xmi:type="notation:Node" xmi:id="_klLkxHpMEem6LP4EDiey6Q" type="2003" element="_kkhdcHpMEem6LP4EDiey6Q"> | ||
112 | <children xmi:type="notation:Node" xmi:id="_klML0HpMEem6LP4EDiey6Q" type="5007"/> | ||
113 | <children xmi:type="notation:Node" xmi:id="_klML0XpMEem6LP4EDiey6Q" type="7004"> | ||
114 | <styles xmi:type="notation:SortingStyle" xmi:id="_klML0npMEem6LP4EDiey6Q"/> | ||
115 | <styles xmi:type="notation:FilteringStyle" xmi:id="_klML03pMEem6LP4EDiey6Q"/> | ||
116 | </children> | ||
117 | <styles xmi:type="notation:ShapeStyle" xmi:id="_klLkxXpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8"/> | ||
118 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klLkxnpMEem6LP4EDiey6Q" x="380" y="800"/> | ||
119 | </children> | ||
120 | <children xmi:type="notation:Node" xmi:id="_klML1HpMEem6LP4EDiey6Q" type="2003" element="_kkirkHpMEem6LP4EDiey6Q"> | ||
121 | <children xmi:type="notation:Node" xmi:id="_klML13pMEem6LP4EDiey6Q" type="5007"/> | ||
122 | <children xmi:type="notation:Node" xmi:id="_klML2HpMEem6LP4EDiey6Q" type="7004"> | ||
123 | <children xmi:type="notation:Node" xmi:id="_klP2MHpMEem6LP4EDiey6Q" type="3010" element="_kkyjMHpMEem6LP4EDiey6Q"> | ||
124 | <styles xmi:type="notation:FontStyle" xmi:id="_klP2MXpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8" bold="true"/> | ||
125 | <layoutConstraint xmi:type="notation:Location" xmi:id="_klP2MnpMEem6LP4EDiey6Q"/> | ||
126 | </children> | ||
127 | <styles xmi:type="notation:SortingStyle" xmi:id="_klML2XpMEem6LP4EDiey6Q"/> | ||
128 | <styles xmi:type="notation:FilteringStyle" xmi:id="_klML2npMEem6LP4EDiey6Q"/> | ||
129 | </children> | ||
130 | <styles xmi:type="notation:ShapeStyle" xmi:id="_klML1XpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8"/> | ||
131 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klML1npMEem6LP4EDiey6Q" x="380" y="640"/> | ||
132 | </children> | ||
133 | <children xmi:type="notation:Node" xmi:id="_klML23pMEem6LP4EDiey6Q" type="2003" element="_kkjSoXpMEem6LP4EDiey6Q"> | ||
134 | <children xmi:type="notation:Node" xmi:id="_klMy4HpMEem6LP4EDiey6Q" type="5007"/> | ||
135 | <children xmi:type="notation:Node" xmi:id="_klMy4XpMEem6LP4EDiey6Q" type="7004"> | ||
136 | <styles xmi:type="notation:SortingStyle" xmi:id="_klMy4npMEem6LP4EDiey6Q"/> | ||
137 | <styles xmi:type="notation:FilteringStyle" xmi:id="_klMy43pMEem6LP4EDiey6Q"/> | ||
138 | </children> | ||
139 | <styles xmi:type="notation:ShapeStyle" xmi:id="_klML3HpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8"/> | ||
140 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klML3XpMEem6LP4EDiey6Q" x="400" y="320"/> | ||
141 | </children> | ||
142 | <children xmi:type="notation:Node" xmi:id="_klMy5HpMEem6LP4EDiey6Q" type="2003" element="_kkkgwHpMEem6LP4EDiey6Q"> | ||
143 | <children xmi:type="notation:Node" xmi:id="_klNZ8HpMEem6LP4EDiey6Q" type="5007"/> | ||
144 | <children xmi:type="notation:Node" xmi:id="_klNZ8XpMEem6LP4EDiey6Q" type="7004"> | ||
145 | <children xmi:type="notation:Node" xmi:id="_klP2M3pMEem6LP4EDiey6Q" type="3010" element="_kkzKQHpMEem6LP4EDiey6Q"> | ||
146 | <styles xmi:type="notation:FontStyle" xmi:id="_klP2NHpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8" bold="true"/> | ||
147 | <layoutConstraint xmi:type="notation:Location" xmi:id="_klP2NXpMEem6LP4EDiey6Q"/> | ||
148 | </children> | ||
149 | <children xmi:type="notation:Node" xmi:id="_klP2NnpMEem6LP4EDiey6Q" type="3010" element="_kkzxUXpMEem6LP4EDiey6Q"> | ||
150 | <styles xmi:type="notation:FontStyle" xmi:id="_klP2N3pMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8" bold="true"/> | ||
151 | <layoutConstraint xmi:type="notation:Location" xmi:id="_klP2OHpMEem6LP4EDiey6Q"/> | ||
152 | </children> | ||
153 | <styles xmi:type="notation:SortingStyle" xmi:id="_klNZ8npMEem6LP4EDiey6Q"/> | ||
154 | <styles xmi:type="notation:FilteringStyle" xmi:id="_klNZ83pMEem6LP4EDiey6Q"/> | ||
155 | </children> | ||
156 | <styles xmi:type="notation:ShapeStyle" xmi:id="_klMy5XpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8"/> | ||
157 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klMy5npMEem6LP4EDiey6Q" x="180" y="320"/> | ||
158 | </children> | ||
159 | <children xmi:type="notation:Node" xmi:id="_klOBAHpMEem6LP4EDiey6Q" type="2003" element="_kklH0HpMEem6LP4EDiey6Q"> | ||
160 | <children xmi:type="notation:Node" xmi:id="_klOBA3pMEem6LP4EDiey6Q" type="5007"/> | ||
161 | <children xmi:type="notation:Node" xmi:id="_klOBBHpMEem6LP4EDiey6Q" type="7004"> | ||
162 | <styles xmi:type="notation:SortingStyle" xmi:id="_klOBBXpMEem6LP4EDiey6Q"/> | ||
163 | <styles xmi:type="notation:FilteringStyle" xmi:id="_klOBBnpMEem6LP4EDiey6Q"/> | ||
164 | </children> | ||
165 | <styles xmi:type="notation:ShapeStyle" xmi:id="_klOBAXpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8"/> | ||
166 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klOBAnpMEem6LP4EDiey6Q" x="400"/> | ||
167 | </children> | ||
168 | <styles xmi:type="notation:DiagramStyle" xmi:id="_kCIiEnpMEem6LP4EDiey6Q"/> | ||
169 | <edges xmi:type="notation:Edge" xmi:id="_klTgkHpMEem6LP4EDiey6Q" type="4001" element="_kk4p0HpMEem6LP4EDiey6Q" source="_klH6YHpMEem6LP4EDiey6Q" target="_klLkxHpMEem6LP4EDiey6Q"> | ||
170 | <children xmi:type="notation:Node" xmi:id="_klUusHpMEem6LP4EDiey6Q" type="6001"> | ||
171 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klUusXpMEem6LP4EDiey6Q" y="-10"/> | ||
172 | </children> | ||
173 | <children xmi:type="notation:Node" xmi:id="_klVVwHpMEem6LP4EDiey6Q" type="6002"> | ||
174 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klVVwXpMEem6LP4EDiey6Q" y="10"/> | ||
175 | </children> | ||
176 | <children xmi:type="notation:Node" xmi:id="_klVVwnpMEem6LP4EDiey6Q" type="6003"> | ||
177 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klVVw3pMEem6LP4EDiey6Q" y="10"/> | ||
178 | </children> | ||
179 | <styles xmi:type="notation:ConnectorStyle" xmi:id="_klTgkXpMEem6LP4EDiey6Q" routing="Rectilinear"/> | ||
180 | <styles xmi:type="notation:FontStyle" xmi:id="_klTgknpMEem6LP4EDiey6Q" fontColor="7490599" fontName="Noto Sans" fontHeight="8"/> | ||
181 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_klTgk3pMEem6LP4EDiey6Q" points="[0, -50, -181, 110]$[181, -110, 0, 50]"/> | ||
182 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klcqgHpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
183 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klcqgXpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
184 | </edges> | ||
185 | <edges xmi:type="notation:Edge" xmi:id="_kldRkHpMEem6LP4EDiey6Q" type="4001" element="_kk8UMHpMEem6LP4EDiey6Q" source="_klH6YHpMEem6LP4EDiey6Q" target="_klK9sHpMEem6LP4EDiey6Q"> | ||
186 | <children xmi:type="notation:Node" xmi:id="_kldRlHpMEem6LP4EDiey6Q" type="6001"> | ||
187 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kldRlXpMEem6LP4EDiey6Q" y="-10"/> | ||
188 | </children> | ||
189 | <children xmi:type="notation:Node" xmi:id="_kldRlnpMEem6LP4EDiey6Q" type="6002"> | ||
190 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kldRl3pMEem6LP4EDiey6Q" y="10"/> | ||
191 | </children> | ||
192 | <children xmi:type="notation:Node" xmi:id="_kldRmHpMEem6LP4EDiey6Q" type="6003"> | ||
193 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kldRmXpMEem6LP4EDiey6Q" y="10"/> | ||
194 | </children> | ||
195 | <styles xmi:type="notation:ConnectorStyle" xmi:id="_kldRkXpMEem6LP4EDiey6Q" routing="Rectilinear"/> | ||
196 | <styles xmi:type="notation:FontStyle" xmi:id="_kldRknpMEem6LP4EDiey6Q" fontColor="7490599" fontName="Noto Sans" fontHeight="8"/> | ||
197 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_kldRk3pMEem6LP4EDiey6Q" points="[0, -50, 0, 430]$[0, -430, 0, 50]"/> | ||
198 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_kld4oHpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
199 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_kld4oXpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
200 | </edges> | ||
201 | <edges xmi:type="notation:Edge" xmi:id="_kld4onpMEem6LP4EDiey6Q" type="4001" element="_kk87RnpMEem6LP4EDiey6Q" source="_klH6YHpMEem6LP4EDiey6Q" target="_klK9t3pMEem6LP4EDiey6Q"> | ||
202 | <children xmi:type="notation:Node" xmi:id="_kld4pnpMEem6LP4EDiey6Q" type="6001"> | ||
203 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kld4p3pMEem6LP4EDiey6Q" y="-10"/> | ||
204 | </children> | ||
205 | <children xmi:type="notation:Node" xmi:id="_kld4qHpMEem6LP4EDiey6Q" type="6002"> | ||
206 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kld4qXpMEem6LP4EDiey6Q" y="10"/> | ||
207 | </children> | ||
208 | <children xmi:type="notation:Node" xmi:id="_klefsHpMEem6LP4EDiey6Q" type="6003"> | ||
209 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klefsXpMEem6LP4EDiey6Q" y="10"/> | ||
210 | </children> | ||
211 | <styles xmi:type="notation:ConnectorStyle" xmi:id="_kld4o3pMEem6LP4EDiey6Q" routing="Rectilinear"/> | ||
212 | <styles xmi:type="notation:FontStyle" xmi:id="_kld4pHpMEem6LP4EDiey6Q" fontColor="7490599" fontName="Noto Sans" fontHeight="8"/> | ||
213 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_kld4pXpMEem6LP4EDiey6Q" points="[0, -50, 49, 750]$[-180, -111, -131, 689]$[-196, -591, -147, 209]$[-196, -690, -147, 110]$[-49, -750, 0, 50]"/> | ||
214 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klefsnpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
215 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klefs3pMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
216 | </edges> | ||
217 | <edges xmi:type="notation:Edge" xmi:id="_kleftHpMEem6LP4EDiey6Q" type="4001" element="_kk9iVnpMEem6LP4EDiey6Q" source="_klK9sHpMEem6LP4EDiey6Q" target="_klMy5HpMEem6LP4EDiey6Q"> | ||
218 | <children xmi:type="notation:Node" xmi:id="_klefuHpMEem6LP4EDiey6Q" type="6001"> | ||
219 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klefuXpMEem6LP4EDiey6Q" y="-10"/> | ||
220 | </children> | ||
221 | <children xmi:type="notation:Node" xmi:id="_klefunpMEem6LP4EDiey6Q" type="6002"> | ||
222 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klefu3pMEem6LP4EDiey6Q" y="10"/> | ||
223 | </children> | ||
224 | <children xmi:type="notation:Node" xmi:id="_klefvHpMEem6LP4EDiey6Q" type="6003"> | ||
225 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klefvXpMEem6LP4EDiey6Q" y="10"/> | ||
226 | </children> | ||
227 | <styles xmi:type="notation:ConnectorStyle" xmi:id="_kleftXpMEem6LP4EDiey6Q" routing="Rectilinear"/> | ||
228 | <styles xmi:type="notation:FontStyle" xmi:id="_kleftnpMEem6LP4EDiey6Q" fontColor="7490599" fontName="Noto Sans" fontHeight="8"/> | ||
229 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_kleft3pMEem6LP4EDiey6Q" points="[0, -50, 0, 110]$[0, -110, 0, 50]"/> | ||
230 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klfGwHpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
231 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klfGwXpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
232 | </edges> | ||
233 | <edges xmi:type="notation:Edge" xmi:id="_klfGwnpMEem6LP4EDiey6Q" type="4001" element="_kk-wcHpMEem6LP4EDiey6Q" source="_klML1HpMEem6LP4EDiey6Q" target="_klK9sHpMEem6LP4EDiey6Q"> | ||
234 | <children xmi:type="notation:Node" xmi:id="_klfGxnpMEem6LP4EDiey6Q" type="6001"> | ||
235 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klfGx3pMEem6LP4EDiey6Q" y="-10"/> | ||
236 | </children> | ||
237 | <children xmi:type="notation:Node" xmi:id="_klfGyHpMEem6LP4EDiey6Q" type="6002"> | ||
238 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klfGyXpMEem6LP4EDiey6Q" y="10"/> | ||
239 | </children> | ||
240 | <children xmi:type="notation:Node" xmi:id="_klfGynpMEem6LP4EDiey6Q" type="6003"> | ||
241 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klfGy3pMEem6LP4EDiey6Q" y="10"/> | ||
242 | </children> | ||
243 | <styles xmi:type="notation:ConnectorStyle" xmi:id="_klfGw3pMEem6LP4EDiey6Q" routing="Rectilinear"/> | ||
244 | <styles xmi:type="notation:FontStyle" xmi:id="_klfGxHpMEem6LP4EDiey6Q" fontColor="7490599" fontName="Noto Sans" fontHeight="8"/> | ||
245 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_klfGxXpMEem6LP4EDiey6Q" points="[0, 0, 181, 60]$[-181, -60, 0, 0]"/> | ||
246 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klft0HpMEem6LP4EDiey6Q" id="(0.5,0.0)"/> | ||
247 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klft0XpMEem6LP4EDiey6Q" id="(0.5,1.0)"/> | ||
248 | </edges> | ||
249 | <edges xmi:type="notation:Edge" xmi:id="_klft0npMEem6LP4EDiey6Q" type="4001" element="_kk_Xg3pMEem6LP4EDiey6Q" source="_klMy5HpMEem6LP4EDiey6Q" target="_klK9t3pMEem6LP4EDiey6Q"> | ||
250 | <children xmi:type="notation:Node" xmi:id="_klft1npMEem6LP4EDiey6Q" type="6001"> | ||
251 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klft13pMEem6LP4EDiey6Q" y="-10"/> | ||
252 | </children> | ||
253 | <children xmi:type="notation:Node" xmi:id="_klft2HpMEem6LP4EDiey6Q" type="6002"> | ||
254 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klft2XpMEem6LP4EDiey6Q" y="10"/> | ||
255 | </children> | ||
256 | <children xmi:type="notation:Node" xmi:id="_klft2npMEem6LP4EDiey6Q" type="6003"> | ||
257 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klft23pMEem6LP4EDiey6Q" y="10"/> | ||
258 | </children> | ||
259 | <styles xmi:type="notation:ConnectorStyle" xmi:id="_klft03pMEem6LP4EDiey6Q" routing="Rectilinear"/> | ||
260 | <styles xmi:type="notation:FontStyle" xmi:id="_klft1HpMEem6LP4EDiey6Q" fontColor="7490599" fontName="Noto Sans" fontHeight="8"/> | ||
261 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_klft1XpMEem6LP4EDiey6Q" points="[0, -50, 49, 110]$[-49, -110, 0, 50]"/> | ||
262 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klgU4HpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
263 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klgU4XpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
264 | </edges> | ||
265 | <edges xmi:type="notation:Edge" xmi:id="_klgU4npMEem6LP4EDiey6Q" type="4001" element="_klBMsHpMEem6LP4EDiey6Q" source="_klML23pMEem6LP4EDiey6Q" target="_klOBAHpMEem6LP4EDiey6Q"> | ||
266 | <children xmi:type="notation:Node" xmi:id="_klgU5npMEem6LP4EDiey6Q" type="6001"> | ||
267 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klgU53pMEem6LP4EDiey6Q" y="-10"/> | ||
268 | </children> | ||
269 | <children xmi:type="notation:Node" xmi:id="_klgU6HpMEem6LP4EDiey6Q" type="6002"> | ||
270 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klgU6XpMEem6LP4EDiey6Q" y="10"/> | ||
271 | </children> | ||
272 | <children xmi:type="notation:Node" xmi:id="_klgU6npMEem6LP4EDiey6Q" type="6003"> | ||
273 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klgU63pMEem6LP4EDiey6Q" y="10"/> | ||
274 | </children> | ||
275 | <styles xmi:type="notation:ConnectorStyle" xmi:id="_klgU43pMEem6LP4EDiey6Q" routing="Rectilinear"/> | ||
276 | <styles xmi:type="notation:FontStyle" xmi:id="_klgU5HpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8" bold="true"/> | ||
277 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_klgU5XpMEem6LP4EDiey6Q" points="[0, -50, 0, 270]$[0, -270, 0, 50]"/> | ||
278 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klg78HpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
279 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klg78XpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
280 | </edges> | ||
281 | <edges xmi:type="notation:Edge" xmi:id="_klg78npMEem6LP4EDiey6Q" type="4001" element="_klDB4HpMEem6LP4EDiey6Q" source="_klK9t3pMEem6LP4EDiey6Q" target="_klOBAHpMEem6LP4EDiey6Q"> | ||
282 | <children xmi:type="notation:Node" xmi:id="_klg79npMEem6LP4EDiey6Q" type="6001"> | ||
283 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klg793pMEem6LP4EDiey6Q" y="-10"/> | ||
284 | </children> | ||
285 | <children xmi:type="notation:Node" xmi:id="_klg7-HpMEem6LP4EDiey6Q" type="6002"> | ||
286 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klg7-XpMEem6LP4EDiey6Q" y="10"/> | ||
287 | </children> | ||
288 | <children xmi:type="notation:Node" xmi:id="_klg7-npMEem6LP4EDiey6Q" type="6003"> | ||
289 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klg7-3pMEem6LP4EDiey6Q" y="10"/> | ||
290 | </children> | ||
291 | <styles xmi:type="notation:ConnectorStyle" xmi:id="_klg783pMEem6LP4EDiey6Q" routing="Rectilinear"/> | ||
292 | <styles xmi:type="notation:FontStyle" xmi:id="_klg79HpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8"/> | ||
293 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_klg79XpMEem6LP4EDiey6Q" points="[0, -50, -247, 110]$[247, -110, 0, 50]"/> | ||
294 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klhjAHpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
295 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klhjAXpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
296 | </edges> | ||
297 | <edges xmi:type="notation:Edge" xmi:id="_klhjAnpMEem6LP4EDiey6Q" type="4001" element="_klDo-XpMEem6LP4EDiey6Q" source="_klLkxHpMEem6LP4EDiey6Q" target="_klML1HpMEem6LP4EDiey6Q"> | ||
298 | <children xmi:type="notation:Node" xmi:id="_klhjBnpMEem6LP4EDiey6Q" type="6001"> | ||
299 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klhjB3pMEem6LP4EDiey6Q" y="-10"/> | ||
300 | </children> | ||
301 | <children xmi:type="notation:Node" xmi:id="_klhjCHpMEem6LP4EDiey6Q" type="6002"> | ||
302 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klhjCXpMEem6LP4EDiey6Q" y="10"/> | ||
303 | </children> | ||
304 | <children xmi:type="notation:Node" xmi:id="_klhjCnpMEem6LP4EDiey6Q" type="6003"> | ||
305 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klhjC3pMEem6LP4EDiey6Q" y="10"/> | ||
306 | </children> | ||
307 | <styles xmi:type="notation:ConnectorStyle" xmi:id="_klhjA3pMEem6LP4EDiey6Q" routing="Rectilinear"/> | ||
308 | <styles xmi:type="notation:FontStyle" xmi:id="_klhjBHpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8"/> | ||
309 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_klhjBXpMEem6LP4EDiey6Q" points="[0, 0, 0, 60]$[0, -60, 0, 0]"/> | ||
310 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_kliKEHpMEem6LP4EDiey6Q" id="(0.5,0.0)"/> | ||
311 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_kliKEXpMEem6LP4EDiey6Q" id="(0.5,1.0)"/> | ||
312 | </edges> | ||
313 | <edges xmi:type="notation:Edge" xmi:id="_kliKEnpMEem6LP4EDiey6Q" type="4001" element="_klEQBnpMEem6LP4EDiey6Q" source="_klK9sHpMEem6LP4EDiey6Q" target="_klML23pMEem6LP4EDiey6Q"> | ||
314 | <children xmi:type="notation:Node" xmi:id="_kliKFnpMEem6LP4EDiey6Q" type="6001"> | ||
315 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kliKF3pMEem6LP4EDiey6Q" x="-5" y="-73"/> | ||
316 | </children> | ||
317 | <children xmi:type="notation:Node" xmi:id="_kliKGHpMEem6LP4EDiey6Q" type="6002"> | ||
318 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kliKGXpMEem6LP4EDiey6Q" x="18" y="18"/> | ||
319 | </children> | ||
320 | <children xmi:type="notation:Node" xmi:id="_kliKGnpMEem6LP4EDiey6Q" type="6003"> | ||
321 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kliKG3pMEem6LP4EDiey6Q" x="-1" y="-45"/> | ||
322 | </children> | ||
323 | <styles xmi:type="notation:ConnectorStyle" xmi:id="_kliKE3pMEem6LP4EDiey6Q" routing="Rectilinear"/> | ||
324 | <styles xmi:type="notation:FontStyle" xmi:id="_kliKFHpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8"/> | ||
325 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_kliKFXpMEem6LP4EDiey6Q" points="[59, 1, -143, 161]$[141, 1, -61, 161]$[141, -111, -61, 49]"/> | ||
326 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klixIHpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
327 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klixIXpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
328 | </edges> | ||
329 | <edges xmi:type="notation:Edge" xmi:id="_klixInpMEem6LP4EDiey6Q" type="4001" element="_klFeIHpMEem6LP4EDiey6Q" source="_klML1HpMEem6LP4EDiey6Q" target="_klML23pMEem6LP4EDiey6Q"> | ||
330 | <children xmi:type="notation:Node" xmi:id="_klixJnpMEem6LP4EDiey6Q" type="6001"> | ||
331 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klixJ3pMEem6LP4EDiey6Q" y="-10"/> | ||
332 | </children> | ||
333 | <children xmi:type="notation:Node" xmi:id="_klixKHpMEem6LP4EDiey6Q" type="6002"> | ||
334 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klixKXpMEem6LP4EDiey6Q" y="10"/> | ||
335 | </children> | ||
336 | <children xmi:type="notation:Node" xmi:id="_klixKnpMEem6LP4EDiey6Q" type="6003"> | ||
337 | <layoutConstraint xmi:type="notation:Bounds" xmi:id="_klixK3pMEem6LP4EDiey6Q" y="10"/> | ||
338 | </children> | ||
339 | <styles xmi:type="notation:ConnectorStyle" xmi:id="_klixI3pMEem6LP4EDiey6Q" routing="Rectilinear"/> | ||
340 | <styles xmi:type="notation:FontStyle" xmi:id="_klixJHpMEem6LP4EDiey6Q" fontName="Noto Sans" fontHeight="8"/> | ||
341 | <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_klixJXpMEem6LP4EDiey6Q" points="[0, -50, -17, 270]$[17, -270, 0, 50]"/> | ||
342 | <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_klixLHpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
343 | <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_kljYMHpMEem6LP4EDiey6Q" id="(0.5,0.5)"/> | ||
344 | </edges> | ||
345 | </data> | ||
346 | </ownedAnnotationEntries> | ||
347 | <ownedDiagramElements xmi:type="diagram:DNodeList" uid="_kkaIsHpMEem6LP4EDiey6Q" name="CyberPhysicalSystem" tooltipText="" outgoingEdges="_kk4p0HpMEem6LP4EDiey6Q _kk8UMHpMEem6LP4EDiey6Q _kk87RnpMEem6LP4EDiey6Q" width="12" height="10"> | ||
348 | <target xmi:type="ecore:EClass" href="model/cps.ecore#//CyberPhysicalSystem"/> | ||
349 | <semanticElements xmi:type="ecore:EClass" href="model/cps.ecore#//CyberPhysicalSystem"/> | ||
350 | <ownedStyle xmi:type="diagram:FlatContainerStyle" uid="_kkdMAHpMEem6LP4EDiey6Q" borderSize="1" borderSizeComputationExpression="1" backgroundStyle="Liquid" foregroundColor="255,252,216"> | ||
351 | <description xmi:type="style:FlatContainerStyleDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@style"/> | ||
352 | </ownedStyle> | ||
353 | <actualMapping xmi:type="description_1:ContainerMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']"/> | ||
354 | </ownedDiagramElements> | ||
355 | <ownedDiagramElements xmi:type="diagram:DNodeList" uid="_kkeaIHpMEem6LP4EDiey6Q" name="ApplicationType" tooltipText="" outgoingEdges="_kk9iVnpMEem6LP4EDiey6Q _klEQBnpMEem6LP4EDiey6Q" incomingEdges="_kk8UMHpMEem6LP4EDiey6Q _kk-wcHpMEem6LP4EDiey6Q" width="12" height="10"> | ||
356 | <target xmi:type="ecore:EClass" href="model/cps.ecore#//ApplicationType"/> | ||
357 | <semanticElements xmi:type="ecore:EClass" href="model/cps.ecore#//ApplicationType"/> | ||
358 | <ownedStyle xmi:type="diagram:FlatContainerStyle" uid="_kkfBMHpMEem6LP4EDiey6Q" borderSize="1" borderSizeComputationExpression="1" backgroundStyle="Liquid" foregroundColor="255,252,216"> | ||
359 | <description xmi:type="style:FlatContainerStyleDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@style"/> | ||
360 | </ownedStyle> | ||
361 | <actualMapping xmi:type="description_1:ContainerMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']"/> | ||
362 | </ownedDiagramElements> | ||
363 | <ownedDiagramElements xmi:type="diagram:DNodeList" uid="_kkfoQXpMEem6LP4EDiey6Q" name="HostType" tooltipText="" outgoingEdges="_klDB4HpMEem6LP4EDiey6Q" incomingEdges="_kk87RnpMEem6LP4EDiey6Q _kk_Xg3pMEem6LP4EDiey6Q" width="12" height="10"> | ||
364 | <target xmi:type="ecore:EClass" href="model/cps.ecore#//HostType"/> | ||
365 | <semanticElements xmi:type="ecore:EClass" href="model/cps.ecore#//HostType"/> | ||
366 | <ownedStyle xmi:type="diagram:FlatContainerStyle" uid="_kkgPUHpMEem6LP4EDiey6Q" borderSize="1" borderSizeComputationExpression="1" backgroundStyle="Liquid" foregroundColor="255,252,216"> | ||
367 | <description xmi:type="style:FlatContainerStyleDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@style"/> | ||
368 | </ownedStyle> | ||
369 | <actualMapping xmi:type="description_1:ContainerMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']"/> | ||
370 | <ownedElements xmi:type="diagram:DNodeListElement" uid="_kktqsHpMEem6LP4EDiey6Q" name="defaultMemory : EInt" tooltipText=""> | ||
371 | <target xmi:type="ecore:EAttribute" href="model/cps.ecore#//HostType/defaultMemory"/> | ||
372 | <semanticElements xmi:type="ecore:EAttribute" href="model/cps.ecore#//HostType/defaultMemory"/> | ||
373 | <ownedStyle xmi:type="diagram:BundledImage" uid="_kkwG8HpMEem6LP4EDiey6Q" labelAlignment="LEFT" description="_kku40HpMEem6LP4EDiey6Q"> | ||
374 | <labelFormat>bold</labelFormat> | ||
375 | </ownedStyle> | ||
376 | <actualMapping xmi:type="description_1:NodeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@subNodeMappings[name='EC%20EAttribute']"/> | ||
377 | </ownedElements> | ||
378 | <ownedElements xmi:type="diagram:DNodeListElement" uid="_kkxVEHpMEem6LP4EDiey6Q" name="defaultHdd : EInt" tooltipText=""> | ||
379 | <target xmi:type="ecore:EAttribute" href="model/cps.ecore#//HostType/defaultHdd"/> | ||
380 | <semanticElements xmi:type="ecore:EAttribute" href="model/cps.ecore#//HostType/defaultHdd"/> | ||
381 | <ownedStyle xmi:type="diagram:BundledImage" uid="_kkxVEXpMEem6LP4EDiey6Q" labelAlignment="LEFT" description="_kku40HpMEem6LP4EDiey6Q"> | ||
382 | <labelFormat>bold</labelFormat> | ||
383 | </ownedStyle> | ||
384 | <actualMapping xmi:type="description_1:NodeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@subNodeMappings[name='EC%20EAttribute']"/> | ||
385 | </ownedElements> | ||
386 | <ownedElements xmi:type="diagram:DNodeListElement" uid="_kkxVEnpMEem6LP4EDiey6Q" name="cost : EInt" tooltipText=""> | ||
387 | <target xmi:type="ecore:EAttribute" href="model/cps.ecore#//HostType/cost"/> | ||
388 | <semanticElements xmi:type="ecore:EAttribute" href="model/cps.ecore#//HostType/cost"/> | ||
389 | <ownedStyle xmi:type="diagram:BundledImage" uid="_kkx8IHpMEem6LP4EDiey6Q" labelAlignment="LEFT" description="_kku40HpMEem6LP4EDiey6Q"> | ||
390 | <labelFormat>bold</labelFormat> | ||
391 | </ownedStyle> | ||
392 | <actualMapping xmi:type="description_1:NodeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@subNodeMappings[name='EC%20EAttribute']"/> | ||
393 | </ownedElements> | ||
394 | </ownedDiagramElements> | ||
395 | <ownedDiagramElements xmi:type="diagram:DNodeList" uid="_kkhdcHpMEem6LP4EDiey6Q" name="Request" tooltipText="" outgoingEdges="_klDo-XpMEem6LP4EDiey6Q" incomingEdges="_kk4p0HpMEem6LP4EDiey6Q" width="12" height="10"> | ||
396 | <target xmi:type="ecore:EClass" href="model/cps.ecore#//Request"/> | ||
397 | <semanticElements xmi:type="ecore:EClass" href="model/cps.ecore#//Request"/> | ||
398 | <ownedStyle xmi:type="diagram:FlatContainerStyle" uid="_kkhdcXpMEem6LP4EDiey6Q" borderSize="1" borderSizeComputationExpression="1" backgroundStyle="Liquid" foregroundColor="255,252,216"> | ||
399 | <description xmi:type="style:FlatContainerStyleDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@style"/> | ||
400 | </ownedStyle> | ||
401 | <actualMapping xmi:type="description_1:ContainerMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']"/> | ||
402 | </ownedDiagramElements> | ||
403 | <ownedDiagramElements xmi:type="diagram:DNodeList" uid="_kkirkHpMEem6LP4EDiey6Q" name="Requirement" tooltipText="" outgoingEdges="_kk-wcHpMEem6LP4EDiey6Q _klFeIHpMEem6LP4EDiey6Q" incomingEdges="_klDo-XpMEem6LP4EDiey6Q" width="12" height="10"> | ||
404 | <target xmi:type="ecore:EClass" href="model/cps.ecore#//Requirement"/> | ||
405 | <semanticElements xmi:type="ecore:EClass" href="model/cps.ecore#//Requirement"/> | ||
406 | <ownedStyle xmi:type="diagram:FlatContainerStyle" uid="_kkirkXpMEem6LP4EDiey6Q" borderSize="1" borderSizeComputationExpression="1" backgroundStyle="Liquid" foregroundColor="255,252,216"> | ||
407 | <description xmi:type="style:FlatContainerStyleDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@style"/> | ||
408 | </ownedStyle> | ||
409 | <actualMapping xmi:type="description_1:ContainerMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']"/> | ||
410 | <ownedElements xmi:type="diagram:DNodeListElement" uid="_kkyjMHpMEem6LP4EDiey6Q" name="count : EInt" tooltipText=""> | ||
411 | <target xmi:type="ecore:EAttribute" href="model/cps.ecore#//Requirement/count"/> | ||
412 | <semanticElements xmi:type="ecore:EAttribute" href="model/cps.ecore#//Requirement/count"/> | ||
413 | <ownedStyle xmi:type="diagram:BundledImage" uid="_kkyjMXpMEem6LP4EDiey6Q" labelAlignment="LEFT" description="_kku40HpMEem6LP4EDiey6Q"> | ||
414 | <labelFormat>bold</labelFormat> | ||
415 | </ownedStyle> | ||
416 | <actualMapping xmi:type="description_1:NodeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@subNodeMappings[name='EC%20EAttribute']"/> | ||
417 | </ownedElements> | ||
418 | </ownedDiagramElements> | ||
419 | <ownedDiagramElements xmi:type="diagram:DNodeList" uid="_kkjSoXpMEem6LP4EDiey6Q" name="ApplicationInstance" tooltipText="" outgoingEdges="_klBMsHpMEem6LP4EDiey6Q" incomingEdges="_klEQBnpMEem6LP4EDiey6Q _klFeIHpMEem6LP4EDiey6Q" width="12" height="10"> | ||
420 | <target xmi:type="ecore:EClass" href="model/cps.ecore#//ApplicationInstance"/> | ||
421 | <semanticElements xmi:type="ecore:EClass" href="model/cps.ecore#//ApplicationInstance"/> | ||
422 | <ownedStyle xmi:type="diagram:FlatContainerStyle" uid="_kkj5sHpMEem6LP4EDiey6Q" borderSize="1" borderSizeComputationExpression="1" backgroundStyle="Liquid" foregroundColor="255,252,216"> | ||
423 | <description xmi:type="style:FlatContainerStyleDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@style"/> | ||
424 | </ownedStyle> | ||
425 | <actualMapping xmi:type="description_1:ContainerMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']"/> | ||
426 | </ownedDiagramElements> | ||
427 | <ownedDiagramElements xmi:type="diagram:DNodeList" uid="_kkkgwHpMEem6LP4EDiey6Q" name="ResourceRequirement" tooltipText="" outgoingEdges="_kk_Xg3pMEem6LP4EDiey6Q" incomingEdges="_kk9iVnpMEem6LP4EDiey6Q" width="12" height="10"> | ||
428 | <target xmi:type="ecore:EClass" href="model/cps.ecore#//ResourceRequirement"/> | ||
429 | <semanticElements xmi:type="ecore:EClass" href="model/cps.ecore#//ResourceRequirement"/> | ||
430 | <ownedStyle xmi:type="diagram:FlatContainerStyle" uid="_kkkgwXpMEem6LP4EDiey6Q" borderSize="1" borderSizeComputationExpression="1" backgroundStyle="Liquid" foregroundColor="255,252,216"> | ||
431 | <description xmi:type="style:FlatContainerStyleDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@style"/> | ||
432 | </ownedStyle> | ||
433 | <actualMapping xmi:type="description_1:ContainerMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']"/> | ||
434 | <ownedElements xmi:type="diagram:DNodeListElement" uid="_kkzKQHpMEem6LP4EDiey6Q" name="requiredMemory : EInt" tooltipText=""> | ||
435 | <target xmi:type="ecore:EAttribute" href="model/cps.ecore#//ResourceRequirement/requiredMemory"/> | ||
436 | <semanticElements xmi:type="ecore:EAttribute" href="model/cps.ecore#//ResourceRequirement/requiredMemory"/> | ||
437 | <ownedStyle xmi:type="diagram:BundledImage" uid="_kkzxUHpMEem6LP4EDiey6Q" labelAlignment="LEFT" description="_kku40HpMEem6LP4EDiey6Q"> | ||
438 | <labelFormat>bold</labelFormat> | ||
439 | </ownedStyle> | ||
440 | <actualMapping xmi:type="description_1:NodeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@subNodeMappings[name='EC%20EAttribute']"/> | ||
441 | </ownedElements> | ||
442 | <ownedElements xmi:type="diagram:DNodeListElement" uid="_kkzxUXpMEem6LP4EDiey6Q" name="requiredHdd : EInt" tooltipText=""> | ||
443 | <target xmi:type="ecore:EAttribute" href="model/cps.ecore#//ResourceRequirement/requiredHdd"/> | ||
444 | <semanticElements xmi:type="ecore:EAttribute" href="model/cps.ecore#//ResourceRequirement/requiredHdd"/> | ||
445 | <ownedStyle xmi:type="diagram:BundledImage" uid="_kk0YYHpMEem6LP4EDiey6Q" labelAlignment="LEFT" description="_kku40HpMEem6LP4EDiey6Q"> | ||
446 | <labelFormat>bold</labelFormat> | ||
447 | </ownedStyle> | ||
448 | <actualMapping xmi:type="description_1:NodeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@subNodeMappings[name='EC%20EAttribute']"/> | ||
449 | </ownedElements> | ||
450 | </ownedDiagramElements> | ||
451 | <ownedDiagramElements xmi:type="diagram:DNodeList" uid="_kklH0HpMEem6LP4EDiey6Q" name="HostInstance" tooltipText="" incomingEdges="_klBMsHpMEem6LP4EDiey6Q _klDB4HpMEem6LP4EDiey6Q" width="12" height="10"> | ||
452 | <target xmi:type="ecore:EClass" href="model/cps.ecore#//HostInstance"/> | ||
453 | <semanticElements xmi:type="ecore:EClass" href="model/cps.ecore#//HostInstance"/> | ||
454 | <ownedStyle xmi:type="diagram:FlatContainerStyle" uid="_kklH0XpMEem6LP4EDiey6Q" borderSize="1" borderSizeComputationExpression="1" backgroundStyle="Liquid" foregroundColor="255,252,216"> | ||
455 | <description xmi:type="style:FlatContainerStyleDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@style"/> | ||
456 | </ownedStyle> | ||
457 | <actualMapping xmi:type="description_1:ContainerMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']"/> | ||
458 | </ownedDiagramElements> | ||
459 | <ownedDiagramElements xmi:type="diagram:DEdge" uid="_kk4p0HpMEem6LP4EDiey6Q" name="[0..*] requests" sourceNode="_kkaIsHpMEem6LP4EDiey6Q" targetNode="_kkhdcHpMEem6LP4EDiey6Q"> | ||
460 | <target xmi:type="ecore:EReference" href="model/cps.ecore#//CyberPhysicalSystem/requests"/> | ||
461 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//CyberPhysicalSystem/requests"/> | ||
462 | <ownedStyle xmi:type="diagram:EdgeStyle" uid="_kk7GEHpMEem6LP4EDiey6Q" description="_kk538HpMEem6LP4EDiey6Q" sourceArrow="FillDiamond" routingStyle="manhattan" strokeColor="0,0,0"> | ||
463 | <centerLabelStyle xmi:type="diagram:CenterLabelStyle" uid="_kk7tIXpMEem6LP4EDiey6Q" showIcon="false"> | ||
464 | <customFeatures>labelSize</customFeatures> | ||
465 | </centerLabelStyle> | ||
466 | <endLabelStyle xmi:type="diagram:EndLabelStyle" uid="_kk7tIHpMEem6LP4EDiey6Q" showIcon="false" labelColor="39,76,114"> | ||
467 | <customFeatures>labelSize</customFeatures> | ||
468 | </endLabelStyle> | ||
469 | </ownedStyle> | ||
470 | <actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='EC_EReference']"/> | ||
471 | </ownedDiagramElements> | ||
472 | <ownedDiagramElements xmi:type="diagram:DEdge" uid="_kk8UMHpMEem6LP4EDiey6Q" name="[0..*] applicationTypes" sourceNode="_kkaIsHpMEem6LP4EDiey6Q" targetNode="_kkeaIHpMEem6LP4EDiey6Q"> | ||
473 | <target xmi:type="ecore:EReference" href="model/cps.ecore#//CyberPhysicalSystem/applicationTypes"/> | ||
474 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//CyberPhysicalSystem/applicationTypes"/> | ||
475 | <ownedStyle xmi:type="diagram:EdgeStyle" uid="_kk87QHpMEem6LP4EDiey6Q" description="_kk538HpMEem6LP4EDiey6Q" sourceArrow="FillDiamond" routingStyle="manhattan" strokeColor="0,0,0"> | ||
476 | <centerLabelStyle xmi:type="diagram:CenterLabelStyle" uid="_kk87QnpMEem6LP4EDiey6Q" showIcon="false"> | ||
477 | <customFeatures>labelSize</customFeatures> | ||
478 | </centerLabelStyle> | ||
479 | <endLabelStyle xmi:type="diagram:EndLabelStyle" uid="_kk87QXpMEem6LP4EDiey6Q" showIcon="false" labelColor="39,76,114"> | ||
480 | <customFeatures>labelSize</customFeatures> | ||
481 | </endLabelStyle> | ||
482 | </ownedStyle> | ||
483 | <actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='EC_EReference']"/> | ||
484 | </ownedDiagramElements> | ||
485 | <ownedDiagramElements xmi:type="diagram:DEdge" uid="_kk87RnpMEem6LP4EDiey6Q" name="[0..*] hostTypes" sourceNode="_kkaIsHpMEem6LP4EDiey6Q" targetNode="_kkfoQXpMEem6LP4EDiey6Q"> | ||
486 | <target xmi:type="ecore:EReference" href="model/cps.ecore#//CyberPhysicalSystem/hostTypes"/> | ||
487 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//CyberPhysicalSystem/hostTypes"/> | ||
488 | <ownedStyle xmi:type="diagram:EdgeStyle" uid="_kk9iUHpMEem6LP4EDiey6Q" description="_kk538HpMEem6LP4EDiey6Q" sourceArrow="FillDiamond" routingStyle="manhattan" strokeColor="0,0,0"> | ||
489 | <centerLabelStyle xmi:type="diagram:CenterLabelStyle" uid="_kk9iUnpMEem6LP4EDiey6Q" showIcon="false"> | ||
490 | <customFeatures>labelSize</customFeatures> | ||
491 | </centerLabelStyle> | ||
492 | <endLabelStyle xmi:type="diagram:EndLabelStyle" uid="_kk9iUXpMEem6LP4EDiey6Q" showIcon="false" labelColor="39,76,114"> | ||
493 | <customFeatures>labelSize</customFeatures> | ||
494 | </endLabelStyle> | ||
495 | </ownedStyle> | ||
496 | <actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='EC_EReference']"/> | ||
497 | </ownedDiagramElements> | ||
498 | <ownedDiagramElements xmi:type="diagram:DEdge" uid="_kk9iVnpMEem6LP4EDiey6Q" name="[0..*] requirements" sourceNode="_kkeaIHpMEem6LP4EDiey6Q" targetNode="_kkkgwHpMEem6LP4EDiey6Q"> | ||
499 | <target xmi:type="ecore:EReference" href="model/cps.ecore#//ApplicationType/requirements"/> | ||
500 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//ApplicationType/requirements"/> | ||
501 | <ownedStyle xmi:type="diagram:EdgeStyle" uid="_kk-JYHpMEem6LP4EDiey6Q" description="_kk538HpMEem6LP4EDiey6Q" sourceArrow="FillDiamond" routingStyle="manhattan" strokeColor="0,0,0"> | ||
502 | <centerLabelStyle xmi:type="diagram:CenterLabelStyle" uid="_kk-JYnpMEem6LP4EDiey6Q" showIcon="false"> | ||
503 | <customFeatures>labelSize</customFeatures> | ||
504 | </centerLabelStyle> | ||
505 | <endLabelStyle xmi:type="diagram:EndLabelStyle" uid="_kk-JYXpMEem6LP4EDiey6Q" showIcon="false" labelColor="39,76,114"> | ||
506 | <customFeatures>labelSize</customFeatures> | ||
507 | </endLabelStyle> | ||
508 | </ownedStyle> | ||
509 | <actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='EC_EReference']"/> | ||
510 | </ownedDiagramElements> | ||
511 | <ownedDiagramElements xmi:type="diagram:DEdge" uid="_kk-wcHpMEem6LP4EDiey6Q" name="[0..1] type" sourceNode="_kkirkHpMEem6LP4EDiey6Q" targetNode="_kkeaIHpMEem6LP4EDiey6Q"> | ||
512 | <target xmi:type="ecore:EReference" href="model/cps.ecore#//Requirement/type"/> | ||
513 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//Requirement/type"/> | ||
514 | <ownedStyle xmi:type="diagram:EdgeStyle" uid="_kk-wcXpMEem6LP4EDiey6Q" routingStyle="manhattan" strokeColor="0,0,0"> | ||
515 | <description xmi:type="style:EdgeStyleDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='EC_EReference']/@style"/> | ||
516 | <centerLabelStyle xmi:type="diagram:CenterLabelStyle" uid="_kk-wc3pMEem6LP4EDiey6Q" showIcon="false"> | ||
517 | <customFeatures>labelSize</customFeatures> | ||
518 | </centerLabelStyle> | ||
519 | <endLabelStyle xmi:type="diagram:EndLabelStyle" uid="_kk-wcnpMEem6LP4EDiey6Q" showIcon="false" labelColor="39,76,114"> | ||
520 | <customFeatures>labelSize</customFeatures> | ||
521 | </endLabelStyle> | ||
522 | </ownedStyle> | ||
523 | <actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='EC_EReference']"/> | ||
524 | </ownedDiagramElements> | ||
525 | <ownedDiagramElements xmi:type="diagram:DEdge" uid="_kk_Xg3pMEem6LP4EDiey6Q" name="[1..1] hostType" sourceNode="_kkkgwHpMEem6LP4EDiey6Q" targetNode="_kkfoQXpMEem6LP4EDiey6Q"> | ||
526 | <target xmi:type="ecore:EReference" href="model/cps.ecore#//ResourceRequirement/hostType"/> | ||
527 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//ResourceRequirement/hostType"/> | ||
528 | <ownedStyle xmi:type="diagram:EdgeStyle" uid="_kk_-k3pMEem6LP4EDiey6Q" description="_kk_-kHpMEem6LP4EDiey6Q" routingStyle="manhattan" strokeColor="0,0,0"> | ||
529 | <centerLabelStyle xmi:type="diagram:CenterLabelStyle" uid="_kk_-lXpMEem6LP4EDiey6Q" showIcon="false"> | ||
530 | <customFeatures>labelSize</customFeatures> | ||
531 | </centerLabelStyle> | ||
532 | <endLabelStyle xmi:type="diagram:EndLabelStyle" uid="_kk_-lHpMEem6LP4EDiey6Q" showIcon="false" labelColor="39,76,114"> | ||
533 | <customFeatures>labelSize</customFeatures> | ||
534 | </endLabelStyle> | ||
535 | </ownedStyle> | ||
536 | <actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='EC_EReference']"/> | ||
537 | </ownedDiagramElements> | ||
538 | <ownedDiagramElements xmi:type="diagram:DEdge" uid="_klBMsHpMEem6LP4EDiey6Q" sourceNode="_kkjSoXpMEem6LP4EDiey6Q" targetNode="_kklH0HpMEem6LP4EDiey6Q" beginLabel="[0..*] applications" endLabel="[1..1] allocatedTo"> | ||
539 | <target xmi:type="ecore:EReference" href="model/cps.ecore#//ApplicationInstance/allocatedTo"/> | ||
540 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//ApplicationInstance/allocatedTo"/> | ||
541 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//HostInstance/applications"/> | ||
542 | <ownedStyle xmi:type="diagram:EdgeStyle" uid="_klBzw3pMEem6LP4EDiey6Q" description="_klBzwHpMEem6LP4EDiey6Q" sourceArrow="InputArrow" routingStyle="manhattan" strokeColor="0,0,0"> | ||
543 | <beginLabelStyle xmi:type="diagram:BeginLabelStyle" uid="_klCa0HpMEem6LP4EDiey6Q" showIcon="false"> | ||
544 | <labelFormat>bold</labelFormat> | ||
545 | </beginLabelStyle> | ||
546 | <endLabelStyle xmi:type="diagram:EndLabelStyle" uid="_klCa0XpMEem6LP4EDiey6Q" showIcon="false"> | ||
547 | <labelFormat>bold</labelFormat> | ||
548 | </endLabelStyle> | ||
549 | </ownedStyle> | ||
550 | <actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='Bi-directional%20EC_EReference%20']"/> | ||
551 | </ownedDiagramElements> | ||
552 | <ownedDiagramElements xmi:type="diagram:DEdge" uid="_klDB4HpMEem6LP4EDiey6Q" sourceNode="_kkfoQXpMEem6LP4EDiey6Q" targetNode="_kklH0HpMEem6LP4EDiey6Q" beginLabel="[1..1] type" endLabel="[0..*] instances"> | ||
553 | <target xmi:type="ecore:EReference" href="model/cps.ecore#//HostType/instances"/> | ||
554 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//HostType/instances"/> | ||
555 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//HostInstance/type"/> | ||
556 | <ownedStyle xmi:type="diagram:EdgeStyle" uid="_klDo83pMEem6LP4EDiey6Q" description="_klDo8HpMEem6LP4EDiey6Q" sourceArrow="FillDiamond" routingStyle="manhattan" strokeColor="0,0,0"> | ||
557 | <beginLabelStyle xmi:type="diagram:BeginLabelStyle" uid="_klDo9HpMEem6LP4EDiey6Q" showIcon="false"/> | ||
558 | <endLabelStyle xmi:type="diagram:EndLabelStyle" uid="_klDo9XpMEem6LP4EDiey6Q" showIcon="false"/> | ||
559 | </ownedStyle> | ||
560 | <actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='Bi-directional%20EC_EReference%20']"/> | ||
561 | </ownedDiagramElements> | ||
562 | <ownedDiagramElements xmi:type="diagram:DEdge" uid="_klDo-XpMEem6LP4EDiey6Q" sourceNode="_kkhdcHpMEem6LP4EDiey6Q" targetNode="_kkirkHpMEem6LP4EDiey6Q" beginLabel="[1..1] request" endLabel="[0..*] requirements"> | ||
563 | <target xmi:type="ecore:EReference" href="model/cps.ecore#//Request/requirements"/> | ||
564 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//Requirement/request"/> | ||
565 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//Request/requirements"/> | ||
566 | <ownedStyle xmi:type="diagram:EdgeStyle" uid="_klEQAHpMEem6LP4EDiey6Q" description="_klDo8HpMEem6LP4EDiey6Q" sourceArrow="FillDiamond" routingStyle="manhattan" strokeColor="0,0,0"> | ||
567 | <beginLabelStyle xmi:type="diagram:BeginLabelStyle" uid="_klEQAXpMEem6LP4EDiey6Q" showIcon="false"/> | ||
568 | <endLabelStyle xmi:type="diagram:EndLabelStyle" uid="_klEQAnpMEem6LP4EDiey6Q" showIcon="false"/> | ||
569 | </ownedStyle> | ||
570 | <actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='Bi-directional%20EC_EReference%20']"/> | ||
571 | </ownedDiagramElements> | ||
572 | <ownedDiagramElements xmi:type="diagram:DEdge" uid="_klEQBnpMEem6LP4EDiey6Q" sourceNode="_kkeaIHpMEem6LP4EDiey6Q" targetNode="_kkjSoXpMEem6LP4EDiey6Q" beginLabel="[1..1] type" endLabel="[0..*] instances"> | ||
573 | <target xmi:type="ecore:EReference" href="model/cps.ecore#//ApplicationType/instances"/> | ||
574 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//ApplicationType/instances"/> | ||
575 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//ApplicationInstance/type"/> | ||
576 | <ownedStyle xmi:type="diagram:EdgeStyle" uid="_klE3EHpMEem6LP4EDiey6Q" description="_klDo8HpMEem6LP4EDiey6Q" sourceArrow="FillDiamond" routingStyle="manhattan" strokeColor="0,0,0"> | ||
577 | <beginLabelStyle xmi:type="diagram:BeginLabelStyle" uid="_klE3EXpMEem6LP4EDiey6Q" showIcon="false"/> | ||
578 | <endLabelStyle xmi:type="diagram:EndLabelStyle" uid="_klE3EnpMEem6LP4EDiey6Q" showIcon="false"/> | ||
579 | </ownedStyle> | ||
580 | <actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='Bi-directional%20EC_EReference%20']"/> | ||
581 | </ownedDiagramElements> | ||
582 | <ownedDiagramElements xmi:type="diagram:DEdge" uid="_klFeIHpMEem6LP4EDiey6Q" sourceNode="_kkirkHpMEem6LP4EDiey6Q" targetNode="_kkjSoXpMEem6LP4EDiey6Q" beginLabel="[0..1] requirement" endLabel="[0..*] instances"> | ||
583 | <target xmi:type="ecore:EReference" href="model/cps.ecore#//Requirement/instances"/> | ||
584 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//Requirement/instances"/> | ||
585 | <semanticElements xmi:type="ecore:EReference" href="model/cps.ecore#//ApplicationInstance/requirement"/> | ||
586 | <ownedStyle xmi:type="diagram:EdgeStyle" uid="_klFeIXpMEem6LP4EDiey6Q" sourceArrow="InputArrow" routingStyle="manhattan" strokeColor="0,0,0"> | ||
587 | <description xmi:type="style:EdgeStyleDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='Bi-directional%20EC_EReference%20']/@style"/> | ||
588 | <beginLabelStyle xmi:type="diagram:BeginLabelStyle" uid="_klFeInpMEem6LP4EDiey6Q" showIcon="false"/> | ||
589 | <endLabelStyle xmi:type="diagram:EndLabelStyle" uid="_klFeI3pMEem6LP4EDiey6Q" showIcon="false"/> | ||
590 | </ownedStyle> | ||
591 | <actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='Bi-directional%20EC_EReference%20']"/> | ||
592 | </ownedDiagramElements> | ||
593 | <description xmi:type="description_1:DiagramDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']"/> | ||
594 | <filterVariableHistory xmi:type="diagram:FilterVariableHistory" uid="_kAqicHpMEem6LP4EDiey6Q"/> | ||
595 | <activatedLayers xmi:type="description_1:Layer" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer"/> | ||
596 | <activatedLayers xmi:type="description_1:AdditionalLayer" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@additionalLayers[name='Package']"/> | ||
597 | <activatedLayers xmi:type="description_1:AdditionalLayer" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@additionalLayers[name='Validation']"/> | ||
598 | <target xmi:type="ecore:EPackage" href="model/cps.ecore#/"/> | ||
599 | </diagram:DSemanticDiagram> | ||
600 | </xmi:XMI> | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore new file mode 100644 index 00000000..d3114d9d --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore | |||
@@ -0,0 +1,44 @@ | |||
1 | /.CpsApplications.java._trace | ||
2 | /.CpsQueries.java._trace | ||
3 | /.CpsHosts.java._trace | ||
4 | /.TotalMemory.java._trace | ||
5 | /.TotalHdd.java._trace | ||
6 | /.AvailableMemory.java._trace | ||
7 | /.AvailableHdd.java._trace | ||
8 | /.AllocationWithoutResourceRequirement.java._trace | ||
9 | /.NotEnoughAvailableMemory.java._trace | ||
10 | /.NotEnoughAvailableHdd.java._trace | ||
11 | /.InstanceDoesNotSatisfyRequirement.java._trace | ||
12 | /.RequirementNotSatisfied.java._trace | ||
13 | /.AverageFreeMemoryMetric.java._trace | ||
14 | /.AverageFreeHddMetric.java._trace | ||
15 | /.CostMetric.java._trace | ||
16 | /.CpsCost.java._trace | ||
17 | /.RedundantInstancesOnSameHost.java._trace | ||
18 | /.Allocate.java._trace | ||
19 | /.CpsTransformationRules.java._trace | ||
20 | /.ResourceRequirement.java._trace | ||
21 | /.CreateInstance.java._trace | ||
22 | /.CreateHostInstance.java._trace | ||
23 | /.UnallocatedAppInstance.java._trace | ||
24 | /.RequiredAppInstances.java._trace | ||
25 | /.GuidanceObjective.java._trace | ||
26 | /.RemoveHostInstance.java._trace | ||
27 | /.UnallocateAppInstance.java._trace | ||
28 | /Allocate.java | ||
29 | /AllocationWithoutResourceRequirement.java | ||
30 | /AverageFreeHddMetric.java | ||
31 | /AverageFreeMemoryMetric.java | ||
32 | /CostMetric.java | ||
33 | /CpsCost.java | ||
34 | /CpsQueries.java | ||
35 | /CreateHostInstance.java | ||
36 | /GuidanceObjective.java | ||
37 | /InstanceDoesNotSatisfyRequirement.java | ||
38 | /NotEnoughAvailableHdd.java | ||
39 | /NotEnoughAvailableMemory.java | ||
40 | /RedundantInstancesOnSameHost.java | ||
41 | /RemoveHostInstance.java | ||
42 | /RequirementNotSatisfied.java | ||
43 | /ResourceRequirement.java | ||
44 | /UnallocateAppInstance.java | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/Allocate.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/Allocate.java new file mode 100644 index 00000000..1fc70124 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/Allocate.java | |||
@@ -0,0 +1,873 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory; | ||
10 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance; | ||
11 | import java.util.Arrays; | ||
12 | import java.util.Collection; | ||
13 | import java.util.Collections; | ||
14 | import java.util.LinkedHashSet; | ||
15 | import java.util.List; | ||
16 | import java.util.Objects; | ||
17 | import java.util.Optional; | ||
18 | import java.util.Set; | ||
19 | import java.util.function.Consumer; | ||
20 | import java.util.stream.Collectors; | ||
21 | import java.util.stream.Stream; | ||
22 | import org.apache.log4j.Logger; | ||
23 | import org.eclipse.emf.ecore.EClass; | ||
24 | import org.eclipse.emf.ecore.EDataType; | ||
25 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
27 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
28 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
29 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
30 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
31 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
32 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
33 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
34 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
44 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
45 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
46 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
47 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
48 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
49 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
50 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
51 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
52 | |||
53 | /** | ||
54 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
55 | * | ||
56 | * <p>Original source: | ||
57 | * <code><pre> | ||
58 | * // | ||
59 | * // Transformation rule preconditions for rule-based DSE | ||
60 | * // | ||
61 | * | ||
62 | * pattern allocate(App : ApplicationInstance, Host : HostInstance) { | ||
63 | * ApplicationInstance.type.requirements(App, Req); | ||
64 | * ResourceRequirement.hostType.instances(Req, Host); | ||
65 | * find unallocatedAppInstance(App); | ||
66 | * find availableMemory(Host, AvailableMem); | ||
67 | * find availableHdd(Host, AvailableHdd); | ||
68 | * ResourceRequirement.requiredMemory(Req, RequiredMem); | ||
69 | * ResourceRequirement.requiredHdd(Req, RequiredHdd); | ||
70 | * check(AvailableMem {@literal >}= RequiredMem); | ||
71 | * check(AvailableHdd {@literal >}= RequiredHdd); | ||
72 | * neg ApplicationInstance.requirement.instances.allocatedTo(App, Host); | ||
73 | * } | ||
74 | * </pre></code> | ||
75 | * | ||
76 | * @see Matcher | ||
77 | * @see Match | ||
78 | * | ||
79 | */ | ||
80 | @SuppressWarnings("all") | ||
81 | public final class Allocate extends BaseGeneratedEMFQuerySpecification<Allocate.Matcher> { | ||
82 | /** | ||
83 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocate pattern, | ||
84 | * to be used in conjunction with {@link Matcher}. | ||
85 | * | ||
86 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
87 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
88 | * usable to represent a match of the pattern in the result of a query, | ||
89 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
90 | * | ||
91 | * @see Matcher | ||
92 | * | ||
93 | */ | ||
94 | public static abstract class Match extends BasePatternMatch { | ||
95 | private ApplicationInstance fApp; | ||
96 | |||
97 | private HostInstance fHost; | ||
98 | |||
99 | private static List<String> parameterNames = makeImmutableList("App", "Host"); | ||
100 | |||
101 | private Match(final ApplicationInstance pApp, final HostInstance pHost) { | ||
102 | this.fApp = pApp; | ||
103 | this.fHost = pHost; | ||
104 | } | ||
105 | |||
106 | @Override | ||
107 | public Object get(final String parameterName) { | ||
108 | switch(parameterName) { | ||
109 | case "App": return this.fApp; | ||
110 | case "Host": return this.fHost; | ||
111 | default: return null; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public Object get(final int index) { | ||
117 | switch(index) { | ||
118 | case 0: return this.fApp; | ||
119 | case 1: return this.fHost; | ||
120 | default: return null; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | public ApplicationInstance getApp() { | ||
125 | return this.fApp; | ||
126 | } | ||
127 | |||
128 | public HostInstance getHost() { | ||
129 | return this.fHost; | ||
130 | } | ||
131 | |||
132 | @Override | ||
133 | public boolean set(final String parameterName, final Object newValue) { | ||
134 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
135 | if ("App".equals(parameterName) ) { | ||
136 | this.fApp = (ApplicationInstance) newValue; | ||
137 | return true; | ||
138 | } | ||
139 | if ("Host".equals(parameterName) ) { | ||
140 | this.fHost = (HostInstance) newValue; | ||
141 | return true; | ||
142 | } | ||
143 | return false; | ||
144 | } | ||
145 | |||
146 | public void setApp(final ApplicationInstance pApp) { | ||
147 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
148 | this.fApp = pApp; | ||
149 | } | ||
150 | |||
151 | public void setHost(final HostInstance pHost) { | ||
152 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
153 | this.fHost = pHost; | ||
154 | } | ||
155 | |||
156 | @Override | ||
157 | public String patternName() { | ||
158 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocate"; | ||
159 | } | ||
160 | |||
161 | @Override | ||
162 | public List<String> parameterNames() { | ||
163 | return Allocate.Match.parameterNames; | ||
164 | } | ||
165 | |||
166 | @Override | ||
167 | public Object[] toArray() { | ||
168 | return new Object[]{fApp, fHost}; | ||
169 | } | ||
170 | |||
171 | @Override | ||
172 | public Allocate.Match toImmutable() { | ||
173 | return isMutable() ? newMatch(fApp, fHost) : this; | ||
174 | } | ||
175 | |||
176 | @Override | ||
177 | public String prettyPrint() { | ||
178 | StringBuilder result = new StringBuilder(); | ||
179 | result.append("\"App\"=" + prettyPrintValue(fApp) + ", "); | ||
180 | result.append("\"Host\"=" + prettyPrintValue(fHost)); | ||
181 | return result.toString(); | ||
182 | } | ||
183 | |||
184 | @Override | ||
185 | public int hashCode() { | ||
186 | return Objects.hash(fApp, fHost); | ||
187 | } | ||
188 | |||
189 | @Override | ||
190 | public boolean equals(final Object obj) { | ||
191 | if (this == obj) | ||
192 | return true; | ||
193 | if (obj == null) { | ||
194 | return false; | ||
195 | } | ||
196 | if ((obj instanceof Allocate.Match)) { | ||
197 | Allocate.Match other = (Allocate.Match) obj; | ||
198 | return Objects.equals(fApp, other.fApp) && Objects.equals(fHost, other.fHost); | ||
199 | } else { | ||
200 | // this should be infrequent | ||
201 | if (!(obj instanceof IPatternMatch)) { | ||
202 | return false; | ||
203 | } | ||
204 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
205 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
206 | } | ||
207 | } | ||
208 | |||
209 | @Override | ||
210 | public Allocate specification() { | ||
211 | return Allocate.instance(); | ||
212 | } | ||
213 | |||
214 | /** | ||
215 | * Returns an empty, mutable match. | ||
216 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
217 | * | ||
218 | * @return the empty match. | ||
219 | * | ||
220 | */ | ||
221 | public static Allocate.Match newEmptyMatch() { | ||
222 | return new Mutable(null, null); | ||
223 | } | ||
224 | |||
225 | /** | ||
226 | * Returns a mutable (partial) match. | ||
227 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
228 | * | ||
229 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
230 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
231 | * @return the new, mutable (partial) match object. | ||
232 | * | ||
233 | */ | ||
234 | public static Allocate.Match newMutableMatch(final ApplicationInstance pApp, final HostInstance pHost) { | ||
235 | return new Mutable(pApp, pHost); | ||
236 | } | ||
237 | |||
238 | /** | ||
239 | * Returns a new (partial) match. | ||
240 | * This can be used e.g. to call the matcher with a partial match. | ||
241 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
242 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
243 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
244 | * @return the (partial) match object. | ||
245 | * | ||
246 | */ | ||
247 | public static Allocate.Match newMatch(final ApplicationInstance pApp, final HostInstance pHost) { | ||
248 | return new Immutable(pApp, pHost); | ||
249 | } | ||
250 | |||
251 | private static final class Mutable extends Allocate.Match { | ||
252 | Mutable(final ApplicationInstance pApp, final HostInstance pHost) { | ||
253 | super(pApp, pHost); | ||
254 | } | ||
255 | |||
256 | @Override | ||
257 | public boolean isMutable() { | ||
258 | return true; | ||
259 | } | ||
260 | } | ||
261 | |||
262 | private static final class Immutable extends Allocate.Match { | ||
263 | Immutable(final ApplicationInstance pApp, final HostInstance pHost) { | ||
264 | super(pApp, pHost); | ||
265 | } | ||
266 | |||
267 | @Override | ||
268 | public boolean isMutable() { | ||
269 | return false; | ||
270 | } | ||
271 | } | ||
272 | } | ||
273 | |||
274 | /** | ||
275 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocate pattern, | ||
276 | * providing pattern-specific query methods. | ||
277 | * | ||
278 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
279 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
280 | * | ||
281 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
282 | * | ||
283 | * <p>Original source: | ||
284 | * <code><pre> | ||
285 | * // | ||
286 | * // Transformation rule preconditions for rule-based DSE | ||
287 | * // | ||
288 | * | ||
289 | * pattern allocate(App : ApplicationInstance, Host : HostInstance) { | ||
290 | * ApplicationInstance.type.requirements(App, Req); | ||
291 | * ResourceRequirement.hostType.instances(Req, Host); | ||
292 | * find unallocatedAppInstance(App); | ||
293 | * find availableMemory(Host, AvailableMem); | ||
294 | * find availableHdd(Host, AvailableHdd); | ||
295 | * ResourceRequirement.requiredMemory(Req, RequiredMem); | ||
296 | * ResourceRequirement.requiredHdd(Req, RequiredHdd); | ||
297 | * check(AvailableMem {@literal >}= RequiredMem); | ||
298 | * check(AvailableHdd {@literal >}= RequiredHdd); | ||
299 | * neg ApplicationInstance.requirement.instances.allocatedTo(App, Host); | ||
300 | * } | ||
301 | * </pre></code> | ||
302 | * | ||
303 | * @see Match | ||
304 | * @see Allocate | ||
305 | * | ||
306 | */ | ||
307 | public static class Matcher extends BaseMatcher<Allocate.Match> { | ||
308 | /** | ||
309 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
310 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
311 | * | ||
312 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
313 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
314 | * | ||
315 | */ | ||
316 | public static Allocate.Matcher on(final ViatraQueryEngine engine) { | ||
317 | // check if matcher already exists | ||
318 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
319 | if (matcher == null) { | ||
320 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
321 | } | ||
322 | return matcher; | ||
323 | } | ||
324 | |||
325 | /** | ||
326 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
327 | * @return an initialized matcher | ||
328 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
329 | * | ||
330 | */ | ||
331 | public static Allocate.Matcher create() { | ||
332 | return new Matcher(); | ||
333 | } | ||
334 | |||
335 | private static final int POSITION_APP = 0; | ||
336 | |||
337 | private static final int POSITION_HOST = 1; | ||
338 | |||
339 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Allocate.Matcher.class); | ||
340 | |||
341 | /** | ||
342 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
343 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
344 | * | ||
345 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
346 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
347 | * | ||
348 | */ | ||
349 | private Matcher() { | ||
350 | super(querySpecification()); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
355 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
356 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
357 | * @return matches represented as a Match object. | ||
358 | * | ||
359 | */ | ||
360 | public Collection<Allocate.Match> getAllMatches(final ApplicationInstance pApp, final HostInstance pHost) { | ||
361 | return rawStreamAllMatches(new Object[]{pApp, pHost}).collect(Collectors.toSet()); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
366 | * </p> | ||
367 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
368 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
369 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
370 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
371 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
372 | * @return a stream of matches represented as a Match object. | ||
373 | * | ||
374 | */ | ||
375 | public Stream<Allocate.Match> streamAllMatches(final ApplicationInstance pApp, final HostInstance pHost) { | ||
376 | return rawStreamAllMatches(new Object[]{pApp, pHost}); | ||
377 | } | ||
378 | |||
379 | /** | ||
380 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
381 | * Neither determinism nor randomness of selection is guaranteed. | ||
382 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
383 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
384 | * @return a match represented as a Match object, or null if no match is found. | ||
385 | * | ||
386 | */ | ||
387 | public Optional<Allocate.Match> getOneArbitraryMatch(final ApplicationInstance pApp, final HostInstance pHost) { | ||
388 | return rawGetOneArbitraryMatch(new Object[]{pApp, pHost}); | ||
389 | } | ||
390 | |||
391 | /** | ||
392 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
393 | * under any possible substitution of the unspecified parameters (if any). | ||
394 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
395 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
396 | * @return true if the input is a valid (partial) match of the pattern. | ||
397 | * | ||
398 | */ | ||
399 | public boolean hasMatch(final ApplicationInstance pApp, final HostInstance pHost) { | ||
400 | return rawHasMatch(new Object[]{pApp, pHost}); | ||
401 | } | ||
402 | |||
403 | /** | ||
404 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
405 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
406 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
407 | * @return the number of pattern matches found. | ||
408 | * | ||
409 | */ | ||
410 | public int countMatches(final ApplicationInstance pApp, final HostInstance pHost) { | ||
411 | return rawCountMatches(new Object[]{pApp, pHost}); | ||
412 | } | ||
413 | |||
414 | /** | ||
415 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
416 | * Neither determinism nor randomness of selection is guaranteed. | ||
417 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
418 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
419 | * @param processor the action that will process the selected match. | ||
420 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
421 | * | ||
422 | */ | ||
423 | public boolean forOneArbitraryMatch(final ApplicationInstance pApp, final HostInstance pHost, final Consumer<? super Allocate.Match> processor) { | ||
424 | return rawForOneArbitraryMatch(new Object[]{pApp, pHost}, processor); | ||
425 | } | ||
426 | |||
427 | /** | ||
428 | * Returns a new (partial) match. | ||
429 | * This can be used e.g. to call the matcher with a partial match. | ||
430 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
431 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
432 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
433 | * @return the (partial) match object. | ||
434 | * | ||
435 | */ | ||
436 | public Allocate.Match newMatch(final ApplicationInstance pApp, final HostInstance pHost) { | ||
437 | return Allocate.Match.newMatch(pApp, pHost); | ||
438 | } | ||
439 | |||
440 | /** | ||
441 | * Retrieve the set of values that occur in matches for App. | ||
442 | * @return the Set of all values or empty set if there are no matches | ||
443 | * | ||
444 | */ | ||
445 | protected Stream<ApplicationInstance> rawStreamAllValuesOfApp(final Object[] parameters) { | ||
446 | return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast); | ||
447 | } | ||
448 | |||
449 | /** | ||
450 | * Retrieve the set of values that occur in matches for App. | ||
451 | * @return the Set of all values or empty set if there are no matches | ||
452 | * | ||
453 | */ | ||
454 | public Set<ApplicationInstance> getAllValuesOfApp() { | ||
455 | return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet()); | ||
456 | } | ||
457 | |||
458 | /** | ||
459 | * Retrieve the set of values that occur in matches for App. | ||
460 | * @return the Set of all values or empty set if there are no matches | ||
461 | * | ||
462 | */ | ||
463 | public Stream<ApplicationInstance> streamAllValuesOfApp() { | ||
464 | return rawStreamAllValuesOfApp(emptyArray()); | ||
465 | } | ||
466 | |||
467 | /** | ||
468 | * Retrieve the set of values that occur in matches for App. | ||
469 | * </p> | ||
470 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
471 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
472 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
473 | * | ||
474 | * @return the Stream of all values or empty set if there are no matches | ||
475 | * | ||
476 | */ | ||
477 | public Stream<ApplicationInstance> streamAllValuesOfApp(final Allocate.Match partialMatch) { | ||
478 | return rawStreamAllValuesOfApp(partialMatch.toArray()); | ||
479 | } | ||
480 | |||
481 | /** | ||
482 | * Retrieve the set of values that occur in matches for App. | ||
483 | * </p> | ||
484 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
485 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
486 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
487 | * | ||
488 | * @return the Stream of all values or empty set if there are no matches | ||
489 | * | ||
490 | */ | ||
491 | public Stream<ApplicationInstance> streamAllValuesOfApp(final HostInstance pHost) { | ||
492 | return rawStreamAllValuesOfApp(new Object[]{null, pHost}); | ||
493 | } | ||
494 | |||
495 | /** | ||
496 | * Retrieve the set of values that occur in matches for App. | ||
497 | * @return the Set of all values or empty set if there are no matches | ||
498 | * | ||
499 | */ | ||
500 | public Set<ApplicationInstance> getAllValuesOfApp(final Allocate.Match partialMatch) { | ||
501 | return rawStreamAllValuesOfApp(partialMatch.toArray()).collect(Collectors.toSet()); | ||
502 | } | ||
503 | |||
504 | /** | ||
505 | * Retrieve the set of values that occur in matches for App. | ||
506 | * @return the Set of all values or empty set if there are no matches | ||
507 | * | ||
508 | */ | ||
509 | public Set<ApplicationInstance> getAllValuesOfApp(final HostInstance pHost) { | ||
510 | return rawStreamAllValuesOfApp(new Object[]{null, pHost}).collect(Collectors.toSet()); | ||
511 | } | ||
512 | |||
513 | /** | ||
514 | * Retrieve the set of values that occur in matches for Host. | ||
515 | * @return the Set of all values or empty set if there are no matches | ||
516 | * | ||
517 | */ | ||
518 | protected Stream<HostInstance> rawStreamAllValuesOfHost(final Object[] parameters) { | ||
519 | return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); | ||
520 | } | ||
521 | |||
522 | /** | ||
523 | * Retrieve the set of values that occur in matches for Host. | ||
524 | * @return the Set of all values or empty set if there are no matches | ||
525 | * | ||
526 | */ | ||
527 | public Set<HostInstance> getAllValuesOfHost() { | ||
528 | return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); | ||
529 | } | ||
530 | |||
531 | /** | ||
532 | * Retrieve the set of values that occur in matches for Host. | ||
533 | * @return the Set of all values or empty set if there are no matches | ||
534 | * | ||
535 | */ | ||
536 | public Stream<HostInstance> streamAllValuesOfHost() { | ||
537 | return rawStreamAllValuesOfHost(emptyArray()); | ||
538 | } | ||
539 | |||
540 | /** | ||
541 | * Retrieve the set of values that occur in matches for Host. | ||
542 | * </p> | ||
543 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
544 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
545 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
546 | * | ||
547 | * @return the Stream of all values or empty set if there are no matches | ||
548 | * | ||
549 | */ | ||
550 | public Stream<HostInstance> streamAllValuesOfHost(final Allocate.Match partialMatch) { | ||
551 | return rawStreamAllValuesOfHost(partialMatch.toArray()); | ||
552 | } | ||
553 | |||
554 | /** | ||
555 | * Retrieve the set of values that occur in matches for Host. | ||
556 | * </p> | ||
557 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
558 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
559 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
560 | * | ||
561 | * @return the Stream of all values or empty set if there are no matches | ||
562 | * | ||
563 | */ | ||
564 | public Stream<HostInstance> streamAllValuesOfHost(final ApplicationInstance pApp) { | ||
565 | return rawStreamAllValuesOfHost(new Object[]{pApp, null}); | ||
566 | } | ||
567 | |||
568 | /** | ||
569 | * Retrieve the set of values that occur in matches for Host. | ||
570 | * @return the Set of all values or empty set if there are no matches | ||
571 | * | ||
572 | */ | ||
573 | public Set<HostInstance> getAllValuesOfHost(final Allocate.Match partialMatch) { | ||
574 | return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); | ||
575 | } | ||
576 | |||
577 | /** | ||
578 | * Retrieve the set of values that occur in matches for Host. | ||
579 | * @return the Set of all values or empty set if there are no matches | ||
580 | * | ||
581 | */ | ||
582 | public Set<HostInstance> getAllValuesOfHost(final ApplicationInstance pApp) { | ||
583 | return rawStreamAllValuesOfHost(new Object[]{pApp, null}).collect(Collectors.toSet()); | ||
584 | } | ||
585 | |||
586 | @Override | ||
587 | protected Allocate.Match tupleToMatch(final Tuple t) { | ||
588 | try { | ||
589 | return Allocate.Match.newMatch((ApplicationInstance) t.get(POSITION_APP), (HostInstance) t.get(POSITION_HOST)); | ||
590 | } catch(ClassCastException e) { | ||
591 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
592 | return null; | ||
593 | } | ||
594 | } | ||
595 | |||
596 | @Override | ||
597 | protected Allocate.Match arrayToMatch(final Object[] match) { | ||
598 | try { | ||
599 | return Allocate.Match.newMatch((ApplicationInstance) match[POSITION_APP], (HostInstance) match[POSITION_HOST]); | ||
600 | } catch(ClassCastException e) { | ||
601 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
602 | return null; | ||
603 | } | ||
604 | } | ||
605 | |||
606 | @Override | ||
607 | protected Allocate.Match arrayToMatchMutable(final Object[] match) { | ||
608 | try { | ||
609 | return Allocate.Match.newMutableMatch((ApplicationInstance) match[POSITION_APP], (HostInstance) match[POSITION_HOST]); | ||
610 | } catch(ClassCastException e) { | ||
611 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
612 | return null; | ||
613 | } | ||
614 | } | ||
615 | |||
616 | /** | ||
617 | * @return the singleton instance of the query specification of this pattern | ||
618 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
619 | * | ||
620 | */ | ||
621 | public static IQuerySpecification<Allocate.Matcher> querySpecification() { | ||
622 | return Allocate.instance(); | ||
623 | } | ||
624 | } | ||
625 | |||
626 | private Allocate() { | ||
627 | super(GeneratedPQuery.INSTANCE); | ||
628 | } | ||
629 | |||
630 | /** | ||
631 | * @return the singleton instance of the query specification | ||
632 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
633 | * | ||
634 | */ | ||
635 | public static Allocate instance() { | ||
636 | try{ | ||
637 | return LazyHolder.INSTANCE; | ||
638 | } catch (ExceptionInInitializerError err) { | ||
639 | throw processInitializerError(err); | ||
640 | } | ||
641 | } | ||
642 | |||
643 | @Override | ||
644 | protected Allocate.Matcher instantiate(final ViatraQueryEngine engine) { | ||
645 | return Allocate.Matcher.on(engine); | ||
646 | } | ||
647 | |||
648 | @Override | ||
649 | public Allocate.Matcher instantiate() { | ||
650 | return Allocate.Matcher.create(); | ||
651 | } | ||
652 | |||
653 | @Override | ||
654 | public Allocate.Match newEmptyMatch() { | ||
655 | return Allocate.Match.newEmptyMatch(); | ||
656 | } | ||
657 | |||
658 | @Override | ||
659 | public Allocate.Match newMatch(final Object... parameters) { | ||
660 | return Allocate.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[1]); | ||
661 | } | ||
662 | |||
663 | /** | ||
664 | * Inner class allowing the singleton instance of {@link Allocate} to be created | ||
665 | * <b>not</b> at the class load time of the outer class, | ||
666 | * but rather at the first call to {@link Allocate#instance()}. | ||
667 | * | ||
668 | * <p> This workaround is required e.g. to support recursion. | ||
669 | * | ||
670 | */ | ||
671 | private static class LazyHolder { | ||
672 | private static final Allocate INSTANCE = new Allocate(); | ||
673 | |||
674 | /** | ||
675 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
676 | * This initialization order is required to support indirect recursion. | ||
677 | * | ||
678 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
679 | * | ||
680 | */ | ||
681 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
682 | |||
683 | public static Object ensureInitialized() { | ||
684 | INSTANCE.ensureInitializedInternal(); | ||
685 | return null; | ||
686 | } | ||
687 | } | ||
688 | |||
689 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
690 | private static final Allocate.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
691 | |||
692 | private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); | ||
693 | |||
694 | private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
695 | |||
696 | private final List<PParameter> parameters = Arrays.asList(parameter_App, parameter_Host); | ||
697 | |||
698 | private class Embedded_1_ApplicationInstance_requirement_instances_allocatedTo extends BaseGeneratedEMFPQuery { | ||
699 | private final PParameter parameter_p0 = new PParameter("p0", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); | ||
700 | |||
701 | private final PParameter parameter_p1 = new PParameter("p1", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
702 | |||
703 | private final List<PParameter> embeddedParameters = Arrays.asList(parameter_p0, parameter_p1); | ||
704 | |||
705 | public Embedded_1_ApplicationInstance_requirement_instances_allocatedTo() { | ||
706 | super(PVisibility.EMBEDDED); | ||
707 | } | ||
708 | |||
709 | @Override | ||
710 | public String getFullyQualifiedName() { | ||
711 | return GeneratedPQuery.this.getFullyQualifiedName() + "$Embedded_1_ApplicationInstance_requirement_instances_allocatedTo"; | ||
712 | } | ||
713 | |||
714 | @Override | ||
715 | public List<PParameter> getParameters() { | ||
716 | return embeddedParameters; | ||
717 | } | ||
718 | |||
719 | @Override | ||
720 | public Set<PBody> doGetContainedBodies() { | ||
721 | PBody body = new PBody(this); | ||
722 | PVariable var_p0 = body.getOrCreateVariableByName("p0"); | ||
723 | PVariable var_p1 = body.getOrCreateVariableByName("p1"); | ||
724 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
725 | new ExportedParameter(body, var_p0, parameter_p0), | ||
726 | new ExportedParameter(body, var_p1, parameter_p1) | ||
727 | )); | ||
728 | // ApplicationInstance.requirement.instances.allocatedTo(App, Host) | ||
729 | new TypeConstraint(body, Tuples.flatTupleOf(var_p0), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
730 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
731 | new TypeConstraint(body, Tuples.flatTupleOf(var_p0, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "requirement"))); | ||
732 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); | ||
733 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
734 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "instances"))); | ||
735 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
736 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
737 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); | ||
738 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
739 | new Equality(body, var__virtual_2_, var_p1); | ||
740 | return Collections.singleton(body); | ||
741 | } | ||
742 | } | ||
743 | |||
744 | private GeneratedPQuery() { | ||
745 | super(PVisibility.PUBLIC); | ||
746 | } | ||
747 | |||
748 | @Override | ||
749 | public String getFullyQualifiedName() { | ||
750 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocate"; | ||
751 | } | ||
752 | |||
753 | @Override | ||
754 | public List<String> getParameterNames() { | ||
755 | return Arrays.asList("App","Host"); | ||
756 | } | ||
757 | |||
758 | @Override | ||
759 | public List<PParameter> getParameters() { | ||
760 | return parameters; | ||
761 | } | ||
762 | |||
763 | @Override | ||
764 | public Set<PBody> doGetContainedBodies() { | ||
765 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
766 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
767 | { | ||
768 | PBody body = new PBody(this); | ||
769 | PVariable var_App = body.getOrCreateVariableByName("App"); | ||
770 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
771 | PVariable var_Req = body.getOrCreateVariableByName("Req"); | ||
772 | PVariable var_AvailableMem = body.getOrCreateVariableByName("AvailableMem"); | ||
773 | PVariable var_AvailableHdd = body.getOrCreateVariableByName("AvailableHdd"); | ||
774 | PVariable var_RequiredMem = body.getOrCreateVariableByName("RequiredMem"); | ||
775 | PVariable var_RequiredHdd = body.getOrCreateVariableByName("RequiredHdd"); | ||
776 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
777 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
778 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
779 | new ExportedParameter(body, var_App, parameter_App), | ||
780 | new ExportedParameter(body, var_Host, parameter_Host) | ||
781 | )); | ||
782 | // ApplicationInstance.type.requirements(App, Req) | ||
783 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
784 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
785 | new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type"))); | ||
786 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); | ||
787 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
788 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "requirements"))); | ||
789 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); | ||
790 | new Equality(body, var__virtual_1_, var_Req); | ||
791 | // ResourceRequirement.hostType.instances(Req, Host) | ||
792 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); | ||
793 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
794 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "hostType"))); | ||
795 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); | ||
796 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); | ||
797 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "instances"))); | ||
798 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
799 | new Equality(body, var__virtual_3_, var_Host); | ||
800 | // find unallocatedAppInstance(App) | ||
801 | new PositivePatternCall(body, Tuples.flatTupleOf(var_App), UnallocatedAppInstance.instance().getInternalQueryRepresentation()); | ||
802 | // find availableMemory(Host, AvailableMem) | ||
803 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_AvailableMem), AvailableMemory.instance().getInternalQueryRepresentation()); | ||
804 | // find availableHdd(Host, AvailableHdd) | ||
805 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_AvailableHdd), AvailableHdd.instance().getInternalQueryRepresentation()); | ||
806 | // ResourceRequirement.requiredMemory(Req, RequiredMem) | ||
807 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); | ||
808 | PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}"); | ||
809 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "requiredMemory"))); | ||
810 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
811 | new Equality(body, var__virtual_4_, var_RequiredMem); | ||
812 | // ResourceRequirement.requiredHdd(Req, RequiredHdd) | ||
813 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); | ||
814 | PVariable var__virtual_5_ = body.getOrCreateVariableByName(".virtual{5}"); | ||
815 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_5_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "requiredHdd"))); | ||
816 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_5_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
817 | new Equality(body, var__virtual_5_, var_RequiredHdd); | ||
818 | // check(AvailableMem >= RequiredMem) | ||
819 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
820 | |||
821 | @Override | ||
822 | public String getShortDescription() { | ||
823 | return "Expression evaluation from pattern allocate"; | ||
824 | } | ||
825 | |||
826 | @Override | ||
827 | public Iterable<String> getInputParameterNames() { | ||
828 | return Arrays.asList("AvailableMem", "RequiredMem");} | ||
829 | |||
830 | @Override | ||
831 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
832 | Integer AvailableMem = (Integer) provider.getValue("AvailableMem"); | ||
833 | Integer RequiredMem = (Integer) provider.getValue("RequiredMem"); | ||
834 | return evaluateExpression_1_1(AvailableMem, RequiredMem); | ||
835 | } | ||
836 | }, null); | ||
837 | // check(AvailableHdd >= RequiredHdd) | ||
838 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
839 | |||
840 | @Override | ||
841 | public String getShortDescription() { | ||
842 | return "Expression evaluation from pattern allocate"; | ||
843 | } | ||
844 | |||
845 | @Override | ||
846 | public Iterable<String> getInputParameterNames() { | ||
847 | return Arrays.asList("AvailableHdd", "RequiredHdd");} | ||
848 | |||
849 | @Override | ||
850 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
851 | Integer AvailableHdd = (Integer) provider.getValue("AvailableHdd"); | ||
852 | Integer RequiredHdd = (Integer) provider.getValue("RequiredHdd"); | ||
853 | return evaluateExpression_1_2(AvailableHdd, RequiredHdd); | ||
854 | } | ||
855 | }, null); | ||
856 | // neg ApplicationInstance.requirement.instances.allocatedTo(App, Host) | ||
857 | new NegativePatternCall(body, Tuples.flatTupleOf(var_App, var_Host), new Allocate.GeneratedPQuery.Embedded_1_ApplicationInstance_requirement_instances_allocatedTo()); | ||
858 | bodies.add(body); | ||
859 | } | ||
860 | return bodies; | ||
861 | } | ||
862 | } | ||
863 | |||
864 | private static boolean evaluateExpression_1_1(final Integer AvailableMem, final Integer RequiredMem) { | ||
865 | boolean _greaterEqualsThan = (AvailableMem.compareTo(RequiredMem) >= 0); | ||
866 | return _greaterEqualsThan; | ||
867 | } | ||
868 | |||
869 | private static boolean evaluateExpression_1_2(final Integer AvailableHdd, final Integer RequiredHdd) { | ||
870 | boolean _greaterEqualsThan = (AvailableHdd.compareTo(RequiredHdd) >= 0); | ||
871 | return _greaterEqualsThan; | ||
872 | } | ||
873 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java new file mode 100644 index 00000000..b49fee74 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java | |||
@@ -0,0 +1,728 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement; | ||
9 | import java.util.Arrays; | ||
10 | import java.util.Collection; | ||
11 | import java.util.LinkedHashSet; | ||
12 | import java.util.List; | ||
13 | import java.util.Objects; | ||
14 | import java.util.Optional; | ||
15 | import java.util.Set; | ||
16 | import java.util.function.Consumer; | ||
17 | import java.util.stream.Collectors; | ||
18 | import java.util.stream.Stream; | ||
19 | import org.apache.log4j.Logger; | ||
20 | import org.eclipse.emf.ecore.EClass; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
44 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
45 | |||
46 | /** | ||
47 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
48 | * | ||
49 | * <p>Original source: | ||
50 | * <code><pre> | ||
51 | * {@literal @}Constraint(severity = "error", key = {Host, App}, | ||
52 | * message = "Application instance must be allocated to a supported host type.") | ||
53 | * pattern allocationWithoutResourceRequirement(Host : HostInstance, App : ApplicationInstance) { | ||
54 | * ApplicationInstance.allocatedTo(App, Host); | ||
55 | * neg find resourceRequirement(Host, App, _); | ||
56 | * } | ||
57 | * </pre></code> | ||
58 | * | ||
59 | * @see Matcher | ||
60 | * @see Match | ||
61 | * | ||
62 | */ | ||
63 | @SuppressWarnings("all") | ||
64 | public final class AllocationWithoutResourceRequirement extends BaseGeneratedEMFQuerySpecification<AllocationWithoutResourceRequirement.Matcher> { | ||
65 | /** | ||
66 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocationWithoutResourceRequirement pattern, | ||
67 | * to be used in conjunction with {@link Matcher}. | ||
68 | * | ||
69 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
70 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
71 | * usable to represent a match of the pattern in the result of a query, | ||
72 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
73 | * | ||
74 | * @see Matcher | ||
75 | * | ||
76 | */ | ||
77 | public static abstract class Match extends BasePatternMatch { | ||
78 | private HostInstance fHost; | ||
79 | |||
80 | private ApplicationInstance fApp; | ||
81 | |||
82 | private static List<String> parameterNames = makeImmutableList("Host", "App"); | ||
83 | |||
84 | private Match(final HostInstance pHost, final ApplicationInstance pApp) { | ||
85 | this.fHost = pHost; | ||
86 | this.fApp = pApp; | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final String parameterName) { | ||
91 | switch(parameterName) { | ||
92 | case "Host": return this.fHost; | ||
93 | case "App": return this.fApp; | ||
94 | default: return null; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | @Override | ||
99 | public Object get(final int index) { | ||
100 | switch(index) { | ||
101 | case 0: return this.fHost; | ||
102 | case 1: return this.fApp; | ||
103 | default: return null; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | public HostInstance getHost() { | ||
108 | return this.fHost; | ||
109 | } | ||
110 | |||
111 | public ApplicationInstance getApp() { | ||
112 | return this.fApp; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public boolean set(final String parameterName, final Object newValue) { | ||
117 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
118 | if ("Host".equals(parameterName) ) { | ||
119 | this.fHost = (HostInstance) newValue; | ||
120 | return true; | ||
121 | } | ||
122 | if ("App".equals(parameterName) ) { | ||
123 | this.fApp = (ApplicationInstance) newValue; | ||
124 | return true; | ||
125 | } | ||
126 | return false; | ||
127 | } | ||
128 | |||
129 | public void setHost(final HostInstance pHost) { | ||
130 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
131 | this.fHost = pHost; | ||
132 | } | ||
133 | |||
134 | public void setApp(final ApplicationInstance pApp) { | ||
135 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
136 | this.fApp = pApp; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public String patternName() { | ||
141 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocationWithoutResourceRequirement"; | ||
142 | } | ||
143 | |||
144 | @Override | ||
145 | public List<String> parameterNames() { | ||
146 | return AllocationWithoutResourceRequirement.Match.parameterNames; | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public Object[] toArray() { | ||
151 | return new Object[]{fHost, fApp}; | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public AllocationWithoutResourceRequirement.Match toImmutable() { | ||
156 | return isMutable() ? newMatch(fHost, fApp) : this; | ||
157 | } | ||
158 | |||
159 | @Override | ||
160 | public String prettyPrint() { | ||
161 | StringBuilder result = new StringBuilder(); | ||
162 | result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); | ||
163 | result.append("\"App\"=" + prettyPrintValue(fApp)); | ||
164 | return result.toString(); | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public int hashCode() { | ||
169 | return Objects.hash(fHost, fApp); | ||
170 | } | ||
171 | |||
172 | @Override | ||
173 | public boolean equals(final Object obj) { | ||
174 | if (this == obj) | ||
175 | return true; | ||
176 | if (obj == null) { | ||
177 | return false; | ||
178 | } | ||
179 | if ((obj instanceof AllocationWithoutResourceRequirement.Match)) { | ||
180 | AllocationWithoutResourceRequirement.Match other = (AllocationWithoutResourceRequirement.Match) obj; | ||
181 | return Objects.equals(fHost, other.fHost) && Objects.equals(fApp, other.fApp); | ||
182 | } else { | ||
183 | // this should be infrequent | ||
184 | if (!(obj instanceof IPatternMatch)) { | ||
185 | return false; | ||
186 | } | ||
187 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
188 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | @Override | ||
193 | public AllocationWithoutResourceRequirement specification() { | ||
194 | return AllocationWithoutResourceRequirement.instance(); | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * Returns an empty, mutable match. | ||
199 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
200 | * | ||
201 | * @return the empty match. | ||
202 | * | ||
203 | */ | ||
204 | public static AllocationWithoutResourceRequirement.Match newEmptyMatch() { | ||
205 | return new Mutable(null, null); | ||
206 | } | ||
207 | |||
208 | /** | ||
209 | * Returns a mutable (partial) match. | ||
210 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
211 | * | ||
212 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
213 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
214 | * @return the new, mutable (partial) match object. | ||
215 | * | ||
216 | */ | ||
217 | public static AllocationWithoutResourceRequirement.Match newMutableMatch(final HostInstance pHost, final ApplicationInstance pApp) { | ||
218 | return new Mutable(pHost, pApp); | ||
219 | } | ||
220 | |||
221 | /** | ||
222 | * Returns a new (partial) match. | ||
223 | * This can be used e.g. to call the matcher with a partial match. | ||
224 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
225 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
226 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
227 | * @return the (partial) match object. | ||
228 | * | ||
229 | */ | ||
230 | public static AllocationWithoutResourceRequirement.Match newMatch(final HostInstance pHost, final ApplicationInstance pApp) { | ||
231 | return new Immutable(pHost, pApp); | ||
232 | } | ||
233 | |||
234 | private static final class Mutable extends AllocationWithoutResourceRequirement.Match { | ||
235 | Mutable(final HostInstance pHost, final ApplicationInstance pApp) { | ||
236 | super(pHost, pApp); | ||
237 | } | ||
238 | |||
239 | @Override | ||
240 | public boolean isMutable() { | ||
241 | return true; | ||
242 | } | ||
243 | } | ||
244 | |||
245 | private static final class Immutable extends AllocationWithoutResourceRequirement.Match { | ||
246 | Immutable(final HostInstance pHost, final ApplicationInstance pApp) { | ||
247 | super(pHost, pApp); | ||
248 | } | ||
249 | |||
250 | @Override | ||
251 | public boolean isMutable() { | ||
252 | return false; | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | |||
257 | /** | ||
258 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocationWithoutResourceRequirement pattern, | ||
259 | * providing pattern-specific query methods. | ||
260 | * | ||
261 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
262 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
263 | * | ||
264 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
265 | * | ||
266 | * <p>Original source: | ||
267 | * <code><pre> | ||
268 | * {@literal @}Constraint(severity = "error", key = {Host, App}, | ||
269 | * message = "Application instance must be allocated to a supported host type.") | ||
270 | * pattern allocationWithoutResourceRequirement(Host : HostInstance, App : ApplicationInstance) { | ||
271 | * ApplicationInstance.allocatedTo(App, Host); | ||
272 | * neg find resourceRequirement(Host, App, _); | ||
273 | * } | ||
274 | * </pre></code> | ||
275 | * | ||
276 | * @see Match | ||
277 | * @see AllocationWithoutResourceRequirement | ||
278 | * | ||
279 | */ | ||
280 | public static class Matcher extends BaseMatcher<AllocationWithoutResourceRequirement.Match> { | ||
281 | /** | ||
282 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
283 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
284 | * | ||
285 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
286 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
287 | * | ||
288 | */ | ||
289 | public static AllocationWithoutResourceRequirement.Matcher on(final ViatraQueryEngine engine) { | ||
290 | // check if matcher already exists | ||
291 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
292 | if (matcher == null) { | ||
293 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
294 | } | ||
295 | return matcher; | ||
296 | } | ||
297 | |||
298 | /** | ||
299 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
300 | * @return an initialized matcher | ||
301 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
302 | * | ||
303 | */ | ||
304 | public static AllocationWithoutResourceRequirement.Matcher create() { | ||
305 | return new Matcher(); | ||
306 | } | ||
307 | |||
308 | private static final int POSITION_HOST = 0; | ||
309 | |||
310 | private static final int POSITION_APP = 1; | ||
311 | |||
312 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AllocationWithoutResourceRequirement.Matcher.class); | ||
313 | |||
314 | /** | ||
315 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
316 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
317 | * | ||
318 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
319 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
320 | * | ||
321 | */ | ||
322 | private Matcher() { | ||
323 | super(querySpecification()); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
328 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
329 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
330 | * @return matches represented as a Match object. | ||
331 | * | ||
332 | */ | ||
333 | public Collection<AllocationWithoutResourceRequirement.Match> getAllMatches(final HostInstance pHost, final ApplicationInstance pApp) { | ||
334 | return rawStreamAllMatches(new Object[]{pHost, pApp}).collect(Collectors.toSet()); | ||
335 | } | ||
336 | |||
337 | /** | ||
338 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
339 | * </p> | ||
340 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
341 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
342 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
343 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
344 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
345 | * @return a stream of matches represented as a Match object. | ||
346 | * | ||
347 | */ | ||
348 | public Stream<AllocationWithoutResourceRequirement.Match> streamAllMatches(final HostInstance pHost, final ApplicationInstance pApp) { | ||
349 | return rawStreamAllMatches(new Object[]{pHost, pApp}); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
354 | * Neither determinism nor randomness of selection is guaranteed. | ||
355 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
356 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
357 | * @return a match represented as a Match object, or null if no match is found. | ||
358 | * | ||
359 | */ | ||
360 | public Optional<AllocationWithoutResourceRequirement.Match> getOneArbitraryMatch(final HostInstance pHost, final ApplicationInstance pApp) { | ||
361 | return rawGetOneArbitraryMatch(new Object[]{pHost, pApp}); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
366 | * under any possible substitution of the unspecified parameters (if any). | ||
367 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
368 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
369 | * @return true if the input is a valid (partial) match of the pattern. | ||
370 | * | ||
371 | */ | ||
372 | public boolean hasMatch(final HostInstance pHost, final ApplicationInstance pApp) { | ||
373 | return rawHasMatch(new Object[]{pHost, pApp}); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
378 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
379 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
380 | * @return the number of pattern matches found. | ||
381 | * | ||
382 | */ | ||
383 | public int countMatches(final HostInstance pHost, final ApplicationInstance pApp) { | ||
384 | return rawCountMatches(new Object[]{pHost, pApp}); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
389 | * Neither determinism nor randomness of selection is guaranteed. | ||
390 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
391 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
392 | * @param processor the action that will process the selected match. | ||
393 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
394 | * | ||
395 | */ | ||
396 | public boolean forOneArbitraryMatch(final HostInstance pHost, final ApplicationInstance pApp, final Consumer<? super AllocationWithoutResourceRequirement.Match> processor) { | ||
397 | return rawForOneArbitraryMatch(new Object[]{pHost, pApp}, processor); | ||
398 | } | ||
399 | |||
400 | /** | ||
401 | * Returns a new (partial) match. | ||
402 | * This can be used e.g. to call the matcher with a partial match. | ||
403 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
404 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
405 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
406 | * @return the (partial) match object. | ||
407 | * | ||
408 | */ | ||
409 | public AllocationWithoutResourceRequirement.Match newMatch(final HostInstance pHost, final ApplicationInstance pApp) { | ||
410 | return AllocationWithoutResourceRequirement.Match.newMatch(pHost, pApp); | ||
411 | } | ||
412 | |||
413 | /** | ||
414 | * Retrieve the set of values that occur in matches for Host. | ||
415 | * @return the Set of all values or empty set if there are no matches | ||
416 | * | ||
417 | */ | ||
418 | protected Stream<HostInstance> rawStreamAllValuesOfHost(final Object[] parameters) { | ||
419 | return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); | ||
420 | } | ||
421 | |||
422 | /** | ||
423 | * Retrieve the set of values that occur in matches for Host. | ||
424 | * @return the Set of all values or empty set if there are no matches | ||
425 | * | ||
426 | */ | ||
427 | public Set<HostInstance> getAllValuesOfHost() { | ||
428 | return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); | ||
429 | } | ||
430 | |||
431 | /** | ||
432 | * Retrieve the set of values that occur in matches for Host. | ||
433 | * @return the Set of all values or empty set if there are no matches | ||
434 | * | ||
435 | */ | ||
436 | public Stream<HostInstance> streamAllValuesOfHost() { | ||
437 | return rawStreamAllValuesOfHost(emptyArray()); | ||
438 | } | ||
439 | |||
440 | /** | ||
441 | * Retrieve the set of values that occur in matches for Host. | ||
442 | * </p> | ||
443 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
444 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
445 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
446 | * | ||
447 | * @return the Stream of all values or empty set if there are no matches | ||
448 | * | ||
449 | */ | ||
450 | public Stream<HostInstance> streamAllValuesOfHost(final AllocationWithoutResourceRequirement.Match partialMatch) { | ||
451 | return rawStreamAllValuesOfHost(partialMatch.toArray()); | ||
452 | } | ||
453 | |||
454 | /** | ||
455 | * Retrieve the set of values that occur in matches for Host. | ||
456 | * </p> | ||
457 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
458 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
459 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
460 | * | ||
461 | * @return the Stream of all values or empty set if there are no matches | ||
462 | * | ||
463 | */ | ||
464 | public Stream<HostInstance> streamAllValuesOfHost(final ApplicationInstance pApp) { | ||
465 | return rawStreamAllValuesOfHost(new Object[]{null, pApp}); | ||
466 | } | ||
467 | |||
468 | /** | ||
469 | * Retrieve the set of values that occur in matches for Host. | ||
470 | * @return the Set of all values or empty set if there are no matches | ||
471 | * | ||
472 | */ | ||
473 | public Set<HostInstance> getAllValuesOfHost(final AllocationWithoutResourceRequirement.Match partialMatch) { | ||
474 | return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); | ||
475 | } | ||
476 | |||
477 | /** | ||
478 | * Retrieve the set of values that occur in matches for Host. | ||
479 | * @return the Set of all values or empty set if there are no matches | ||
480 | * | ||
481 | */ | ||
482 | public Set<HostInstance> getAllValuesOfHost(final ApplicationInstance pApp) { | ||
483 | return rawStreamAllValuesOfHost(new Object[]{null, pApp}).collect(Collectors.toSet()); | ||
484 | } | ||
485 | |||
486 | /** | ||
487 | * Retrieve the set of values that occur in matches for App. | ||
488 | * @return the Set of all values or empty set if there are no matches | ||
489 | * | ||
490 | */ | ||
491 | protected Stream<ApplicationInstance> rawStreamAllValuesOfApp(final Object[] parameters) { | ||
492 | return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast); | ||
493 | } | ||
494 | |||
495 | /** | ||
496 | * Retrieve the set of values that occur in matches for App. | ||
497 | * @return the Set of all values or empty set if there are no matches | ||
498 | * | ||
499 | */ | ||
500 | public Set<ApplicationInstance> getAllValuesOfApp() { | ||
501 | return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet()); | ||
502 | } | ||
503 | |||
504 | /** | ||
505 | * Retrieve the set of values that occur in matches for App. | ||
506 | * @return the Set of all values or empty set if there are no matches | ||
507 | * | ||
508 | */ | ||
509 | public Stream<ApplicationInstance> streamAllValuesOfApp() { | ||
510 | return rawStreamAllValuesOfApp(emptyArray()); | ||
511 | } | ||
512 | |||
513 | /** | ||
514 | * Retrieve the set of values that occur in matches for App. | ||
515 | * </p> | ||
516 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
517 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
518 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
519 | * | ||
520 | * @return the Stream of all values or empty set if there are no matches | ||
521 | * | ||
522 | */ | ||
523 | public Stream<ApplicationInstance> streamAllValuesOfApp(final AllocationWithoutResourceRequirement.Match partialMatch) { | ||
524 | return rawStreamAllValuesOfApp(partialMatch.toArray()); | ||
525 | } | ||
526 | |||
527 | /** | ||
528 | * Retrieve the set of values that occur in matches for App. | ||
529 | * </p> | ||
530 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
531 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
532 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
533 | * | ||
534 | * @return the Stream of all values or empty set if there are no matches | ||
535 | * | ||
536 | */ | ||
537 | public Stream<ApplicationInstance> streamAllValuesOfApp(final HostInstance pHost) { | ||
538 | return rawStreamAllValuesOfApp(new Object[]{pHost, null}); | ||
539 | } | ||
540 | |||
541 | /** | ||
542 | * Retrieve the set of values that occur in matches for App. | ||
543 | * @return the Set of all values or empty set if there are no matches | ||
544 | * | ||
545 | */ | ||
546 | public Set<ApplicationInstance> getAllValuesOfApp(final AllocationWithoutResourceRequirement.Match partialMatch) { | ||
547 | return rawStreamAllValuesOfApp(partialMatch.toArray()).collect(Collectors.toSet()); | ||
548 | } | ||
549 | |||
550 | /** | ||
551 | * Retrieve the set of values that occur in matches for App. | ||
552 | * @return the Set of all values or empty set if there are no matches | ||
553 | * | ||
554 | */ | ||
555 | public Set<ApplicationInstance> getAllValuesOfApp(final HostInstance pHost) { | ||
556 | return rawStreamAllValuesOfApp(new Object[]{pHost, null}).collect(Collectors.toSet()); | ||
557 | } | ||
558 | |||
559 | @Override | ||
560 | protected AllocationWithoutResourceRequirement.Match tupleToMatch(final Tuple t) { | ||
561 | try { | ||
562 | return AllocationWithoutResourceRequirement.Match.newMatch((HostInstance) t.get(POSITION_HOST), (ApplicationInstance) t.get(POSITION_APP)); | ||
563 | } catch(ClassCastException e) { | ||
564 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
565 | return null; | ||
566 | } | ||
567 | } | ||
568 | |||
569 | @Override | ||
570 | protected AllocationWithoutResourceRequirement.Match arrayToMatch(final Object[] match) { | ||
571 | try { | ||
572 | return AllocationWithoutResourceRequirement.Match.newMatch((HostInstance) match[POSITION_HOST], (ApplicationInstance) match[POSITION_APP]); | ||
573 | } catch(ClassCastException e) { | ||
574 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
575 | return null; | ||
576 | } | ||
577 | } | ||
578 | |||
579 | @Override | ||
580 | protected AllocationWithoutResourceRequirement.Match arrayToMatchMutable(final Object[] match) { | ||
581 | try { | ||
582 | return AllocationWithoutResourceRequirement.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (ApplicationInstance) match[POSITION_APP]); | ||
583 | } catch(ClassCastException e) { | ||
584 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
585 | return null; | ||
586 | } | ||
587 | } | ||
588 | |||
589 | /** | ||
590 | * @return the singleton instance of the query specification of this pattern | ||
591 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
592 | * | ||
593 | */ | ||
594 | public static IQuerySpecification<AllocationWithoutResourceRequirement.Matcher> querySpecification() { | ||
595 | return AllocationWithoutResourceRequirement.instance(); | ||
596 | } | ||
597 | } | ||
598 | |||
599 | private AllocationWithoutResourceRequirement() { | ||
600 | super(GeneratedPQuery.INSTANCE); | ||
601 | } | ||
602 | |||
603 | /** | ||
604 | * @return the singleton instance of the query specification | ||
605 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
606 | * | ||
607 | */ | ||
608 | public static AllocationWithoutResourceRequirement instance() { | ||
609 | try{ | ||
610 | return LazyHolder.INSTANCE; | ||
611 | } catch (ExceptionInInitializerError err) { | ||
612 | throw processInitializerError(err); | ||
613 | } | ||
614 | } | ||
615 | |||
616 | @Override | ||
617 | protected AllocationWithoutResourceRequirement.Matcher instantiate(final ViatraQueryEngine engine) { | ||
618 | return AllocationWithoutResourceRequirement.Matcher.on(engine); | ||
619 | } | ||
620 | |||
621 | @Override | ||
622 | public AllocationWithoutResourceRequirement.Matcher instantiate() { | ||
623 | return AllocationWithoutResourceRequirement.Matcher.create(); | ||
624 | } | ||
625 | |||
626 | @Override | ||
627 | public AllocationWithoutResourceRequirement.Match newEmptyMatch() { | ||
628 | return AllocationWithoutResourceRequirement.Match.newEmptyMatch(); | ||
629 | } | ||
630 | |||
631 | @Override | ||
632 | public AllocationWithoutResourceRequirement.Match newMatch(final Object... parameters) { | ||
633 | return AllocationWithoutResourceRequirement.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[1]); | ||
634 | } | ||
635 | |||
636 | /** | ||
637 | * Inner class allowing the singleton instance of {@link AllocationWithoutResourceRequirement} to be created | ||
638 | * <b>not</b> at the class load time of the outer class, | ||
639 | * but rather at the first call to {@link AllocationWithoutResourceRequirement#instance()}. | ||
640 | * | ||
641 | * <p> This workaround is required e.g. to support recursion. | ||
642 | * | ||
643 | */ | ||
644 | private static class LazyHolder { | ||
645 | private static final AllocationWithoutResourceRequirement INSTANCE = new AllocationWithoutResourceRequirement(); | ||
646 | |||
647 | /** | ||
648 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
649 | * This initialization order is required to support indirect recursion. | ||
650 | * | ||
651 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
652 | * | ||
653 | */ | ||
654 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
655 | |||
656 | public static Object ensureInitialized() { | ||
657 | INSTANCE.ensureInitializedInternal(); | ||
658 | return null; | ||
659 | } | ||
660 | } | ||
661 | |||
662 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
663 | private static final AllocationWithoutResourceRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
664 | |||
665 | private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
666 | |||
667 | private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); | ||
668 | |||
669 | private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_App); | ||
670 | |||
671 | private GeneratedPQuery() { | ||
672 | super(PVisibility.PUBLIC); | ||
673 | } | ||
674 | |||
675 | @Override | ||
676 | public String getFullyQualifiedName() { | ||
677 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocationWithoutResourceRequirement"; | ||
678 | } | ||
679 | |||
680 | @Override | ||
681 | public List<String> getParameterNames() { | ||
682 | return Arrays.asList("Host","App"); | ||
683 | } | ||
684 | |||
685 | @Override | ||
686 | public List<PParameter> getParameters() { | ||
687 | return parameters; | ||
688 | } | ||
689 | |||
690 | @Override | ||
691 | public Set<PBody> doGetContainedBodies() { | ||
692 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
693 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
694 | { | ||
695 | PBody body = new PBody(this); | ||
696 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
697 | PVariable var_App = body.getOrCreateVariableByName("App"); | ||
698 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
699 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
700 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
701 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
702 | new ExportedParameter(body, var_Host, parameter_Host), | ||
703 | new ExportedParameter(body, var_App, parameter_App) | ||
704 | )); | ||
705 | // ApplicationInstance.allocatedTo(App, Host) | ||
706 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
707 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
708 | new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); | ||
709 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
710 | new Equality(body, var__virtual_0_, var_Host); | ||
711 | // neg find resourceRequirement(Host, App, _) | ||
712 | new NegativePatternCall(body, Tuples.flatTupleOf(var_Host, var_App, var___0_), ResourceRequirement.instance().getInternalQueryRepresentation()); | ||
713 | bodies.add(body); | ||
714 | } | ||
715 | { | ||
716 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
717 | annotation.addAttribute("severity", "error"); | ||
718 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
719 | new ParameterReference("Host"), | ||
720 | new ParameterReference("App") | ||
721 | })); | ||
722 | annotation.addAttribute("message", "Application instance must be allocated to a supported host type."); | ||
723 | addAnnotation(annotation); | ||
724 | } | ||
725 | return bodies; | ||
726 | } | ||
727 | } | ||
728 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java new file mode 100644 index 00000000..607854bf --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java | |||
@@ -0,0 +1,554 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Objects; | ||
12 | import java.util.Optional; | ||
13 | import java.util.Set; | ||
14 | import java.util.function.Consumer; | ||
15 | import java.util.stream.Collectors; | ||
16 | import java.util.stream.Stream; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
19 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
20 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
21 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.aggregators.avg; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
40 | |||
41 | /** | ||
42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
43 | * | ||
44 | * <p>Original source: | ||
45 | * <code><pre> | ||
46 | * // Free HDD | ||
47 | * | ||
48 | * pattern averageFreeHddMetric(Average : java Double) { | ||
49 | * Average == avg find freeHddPercentage(_, #_); | ||
50 | * } | ||
51 | * </pre></code> | ||
52 | * | ||
53 | * @see Matcher | ||
54 | * @see Match | ||
55 | * | ||
56 | */ | ||
57 | @SuppressWarnings("all") | ||
58 | public final class AverageFreeHddMetric extends BaseGeneratedEMFQuerySpecification<AverageFreeHddMetric.Matcher> { | ||
59 | /** | ||
60 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric pattern, | ||
61 | * to be used in conjunction with {@link Matcher}. | ||
62 | * | ||
63 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
64 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
65 | * usable to represent a match of the pattern in the result of a query, | ||
66 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
67 | * | ||
68 | * @see Matcher | ||
69 | * | ||
70 | */ | ||
71 | public static abstract class Match extends BasePatternMatch { | ||
72 | private Double fAverage; | ||
73 | |||
74 | private static List<String> parameterNames = makeImmutableList("Average"); | ||
75 | |||
76 | private Match(final Double pAverage) { | ||
77 | this.fAverage = pAverage; | ||
78 | } | ||
79 | |||
80 | @Override | ||
81 | public Object get(final String parameterName) { | ||
82 | switch(parameterName) { | ||
83 | case "Average": return this.fAverage; | ||
84 | default: return null; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | @Override | ||
89 | public Object get(final int index) { | ||
90 | switch(index) { | ||
91 | case 0: return this.fAverage; | ||
92 | default: return null; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public Double getAverage() { | ||
97 | return this.fAverage; | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public boolean set(final String parameterName, final Object newValue) { | ||
102 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
103 | if ("Average".equals(parameterName) ) { | ||
104 | this.fAverage = (Double) newValue; | ||
105 | return true; | ||
106 | } | ||
107 | return false; | ||
108 | } | ||
109 | |||
110 | public void setAverage(final Double pAverage) { | ||
111 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
112 | this.fAverage = pAverage; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public String patternName() { | ||
117 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric"; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public List<String> parameterNames() { | ||
122 | return AverageFreeHddMetric.Match.parameterNames; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public Object[] toArray() { | ||
127 | return new Object[]{fAverage}; | ||
128 | } | ||
129 | |||
130 | @Override | ||
131 | public AverageFreeHddMetric.Match toImmutable() { | ||
132 | return isMutable() ? newMatch(fAverage) : this; | ||
133 | } | ||
134 | |||
135 | @Override | ||
136 | public String prettyPrint() { | ||
137 | StringBuilder result = new StringBuilder(); | ||
138 | result.append("\"Average\"=" + prettyPrintValue(fAverage)); | ||
139 | return result.toString(); | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public int hashCode() { | ||
144 | return Objects.hash(fAverage); | ||
145 | } | ||
146 | |||
147 | @Override | ||
148 | public boolean equals(final Object obj) { | ||
149 | if (this == obj) | ||
150 | return true; | ||
151 | if (obj == null) { | ||
152 | return false; | ||
153 | } | ||
154 | if ((obj instanceof AverageFreeHddMetric.Match)) { | ||
155 | AverageFreeHddMetric.Match other = (AverageFreeHddMetric.Match) obj; | ||
156 | return Objects.equals(fAverage, other.fAverage); | ||
157 | } else { | ||
158 | // this should be infrequent | ||
159 | if (!(obj instanceof IPatternMatch)) { | ||
160 | return false; | ||
161 | } | ||
162 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
163 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public AverageFreeHddMetric specification() { | ||
169 | return AverageFreeHddMetric.instance(); | ||
170 | } | ||
171 | |||
172 | /** | ||
173 | * Returns an empty, mutable match. | ||
174 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
175 | * | ||
176 | * @return the empty match. | ||
177 | * | ||
178 | */ | ||
179 | public static AverageFreeHddMetric.Match newEmptyMatch() { | ||
180 | return new Mutable(null); | ||
181 | } | ||
182 | |||
183 | /** | ||
184 | * Returns a mutable (partial) match. | ||
185 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
186 | * | ||
187 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
188 | * @return the new, mutable (partial) match object. | ||
189 | * | ||
190 | */ | ||
191 | public static AverageFreeHddMetric.Match newMutableMatch(final Double pAverage) { | ||
192 | return new Mutable(pAverage); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * Returns a new (partial) match. | ||
197 | * This can be used e.g. to call the matcher with a partial match. | ||
198 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
199 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
200 | * @return the (partial) match object. | ||
201 | * | ||
202 | */ | ||
203 | public static AverageFreeHddMetric.Match newMatch(final Double pAverage) { | ||
204 | return new Immutable(pAverage); | ||
205 | } | ||
206 | |||
207 | private static final class Mutable extends AverageFreeHddMetric.Match { | ||
208 | Mutable(final Double pAverage) { | ||
209 | super(pAverage); | ||
210 | } | ||
211 | |||
212 | @Override | ||
213 | public boolean isMutable() { | ||
214 | return true; | ||
215 | } | ||
216 | } | ||
217 | |||
218 | private static final class Immutable extends AverageFreeHddMetric.Match { | ||
219 | Immutable(final Double pAverage) { | ||
220 | super(pAverage); | ||
221 | } | ||
222 | |||
223 | @Override | ||
224 | public boolean isMutable() { | ||
225 | return false; | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | |||
230 | /** | ||
231 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric pattern, | ||
232 | * providing pattern-specific query methods. | ||
233 | * | ||
234 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
235 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
236 | * | ||
237 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
238 | * | ||
239 | * <p>Original source: | ||
240 | * <code><pre> | ||
241 | * // Free HDD | ||
242 | * | ||
243 | * pattern averageFreeHddMetric(Average : java Double) { | ||
244 | * Average == avg find freeHddPercentage(_, #_); | ||
245 | * } | ||
246 | * </pre></code> | ||
247 | * | ||
248 | * @see Match | ||
249 | * @see AverageFreeHddMetric | ||
250 | * | ||
251 | */ | ||
252 | public static class Matcher extends BaseMatcher<AverageFreeHddMetric.Match> { | ||
253 | /** | ||
254 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
255 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
256 | * | ||
257 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
258 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
259 | * | ||
260 | */ | ||
261 | public static AverageFreeHddMetric.Matcher on(final ViatraQueryEngine engine) { | ||
262 | // check if matcher already exists | ||
263 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
264 | if (matcher == null) { | ||
265 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
266 | } | ||
267 | return matcher; | ||
268 | } | ||
269 | |||
270 | /** | ||
271 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
272 | * @return an initialized matcher | ||
273 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
274 | * | ||
275 | */ | ||
276 | public static AverageFreeHddMetric.Matcher create() { | ||
277 | return new Matcher(); | ||
278 | } | ||
279 | |||
280 | private static final int POSITION_AVERAGE = 0; | ||
281 | |||
282 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AverageFreeHddMetric.Matcher.class); | ||
283 | |||
284 | /** | ||
285 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
286 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
287 | * | ||
288 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
289 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
290 | * | ||
291 | */ | ||
292 | private Matcher() { | ||
293 | super(querySpecification()); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
298 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
299 | * @return matches represented as a Match object. | ||
300 | * | ||
301 | */ | ||
302 | public Collection<AverageFreeHddMetric.Match> getAllMatches(final Double pAverage) { | ||
303 | return rawStreamAllMatches(new Object[]{pAverage}).collect(Collectors.toSet()); | ||
304 | } | ||
305 | |||
306 | /** | ||
307 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
308 | * </p> | ||
309 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
310 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
311 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
312 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
313 | * @return a stream of matches represented as a Match object. | ||
314 | * | ||
315 | */ | ||
316 | public Stream<AverageFreeHddMetric.Match> streamAllMatches(final Double pAverage) { | ||
317 | return rawStreamAllMatches(new Object[]{pAverage}); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
322 | * Neither determinism nor randomness of selection is guaranteed. | ||
323 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
324 | * @return a match represented as a Match object, or null if no match is found. | ||
325 | * | ||
326 | */ | ||
327 | public Optional<AverageFreeHddMetric.Match> getOneArbitraryMatch(final Double pAverage) { | ||
328 | return rawGetOneArbitraryMatch(new Object[]{pAverage}); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
333 | * under any possible substitution of the unspecified parameters (if any). | ||
334 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
335 | * @return true if the input is a valid (partial) match of the pattern. | ||
336 | * | ||
337 | */ | ||
338 | public boolean hasMatch(final Double pAverage) { | ||
339 | return rawHasMatch(new Object[]{pAverage}); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
344 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
345 | * @return the number of pattern matches found. | ||
346 | * | ||
347 | */ | ||
348 | public int countMatches(final Double pAverage) { | ||
349 | return rawCountMatches(new Object[]{pAverage}); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
354 | * Neither determinism nor randomness of selection is guaranteed. | ||
355 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
356 | * @param processor the action that will process the selected match. | ||
357 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
358 | * | ||
359 | */ | ||
360 | public boolean forOneArbitraryMatch(final Double pAverage, final Consumer<? super AverageFreeHddMetric.Match> processor) { | ||
361 | return rawForOneArbitraryMatch(new Object[]{pAverage}, processor); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Returns a new (partial) match. | ||
366 | * This can be used e.g. to call the matcher with a partial match. | ||
367 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
368 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
369 | * @return the (partial) match object. | ||
370 | * | ||
371 | */ | ||
372 | public AverageFreeHddMetric.Match newMatch(final Double pAverage) { | ||
373 | return AverageFreeHddMetric.Match.newMatch(pAverage); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Retrieve the set of values that occur in matches for Average. | ||
378 | * @return the Set of all values or empty set if there are no matches | ||
379 | * | ||
380 | */ | ||
381 | protected Stream<Double> rawStreamAllValuesOfAverage(final Object[] parameters) { | ||
382 | return rawStreamAllValues(POSITION_AVERAGE, parameters).map(Double.class::cast); | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * Retrieve the set of values that occur in matches for Average. | ||
387 | * @return the Set of all values or empty set if there are no matches | ||
388 | * | ||
389 | */ | ||
390 | public Set<Double> getAllValuesOfAverage() { | ||
391 | return rawStreamAllValuesOfAverage(emptyArray()).collect(Collectors.toSet()); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Retrieve the set of values that occur in matches for Average. | ||
396 | * @return the Set of all values or empty set if there are no matches | ||
397 | * | ||
398 | */ | ||
399 | public Stream<Double> streamAllValuesOfAverage() { | ||
400 | return rawStreamAllValuesOfAverage(emptyArray()); | ||
401 | } | ||
402 | |||
403 | @Override | ||
404 | protected AverageFreeHddMetric.Match tupleToMatch(final Tuple t) { | ||
405 | try { | ||
406 | return AverageFreeHddMetric.Match.newMatch((Double) t.get(POSITION_AVERAGE)); | ||
407 | } catch(ClassCastException e) { | ||
408 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
409 | return null; | ||
410 | } | ||
411 | } | ||
412 | |||
413 | @Override | ||
414 | protected AverageFreeHddMetric.Match arrayToMatch(final Object[] match) { | ||
415 | try { | ||
416 | return AverageFreeHddMetric.Match.newMatch((Double) match[POSITION_AVERAGE]); | ||
417 | } catch(ClassCastException e) { | ||
418 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
419 | return null; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | @Override | ||
424 | protected AverageFreeHddMetric.Match arrayToMatchMutable(final Object[] match) { | ||
425 | try { | ||
426 | return AverageFreeHddMetric.Match.newMutableMatch((Double) match[POSITION_AVERAGE]); | ||
427 | } catch(ClassCastException e) { | ||
428 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
429 | return null; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * @return the singleton instance of the query specification of this pattern | ||
435 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
436 | * | ||
437 | */ | ||
438 | public static IQuerySpecification<AverageFreeHddMetric.Matcher> querySpecification() { | ||
439 | return AverageFreeHddMetric.instance(); | ||
440 | } | ||
441 | } | ||
442 | |||
443 | private AverageFreeHddMetric() { | ||
444 | super(GeneratedPQuery.INSTANCE); | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @return the singleton instance of the query specification | ||
449 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
450 | * | ||
451 | */ | ||
452 | public static AverageFreeHddMetric instance() { | ||
453 | try{ | ||
454 | return LazyHolder.INSTANCE; | ||
455 | } catch (ExceptionInInitializerError err) { | ||
456 | throw processInitializerError(err); | ||
457 | } | ||
458 | } | ||
459 | |||
460 | @Override | ||
461 | protected AverageFreeHddMetric.Matcher instantiate(final ViatraQueryEngine engine) { | ||
462 | return AverageFreeHddMetric.Matcher.on(engine); | ||
463 | } | ||
464 | |||
465 | @Override | ||
466 | public AverageFreeHddMetric.Matcher instantiate() { | ||
467 | return AverageFreeHddMetric.Matcher.create(); | ||
468 | } | ||
469 | |||
470 | @Override | ||
471 | public AverageFreeHddMetric.Match newEmptyMatch() { | ||
472 | return AverageFreeHddMetric.Match.newEmptyMatch(); | ||
473 | } | ||
474 | |||
475 | @Override | ||
476 | public AverageFreeHddMetric.Match newMatch(final Object... parameters) { | ||
477 | return AverageFreeHddMetric.Match.newMatch((java.lang.Double) parameters[0]); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Inner class allowing the singleton instance of {@link AverageFreeHddMetric} to be created | ||
482 | * <b>not</b> at the class load time of the outer class, | ||
483 | * but rather at the first call to {@link AverageFreeHddMetric#instance()}. | ||
484 | * | ||
485 | * <p> This workaround is required e.g. to support recursion. | ||
486 | * | ||
487 | */ | ||
488 | private static class LazyHolder { | ||
489 | private static final AverageFreeHddMetric INSTANCE = new AverageFreeHddMetric(); | ||
490 | |||
491 | /** | ||
492 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
493 | * This initialization order is required to support indirect recursion. | ||
494 | * | ||
495 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
496 | * | ||
497 | */ | ||
498 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
499 | |||
500 | public static Object ensureInitialized() { | ||
501 | INSTANCE.ensureInitializedInternal(); | ||
502 | return null; | ||
503 | } | ||
504 | } | ||
505 | |||
506 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
507 | private static final AverageFreeHddMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
508 | |||
509 | private final PParameter parameter_Average = new PParameter("Average", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
510 | |||
511 | private final List<PParameter> parameters = Arrays.asList(parameter_Average); | ||
512 | |||
513 | private GeneratedPQuery() { | ||
514 | super(PVisibility.PUBLIC); | ||
515 | } | ||
516 | |||
517 | @Override | ||
518 | public String getFullyQualifiedName() { | ||
519 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric"; | ||
520 | } | ||
521 | |||
522 | @Override | ||
523 | public List<String> getParameterNames() { | ||
524 | return Arrays.asList("Average"); | ||
525 | } | ||
526 | |||
527 | @Override | ||
528 | public List<PParameter> getParameters() { | ||
529 | return parameters; | ||
530 | } | ||
531 | |||
532 | @Override | ||
533 | public Set<PBody> doGetContainedBodies() { | ||
534 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
535 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
536 | { | ||
537 | PBody body = new PBody(this); | ||
538 | PVariable var_Average = body.getOrCreateVariableByName("Average"); | ||
539 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
540 | PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); | ||
541 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Average), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
542 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
543 | new ExportedParameter(body, var_Average, parameter_Average) | ||
544 | )); | ||
545 | // Average == avg find freeHddPercentage(_, #_) | ||
546 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
547 | new AggregatorConstraint(new avg().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var___0_, var___1_), FreeHddPercentage.instance().getInternalQueryRepresentation(), var__virtual_0_, 1); | ||
548 | new Equality(body, var_Average, var__virtual_0_); | ||
549 | bodies.add(body); | ||
550 | } | ||
551 | return bodies; | ||
552 | } | ||
553 | } | ||
554 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java new file mode 100644 index 00000000..627a5f89 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java | |||
@@ -0,0 +1,562 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Objects; | ||
12 | import java.util.Optional; | ||
13 | import java.util.Set; | ||
14 | import java.util.function.Consumer; | ||
15 | import java.util.stream.Collectors; | ||
16 | import java.util.stream.Stream; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
19 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
20 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
21 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.aggregators.avg; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
40 | |||
41 | /** | ||
42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
43 | * | ||
44 | * <p>Original source: | ||
45 | * <code><pre> | ||
46 | * // | ||
47 | * // Metrics | ||
48 | * // | ||
49 | * | ||
50 | * // Free memory | ||
51 | * | ||
52 | * pattern averageFreeMemoryMetric(Average : java Double) { | ||
53 | * Average == avg find freeMemoryPercentage(_, #_); | ||
54 | * } | ||
55 | * </pre></code> | ||
56 | * | ||
57 | * @see Matcher | ||
58 | * @see Match | ||
59 | * | ||
60 | */ | ||
61 | @SuppressWarnings("all") | ||
62 | public final class AverageFreeMemoryMetric extends BaseGeneratedEMFQuerySpecification<AverageFreeMemoryMetric.Matcher> { | ||
63 | /** | ||
64 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeMemoryMetric pattern, | ||
65 | * to be used in conjunction with {@link Matcher}. | ||
66 | * | ||
67 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
68 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
69 | * usable to represent a match of the pattern in the result of a query, | ||
70 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
71 | * | ||
72 | * @see Matcher | ||
73 | * | ||
74 | */ | ||
75 | public static abstract class Match extends BasePatternMatch { | ||
76 | private Double fAverage; | ||
77 | |||
78 | private static List<String> parameterNames = makeImmutableList("Average"); | ||
79 | |||
80 | private Match(final Double pAverage) { | ||
81 | this.fAverage = pAverage; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | switch(parameterName) { | ||
87 | case "Average": return this.fAverage; | ||
88 | default: return null; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | @Override | ||
93 | public Object get(final int index) { | ||
94 | switch(index) { | ||
95 | case 0: return this.fAverage; | ||
96 | default: return null; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | public Double getAverage() { | ||
101 | return this.fAverage; | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public boolean set(final String parameterName, final Object newValue) { | ||
106 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
107 | if ("Average".equals(parameterName) ) { | ||
108 | this.fAverage = (Double) newValue; | ||
109 | return true; | ||
110 | } | ||
111 | return false; | ||
112 | } | ||
113 | |||
114 | public void setAverage(final Double pAverage) { | ||
115 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
116 | this.fAverage = pAverage; | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public String patternName() { | ||
121 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeMemoryMetric"; | ||
122 | } | ||
123 | |||
124 | @Override | ||
125 | public List<String> parameterNames() { | ||
126 | return AverageFreeMemoryMetric.Match.parameterNames; | ||
127 | } | ||
128 | |||
129 | @Override | ||
130 | public Object[] toArray() { | ||
131 | return new Object[]{fAverage}; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public AverageFreeMemoryMetric.Match toImmutable() { | ||
136 | return isMutable() ? newMatch(fAverage) : this; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public String prettyPrint() { | ||
141 | StringBuilder result = new StringBuilder(); | ||
142 | result.append("\"Average\"=" + prettyPrintValue(fAverage)); | ||
143 | return result.toString(); | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public int hashCode() { | ||
148 | return Objects.hash(fAverage); | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public boolean equals(final Object obj) { | ||
153 | if (this == obj) | ||
154 | return true; | ||
155 | if (obj == null) { | ||
156 | return false; | ||
157 | } | ||
158 | if ((obj instanceof AverageFreeMemoryMetric.Match)) { | ||
159 | AverageFreeMemoryMetric.Match other = (AverageFreeMemoryMetric.Match) obj; | ||
160 | return Objects.equals(fAverage, other.fAverage); | ||
161 | } else { | ||
162 | // this should be infrequent | ||
163 | if (!(obj instanceof IPatternMatch)) { | ||
164 | return false; | ||
165 | } | ||
166 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
167 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
168 | } | ||
169 | } | ||
170 | |||
171 | @Override | ||
172 | public AverageFreeMemoryMetric specification() { | ||
173 | return AverageFreeMemoryMetric.instance(); | ||
174 | } | ||
175 | |||
176 | /** | ||
177 | * Returns an empty, mutable match. | ||
178 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
179 | * | ||
180 | * @return the empty match. | ||
181 | * | ||
182 | */ | ||
183 | public static AverageFreeMemoryMetric.Match newEmptyMatch() { | ||
184 | return new Mutable(null); | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * Returns a mutable (partial) match. | ||
189 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
190 | * | ||
191 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
192 | * @return the new, mutable (partial) match object. | ||
193 | * | ||
194 | */ | ||
195 | public static AverageFreeMemoryMetric.Match newMutableMatch(final Double pAverage) { | ||
196 | return new Mutable(pAverage); | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * Returns a new (partial) match. | ||
201 | * This can be used e.g. to call the matcher with a partial match. | ||
202 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
203 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
204 | * @return the (partial) match object. | ||
205 | * | ||
206 | */ | ||
207 | public static AverageFreeMemoryMetric.Match newMatch(final Double pAverage) { | ||
208 | return new Immutable(pAverage); | ||
209 | } | ||
210 | |||
211 | private static final class Mutable extends AverageFreeMemoryMetric.Match { | ||
212 | Mutable(final Double pAverage) { | ||
213 | super(pAverage); | ||
214 | } | ||
215 | |||
216 | @Override | ||
217 | public boolean isMutable() { | ||
218 | return true; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | private static final class Immutable extends AverageFreeMemoryMetric.Match { | ||
223 | Immutable(final Double pAverage) { | ||
224 | super(pAverage); | ||
225 | } | ||
226 | |||
227 | @Override | ||
228 | public boolean isMutable() { | ||
229 | return false; | ||
230 | } | ||
231 | } | ||
232 | } | ||
233 | |||
234 | /** | ||
235 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeMemoryMetric pattern, | ||
236 | * providing pattern-specific query methods. | ||
237 | * | ||
238 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
239 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
240 | * | ||
241 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
242 | * | ||
243 | * <p>Original source: | ||
244 | * <code><pre> | ||
245 | * // | ||
246 | * // Metrics | ||
247 | * // | ||
248 | * | ||
249 | * // Free memory | ||
250 | * | ||
251 | * pattern averageFreeMemoryMetric(Average : java Double) { | ||
252 | * Average == avg find freeMemoryPercentage(_, #_); | ||
253 | * } | ||
254 | * </pre></code> | ||
255 | * | ||
256 | * @see Match | ||
257 | * @see AverageFreeMemoryMetric | ||
258 | * | ||
259 | */ | ||
260 | public static class Matcher extends BaseMatcher<AverageFreeMemoryMetric.Match> { | ||
261 | /** | ||
262 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
263 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
264 | * | ||
265 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
266 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
267 | * | ||
268 | */ | ||
269 | public static AverageFreeMemoryMetric.Matcher on(final ViatraQueryEngine engine) { | ||
270 | // check if matcher already exists | ||
271 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
272 | if (matcher == null) { | ||
273 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
274 | } | ||
275 | return matcher; | ||
276 | } | ||
277 | |||
278 | /** | ||
279 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
280 | * @return an initialized matcher | ||
281 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
282 | * | ||
283 | */ | ||
284 | public static AverageFreeMemoryMetric.Matcher create() { | ||
285 | return new Matcher(); | ||
286 | } | ||
287 | |||
288 | private static final int POSITION_AVERAGE = 0; | ||
289 | |||
290 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AverageFreeMemoryMetric.Matcher.class); | ||
291 | |||
292 | /** | ||
293 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
294 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
295 | * | ||
296 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
297 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
298 | * | ||
299 | */ | ||
300 | private Matcher() { | ||
301 | super(querySpecification()); | ||
302 | } | ||
303 | |||
304 | /** | ||
305 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
306 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
307 | * @return matches represented as a Match object. | ||
308 | * | ||
309 | */ | ||
310 | public Collection<AverageFreeMemoryMetric.Match> getAllMatches(final Double pAverage) { | ||
311 | return rawStreamAllMatches(new Object[]{pAverage}).collect(Collectors.toSet()); | ||
312 | } | ||
313 | |||
314 | /** | ||
315 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
316 | * </p> | ||
317 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
318 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
319 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
320 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
321 | * @return a stream of matches represented as a Match object. | ||
322 | * | ||
323 | */ | ||
324 | public Stream<AverageFreeMemoryMetric.Match> streamAllMatches(final Double pAverage) { | ||
325 | return rawStreamAllMatches(new Object[]{pAverage}); | ||
326 | } | ||
327 | |||
328 | /** | ||
329 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
330 | * Neither determinism nor randomness of selection is guaranteed. | ||
331 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
332 | * @return a match represented as a Match object, or null if no match is found. | ||
333 | * | ||
334 | */ | ||
335 | public Optional<AverageFreeMemoryMetric.Match> getOneArbitraryMatch(final Double pAverage) { | ||
336 | return rawGetOneArbitraryMatch(new Object[]{pAverage}); | ||
337 | } | ||
338 | |||
339 | /** | ||
340 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
341 | * under any possible substitution of the unspecified parameters (if any). | ||
342 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
343 | * @return true if the input is a valid (partial) match of the pattern. | ||
344 | * | ||
345 | */ | ||
346 | public boolean hasMatch(final Double pAverage) { | ||
347 | return rawHasMatch(new Object[]{pAverage}); | ||
348 | } | ||
349 | |||
350 | /** | ||
351 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
352 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
353 | * @return the number of pattern matches found. | ||
354 | * | ||
355 | */ | ||
356 | public int countMatches(final Double pAverage) { | ||
357 | return rawCountMatches(new Object[]{pAverage}); | ||
358 | } | ||
359 | |||
360 | /** | ||
361 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
362 | * Neither determinism nor randomness of selection is guaranteed. | ||
363 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
364 | * @param processor the action that will process the selected match. | ||
365 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
366 | * | ||
367 | */ | ||
368 | public boolean forOneArbitraryMatch(final Double pAverage, final Consumer<? super AverageFreeMemoryMetric.Match> processor) { | ||
369 | return rawForOneArbitraryMatch(new Object[]{pAverage}, processor); | ||
370 | } | ||
371 | |||
372 | /** | ||
373 | * Returns a new (partial) match. | ||
374 | * This can be used e.g. to call the matcher with a partial match. | ||
375 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
376 | * @param pAverage the fixed value of pattern parameter Average, or null if not bound. | ||
377 | * @return the (partial) match object. | ||
378 | * | ||
379 | */ | ||
380 | public AverageFreeMemoryMetric.Match newMatch(final Double pAverage) { | ||
381 | return AverageFreeMemoryMetric.Match.newMatch(pAverage); | ||
382 | } | ||
383 | |||
384 | /** | ||
385 | * Retrieve the set of values that occur in matches for Average. | ||
386 | * @return the Set of all values or empty set if there are no matches | ||
387 | * | ||
388 | */ | ||
389 | protected Stream<Double> rawStreamAllValuesOfAverage(final Object[] parameters) { | ||
390 | return rawStreamAllValues(POSITION_AVERAGE, parameters).map(Double.class::cast); | ||
391 | } | ||
392 | |||
393 | /** | ||
394 | * Retrieve the set of values that occur in matches for Average. | ||
395 | * @return the Set of all values or empty set if there are no matches | ||
396 | * | ||
397 | */ | ||
398 | public Set<Double> getAllValuesOfAverage() { | ||
399 | return rawStreamAllValuesOfAverage(emptyArray()).collect(Collectors.toSet()); | ||
400 | } | ||
401 | |||
402 | /** | ||
403 | * Retrieve the set of values that occur in matches for Average. | ||
404 | * @return the Set of all values or empty set if there are no matches | ||
405 | * | ||
406 | */ | ||
407 | public Stream<Double> streamAllValuesOfAverage() { | ||
408 | return rawStreamAllValuesOfAverage(emptyArray()); | ||
409 | } | ||
410 | |||
411 | @Override | ||
412 | protected AverageFreeMemoryMetric.Match tupleToMatch(final Tuple t) { | ||
413 | try { | ||
414 | return AverageFreeMemoryMetric.Match.newMatch((Double) t.get(POSITION_AVERAGE)); | ||
415 | } catch(ClassCastException e) { | ||
416 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
417 | return null; | ||
418 | } | ||
419 | } | ||
420 | |||
421 | @Override | ||
422 | protected AverageFreeMemoryMetric.Match arrayToMatch(final Object[] match) { | ||
423 | try { | ||
424 | return AverageFreeMemoryMetric.Match.newMatch((Double) match[POSITION_AVERAGE]); | ||
425 | } catch(ClassCastException e) { | ||
426 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
427 | return null; | ||
428 | } | ||
429 | } | ||
430 | |||
431 | @Override | ||
432 | protected AverageFreeMemoryMetric.Match arrayToMatchMutable(final Object[] match) { | ||
433 | try { | ||
434 | return AverageFreeMemoryMetric.Match.newMutableMatch((Double) match[POSITION_AVERAGE]); | ||
435 | } catch(ClassCastException e) { | ||
436 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
437 | return null; | ||
438 | } | ||
439 | } | ||
440 | |||
441 | /** | ||
442 | * @return the singleton instance of the query specification of this pattern | ||
443 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
444 | * | ||
445 | */ | ||
446 | public static IQuerySpecification<AverageFreeMemoryMetric.Matcher> querySpecification() { | ||
447 | return AverageFreeMemoryMetric.instance(); | ||
448 | } | ||
449 | } | ||
450 | |||
451 | private AverageFreeMemoryMetric() { | ||
452 | super(GeneratedPQuery.INSTANCE); | ||
453 | } | ||
454 | |||
455 | /** | ||
456 | * @return the singleton instance of the query specification | ||
457 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
458 | * | ||
459 | */ | ||
460 | public static AverageFreeMemoryMetric instance() { | ||
461 | try{ | ||
462 | return LazyHolder.INSTANCE; | ||
463 | } catch (ExceptionInInitializerError err) { | ||
464 | throw processInitializerError(err); | ||
465 | } | ||
466 | } | ||
467 | |||
468 | @Override | ||
469 | protected AverageFreeMemoryMetric.Matcher instantiate(final ViatraQueryEngine engine) { | ||
470 | return AverageFreeMemoryMetric.Matcher.on(engine); | ||
471 | } | ||
472 | |||
473 | @Override | ||
474 | public AverageFreeMemoryMetric.Matcher instantiate() { | ||
475 | return AverageFreeMemoryMetric.Matcher.create(); | ||
476 | } | ||
477 | |||
478 | @Override | ||
479 | public AverageFreeMemoryMetric.Match newEmptyMatch() { | ||
480 | return AverageFreeMemoryMetric.Match.newEmptyMatch(); | ||
481 | } | ||
482 | |||
483 | @Override | ||
484 | public AverageFreeMemoryMetric.Match newMatch(final Object... parameters) { | ||
485 | return AverageFreeMemoryMetric.Match.newMatch((java.lang.Double) parameters[0]); | ||
486 | } | ||
487 | |||
488 | /** | ||
489 | * Inner class allowing the singleton instance of {@link AverageFreeMemoryMetric} to be created | ||
490 | * <b>not</b> at the class load time of the outer class, | ||
491 | * but rather at the first call to {@link AverageFreeMemoryMetric#instance()}. | ||
492 | * | ||
493 | * <p> This workaround is required e.g. to support recursion. | ||
494 | * | ||
495 | */ | ||
496 | private static class LazyHolder { | ||
497 | private static final AverageFreeMemoryMetric INSTANCE = new AverageFreeMemoryMetric(); | ||
498 | |||
499 | /** | ||
500 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
501 | * This initialization order is required to support indirect recursion. | ||
502 | * | ||
503 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
504 | * | ||
505 | */ | ||
506 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
507 | |||
508 | public static Object ensureInitialized() { | ||
509 | INSTANCE.ensureInitializedInternal(); | ||
510 | return null; | ||
511 | } | ||
512 | } | ||
513 | |||
514 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
515 | private static final AverageFreeMemoryMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
516 | |||
517 | private final PParameter parameter_Average = new PParameter("Average", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
518 | |||
519 | private final List<PParameter> parameters = Arrays.asList(parameter_Average); | ||
520 | |||
521 | private GeneratedPQuery() { | ||
522 | super(PVisibility.PUBLIC); | ||
523 | } | ||
524 | |||
525 | @Override | ||
526 | public String getFullyQualifiedName() { | ||
527 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeMemoryMetric"; | ||
528 | } | ||
529 | |||
530 | @Override | ||
531 | public List<String> getParameterNames() { | ||
532 | return Arrays.asList("Average"); | ||
533 | } | ||
534 | |||
535 | @Override | ||
536 | public List<PParameter> getParameters() { | ||
537 | return parameters; | ||
538 | } | ||
539 | |||
540 | @Override | ||
541 | public Set<PBody> doGetContainedBodies() { | ||
542 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
543 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
544 | { | ||
545 | PBody body = new PBody(this); | ||
546 | PVariable var_Average = body.getOrCreateVariableByName("Average"); | ||
547 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
548 | PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); | ||
549 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Average), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
550 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
551 | new ExportedParameter(body, var_Average, parameter_Average) | ||
552 | )); | ||
553 | // Average == avg find freeMemoryPercentage(_, #_) | ||
554 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
555 | new AggregatorConstraint(new avg().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var___0_, var___1_), FreeMemoryPercentage.instance().getInternalQueryRepresentation(), var__virtual_0_, 1); | ||
556 | new Equality(body, var_Average, var__virtual_0_); | ||
557 | bodies.add(body); | ||
558 | } | ||
559 | return bodies; | ||
560 | } | ||
561 | } | ||
562 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java new file mode 100644 index 00000000..eff44f0a --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java | |||
@@ -0,0 +1,554 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Objects; | ||
12 | import java.util.Optional; | ||
13 | import java.util.Set; | ||
14 | import java.util.function.Consumer; | ||
15 | import java.util.stream.Collectors; | ||
16 | import java.util.stream.Stream; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
19 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
20 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
21 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
40 | |||
41 | /** | ||
42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
43 | * | ||
44 | * <p>Original source: | ||
45 | * <code><pre> | ||
46 | * // Total cost | ||
47 | * | ||
48 | * pattern costMetric(Cost : java Integer) { | ||
49 | * Cost == sum find cpsCost(_, #_); | ||
50 | * } | ||
51 | * </pre></code> | ||
52 | * | ||
53 | * @see Matcher | ||
54 | * @see Match | ||
55 | * | ||
56 | */ | ||
57 | @SuppressWarnings("all") | ||
58 | public final class CostMetric extends BaseGeneratedEMFQuerySpecification<CostMetric.Matcher> { | ||
59 | /** | ||
60 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.costMetric pattern, | ||
61 | * to be used in conjunction with {@link Matcher}. | ||
62 | * | ||
63 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
64 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
65 | * usable to represent a match of the pattern in the result of a query, | ||
66 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
67 | * | ||
68 | * @see Matcher | ||
69 | * | ||
70 | */ | ||
71 | public static abstract class Match extends BasePatternMatch { | ||
72 | private Integer fCost; | ||
73 | |||
74 | private static List<String> parameterNames = makeImmutableList("Cost"); | ||
75 | |||
76 | private Match(final Integer pCost) { | ||
77 | this.fCost = pCost; | ||
78 | } | ||
79 | |||
80 | @Override | ||
81 | public Object get(final String parameterName) { | ||
82 | switch(parameterName) { | ||
83 | case "Cost": return this.fCost; | ||
84 | default: return null; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | @Override | ||
89 | public Object get(final int index) { | ||
90 | switch(index) { | ||
91 | case 0: return this.fCost; | ||
92 | default: return null; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public Integer getCost() { | ||
97 | return this.fCost; | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public boolean set(final String parameterName, final Object newValue) { | ||
102 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
103 | if ("Cost".equals(parameterName) ) { | ||
104 | this.fCost = (Integer) newValue; | ||
105 | return true; | ||
106 | } | ||
107 | return false; | ||
108 | } | ||
109 | |||
110 | public void setCost(final Integer pCost) { | ||
111 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
112 | this.fCost = pCost; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public String patternName() { | ||
117 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.costMetric"; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public List<String> parameterNames() { | ||
122 | return CostMetric.Match.parameterNames; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public Object[] toArray() { | ||
127 | return new Object[]{fCost}; | ||
128 | } | ||
129 | |||
130 | @Override | ||
131 | public CostMetric.Match toImmutable() { | ||
132 | return isMutable() ? newMatch(fCost) : this; | ||
133 | } | ||
134 | |||
135 | @Override | ||
136 | public String prettyPrint() { | ||
137 | StringBuilder result = new StringBuilder(); | ||
138 | result.append("\"Cost\"=" + prettyPrintValue(fCost)); | ||
139 | return result.toString(); | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public int hashCode() { | ||
144 | return Objects.hash(fCost); | ||
145 | } | ||
146 | |||
147 | @Override | ||
148 | public boolean equals(final Object obj) { | ||
149 | if (this == obj) | ||
150 | return true; | ||
151 | if (obj == null) { | ||
152 | return false; | ||
153 | } | ||
154 | if ((obj instanceof CostMetric.Match)) { | ||
155 | CostMetric.Match other = (CostMetric.Match) obj; | ||
156 | return Objects.equals(fCost, other.fCost); | ||
157 | } else { | ||
158 | // this should be infrequent | ||
159 | if (!(obj instanceof IPatternMatch)) { | ||
160 | return false; | ||
161 | } | ||
162 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
163 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public CostMetric specification() { | ||
169 | return CostMetric.instance(); | ||
170 | } | ||
171 | |||
172 | /** | ||
173 | * Returns an empty, mutable match. | ||
174 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
175 | * | ||
176 | * @return the empty match. | ||
177 | * | ||
178 | */ | ||
179 | public static CostMetric.Match newEmptyMatch() { | ||
180 | return new Mutable(null); | ||
181 | } | ||
182 | |||
183 | /** | ||
184 | * Returns a mutable (partial) match. | ||
185 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
186 | * | ||
187 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
188 | * @return the new, mutable (partial) match object. | ||
189 | * | ||
190 | */ | ||
191 | public static CostMetric.Match newMutableMatch(final Integer pCost) { | ||
192 | return new Mutable(pCost); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * Returns a new (partial) match. | ||
197 | * This can be used e.g. to call the matcher with a partial match. | ||
198 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
199 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
200 | * @return the (partial) match object. | ||
201 | * | ||
202 | */ | ||
203 | public static CostMetric.Match newMatch(final Integer pCost) { | ||
204 | return new Immutable(pCost); | ||
205 | } | ||
206 | |||
207 | private static final class Mutable extends CostMetric.Match { | ||
208 | Mutable(final Integer pCost) { | ||
209 | super(pCost); | ||
210 | } | ||
211 | |||
212 | @Override | ||
213 | public boolean isMutable() { | ||
214 | return true; | ||
215 | } | ||
216 | } | ||
217 | |||
218 | private static final class Immutable extends CostMetric.Match { | ||
219 | Immutable(final Integer pCost) { | ||
220 | super(pCost); | ||
221 | } | ||
222 | |||
223 | @Override | ||
224 | public boolean isMutable() { | ||
225 | return false; | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | |||
230 | /** | ||
231 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.costMetric pattern, | ||
232 | * providing pattern-specific query methods. | ||
233 | * | ||
234 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
235 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
236 | * | ||
237 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
238 | * | ||
239 | * <p>Original source: | ||
240 | * <code><pre> | ||
241 | * // Total cost | ||
242 | * | ||
243 | * pattern costMetric(Cost : java Integer) { | ||
244 | * Cost == sum find cpsCost(_, #_); | ||
245 | * } | ||
246 | * </pre></code> | ||
247 | * | ||
248 | * @see Match | ||
249 | * @see CostMetric | ||
250 | * | ||
251 | */ | ||
252 | public static class Matcher extends BaseMatcher<CostMetric.Match> { | ||
253 | /** | ||
254 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
255 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
256 | * | ||
257 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
258 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
259 | * | ||
260 | */ | ||
261 | public static CostMetric.Matcher on(final ViatraQueryEngine engine) { | ||
262 | // check if matcher already exists | ||
263 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
264 | if (matcher == null) { | ||
265 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
266 | } | ||
267 | return matcher; | ||
268 | } | ||
269 | |||
270 | /** | ||
271 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
272 | * @return an initialized matcher | ||
273 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
274 | * | ||
275 | */ | ||
276 | public static CostMetric.Matcher create() { | ||
277 | return new Matcher(); | ||
278 | } | ||
279 | |||
280 | private static final int POSITION_COST = 0; | ||
281 | |||
282 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CostMetric.Matcher.class); | ||
283 | |||
284 | /** | ||
285 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
286 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
287 | * | ||
288 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
289 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
290 | * | ||
291 | */ | ||
292 | private Matcher() { | ||
293 | super(querySpecification()); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
298 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
299 | * @return matches represented as a Match object. | ||
300 | * | ||
301 | */ | ||
302 | public Collection<CostMetric.Match> getAllMatches(final Integer pCost) { | ||
303 | return rawStreamAllMatches(new Object[]{pCost}).collect(Collectors.toSet()); | ||
304 | } | ||
305 | |||
306 | /** | ||
307 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
308 | * </p> | ||
309 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
310 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
311 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
312 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
313 | * @return a stream of matches represented as a Match object. | ||
314 | * | ||
315 | */ | ||
316 | public Stream<CostMetric.Match> streamAllMatches(final Integer pCost) { | ||
317 | return rawStreamAllMatches(new Object[]{pCost}); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
322 | * Neither determinism nor randomness of selection is guaranteed. | ||
323 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
324 | * @return a match represented as a Match object, or null if no match is found. | ||
325 | * | ||
326 | */ | ||
327 | public Optional<CostMetric.Match> getOneArbitraryMatch(final Integer pCost) { | ||
328 | return rawGetOneArbitraryMatch(new Object[]{pCost}); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
333 | * under any possible substitution of the unspecified parameters (if any). | ||
334 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
335 | * @return true if the input is a valid (partial) match of the pattern. | ||
336 | * | ||
337 | */ | ||
338 | public boolean hasMatch(final Integer pCost) { | ||
339 | return rawHasMatch(new Object[]{pCost}); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
344 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
345 | * @return the number of pattern matches found. | ||
346 | * | ||
347 | */ | ||
348 | public int countMatches(final Integer pCost) { | ||
349 | return rawCountMatches(new Object[]{pCost}); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
354 | * Neither determinism nor randomness of selection is guaranteed. | ||
355 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
356 | * @param processor the action that will process the selected match. | ||
357 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
358 | * | ||
359 | */ | ||
360 | public boolean forOneArbitraryMatch(final Integer pCost, final Consumer<? super CostMetric.Match> processor) { | ||
361 | return rawForOneArbitraryMatch(new Object[]{pCost}, processor); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Returns a new (partial) match. | ||
366 | * This can be used e.g. to call the matcher with a partial match. | ||
367 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
368 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
369 | * @return the (partial) match object. | ||
370 | * | ||
371 | */ | ||
372 | public CostMetric.Match newMatch(final Integer pCost) { | ||
373 | return CostMetric.Match.newMatch(pCost); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Retrieve the set of values that occur in matches for Cost. | ||
378 | * @return the Set of all values or empty set if there are no matches | ||
379 | * | ||
380 | */ | ||
381 | protected Stream<Integer> rawStreamAllValuesOfCost(final Object[] parameters) { | ||
382 | return rawStreamAllValues(POSITION_COST, parameters).map(Integer.class::cast); | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * Retrieve the set of values that occur in matches for Cost. | ||
387 | * @return the Set of all values or empty set if there are no matches | ||
388 | * | ||
389 | */ | ||
390 | public Set<Integer> getAllValuesOfCost() { | ||
391 | return rawStreamAllValuesOfCost(emptyArray()).collect(Collectors.toSet()); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Retrieve the set of values that occur in matches for Cost. | ||
396 | * @return the Set of all values or empty set if there are no matches | ||
397 | * | ||
398 | */ | ||
399 | public Stream<Integer> streamAllValuesOfCost() { | ||
400 | return rawStreamAllValuesOfCost(emptyArray()); | ||
401 | } | ||
402 | |||
403 | @Override | ||
404 | protected CostMetric.Match tupleToMatch(final Tuple t) { | ||
405 | try { | ||
406 | return CostMetric.Match.newMatch((Integer) t.get(POSITION_COST)); | ||
407 | } catch(ClassCastException e) { | ||
408 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
409 | return null; | ||
410 | } | ||
411 | } | ||
412 | |||
413 | @Override | ||
414 | protected CostMetric.Match arrayToMatch(final Object[] match) { | ||
415 | try { | ||
416 | return CostMetric.Match.newMatch((Integer) match[POSITION_COST]); | ||
417 | } catch(ClassCastException e) { | ||
418 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
419 | return null; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | @Override | ||
424 | protected CostMetric.Match arrayToMatchMutable(final Object[] match) { | ||
425 | try { | ||
426 | return CostMetric.Match.newMutableMatch((Integer) match[POSITION_COST]); | ||
427 | } catch(ClassCastException e) { | ||
428 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
429 | return null; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * @return the singleton instance of the query specification of this pattern | ||
435 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
436 | * | ||
437 | */ | ||
438 | public static IQuerySpecification<CostMetric.Matcher> querySpecification() { | ||
439 | return CostMetric.instance(); | ||
440 | } | ||
441 | } | ||
442 | |||
443 | private CostMetric() { | ||
444 | super(GeneratedPQuery.INSTANCE); | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @return the singleton instance of the query specification | ||
449 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
450 | * | ||
451 | */ | ||
452 | public static CostMetric instance() { | ||
453 | try{ | ||
454 | return LazyHolder.INSTANCE; | ||
455 | } catch (ExceptionInInitializerError err) { | ||
456 | throw processInitializerError(err); | ||
457 | } | ||
458 | } | ||
459 | |||
460 | @Override | ||
461 | protected CostMetric.Matcher instantiate(final ViatraQueryEngine engine) { | ||
462 | return CostMetric.Matcher.on(engine); | ||
463 | } | ||
464 | |||
465 | @Override | ||
466 | public CostMetric.Matcher instantiate() { | ||
467 | return CostMetric.Matcher.create(); | ||
468 | } | ||
469 | |||
470 | @Override | ||
471 | public CostMetric.Match newEmptyMatch() { | ||
472 | return CostMetric.Match.newEmptyMatch(); | ||
473 | } | ||
474 | |||
475 | @Override | ||
476 | public CostMetric.Match newMatch(final Object... parameters) { | ||
477 | return CostMetric.Match.newMatch((java.lang.Integer) parameters[0]); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Inner class allowing the singleton instance of {@link CostMetric} to be created | ||
482 | * <b>not</b> at the class load time of the outer class, | ||
483 | * but rather at the first call to {@link CostMetric#instance()}. | ||
484 | * | ||
485 | * <p> This workaround is required e.g. to support recursion. | ||
486 | * | ||
487 | */ | ||
488 | private static class LazyHolder { | ||
489 | private static final CostMetric INSTANCE = new CostMetric(); | ||
490 | |||
491 | /** | ||
492 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
493 | * This initialization order is required to support indirect recursion. | ||
494 | * | ||
495 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
496 | * | ||
497 | */ | ||
498 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
499 | |||
500 | public static Object ensureInitialized() { | ||
501 | INSTANCE.ensureInitializedInternal(); | ||
502 | return null; | ||
503 | } | ||
504 | } | ||
505 | |||
506 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
507 | private static final CostMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
508 | |||
509 | private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); | ||
510 | |||
511 | private final List<PParameter> parameters = Arrays.asList(parameter_Cost); | ||
512 | |||
513 | private GeneratedPQuery() { | ||
514 | super(PVisibility.PUBLIC); | ||
515 | } | ||
516 | |||
517 | @Override | ||
518 | public String getFullyQualifiedName() { | ||
519 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.costMetric"; | ||
520 | } | ||
521 | |||
522 | @Override | ||
523 | public List<String> getParameterNames() { | ||
524 | return Arrays.asList("Cost"); | ||
525 | } | ||
526 | |||
527 | @Override | ||
528 | public List<PParameter> getParameters() { | ||
529 | return parameters; | ||
530 | } | ||
531 | |||
532 | @Override | ||
533 | public Set<PBody> doGetContainedBodies() { | ||
534 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
535 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
536 | { | ||
537 | PBody body = new PBody(this); | ||
538 | PVariable var_Cost = body.getOrCreateVariableByName("Cost"); | ||
539 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
540 | PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); | ||
541 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Integer.class)); | ||
542 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
543 | new ExportedParameter(body, var_Cost, parameter_Cost) | ||
544 | )); | ||
545 | // Cost == sum find cpsCost(_, #_) | ||
546 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
547 | new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var___0_, var___1_), CpsCost.instance().getInternalQueryRepresentation(), var__virtual_0_, 1); | ||
548 | new Equality(body, var_Cost, var__virtual_0_); | ||
549 | bodies.add(body); | ||
550 | } | ||
551 | return bodies; | ||
552 | } | ||
553 | } | ||
554 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java new file mode 100644 index 00000000..1cf09b0d --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java | |||
@@ -0,0 +1,749 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsApplications; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost; | ||
9 | import java.util.Arrays; | ||
10 | import java.util.Collection; | ||
11 | import java.util.LinkedHashSet; | ||
12 | import java.util.List; | ||
13 | import java.util.Objects; | ||
14 | import java.util.Optional; | ||
15 | import java.util.Set; | ||
16 | import java.util.function.Consumer; | ||
17 | import java.util.stream.Collectors; | ||
18 | import java.util.stream.Stream; | ||
19 | import org.apache.log4j.Logger; | ||
20 | import org.eclipse.emf.ecore.EClass; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
44 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
45 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
46 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
47 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
48 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
49 | |||
50 | /** | ||
51 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
52 | * | ||
53 | * <p>Original source: | ||
54 | * <code><pre> | ||
55 | * pattern cpsCost(Cps : CyberPhysicalSystem, Cost : java Integer) { | ||
56 | * AppCount == count find cpsApplications(Cps, _); | ||
57 | * HostCost == sum find hostInstanceCost(Cps, _, #_); | ||
58 | * Cost == eval(5 AppCount + HostCost); | ||
59 | * } | ||
60 | * </pre></code> | ||
61 | * | ||
62 | * @see Matcher | ||
63 | * @see Match | ||
64 | * | ||
65 | */ | ||
66 | @SuppressWarnings("all") | ||
67 | public final class CpsCost extends BaseGeneratedEMFQuerySpecification<CpsCost.Matcher> { | ||
68 | /** | ||
69 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsCost pattern, | ||
70 | * to be used in conjunction with {@link Matcher}. | ||
71 | * | ||
72 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
73 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
74 | * usable to represent a match of the pattern in the result of a query, | ||
75 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
76 | * | ||
77 | * @see Matcher | ||
78 | * | ||
79 | */ | ||
80 | public static abstract class Match extends BasePatternMatch { | ||
81 | private CyberPhysicalSystem fCps; | ||
82 | |||
83 | private Integer fCost; | ||
84 | |||
85 | private static List<String> parameterNames = makeImmutableList("Cps", "Cost"); | ||
86 | |||
87 | private Match(final CyberPhysicalSystem pCps, final Integer pCost) { | ||
88 | this.fCps = pCps; | ||
89 | this.fCost = pCost; | ||
90 | } | ||
91 | |||
92 | @Override | ||
93 | public Object get(final String parameterName) { | ||
94 | switch(parameterName) { | ||
95 | case "Cps": return this.fCps; | ||
96 | case "Cost": return this.fCost; | ||
97 | default: return null; | ||
98 | } | ||
99 | } | ||
100 | |||
101 | @Override | ||
102 | public Object get(final int index) { | ||
103 | switch(index) { | ||
104 | case 0: return this.fCps; | ||
105 | case 1: return this.fCost; | ||
106 | default: return null; | ||
107 | } | ||
108 | } | ||
109 | |||
110 | public CyberPhysicalSystem getCps() { | ||
111 | return this.fCps; | ||
112 | } | ||
113 | |||
114 | public Integer getCost() { | ||
115 | return this.fCost; | ||
116 | } | ||
117 | |||
118 | @Override | ||
119 | public boolean set(final String parameterName, final Object newValue) { | ||
120 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
121 | if ("Cps".equals(parameterName) ) { | ||
122 | this.fCps = (CyberPhysicalSystem) newValue; | ||
123 | return true; | ||
124 | } | ||
125 | if ("Cost".equals(parameterName) ) { | ||
126 | this.fCost = (Integer) newValue; | ||
127 | return true; | ||
128 | } | ||
129 | return false; | ||
130 | } | ||
131 | |||
132 | public void setCps(final CyberPhysicalSystem pCps) { | ||
133 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
134 | this.fCps = pCps; | ||
135 | } | ||
136 | |||
137 | public void setCost(final Integer pCost) { | ||
138 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
139 | this.fCost = pCost; | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public String patternName() { | ||
144 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsCost"; | ||
145 | } | ||
146 | |||
147 | @Override | ||
148 | public List<String> parameterNames() { | ||
149 | return CpsCost.Match.parameterNames; | ||
150 | } | ||
151 | |||
152 | @Override | ||
153 | public Object[] toArray() { | ||
154 | return new Object[]{fCps, fCost}; | ||
155 | } | ||
156 | |||
157 | @Override | ||
158 | public CpsCost.Match toImmutable() { | ||
159 | return isMutable() ? newMatch(fCps, fCost) : this; | ||
160 | } | ||
161 | |||
162 | @Override | ||
163 | public String prettyPrint() { | ||
164 | StringBuilder result = new StringBuilder(); | ||
165 | result.append("\"Cps\"=" + prettyPrintValue(fCps) + ", "); | ||
166 | result.append("\"Cost\"=" + prettyPrintValue(fCost)); | ||
167 | return result.toString(); | ||
168 | } | ||
169 | |||
170 | @Override | ||
171 | public int hashCode() { | ||
172 | return Objects.hash(fCps, fCost); | ||
173 | } | ||
174 | |||
175 | @Override | ||
176 | public boolean equals(final Object obj) { | ||
177 | if (this == obj) | ||
178 | return true; | ||
179 | if (obj == null) { | ||
180 | return false; | ||
181 | } | ||
182 | if ((obj instanceof CpsCost.Match)) { | ||
183 | CpsCost.Match other = (CpsCost.Match) obj; | ||
184 | return Objects.equals(fCps, other.fCps) && Objects.equals(fCost, other.fCost); | ||
185 | } else { | ||
186 | // this should be infrequent | ||
187 | if (!(obj instanceof IPatternMatch)) { | ||
188 | return false; | ||
189 | } | ||
190 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
191 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
192 | } | ||
193 | } | ||
194 | |||
195 | @Override | ||
196 | public CpsCost specification() { | ||
197 | return CpsCost.instance(); | ||
198 | } | ||
199 | |||
200 | /** | ||
201 | * Returns an empty, mutable match. | ||
202 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
203 | * | ||
204 | * @return the empty match. | ||
205 | * | ||
206 | */ | ||
207 | public static CpsCost.Match newEmptyMatch() { | ||
208 | return new Mutable(null, null); | ||
209 | } | ||
210 | |||
211 | /** | ||
212 | * Returns a mutable (partial) match. | ||
213 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
214 | * | ||
215 | * @param pCps the fixed value of pattern parameter Cps, or null if not bound. | ||
216 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
217 | * @return the new, mutable (partial) match object. | ||
218 | * | ||
219 | */ | ||
220 | public static CpsCost.Match newMutableMatch(final CyberPhysicalSystem pCps, final Integer pCost) { | ||
221 | return new Mutable(pCps, pCost); | ||
222 | } | ||
223 | |||
224 | /** | ||
225 | * Returns a new (partial) match. | ||
226 | * This can be used e.g. to call the matcher with a partial match. | ||
227 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
228 | * @param pCps the fixed value of pattern parameter Cps, or null if not bound. | ||
229 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
230 | * @return the (partial) match object. | ||
231 | * | ||
232 | */ | ||
233 | public static CpsCost.Match newMatch(final CyberPhysicalSystem pCps, final Integer pCost) { | ||
234 | return new Immutable(pCps, pCost); | ||
235 | } | ||
236 | |||
237 | private static final class Mutable extends CpsCost.Match { | ||
238 | Mutable(final CyberPhysicalSystem pCps, final Integer pCost) { | ||
239 | super(pCps, pCost); | ||
240 | } | ||
241 | |||
242 | @Override | ||
243 | public boolean isMutable() { | ||
244 | return true; | ||
245 | } | ||
246 | } | ||
247 | |||
248 | private static final class Immutable extends CpsCost.Match { | ||
249 | Immutable(final CyberPhysicalSystem pCps, final Integer pCost) { | ||
250 | super(pCps, pCost); | ||
251 | } | ||
252 | |||
253 | @Override | ||
254 | public boolean isMutable() { | ||
255 | return false; | ||
256 | } | ||
257 | } | ||
258 | } | ||
259 | |||
260 | /** | ||
261 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsCost pattern, | ||
262 | * providing pattern-specific query methods. | ||
263 | * | ||
264 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
265 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
266 | * | ||
267 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
268 | * | ||
269 | * <p>Original source: | ||
270 | * <code><pre> | ||
271 | * pattern cpsCost(Cps : CyberPhysicalSystem, Cost : java Integer) { | ||
272 | * AppCount == count find cpsApplications(Cps, _); | ||
273 | * HostCost == sum find hostInstanceCost(Cps, _, #_); | ||
274 | * Cost == eval(5 AppCount + HostCost); | ||
275 | * } | ||
276 | * </pre></code> | ||
277 | * | ||
278 | * @see Match | ||
279 | * @see CpsCost | ||
280 | * | ||
281 | */ | ||
282 | public static class Matcher extends BaseMatcher<CpsCost.Match> { | ||
283 | /** | ||
284 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
285 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
286 | * | ||
287 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
288 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
289 | * | ||
290 | */ | ||
291 | public static CpsCost.Matcher on(final ViatraQueryEngine engine) { | ||
292 | // check if matcher already exists | ||
293 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
294 | if (matcher == null) { | ||
295 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
296 | } | ||
297 | return matcher; | ||
298 | } | ||
299 | |||
300 | /** | ||
301 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
302 | * @return an initialized matcher | ||
303 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
304 | * | ||
305 | */ | ||
306 | public static CpsCost.Matcher create() { | ||
307 | return new Matcher(); | ||
308 | } | ||
309 | |||
310 | private static final int POSITION_CPS = 0; | ||
311 | |||
312 | private static final int POSITION_COST = 1; | ||
313 | |||
314 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CpsCost.Matcher.class); | ||
315 | |||
316 | /** | ||
317 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
318 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
319 | * | ||
320 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
321 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
322 | * | ||
323 | */ | ||
324 | private Matcher() { | ||
325 | super(querySpecification()); | ||
326 | } | ||
327 | |||
328 | /** | ||
329 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
330 | * @param pCps the fixed value of pattern parameter Cps, or null if not bound. | ||
331 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
332 | * @return matches represented as a Match object. | ||
333 | * | ||
334 | */ | ||
335 | public Collection<CpsCost.Match> getAllMatches(final CyberPhysicalSystem pCps, final Integer pCost) { | ||
336 | return rawStreamAllMatches(new Object[]{pCps, pCost}).collect(Collectors.toSet()); | ||
337 | } | ||
338 | |||
339 | /** | ||
340 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
341 | * </p> | ||
342 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
343 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
344 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
345 | * @param pCps the fixed value of pattern parameter Cps, or null if not bound. | ||
346 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
347 | * @return a stream of matches represented as a Match object. | ||
348 | * | ||
349 | */ | ||
350 | public Stream<CpsCost.Match> streamAllMatches(final CyberPhysicalSystem pCps, final Integer pCost) { | ||
351 | return rawStreamAllMatches(new Object[]{pCps, pCost}); | ||
352 | } | ||
353 | |||
354 | /** | ||
355 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
356 | * Neither determinism nor randomness of selection is guaranteed. | ||
357 | * @param pCps the fixed value of pattern parameter Cps, or null if not bound. | ||
358 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
359 | * @return a match represented as a Match object, or null if no match is found. | ||
360 | * | ||
361 | */ | ||
362 | public Optional<CpsCost.Match> getOneArbitraryMatch(final CyberPhysicalSystem pCps, final Integer pCost) { | ||
363 | return rawGetOneArbitraryMatch(new Object[]{pCps, pCost}); | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
368 | * under any possible substitution of the unspecified parameters (if any). | ||
369 | * @param pCps the fixed value of pattern parameter Cps, or null if not bound. | ||
370 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
371 | * @return true if the input is a valid (partial) match of the pattern. | ||
372 | * | ||
373 | */ | ||
374 | public boolean hasMatch(final CyberPhysicalSystem pCps, final Integer pCost) { | ||
375 | return rawHasMatch(new Object[]{pCps, pCost}); | ||
376 | } | ||
377 | |||
378 | /** | ||
379 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
380 | * @param pCps the fixed value of pattern parameter Cps, or null if not bound. | ||
381 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
382 | * @return the number of pattern matches found. | ||
383 | * | ||
384 | */ | ||
385 | public int countMatches(final CyberPhysicalSystem pCps, final Integer pCost) { | ||
386 | return rawCountMatches(new Object[]{pCps, pCost}); | ||
387 | } | ||
388 | |||
389 | /** | ||
390 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
391 | * Neither determinism nor randomness of selection is guaranteed. | ||
392 | * @param pCps the fixed value of pattern parameter Cps, or null if not bound. | ||
393 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
394 | * @param processor the action that will process the selected match. | ||
395 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
396 | * | ||
397 | */ | ||
398 | public boolean forOneArbitraryMatch(final CyberPhysicalSystem pCps, final Integer pCost, final Consumer<? super CpsCost.Match> processor) { | ||
399 | return rawForOneArbitraryMatch(new Object[]{pCps, pCost}, processor); | ||
400 | } | ||
401 | |||
402 | /** | ||
403 | * Returns a new (partial) match. | ||
404 | * This can be used e.g. to call the matcher with a partial match. | ||
405 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
406 | * @param pCps the fixed value of pattern parameter Cps, or null if not bound. | ||
407 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
408 | * @return the (partial) match object. | ||
409 | * | ||
410 | */ | ||
411 | public CpsCost.Match newMatch(final CyberPhysicalSystem pCps, final Integer pCost) { | ||
412 | return CpsCost.Match.newMatch(pCps, pCost); | ||
413 | } | ||
414 | |||
415 | /** | ||
416 | * Retrieve the set of values that occur in matches for Cps. | ||
417 | * @return the Set of all values or empty set if there are no matches | ||
418 | * | ||
419 | */ | ||
420 | protected Stream<CyberPhysicalSystem> rawStreamAllValuesOfCps(final Object[] parameters) { | ||
421 | return rawStreamAllValues(POSITION_CPS, parameters).map(CyberPhysicalSystem.class::cast); | ||
422 | } | ||
423 | |||
424 | /** | ||
425 | * Retrieve the set of values that occur in matches for Cps. | ||
426 | * @return the Set of all values or empty set if there are no matches | ||
427 | * | ||
428 | */ | ||
429 | public Set<CyberPhysicalSystem> getAllValuesOfCps() { | ||
430 | return rawStreamAllValuesOfCps(emptyArray()).collect(Collectors.toSet()); | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * Retrieve the set of values that occur in matches for Cps. | ||
435 | * @return the Set of all values or empty set if there are no matches | ||
436 | * | ||
437 | */ | ||
438 | public Stream<CyberPhysicalSystem> streamAllValuesOfCps() { | ||
439 | return rawStreamAllValuesOfCps(emptyArray()); | ||
440 | } | ||
441 | |||
442 | /** | ||
443 | * Retrieve the set of values that occur in matches for Cps. | ||
444 | * </p> | ||
445 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
446 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
447 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
448 | * | ||
449 | * @return the Stream of all values or empty set if there are no matches | ||
450 | * | ||
451 | */ | ||
452 | public Stream<CyberPhysicalSystem> streamAllValuesOfCps(final CpsCost.Match partialMatch) { | ||
453 | return rawStreamAllValuesOfCps(partialMatch.toArray()); | ||
454 | } | ||
455 | |||
456 | /** | ||
457 | * Retrieve the set of values that occur in matches for Cps. | ||
458 | * </p> | ||
459 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
460 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
461 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
462 | * | ||
463 | * @return the Stream of all values or empty set if there are no matches | ||
464 | * | ||
465 | */ | ||
466 | public Stream<CyberPhysicalSystem> streamAllValuesOfCps(final Integer pCost) { | ||
467 | return rawStreamAllValuesOfCps(new Object[]{null, pCost}); | ||
468 | } | ||
469 | |||
470 | /** | ||
471 | * Retrieve the set of values that occur in matches for Cps. | ||
472 | * @return the Set of all values or empty set if there are no matches | ||
473 | * | ||
474 | */ | ||
475 | public Set<CyberPhysicalSystem> getAllValuesOfCps(final CpsCost.Match partialMatch) { | ||
476 | return rawStreamAllValuesOfCps(partialMatch.toArray()).collect(Collectors.toSet()); | ||
477 | } | ||
478 | |||
479 | /** | ||
480 | * Retrieve the set of values that occur in matches for Cps. | ||
481 | * @return the Set of all values or empty set if there are no matches | ||
482 | * | ||
483 | */ | ||
484 | public Set<CyberPhysicalSystem> getAllValuesOfCps(final Integer pCost) { | ||
485 | return rawStreamAllValuesOfCps(new Object[]{null, pCost}).collect(Collectors.toSet()); | ||
486 | } | ||
487 | |||
488 | /** | ||
489 | * Retrieve the set of values that occur in matches for Cost. | ||
490 | * @return the Set of all values or empty set if there are no matches | ||
491 | * | ||
492 | */ | ||
493 | protected Stream<Integer> rawStreamAllValuesOfCost(final Object[] parameters) { | ||
494 | return rawStreamAllValues(POSITION_COST, parameters).map(Integer.class::cast); | ||
495 | } | ||
496 | |||
497 | /** | ||
498 | * Retrieve the set of values that occur in matches for Cost. | ||
499 | * @return the Set of all values or empty set if there are no matches | ||
500 | * | ||
501 | */ | ||
502 | public Set<Integer> getAllValuesOfCost() { | ||
503 | return rawStreamAllValuesOfCost(emptyArray()).collect(Collectors.toSet()); | ||
504 | } | ||
505 | |||
506 | /** | ||
507 | * Retrieve the set of values that occur in matches for Cost. | ||
508 | * @return the Set of all values or empty set if there are no matches | ||
509 | * | ||
510 | */ | ||
511 | public Stream<Integer> streamAllValuesOfCost() { | ||
512 | return rawStreamAllValuesOfCost(emptyArray()); | ||
513 | } | ||
514 | |||
515 | /** | ||
516 | * Retrieve the set of values that occur in matches for Cost. | ||
517 | * </p> | ||
518 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
519 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
520 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
521 | * | ||
522 | * @return the Stream of all values or empty set if there are no matches | ||
523 | * | ||
524 | */ | ||
525 | public Stream<Integer> streamAllValuesOfCost(final CpsCost.Match partialMatch) { | ||
526 | return rawStreamAllValuesOfCost(partialMatch.toArray()); | ||
527 | } | ||
528 | |||
529 | /** | ||
530 | * Retrieve the set of values that occur in matches for Cost. | ||
531 | * </p> | ||
532 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
533 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
534 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
535 | * | ||
536 | * @return the Stream of all values or empty set if there are no matches | ||
537 | * | ||
538 | */ | ||
539 | public Stream<Integer> streamAllValuesOfCost(final CyberPhysicalSystem pCps) { | ||
540 | return rawStreamAllValuesOfCost(new Object[]{pCps, null}); | ||
541 | } | ||
542 | |||
543 | /** | ||
544 | * Retrieve the set of values that occur in matches for Cost. | ||
545 | * @return the Set of all values or empty set if there are no matches | ||
546 | * | ||
547 | */ | ||
548 | public Set<Integer> getAllValuesOfCost(final CpsCost.Match partialMatch) { | ||
549 | return rawStreamAllValuesOfCost(partialMatch.toArray()).collect(Collectors.toSet()); | ||
550 | } | ||
551 | |||
552 | /** | ||
553 | * Retrieve the set of values that occur in matches for Cost. | ||
554 | * @return the Set of all values or empty set if there are no matches | ||
555 | * | ||
556 | */ | ||
557 | public Set<Integer> getAllValuesOfCost(final CyberPhysicalSystem pCps) { | ||
558 | return rawStreamAllValuesOfCost(new Object[]{pCps, null}).collect(Collectors.toSet()); | ||
559 | } | ||
560 | |||
561 | @Override | ||
562 | protected CpsCost.Match tupleToMatch(final Tuple t) { | ||
563 | try { | ||
564 | return CpsCost.Match.newMatch((CyberPhysicalSystem) t.get(POSITION_CPS), (Integer) t.get(POSITION_COST)); | ||
565 | } catch(ClassCastException e) { | ||
566 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
567 | return null; | ||
568 | } | ||
569 | } | ||
570 | |||
571 | @Override | ||
572 | protected CpsCost.Match arrayToMatch(final Object[] match) { | ||
573 | try { | ||
574 | return CpsCost.Match.newMatch((CyberPhysicalSystem) match[POSITION_CPS], (Integer) match[POSITION_COST]); | ||
575 | } catch(ClassCastException e) { | ||
576 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
577 | return null; | ||
578 | } | ||
579 | } | ||
580 | |||
581 | @Override | ||
582 | protected CpsCost.Match arrayToMatchMutable(final Object[] match) { | ||
583 | try { | ||
584 | return CpsCost.Match.newMutableMatch((CyberPhysicalSystem) match[POSITION_CPS], (Integer) match[POSITION_COST]); | ||
585 | } catch(ClassCastException e) { | ||
586 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
587 | return null; | ||
588 | } | ||
589 | } | ||
590 | |||
591 | /** | ||
592 | * @return the singleton instance of the query specification of this pattern | ||
593 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
594 | * | ||
595 | */ | ||
596 | public static IQuerySpecification<CpsCost.Matcher> querySpecification() { | ||
597 | return CpsCost.instance(); | ||
598 | } | ||
599 | } | ||
600 | |||
601 | private CpsCost() { | ||
602 | super(GeneratedPQuery.INSTANCE); | ||
603 | } | ||
604 | |||
605 | /** | ||
606 | * @return the singleton instance of the query specification | ||
607 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
608 | * | ||
609 | */ | ||
610 | public static CpsCost instance() { | ||
611 | try{ | ||
612 | return LazyHolder.INSTANCE; | ||
613 | } catch (ExceptionInInitializerError err) { | ||
614 | throw processInitializerError(err); | ||
615 | } | ||
616 | } | ||
617 | |||
618 | @Override | ||
619 | protected CpsCost.Matcher instantiate(final ViatraQueryEngine engine) { | ||
620 | return CpsCost.Matcher.on(engine); | ||
621 | } | ||
622 | |||
623 | @Override | ||
624 | public CpsCost.Matcher instantiate() { | ||
625 | return CpsCost.Matcher.create(); | ||
626 | } | ||
627 | |||
628 | @Override | ||
629 | public CpsCost.Match newEmptyMatch() { | ||
630 | return CpsCost.Match.newEmptyMatch(); | ||
631 | } | ||
632 | |||
633 | @Override | ||
634 | public CpsCost.Match newMatch(final Object... parameters) { | ||
635 | return CpsCost.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem) parameters[0], (java.lang.Integer) parameters[1]); | ||
636 | } | ||
637 | |||
638 | /** | ||
639 | * Inner class allowing the singleton instance of {@link CpsCost} to be created | ||
640 | * <b>not</b> at the class load time of the outer class, | ||
641 | * but rather at the first call to {@link CpsCost#instance()}. | ||
642 | * | ||
643 | * <p> This workaround is required e.g. to support recursion. | ||
644 | * | ||
645 | */ | ||
646 | private static class LazyHolder { | ||
647 | private static final CpsCost INSTANCE = new CpsCost(); | ||
648 | |||
649 | /** | ||
650 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
651 | * This initialization order is required to support indirect recursion. | ||
652 | * | ||
653 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
654 | * | ||
655 | */ | ||
656 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
657 | |||
658 | public static Object ensureInitialized() { | ||
659 | INSTANCE.ensureInitializedInternal(); | ||
660 | return null; | ||
661 | } | ||
662 | } | ||
663 | |||
664 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
665 | private static final CpsCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
666 | |||
667 | private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); | ||
668 | |||
669 | private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); | ||
670 | |||
671 | private final List<PParameter> parameters = Arrays.asList(parameter_Cps, parameter_Cost); | ||
672 | |||
673 | private GeneratedPQuery() { | ||
674 | super(PVisibility.PUBLIC); | ||
675 | } | ||
676 | |||
677 | @Override | ||
678 | public String getFullyQualifiedName() { | ||
679 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsCost"; | ||
680 | } | ||
681 | |||
682 | @Override | ||
683 | public List<String> getParameterNames() { | ||
684 | return Arrays.asList("Cps","Cost"); | ||
685 | } | ||
686 | |||
687 | @Override | ||
688 | public List<PParameter> getParameters() { | ||
689 | return parameters; | ||
690 | } | ||
691 | |||
692 | @Override | ||
693 | public Set<PBody> doGetContainedBodies() { | ||
694 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
695 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
696 | { | ||
697 | PBody body = new PBody(this); | ||
698 | PVariable var_Cps = body.getOrCreateVariableByName("Cps"); | ||
699 | PVariable var_Cost = body.getOrCreateVariableByName("Cost"); | ||
700 | PVariable var_AppCount = body.getOrCreateVariableByName("AppCount"); | ||
701 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
702 | PVariable var_HostCost = body.getOrCreateVariableByName("HostCost"); | ||
703 | PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); | ||
704 | PVariable var___2_ = body.getOrCreateVariableByName("_<2>"); | ||
705 | new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); | ||
706 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Integer.class)); | ||
707 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
708 | new ExportedParameter(body, var_Cps, parameter_Cps), | ||
709 | new ExportedParameter(body, var_Cost, parameter_Cost) | ||
710 | )); | ||
711 | // AppCount == count find cpsApplications(Cps, _) | ||
712 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
713 | new PatternMatchCounter(body, Tuples.flatTupleOf(var_Cps, var___0_), CpsApplications.instance().getInternalQueryRepresentation(), var__virtual_0_); | ||
714 | new Equality(body, var_AppCount, var__virtual_0_); | ||
715 | // HostCost == sum find hostInstanceCost(Cps, _, #_) | ||
716 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
717 | new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Cps, var___1_, var___2_), HostInstanceCost.instance().getInternalQueryRepresentation(), var__virtual_1_, 2); | ||
718 | new Equality(body, var_HostCost, var__virtual_1_); | ||
719 | // Cost == eval(5 * AppCount + HostCost) | ||
720 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
721 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
722 | |||
723 | @Override | ||
724 | public String getShortDescription() { | ||
725 | return "Expression evaluation from pattern cpsCost"; | ||
726 | } | ||
727 | |||
728 | @Override | ||
729 | public Iterable<String> getInputParameterNames() { | ||
730 | return Arrays.asList("AppCount", "HostCost");} | ||
731 | |||
732 | @Override | ||
733 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
734 | Integer AppCount = (Integer) provider.getValue("AppCount"); | ||
735 | Integer HostCost = (Integer) provider.getValue("HostCost"); | ||
736 | return evaluateExpression_1_1(AppCount, HostCost); | ||
737 | } | ||
738 | }, var__virtual_2_ ); | ||
739 | new Equality(body, var_Cost, var__virtual_2_); | ||
740 | bodies.add(body); | ||
741 | } | ||
742 | return bodies; | ||
743 | } | ||
744 | } | ||
745 | |||
746 | private static int evaluateExpression_1_1(final Integer AppCount, final Integer HostCost) { | ||
747 | return ((5 * (AppCount).intValue()) + (HostCost).intValue()); | ||
748 | } | ||
749 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java new file mode 100644 index 00000000..c889fbe0 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java | |||
@@ -0,0 +1,218 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric; | ||
10 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric; | ||
11 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost; | ||
12 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance; | ||
13 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective; | ||
14 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement; | ||
15 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd; | ||
16 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory; | ||
17 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RedundantInstancesOnSameHost; | ||
18 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RemoveHostInstance; | ||
19 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied; | ||
20 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement; | ||
21 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.UnallocateAppInstance; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; | ||
24 | |||
25 | /** | ||
26 | * A pattern group formed of all public patterns defined in CpsQueries.vql. | ||
27 | * | ||
28 | * <p>Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare | ||
29 | * a VIATRA Query engine for matching all patterns originally defined in file CpsQueries.vql, | ||
30 | * in order to achieve better performance than one-by-one on-demand matcher initialization. | ||
31 | * | ||
32 | * <p> From package hu.bme.mit.inf.dslreasoner.domains.cps.queries, the group contains the definition of the following patterns: <ul> | ||
33 | * <li>resourceRequirement</li> | ||
34 | * <li>allocationWithoutResourceRequirement</li> | ||
35 | * <li>notEnoughAvailableMemory</li> | ||
36 | * <li>notEnoughAvailableHdd</li> | ||
37 | * <li>instanceDoesNotSatisfyRequirement</li> | ||
38 | * <li>requirementNotSatisfied</li> | ||
39 | * <li>redundantInstancesOnSameHost</li> | ||
40 | * <li>averageFreeMemoryMetric</li> | ||
41 | * <li>averageFreeHddMetric</li> | ||
42 | * <li>costMetric</li> | ||
43 | * <li>cpsCost</li> | ||
44 | * <li>allocate</li> | ||
45 | * <li>unallocateAppInstance</li> | ||
46 | * <li>createHostInstance</li> | ||
47 | * <li>removeHostInstance</li> | ||
48 | * <li>guidanceObjective</li> | ||
49 | * </ul> | ||
50 | * | ||
51 | * @see IQueryGroup | ||
52 | * | ||
53 | */ | ||
54 | @SuppressWarnings("all") | ||
55 | public final class CpsQueries extends BaseGeneratedPatternGroup { | ||
56 | /** | ||
57 | * Access the pattern group. | ||
58 | * | ||
59 | * @return the singleton instance of the group | ||
60 | * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications | ||
61 | * | ||
62 | */ | ||
63 | public static CpsQueries instance() { | ||
64 | if (INSTANCE == null) { | ||
65 | INSTANCE = new CpsQueries(); | ||
66 | } | ||
67 | return INSTANCE; | ||
68 | } | ||
69 | |||
70 | private static CpsQueries INSTANCE; | ||
71 | |||
72 | private CpsQueries() { | ||
73 | querySpecifications.add(ResourceRequirement.instance()); | ||
74 | querySpecifications.add(AllocationWithoutResourceRequirement.instance()); | ||
75 | querySpecifications.add(NotEnoughAvailableMemory.instance()); | ||
76 | querySpecifications.add(NotEnoughAvailableHdd.instance()); | ||
77 | querySpecifications.add(InstanceDoesNotSatisfyRequirement.instance()); | ||
78 | querySpecifications.add(RequirementNotSatisfied.instance()); | ||
79 | querySpecifications.add(RedundantInstancesOnSameHost.instance()); | ||
80 | querySpecifications.add(AverageFreeMemoryMetric.instance()); | ||
81 | querySpecifications.add(AverageFreeHddMetric.instance()); | ||
82 | querySpecifications.add(CostMetric.instance()); | ||
83 | querySpecifications.add(CpsCost.instance()); | ||
84 | querySpecifications.add(Allocate.instance()); | ||
85 | querySpecifications.add(UnallocateAppInstance.instance()); | ||
86 | querySpecifications.add(CreateHostInstance.instance()); | ||
87 | querySpecifications.add(RemoveHostInstance.instance()); | ||
88 | querySpecifications.add(GuidanceObjective.instance()); | ||
89 | } | ||
90 | |||
91 | public ResourceRequirement getResourceRequirement() { | ||
92 | return ResourceRequirement.instance(); | ||
93 | } | ||
94 | |||
95 | public ResourceRequirement.Matcher getResourceRequirement(final ViatraQueryEngine engine) { | ||
96 | return ResourceRequirement.Matcher.on(engine); | ||
97 | } | ||
98 | |||
99 | public AllocationWithoutResourceRequirement getAllocationWithoutResourceRequirement() { | ||
100 | return AllocationWithoutResourceRequirement.instance(); | ||
101 | } | ||
102 | |||
103 | public AllocationWithoutResourceRequirement.Matcher getAllocationWithoutResourceRequirement(final ViatraQueryEngine engine) { | ||
104 | return AllocationWithoutResourceRequirement.Matcher.on(engine); | ||
105 | } | ||
106 | |||
107 | public NotEnoughAvailableMemory getNotEnoughAvailableMemory() { | ||
108 | return NotEnoughAvailableMemory.instance(); | ||
109 | } | ||
110 | |||
111 | public NotEnoughAvailableMemory.Matcher getNotEnoughAvailableMemory(final ViatraQueryEngine engine) { | ||
112 | return NotEnoughAvailableMemory.Matcher.on(engine); | ||
113 | } | ||
114 | |||
115 | public NotEnoughAvailableHdd getNotEnoughAvailableHdd() { | ||
116 | return NotEnoughAvailableHdd.instance(); | ||
117 | } | ||
118 | |||
119 | public NotEnoughAvailableHdd.Matcher getNotEnoughAvailableHdd(final ViatraQueryEngine engine) { | ||
120 | return NotEnoughAvailableHdd.Matcher.on(engine); | ||
121 | } | ||
122 | |||
123 | public InstanceDoesNotSatisfyRequirement getInstanceDoesNotSatisfyRequirement() { | ||
124 | return InstanceDoesNotSatisfyRequirement.instance(); | ||
125 | } | ||
126 | |||
127 | public InstanceDoesNotSatisfyRequirement.Matcher getInstanceDoesNotSatisfyRequirement(final ViatraQueryEngine engine) { | ||
128 | return InstanceDoesNotSatisfyRequirement.Matcher.on(engine); | ||
129 | } | ||
130 | |||
131 | public RequirementNotSatisfied getRequirementNotSatisfied() { | ||
132 | return RequirementNotSatisfied.instance(); | ||
133 | } | ||
134 | |||
135 | public RequirementNotSatisfied.Matcher getRequirementNotSatisfied(final ViatraQueryEngine engine) { | ||
136 | return RequirementNotSatisfied.Matcher.on(engine); | ||
137 | } | ||
138 | |||
139 | public RedundantInstancesOnSameHost getRedundantInstancesOnSameHost() { | ||
140 | return RedundantInstancesOnSameHost.instance(); | ||
141 | } | ||
142 | |||
143 | public RedundantInstancesOnSameHost.Matcher getRedundantInstancesOnSameHost(final ViatraQueryEngine engine) { | ||
144 | return RedundantInstancesOnSameHost.Matcher.on(engine); | ||
145 | } | ||
146 | |||
147 | public AverageFreeMemoryMetric getAverageFreeMemoryMetric() { | ||
148 | return AverageFreeMemoryMetric.instance(); | ||
149 | } | ||
150 | |||
151 | public AverageFreeMemoryMetric.Matcher getAverageFreeMemoryMetric(final ViatraQueryEngine engine) { | ||
152 | return AverageFreeMemoryMetric.Matcher.on(engine); | ||
153 | } | ||
154 | |||
155 | public AverageFreeHddMetric getAverageFreeHddMetric() { | ||
156 | return AverageFreeHddMetric.instance(); | ||
157 | } | ||
158 | |||
159 | public AverageFreeHddMetric.Matcher getAverageFreeHddMetric(final ViatraQueryEngine engine) { | ||
160 | return AverageFreeHddMetric.Matcher.on(engine); | ||
161 | } | ||
162 | |||
163 | public CostMetric getCostMetric() { | ||
164 | return CostMetric.instance(); | ||
165 | } | ||
166 | |||
167 | public CostMetric.Matcher getCostMetric(final ViatraQueryEngine engine) { | ||
168 | return CostMetric.Matcher.on(engine); | ||
169 | } | ||
170 | |||
171 | public CpsCost getCpsCost() { | ||
172 | return CpsCost.instance(); | ||
173 | } | ||
174 | |||
175 | public CpsCost.Matcher getCpsCost(final ViatraQueryEngine engine) { | ||
176 | return CpsCost.Matcher.on(engine); | ||
177 | } | ||
178 | |||
179 | public Allocate getAllocate() { | ||
180 | return Allocate.instance(); | ||
181 | } | ||
182 | |||
183 | public Allocate.Matcher getAllocate(final ViatraQueryEngine engine) { | ||
184 | return Allocate.Matcher.on(engine); | ||
185 | } | ||
186 | |||
187 | public UnallocateAppInstance getUnallocateAppInstance() { | ||
188 | return UnallocateAppInstance.instance(); | ||
189 | } | ||
190 | |||
191 | public UnallocateAppInstance.Matcher getUnallocateAppInstance(final ViatraQueryEngine engine) { | ||
192 | return UnallocateAppInstance.Matcher.on(engine); | ||
193 | } | ||
194 | |||
195 | public CreateHostInstance getCreateHostInstance() { | ||
196 | return CreateHostInstance.instance(); | ||
197 | } | ||
198 | |||
199 | public CreateHostInstance.Matcher getCreateHostInstance(final ViatraQueryEngine engine) { | ||
200 | return CreateHostInstance.Matcher.on(engine); | ||
201 | } | ||
202 | |||
203 | public RemoveHostInstance getRemoveHostInstance() { | ||
204 | return RemoveHostInstance.instance(); | ||
205 | } | ||
206 | |||
207 | public RemoveHostInstance.Matcher getRemoveHostInstance(final ViatraQueryEngine engine) { | ||
208 | return RemoveHostInstance.Matcher.on(engine); | ||
209 | } | ||
210 | |||
211 | public GuidanceObjective getGuidanceObjective() { | ||
212 | return GuidanceObjective.instance(); | ||
213 | } | ||
214 | |||
215 | public GuidanceObjective.Matcher getGuidanceObjective(final ViatraQueryEngine engine) { | ||
216 | return GuidanceObjective.Matcher.on(engine); | ||
217 | } | ||
218 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CreateHostInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CreateHostInstance.java new file mode 100644 index 00000000..04036e11 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CreateHostInstance.java | |||
@@ -0,0 +1,563 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * pattern createHostInstance(HostType : HostType) { | ||
49 | * find unallocatedAppInstance(App); | ||
50 | * ApplicationInstance.type.requirements.hostType(App, HostType); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class CreateHostInstance extends BaseGeneratedEMFQuerySpecification<CreateHostInstance.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.createHostInstance pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private HostType fHostType; | ||
74 | |||
75 | private static List<String> parameterNames = makeImmutableList("HostType"); | ||
76 | |||
77 | private Match(final HostType pHostType) { | ||
78 | this.fHostType = pHostType; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "HostType": return this.fHostType; | ||
85 | default: return null; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final int index) { | ||
91 | switch(index) { | ||
92 | case 0: return this.fHostType; | ||
93 | default: return null; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | public HostType getHostType() { | ||
98 | return this.fHostType; | ||
99 | } | ||
100 | |||
101 | @Override | ||
102 | public boolean set(final String parameterName, final Object newValue) { | ||
103 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
104 | if ("HostType".equals(parameterName) ) { | ||
105 | this.fHostType = (HostType) newValue; | ||
106 | return true; | ||
107 | } | ||
108 | return false; | ||
109 | } | ||
110 | |||
111 | public void setHostType(final HostType pHostType) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | this.fHostType = pHostType; | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public String patternName() { | ||
118 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.createHostInstance"; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public List<String> parameterNames() { | ||
123 | return CreateHostInstance.Match.parameterNames; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public Object[] toArray() { | ||
128 | return new Object[]{fHostType}; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public CreateHostInstance.Match toImmutable() { | ||
133 | return isMutable() ? newMatch(fHostType) : this; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public String prettyPrint() { | ||
138 | StringBuilder result = new StringBuilder(); | ||
139 | result.append("\"HostType\"=" + prettyPrintValue(fHostType)); | ||
140 | return result.toString(); | ||
141 | } | ||
142 | |||
143 | @Override | ||
144 | public int hashCode() { | ||
145 | return Objects.hash(fHostType); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public boolean equals(final Object obj) { | ||
150 | if (this == obj) | ||
151 | return true; | ||
152 | if (obj == null) { | ||
153 | return false; | ||
154 | } | ||
155 | if ((obj instanceof CreateHostInstance.Match)) { | ||
156 | CreateHostInstance.Match other = (CreateHostInstance.Match) obj; | ||
157 | return Objects.equals(fHostType, other.fHostType); | ||
158 | } else { | ||
159 | // this should be infrequent | ||
160 | if (!(obj instanceof IPatternMatch)) { | ||
161 | return false; | ||
162 | } | ||
163 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
164 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public CreateHostInstance specification() { | ||
170 | return CreateHostInstance.instance(); | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * Returns an empty, mutable match. | ||
175 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
176 | * | ||
177 | * @return the empty match. | ||
178 | * | ||
179 | */ | ||
180 | public static CreateHostInstance.Match newEmptyMatch() { | ||
181 | return new Mutable(null); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Returns a mutable (partial) match. | ||
186 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
187 | * | ||
188 | * @param pHostType the fixed value of pattern parameter HostType, or null if not bound. | ||
189 | * @return the new, mutable (partial) match object. | ||
190 | * | ||
191 | */ | ||
192 | public static CreateHostInstance.Match newMutableMatch(final HostType pHostType) { | ||
193 | return new Mutable(pHostType); | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * Returns a new (partial) match. | ||
198 | * This can be used e.g. to call the matcher with a partial match. | ||
199 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
200 | * @param pHostType the fixed value of pattern parameter HostType, or null if not bound. | ||
201 | * @return the (partial) match object. | ||
202 | * | ||
203 | */ | ||
204 | public static CreateHostInstance.Match newMatch(final HostType pHostType) { | ||
205 | return new Immutable(pHostType); | ||
206 | } | ||
207 | |||
208 | private static final class Mutable extends CreateHostInstance.Match { | ||
209 | Mutable(final HostType pHostType) { | ||
210 | super(pHostType); | ||
211 | } | ||
212 | |||
213 | @Override | ||
214 | public boolean isMutable() { | ||
215 | return true; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | private static final class Immutable extends CreateHostInstance.Match { | ||
220 | Immutable(final HostType pHostType) { | ||
221 | super(pHostType); | ||
222 | } | ||
223 | |||
224 | @Override | ||
225 | public boolean isMutable() { | ||
226 | return false; | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.createHostInstance pattern, | ||
233 | * providing pattern-specific query methods. | ||
234 | * | ||
235 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
236 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
237 | * | ||
238 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
239 | * | ||
240 | * <p>Original source: | ||
241 | * <code><pre> | ||
242 | * pattern createHostInstance(HostType : HostType) { | ||
243 | * find unallocatedAppInstance(App); | ||
244 | * ApplicationInstance.type.requirements.hostType(App, HostType); | ||
245 | * } | ||
246 | * </pre></code> | ||
247 | * | ||
248 | * @see Match | ||
249 | * @see CreateHostInstance | ||
250 | * | ||
251 | */ | ||
252 | public static class Matcher extends BaseMatcher<CreateHostInstance.Match> { | ||
253 | /** | ||
254 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
255 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
256 | * | ||
257 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
258 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
259 | * | ||
260 | */ | ||
261 | public static CreateHostInstance.Matcher on(final ViatraQueryEngine engine) { | ||
262 | // check if matcher already exists | ||
263 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
264 | if (matcher == null) { | ||
265 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
266 | } | ||
267 | return matcher; | ||
268 | } | ||
269 | |||
270 | /** | ||
271 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
272 | * @return an initialized matcher | ||
273 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
274 | * | ||
275 | */ | ||
276 | public static CreateHostInstance.Matcher create() { | ||
277 | return new Matcher(); | ||
278 | } | ||
279 | |||
280 | private static final int POSITION_HOSTTYPE = 0; | ||
281 | |||
282 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CreateHostInstance.Matcher.class); | ||
283 | |||
284 | /** | ||
285 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
286 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
287 | * | ||
288 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
289 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
290 | * | ||
291 | */ | ||
292 | private Matcher() { | ||
293 | super(querySpecification()); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
298 | * @param pHostType the fixed value of pattern parameter HostType, or null if not bound. | ||
299 | * @return matches represented as a Match object. | ||
300 | * | ||
301 | */ | ||
302 | public Collection<CreateHostInstance.Match> getAllMatches(final HostType pHostType) { | ||
303 | return rawStreamAllMatches(new Object[]{pHostType}).collect(Collectors.toSet()); | ||
304 | } | ||
305 | |||
306 | /** | ||
307 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
308 | * </p> | ||
309 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
310 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
311 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
312 | * @param pHostType the fixed value of pattern parameter HostType, or null if not bound. | ||
313 | * @return a stream of matches represented as a Match object. | ||
314 | * | ||
315 | */ | ||
316 | public Stream<CreateHostInstance.Match> streamAllMatches(final HostType pHostType) { | ||
317 | return rawStreamAllMatches(new Object[]{pHostType}); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
322 | * Neither determinism nor randomness of selection is guaranteed. | ||
323 | * @param pHostType the fixed value of pattern parameter HostType, or null if not bound. | ||
324 | * @return a match represented as a Match object, or null if no match is found. | ||
325 | * | ||
326 | */ | ||
327 | public Optional<CreateHostInstance.Match> getOneArbitraryMatch(final HostType pHostType) { | ||
328 | return rawGetOneArbitraryMatch(new Object[]{pHostType}); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
333 | * under any possible substitution of the unspecified parameters (if any). | ||
334 | * @param pHostType the fixed value of pattern parameter HostType, or null if not bound. | ||
335 | * @return true if the input is a valid (partial) match of the pattern. | ||
336 | * | ||
337 | */ | ||
338 | public boolean hasMatch(final HostType pHostType) { | ||
339 | return rawHasMatch(new Object[]{pHostType}); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
344 | * @param pHostType the fixed value of pattern parameter HostType, or null if not bound. | ||
345 | * @return the number of pattern matches found. | ||
346 | * | ||
347 | */ | ||
348 | public int countMatches(final HostType pHostType) { | ||
349 | return rawCountMatches(new Object[]{pHostType}); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
354 | * Neither determinism nor randomness of selection is guaranteed. | ||
355 | * @param pHostType the fixed value of pattern parameter HostType, or null if not bound. | ||
356 | * @param processor the action that will process the selected match. | ||
357 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
358 | * | ||
359 | */ | ||
360 | public boolean forOneArbitraryMatch(final HostType pHostType, final Consumer<? super CreateHostInstance.Match> processor) { | ||
361 | return rawForOneArbitraryMatch(new Object[]{pHostType}, processor); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Returns a new (partial) match. | ||
366 | * This can be used e.g. to call the matcher with a partial match. | ||
367 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
368 | * @param pHostType the fixed value of pattern parameter HostType, or null if not bound. | ||
369 | * @return the (partial) match object. | ||
370 | * | ||
371 | */ | ||
372 | public CreateHostInstance.Match newMatch(final HostType pHostType) { | ||
373 | return CreateHostInstance.Match.newMatch(pHostType); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Retrieve the set of values that occur in matches for HostType. | ||
378 | * @return the Set of all values or empty set if there are no matches | ||
379 | * | ||
380 | */ | ||
381 | protected Stream<HostType> rawStreamAllValuesOfHostType(final Object[] parameters) { | ||
382 | return rawStreamAllValues(POSITION_HOSTTYPE, parameters).map(HostType.class::cast); | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * Retrieve the set of values that occur in matches for HostType. | ||
387 | * @return the Set of all values or empty set if there are no matches | ||
388 | * | ||
389 | */ | ||
390 | public Set<HostType> getAllValuesOfHostType() { | ||
391 | return rawStreamAllValuesOfHostType(emptyArray()).collect(Collectors.toSet()); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Retrieve the set of values that occur in matches for HostType. | ||
396 | * @return the Set of all values or empty set if there are no matches | ||
397 | * | ||
398 | */ | ||
399 | public Stream<HostType> streamAllValuesOfHostType() { | ||
400 | return rawStreamAllValuesOfHostType(emptyArray()); | ||
401 | } | ||
402 | |||
403 | @Override | ||
404 | protected CreateHostInstance.Match tupleToMatch(final Tuple t) { | ||
405 | try { | ||
406 | return CreateHostInstance.Match.newMatch((HostType) t.get(POSITION_HOSTTYPE)); | ||
407 | } catch(ClassCastException e) { | ||
408 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
409 | return null; | ||
410 | } | ||
411 | } | ||
412 | |||
413 | @Override | ||
414 | protected CreateHostInstance.Match arrayToMatch(final Object[] match) { | ||
415 | try { | ||
416 | return CreateHostInstance.Match.newMatch((HostType) match[POSITION_HOSTTYPE]); | ||
417 | } catch(ClassCastException e) { | ||
418 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
419 | return null; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | @Override | ||
424 | protected CreateHostInstance.Match arrayToMatchMutable(final Object[] match) { | ||
425 | try { | ||
426 | return CreateHostInstance.Match.newMutableMatch((HostType) match[POSITION_HOSTTYPE]); | ||
427 | } catch(ClassCastException e) { | ||
428 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
429 | return null; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * @return the singleton instance of the query specification of this pattern | ||
435 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
436 | * | ||
437 | */ | ||
438 | public static IQuerySpecification<CreateHostInstance.Matcher> querySpecification() { | ||
439 | return CreateHostInstance.instance(); | ||
440 | } | ||
441 | } | ||
442 | |||
443 | private CreateHostInstance() { | ||
444 | super(GeneratedPQuery.INSTANCE); | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @return the singleton instance of the query specification | ||
449 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
450 | * | ||
451 | */ | ||
452 | public static CreateHostInstance instance() { | ||
453 | try{ | ||
454 | return LazyHolder.INSTANCE; | ||
455 | } catch (ExceptionInInitializerError err) { | ||
456 | throw processInitializerError(err); | ||
457 | } | ||
458 | } | ||
459 | |||
460 | @Override | ||
461 | protected CreateHostInstance.Matcher instantiate(final ViatraQueryEngine engine) { | ||
462 | return CreateHostInstance.Matcher.on(engine); | ||
463 | } | ||
464 | |||
465 | @Override | ||
466 | public CreateHostInstance.Matcher instantiate() { | ||
467 | return CreateHostInstance.Matcher.create(); | ||
468 | } | ||
469 | |||
470 | @Override | ||
471 | public CreateHostInstance.Match newEmptyMatch() { | ||
472 | return CreateHostInstance.Match.newEmptyMatch(); | ||
473 | } | ||
474 | |||
475 | @Override | ||
476 | public CreateHostInstance.Match newMatch(final Object... parameters) { | ||
477 | return CreateHostInstance.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostType) parameters[0]); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Inner class allowing the singleton instance of {@link CreateHostInstance} to be created | ||
482 | * <b>not</b> at the class load time of the outer class, | ||
483 | * but rather at the first call to {@link CreateHostInstance#instance()}. | ||
484 | * | ||
485 | * <p> This workaround is required e.g. to support recursion. | ||
486 | * | ||
487 | */ | ||
488 | private static class LazyHolder { | ||
489 | private static final CreateHostInstance INSTANCE = new CreateHostInstance(); | ||
490 | |||
491 | /** | ||
492 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
493 | * This initialization order is required to support indirect recursion. | ||
494 | * | ||
495 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
496 | * | ||
497 | */ | ||
498 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
499 | |||
500 | public static Object ensureInitialized() { | ||
501 | INSTANCE.ensureInitializedInternal(); | ||
502 | return null; | ||
503 | } | ||
504 | } | ||
505 | |||
506 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
507 | private static final CreateHostInstance.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
508 | |||
509 | private final PParameter parameter_HostType = new PParameter("HostType", "hu.bme.mit.inf.dslreasoner.domains.cps.HostType", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostType")), PParameterDirection.INOUT); | ||
510 | |||
511 | private final List<PParameter> parameters = Arrays.asList(parameter_HostType); | ||
512 | |||
513 | private GeneratedPQuery() { | ||
514 | super(PVisibility.PUBLIC); | ||
515 | } | ||
516 | |||
517 | @Override | ||
518 | public String getFullyQualifiedName() { | ||
519 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.createHostInstance"; | ||
520 | } | ||
521 | |||
522 | @Override | ||
523 | public List<String> getParameterNames() { | ||
524 | return Arrays.asList("HostType"); | ||
525 | } | ||
526 | |||
527 | @Override | ||
528 | public List<PParameter> getParameters() { | ||
529 | return parameters; | ||
530 | } | ||
531 | |||
532 | @Override | ||
533 | public Set<PBody> doGetContainedBodies() { | ||
534 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
535 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
536 | { | ||
537 | PBody body = new PBody(this); | ||
538 | PVariable var_HostType = body.getOrCreateVariableByName("HostType"); | ||
539 | PVariable var_App = body.getOrCreateVariableByName("App"); | ||
540 | new TypeConstraint(body, Tuples.flatTupleOf(var_HostType), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); | ||
541 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
542 | new ExportedParameter(body, var_HostType, parameter_HostType) | ||
543 | )); | ||
544 | // find unallocatedAppInstance(App) | ||
545 | new PositivePatternCall(body, Tuples.flatTupleOf(var_App), UnallocatedAppInstance.instance().getInternalQueryRepresentation()); | ||
546 | // ApplicationInstance.type.requirements.hostType(App, HostType) | ||
547 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
548 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
549 | new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type"))); | ||
550 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); | ||
551 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
552 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "requirements"))); | ||
553 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); | ||
554 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
555 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "hostType"))); | ||
556 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); | ||
557 | new Equality(body, var__virtual_2_, var_HostType); | ||
558 | bodies.add(body); | ||
559 | } | ||
560 | return bodies; | ||
561 | } | ||
562 | } | ||
563 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/GuidanceObjective.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/GuidanceObjective.java new file mode 100644 index 00000000..1ed6c9cc --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/GuidanceObjective.java | |||
@@ -0,0 +1,601 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.NoHostToAllocateTo; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.RequiredAppInstances; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance; | ||
9 | import java.util.Arrays; | ||
10 | import java.util.Collection; | ||
11 | import java.util.LinkedHashSet; | ||
12 | import java.util.List; | ||
13 | import java.util.Objects; | ||
14 | import java.util.Optional; | ||
15 | import java.util.Set; | ||
16 | import java.util.function.Consumer; | ||
17 | import java.util.stream.Collectors; | ||
18 | import java.util.stream.Stream; | ||
19 | import org.apache.log4j.Logger; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
44 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
45 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
46 | |||
47 | /** | ||
48 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
49 | * | ||
50 | * <p>Original source: | ||
51 | * <code><pre> | ||
52 | * pattern guidanceObjective(Value : java Integer) { | ||
53 | * UnallocatedInstances == count find unallocatedAppInstance(_); | ||
54 | * RequiredInstances == sum find requiredAppInstances(_, #_); | ||
55 | * NoHostToAllocate == count find noHostToAllocateTo(_); | ||
56 | * Value == eval(2 UnallocatedInstances + 4 RequiredInstances + NoHostToAllocate); | ||
57 | * } | ||
58 | * </pre></code> | ||
59 | * | ||
60 | * @see Matcher | ||
61 | * @see Match | ||
62 | * | ||
63 | */ | ||
64 | @SuppressWarnings("all") | ||
65 | public final class GuidanceObjective extends BaseGeneratedEMFQuerySpecification<GuidanceObjective.Matcher> { | ||
66 | /** | ||
67 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.guidanceObjective pattern, | ||
68 | * to be used in conjunction with {@link Matcher}. | ||
69 | * | ||
70 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
71 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
72 | * usable to represent a match of the pattern in the result of a query, | ||
73 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
74 | * | ||
75 | * @see Matcher | ||
76 | * | ||
77 | */ | ||
78 | public static abstract class Match extends BasePatternMatch { | ||
79 | private Integer fValue; | ||
80 | |||
81 | private static List<String> parameterNames = makeImmutableList("Value"); | ||
82 | |||
83 | private Match(final Integer pValue) { | ||
84 | this.fValue = pValue; | ||
85 | } | ||
86 | |||
87 | @Override | ||
88 | public Object get(final String parameterName) { | ||
89 | switch(parameterName) { | ||
90 | case "Value": return this.fValue; | ||
91 | default: return null; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | @Override | ||
96 | public Object get(final int index) { | ||
97 | switch(index) { | ||
98 | case 0: return this.fValue; | ||
99 | default: return null; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | public Integer getValue() { | ||
104 | return this.fValue; | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public boolean set(final String parameterName, final Object newValue) { | ||
109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
110 | if ("Value".equals(parameterName) ) { | ||
111 | this.fValue = (Integer) newValue; | ||
112 | return true; | ||
113 | } | ||
114 | return false; | ||
115 | } | ||
116 | |||
117 | public void setValue(final Integer pValue) { | ||
118 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
119 | this.fValue = pValue; | ||
120 | } | ||
121 | |||
122 | @Override | ||
123 | public String patternName() { | ||
124 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.guidanceObjective"; | ||
125 | } | ||
126 | |||
127 | @Override | ||
128 | public List<String> parameterNames() { | ||
129 | return GuidanceObjective.Match.parameterNames; | ||
130 | } | ||
131 | |||
132 | @Override | ||
133 | public Object[] toArray() { | ||
134 | return new Object[]{fValue}; | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public GuidanceObjective.Match toImmutable() { | ||
139 | return isMutable() ? newMatch(fValue) : this; | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public String prettyPrint() { | ||
144 | StringBuilder result = new StringBuilder(); | ||
145 | result.append("\"Value\"=" + prettyPrintValue(fValue)); | ||
146 | return result.toString(); | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public int hashCode() { | ||
151 | return Objects.hash(fValue); | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public boolean equals(final Object obj) { | ||
156 | if (this == obj) | ||
157 | return true; | ||
158 | if (obj == null) { | ||
159 | return false; | ||
160 | } | ||
161 | if ((obj instanceof GuidanceObjective.Match)) { | ||
162 | GuidanceObjective.Match other = (GuidanceObjective.Match) obj; | ||
163 | return Objects.equals(fValue, other.fValue); | ||
164 | } else { | ||
165 | // this should be infrequent | ||
166 | if (!(obj instanceof IPatternMatch)) { | ||
167 | return false; | ||
168 | } | ||
169 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
170 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
171 | } | ||
172 | } | ||
173 | |||
174 | @Override | ||
175 | public GuidanceObjective specification() { | ||
176 | return GuidanceObjective.instance(); | ||
177 | } | ||
178 | |||
179 | /** | ||
180 | * Returns an empty, mutable match. | ||
181 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
182 | * | ||
183 | * @return the empty match. | ||
184 | * | ||
185 | */ | ||
186 | public static GuidanceObjective.Match newEmptyMatch() { | ||
187 | return new Mutable(null); | ||
188 | } | ||
189 | |||
190 | /** | ||
191 | * Returns a mutable (partial) match. | ||
192 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
193 | * | ||
194 | * @param pValue the fixed value of pattern parameter Value, or null if not bound. | ||
195 | * @return the new, mutable (partial) match object. | ||
196 | * | ||
197 | */ | ||
198 | public static GuidanceObjective.Match newMutableMatch(final Integer pValue) { | ||
199 | return new Mutable(pValue); | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * Returns a new (partial) match. | ||
204 | * This can be used e.g. to call the matcher with a partial match. | ||
205 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
206 | * @param pValue the fixed value of pattern parameter Value, or null if not bound. | ||
207 | * @return the (partial) match object. | ||
208 | * | ||
209 | */ | ||
210 | public static GuidanceObjective.Match newMatch(final Integer pValue) { | ||
211 | return new Immutable(pValue); | ||
212 | } | ||
213 | |||
214 | private static final class Mutable extends GuidanceObjective.Match { | ||
215 | Mutable(final Integer pValue) { | ||
216 | super(pValue); | ||
217 | } | ||
218 | |||
219 | @Override | ||
220 | public boolean isMutable() { | ||
221 | return true; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | private static final class Immutable extends GuidanceObjective.Match { | ||
226 | Immutable(final Integer pValue) { | ||
227 | super(pValue); | ||
228 | } | ||
229 | |||
230 | @Override | ||
231 | public boolean isMutable() { | ||
232 | return false; | ||
233 | } | ||
234 | } | ||
235 | } | ||
236 | |||
237 | /** | ||
238 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.guidanceObjective pattern, | ||
239 | * providing pattern-specific query methods. | ||
240 | * | ||
241 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
242 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
243 | * | ||
244 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
245 | * | ||
246 | * <p>Original source: | ||
247 | * <code><pre> | ||
248 | * pattern guidanceObjective(Value : java Integer) { | ||
249 | * UnallocatedInstances == count find unallocatedAppInstance(_); | ||
250 | * RequiredInstances == sum find requiredAppInstances(_, #_); | ||
251 | * NoHostToAllocate == count find noHostToAllocateTo(_); | ||
252 | * Value == eval(2 UnallocatedInstances + 4 RequiredInstances + NoHostToAllocate); | ||
253 | * } | ||
254 | * </pre></code> | ||
255 | * | ||
256 | * @see Match | ||
257 | * @see GuidanceObjective | ||
258 | * | ||
259 | */ | ||
260 | public static class Matcher extends BaseMatcher<GuidanceObjective.Match> { | ||
261 | /** | ||
262 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
263 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
264 | * | ||
265 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
266 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
267 | * | ||
268 | */ | ||
269 | public static GuidanceObjective.Matcher on(final ViatraQueryEngine engine) { | ||
270 | // check if matcher already exists | ||
271 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
272 | if (matcher == null) { | ||
273 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
274 | } | ||
275 | return matcher; | ||
276 | } | ||
277 | |||
278 | /** | ||
279 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
280 | * @return an initialized matcher | ||
281 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
282 | * | ||
283 | */ | ||
284 | public static GuidanceObjective.Matcher create() { | ||
285 | return new Matcher(); | ||
286 | } | ||
287 | |||
288 | private static final int POSITION_VALUE = 0; | ||
289 | |||
290 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(GuidanceObjective.Matcher.class); | ||
291 | |||
292 | /** | ||
293 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
294 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
295 | * | ||
296 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
297 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
298 | * | ||
299 | */ | ||
300 | private Matcher() { | ||
301 | super(querySpecification()); | ||
302 | } | ||
303 | |||
304 | /** | ||
305 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
306 | * @param pValue the fixed value of pattern parameter Value, or null if not bound. | ||
307 | * @return matches represented as a Match object. | ||
308 | * | ||
309 | */ | ||
310 | public Collection<GuidanceObjective.Match> getAllMatches(final Integer pValue) { | ||
311 | return rawStreamAllMatches(new Object[]{pValue}).collect(Collectors.toSet()); | ||
312 | } | ||
313 | |||
314 | /** | ||
315 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
316 | * </p> | ||
317 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
318 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
319 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
320 | * @param pValue the fixed value of pattern parameter Value, or null if not bound. | ||
321 | * @return a stream of matches represented as a Match object. | ||
322 | * | ||
323 | */ | ||
324 | public Stream<GuidanceObjective.Match> streamAllMatches(final Integer pValue) { | ||
325 | return rawStreamAllMatches(new Object[]{pValue}); | ||
326 | } | ||
327 | |||
328 | /** | ||
329 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
330 | * Neither determinism nor randomness of selection is guaranteed. | ||
331 | * @param pValue the fixed value of pattern parameter Value, or null if not bound. | ||
332 | * @return a match represented as a Match object, or null if no match is found. | ||
333 | * | ||
334 | */ | ||
335 | public Optional<GuidanceObjective.Match> getOneArbitraryMatch(final Integer pValue) { | ||
336 | return rawGetOneArbitraryMatch(new Object[]{pValue}); | ||
337 | } | ||
338 | |||
339 | /** | ||
340 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
341 | * under any possible substitution of the unspecified parameters (if any). | ||
342 | * @param pValue the fixed value of pattern parameter Value, or null if not bound. | ||
343 | * @return true if the input is a valid (partial) match of the pattern. | ||
344 | * | ||
345 | */ | ||
346 | public boolean hasMatch(final Integer pValue) { | ||
347 | return rawHasMatch(new Object[]{pValue}); | ||
348 | } | ||
349 | |||
350 | /** | ||
351 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
352 | * @param pValue the fixed value of pattern parameter Value, or null if not bound. | ||
353 | * @return the number of pattern matches found. | ||
354 | * | ||
355 | */ | ||
356 | public int countMatches(final Integer pValue) { | ||
357 | return rawCountMatches(new Object[]{pValue}); | ||
358 | } | ||
359 | |||
360 | /** | ||
361 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
362 | * Neither determinism nor randomness of selection is guaranteed. | ||
363 | * @param pValue the fixed value of pattern parameter Value, or null if not bound. | ||
364 | * @param processor the action that will process the selected match. | ||
365 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
366 | * | ||
367 | */ | ||
368 | public boolean forOneArbitraryMatch(final Integer pValue, final Consumer<? super GuidanceObjective.Match> processor) { | ||
369 | return rawForOneArbitraryMatch(new Object[]{pValue}, processor); | ||
370 | } | ||
371 | |||
372 | /** | ||
373 | * Returns a new (partial) match. | ||
374 | * This can be used e.g. to call the matcher with a partial match. | ||
375 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
376 | * @param pValue the fixed value of pattern parameter Value, or null if not bound. | ||
377 | * @return the (partial) match object. | ||
378 | * | ||
379 | */ | ||
380 | public GuidanceObjective.Match newMatch(final Integer pValue) { | ||
381 | return GuidanceObjective.Match.newMatch(pValue); | ||
382 | } | ||
383 | |||
384 | /** | ||
385 | * Retrieve the set of values that occur in matches for Value. | ||
386 | * @return the Set of all values or empty set if there are no matches | ||
387 | * | ||
388 | */ | ||
389 | protected Stream<Integer> rawStreamAllValuesOfValue(final Object[] parameters) { | ||
390 | return rawStreamAllValues(POSITION_VALUE, parameters).map(Integer.class::cast); | ||
391 | } | ||
392 | |||
393 | /** | ||
394 | * Retrieve the set of values that occur in matches for Value. | ||
395 | * @return the Set of all values or empty set if there are no matches | ||
396 | * | ||
397 | */ | ||
398 | public Set<Integer> getAllValuesOfValue() { | ||
399 | return rawStreamAllValuesOfValue(emptyArray()).collect(Collectors.toSet()); | ||
400 | } | ||
401 | |||
402 | /** | ||
403 | * Retrieve the set of values that occur in matches for Value. | ||
404 | * @return the Set of all values or empty set if there are no matches | ||
405 | * | ||
406 | */ | ||
407 | public Stream<Integer> streamAllValuesOfValue() { | ||
408 | return rawStreamAllValuesOfValue(emptyArray()); | ||
409 | } | ||
410 | |||
411 | @Override | ||
412 | protected GuidanceObjective.Match tupleToMatch(final Tuple t) { | ||
413 | try { | ||
414 | return GuidanceObjective.Match.newMatch((Integer) t.get(POSITION_VALUE)); | ||
415 | } catch(ClassCastException e) { | ||
416 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
417 | return null; | ||
418 | } | ||
419 | } | ||
420 | |||
421 | @Override | ||
422 | protected GuidanceObjective.Match arrayToMatch(final Object[] match) { | ||
423 | try { | ||
424 | return GuidanceObjective.Match.newMatch((Integer) match[POSITION_VALUE]); | ||
425 | } catch(ClassCastException e) { | ||
426 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
427 | return null; | ||
428 | } | ||
429 | } | ||
430 | |||
431 | @Override | ||
432 | protected GuidanceObjective.Match arrayToMatchMutable(final Object[] match) { | ||
433 | try { | ||
434 | return GuidanceObjective.Match.newMutableMatch((Integer) match[POSITION_VALUE]); | ||
435 | } catch(ClassCastException e) { | ||
436 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
437 | return null; | ||
438 | } | ||
439 | } | ||
440 | |||
441 | /** | ||
442 | * @return the singleton instance of the query specification of this pattern | ||
443 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
444 | * | ||
445 | */ | ||
446 | public static IQuerySpecification<GuidanceObjective.Matcher> querySpecification() { | ||
447 | return GuidanceObjective.instance(); | ||
448 | } | ||
449 | } | ||
450 | |||
451 | private GuidanceObjective() { | ||
452 | super(GeneratedPQuery.INSTANCE); | ||
453 | } | ||
454 | |||
455 | /** | ||
456 | * @return the singleton instance of the query specification | ||
457 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
458 | * | ||
459 | */ | ||
460 | public static GuidanceObjective instance() { | ||
461 | try{ | ||
462 | return LazyHolder.INSTANCE; | ||
463 | } catch (ExceptionInInitializerError err) { | ||
464 | throw processInitializerError(err); | ||
465 | } | ||
466 | } | ||
467 | |||
468 | @Override | ||
469 | protected GuidanceObjective.Matcher instantiate(final ViatraQueryEngine engine) { | ||
470 | return GuidanceObjective.Matcher.on(engine); | ||
471 | } | ||
472 | |||
473 | @Override | ||
474 | public GuidanceObjective.Matcher instantiate() { | ||
475 | return GuidanceObjective.Matcher.create(); | ||
476 | } | ||
477 | |||
478 | @Override | ||
479 | public GuidanceObjective.Match newEmptyMatch() { | ||
480 | return GuidanceObjective.Match.newEmptyMatch(); | ||
481 | } | ||
482 | |||
483 | @Override | ||
484 | public GuidanceObjective.Match newMatch(final Object... parameters) { | ||
485 | return GuidanceObjective.Match.newMatch((java.lang.Integer) parameters[0]); | ||
486 | } | ||
487 | |||
488 | /** | ||
489 | * Inner class allowing the singleton instance of {@link GuidanceObjective} to be created | ||
490 | * <b>not</b> at the class load time of the outer class, | ||
491 | * but rather at the first call to {@link GuidanceObjective#instance()}. | ||
492 | * | ||
493 | * <p> This workaround is required e.g. to support recursion. | ||
494 | * | ||
495 | */ | ||
496 | private static class LazyHolder { | ||
497 | private static final GuidanceObjective INSTANCE = new GuidanceObjective(); | ||
498 | |||
499 | /** | ||
500 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
501 | * This initialization order is required to support indirect recursion. | ||
502 | * | ||
503 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
504 | * | ||
505 | */ | ||
506 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
507 | |||
508 | public static Object ensureInitialized() { | ||
509 | INSTANCE.ensureInitializedInternal(); | ||
510 | return null; | ||
511 | } | ||
512 | } | ||
513 | |||
514 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
515 | private static final GuidanceObjective.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
516 | |||
517 | private final PParameter parameter_Value = new PParameter("Value", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); | ||
518 | |||
519 | private final List<PParameter> parameters = Arrays.asList(parameter_Value); | ||
520 | |||
521 | private GeneratedPQuery() { | ||
522 | super(PVisibility.PUBLIC); | ||
523 | } | ||
524 | |||
525 | @Override | ||
526 | public String getFullyQualifiedName() { | ||
527 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.guidanceObjective"; | ||
528 | } | ||
529 | |||
530 | @Override | ||
531 | public List<String> getParameterNames() { | ||
532 | return Arrays.asList("Value"); | ||
533 | } | ||
534 | |||
535 | @Override | ||
536 | public List<PParameter> getParameters() { | ||
537 | return parameters; | ||
538 | } | ||
539 | |||
540 | @Override | ||
541 | public Set<PBody> doGetContainedBodies() { | ||
542 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
543 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
544 | { | ||
545 | PBody body = new PBody(this); | ||
546 | PVariable var_Value = body.getOrCreateVariableByName("Value"); | ||
547 | PVariable var_UnallocatedInstances = body.getOrCreateVariableByName("UnallocatedInstances"); | ||
548 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
549 | PVariable var_RequiredInstances = body.getOrCreateVariableByName("RequiredInstances"); | ||
550 | PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); | ||
551 | PVariable var___2_ = body.getOrCreateVariableByName("_<2>"); | ||
552 | PVariable var_NoHostToAllocate = body.getOrCreateVariableByName("NoHostToAllocate"); | ||
553 | PVariable var___3_ = body.getOrCreateVariableByName("_<3>"); | ||
554 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Value), new JavaTransitiveInstancesKey(java.lang.Integer.class)); | ||
555 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
556 | new ExportedParameter(body, var_Value, parameter_Value) | ||
557 | )); | ||
558 | // UnallocatedInstances == count find unallocatedAppInstance(_) | ||
559 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
560 | new PatternMatchCounter(body, Tuples.flatTupleOf(var___0_), UnallocatedAppInstance.instance().getInternalQueryRepresentation(), var__virtual_0_); | ||
561 | new Equality(body, var_UnallocatedInstances, var__virtual_0_); | ||
562 | // RequiredInstances == sum find requiredAppInstances(_, #_) | ||
563 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
564 | new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var___1_, var___2_), RequiredAppInstances.instance().getInternalQueryRepresentation(), var__virtual_1_, 1); | ||
565 | new Equality(body, var_RequiredInstances, var__virtual_1_); | ||
566 | // NoHostToAllocate == count find noHostToAllocateTo(_) | ||
567 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
568 | new PatternMatchCounter(body, Tuples.flatTupleOf(var___3_), NoHostToAllocateTo.instance().getInternalQueryRepresentation(), var__virtual_2_); | ||
569 | new Equality(body, var_NoHostToAllocate, var__virtual_2_); | ||
570 | // Value == eval(2 * UnallocatedInstances + 4 * RequiredInstances + NoHostToAllocate) | ||
571 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); | ||
572 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
573 | |||
574 | @Override | ||
575 | public String getShortDescription() { | ||
576 | return "Expression evaluation from pattern guidanceObjective"; | ||
577 | } | ||
578 | |||
579 | @Override | ||
580 | public Iterable<String> getInputParameterNames() { | ||
581 | return Arrays.asList("NoHostToAllocate", "RequiredInstances", "UnallocatedInstances");} | ||
582 | |||
583 | @Override | ||
584 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
585 | Integer NoHostToAllocate = (Integer) provider.getValue("NoHostToAllocate"); | ||
586 | Integer RequiredInstances = (Integer) provider.getValue("RequiredInstances"); | ||
587 | Integer UnallocatedInstances = (Integer) provider.getValue("UnallocatedInstances"); | ||
588 | return evaluateExpression_1_1(NoHostToAllocate, RequiredInstances, UnallocatedInstances); | ||
589 | } | ||
590 | }, var__virtual_3_ ); | ||
591 | new Equality(body, var_Value, var__virtual_3_); | ||
592 | bodies.add(body); | ||
593 | } | ||
594 | return bodies; | ||
595 | } | ||
596 | } | ||
597 | |||
598 | private static int evaluateExpression_1_1(final Integer NoHostToAllocate, final Integer RequiredInstances, final Integer UnallocatedInstances) { | ||
599 | return (((2 * (UnallocatedInstances).intValue()) + (4 * (RequiredInstances).intValue())) + (NoHostToAllocate).intValue()); | ||
600 | } | ||
601 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/InstanceDoesNotSatisfyRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/InstanceDoesNotSatisfyRequirement.java new file mode 100644 index 00000000..932501ff --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/InstanceDoesNotSatisfyRequirement.java | |||
@@ -0,0 +1,727 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance; | ||
9 | import java.util.Arrays; | ||
10 | import java.util.Collection; | ||
11 | import java.util.LinkedHashSet; | ||
12 | import java.util.List; | ||
13 | import java.util.Objects; | ||
14 | import java.util.Optional; | ||
15 | import java.util.Set; | ||
16 | import java.util.function.Consumer; | ||
17 | import java.util.stream.Collectors; | ||
18 | import java.util.stream.Stream; | ||
19 | import org.apache.log4j.Logger; | ||
20 | import org.eclipse.emf.ecore.EClass; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
44 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
45 | |||
46 | /** | ||
47 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
48 | * | ||
49 | * <p>Original source: | ||
50 | * <code><pre> | ||
51 | * {@literal @}Constraint(severity = "error", key = {Req, App}, | ||
52 | * message = "Requirement must be satisfied by the required application type.") | ||
53 | * pattern instanceDoesNotSatisfyRequirement(Req : Requirement, App : ApplicationInstance) { | ||
54 | * Requirement.instances(Req, App); | ||
55 | * neg find satisfyingInstance(Req, App); | ||
56 | * } | ||
57 | * </pre></code> | ||
58 | * | ||
59 | * @see Matcher | ||
60 | * @see Match | ||
61 | * | ||
62 | */ | ||
63 | @SuppressWarnings("all") | ||
64 | public final class InstanceDoesNotSatisfyRequirement extends BaseGeneratedEMFQuerySpecification<InstanceDoesNotSatisfyRequirement.Matcher> { | ||
65 | /** | ||
66 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.instanceDoesNotSatisfyRequirement pattern, | ||
67 | * to be used in conjunction with {@link Matcher}. | ||
68 | * | ||
69 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
70 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
71 | * usable to represent a match of the pattern in the result of a query, | ||
72 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
73 | * | ||
74 | * @see Matcher | ||
75 | * | ||
76 | */ | ||
77 | public static abstract class Match extends BasePatternMatch { | ||
78 | private Requirement fReq; | ||
79 | |||
80 | private ApplicationInstance fApp; | ||
81 | |||
82 | private static List<String> parameterNames = makeImmutableList("Req", "App"); | ||
83 | |||
84 | private Match(final Requirement pReq, final ApplicationInstance pApp) { | ||
85 | this.fReq = pReq; | ||
86 | this.fApp = pApp; | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final String parameterName) { | ||
91 | switch(parameterName) { | ||
92 | case "Req": return this.fReq; | ||
93 | case "App": return this.fApp; | ||
94 | default: return null; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | @Override | ||
99 | public Object get(final int index) { | ||
100 | switch(index) { | ||
101 | case 0: return this.fReq; | ||
102 | case 1: return this.fApp; | ||
103 | default: return null; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | public Requirement getReq() { | ||
108 | return this.fReq; | ||
109 | } | ||
110 | |||
111 | public ApplicationInstance getApp() { | ||
112 | return this.fApp; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public boolean set(final String parameterName, final Object newValue) { | ||
117 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
118 | if ("Req".equals(parameterName) ) { | ||
119 | this.fReq = (Requirement) newValue; | ||
120 | return true; | ||
121 | } | ||
122 | if ("App".equals(parameterName) ) { | ||
123 | this.fApp = (ApplicationInstance) newValue; | ||
124 | return true; | ||
125 | } | ||
126 | return false; | ||
127 | } | ||
128 | |||
129 | public void setReq(final Requirement pReq) { | ||
130 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
131 | this.fReq = pReq; | ||
132 | } | ||
133 | |||
134 | public void setApp(final ApplicationInstance pApp) { | ||
135 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
136 | this.fApp = pApp; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public String patternName() { | ||
141 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.instanceDoesNotSatisfyRequirement"; | ||
142 | } | ||
143 | |||
144 | @Override | ||
145 | public List<String> parameterNames() { | ||
146 | return InstanceDoesNotSatisfyRequirement.Match.parameterNames; | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public Object[] toArray() { | ||
151 | return new Object[]{fReq, fApp}; | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public InstanceDoesNotSatisfyRequirement.Match toImmutable() { | ||
156 | return isMutable() ? newMatch(fReq, fApp) : this; | ||
157 | } | ||
158 | |||
159 | @Override | ||
160 | public String prettyPrint() { | ||
161 | StringBuilder result = new StringBuilder(); | ||
162 | result.append("\"Req\"=" + prettyPrintValue(fReq) + ", "); | ||
163 | result.append("\"App\"=" + prettyPrintValue(fApp)); | ||
164 | return result.toString(); | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public int hashCode() { | ||
169 | return Objects.hash(fReq, fApp); | ||
170 | } | ||
171 | |||
172 | @Override | ||
173 | public boolean equals(final Object obj) { | ||
174 | if (this == obj) | ||
175 | return true; | ||
176 | if (obj == null) { | ||
177 | return false; | ||
178 | } | ||
179 | if ((obj instanceof InstanceDoesNotSatisfyRequirement.Match)) { | ||
180 | InstanceDoesNotSatisfyRequirement.Match other = (InstanceDoesNotSatisfyRequirement.Match) obj; | ||
181 | return Objects.equals(fReq, other.fReq) && Objects.equals(fApp, other.fApp); | ||
182 | } else { | ||
183 | // this should be infrequent | ||
184 | if (!(obj instanceof IPatternMatch)) { | ||
185 | return false; | ||
186 | } | ||
187 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
188 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | @Override | ||
193 | public InstanceDoesNotSatisfyRequirement specification() { | ||
194 | return InstanceDoesNotSatisfyRequirement.instance(); | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * Returns an empty, mutable match. | ||
199 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
200 | * | ||
201 | * @return the empty match. | ||
202 | * | ||
203 | */ | ||
204 | public static InstanceDoesNotSatisfyRequirement.Match newEmptyMatch() { | ||
205 | return new Mutable(null, null); | ||
206 | } | ||
207 | |||
208 | /** | ||
209 | * Returns a mutable (partial) match. | ||
210 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
211 | * | ||
212 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
213 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
214 | * @return the new, mutable (partial) match object. | ||
215 | * | ||
216 | */ | ||
217 | public static InstanceDoesNotSatisfyRequirement.Match newMutableMatch(final Requirement pReq, final ApplicationInstance pApp) { | ||
218 | return new Mutable(pReq, pApp); | ||
219 | } | ||
220 | |||
221 | /** | ||
222 | * Returns a new (partial) match. | ||
223 | * This can be used e.g. to call the matcher with a partial match. | ||
224 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
225 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
226 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
227 | * @return the (partial) match object. | ||
228 | * | ||
229 | */ | ||
230 | public static InstanceDoesNotSatisfyRequirement.Match newMatch(final Requirement pReq, final ApplicationInstance pApp) { | ||
231 | return new Immutable(pReq, pApp); | ||
232 | } | ||
233 | |||
234 | private static final class Mutable extends InstanceDoesNotSatisfyRequirement.Match { | ||
235 | Mutable(final Requirement pReq, final ApplicationInstance pApp) { | ||
236 | super(pReq, pApp); | ||
237 | } | ||
238 | |||
239 | @Override | ||
240 | public boolean isMutable() { | ||
241 | return true; | ||
242 | } | ||
243 | } | ||
244 | |||
245 | private static final class Immutable extends InstanceDoesNotSatisfyRequirement.Match { | ||
246 | Immutable(final Requirement pReq, final ApplicationInstance pApp) { | ||
247 | super(pReq, pApp); | ||
248 | } | ||
249 | |||
250 | @Override | ||
251 | public boolean isMutable() { | ||
252 | return false; | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | |||
257 | /** | ||
258 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.instanceDoesNotSatisfyRequirement pattern, | ||
259 | * providing pattern-specific query methods. | ||
260 | * | ||
261 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
262 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
263 | * | ||
264 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
265 | * | ||
266 | * <p>Original source: | ||
267 | * <code><pre> | ||
268 | * {@literal @}Constraint(severity = "error", key = {Req, App}, | ||
269 | * message = "Requirement must be satisfied by the required application type.") | ||
270 | * pattern instanceDoesNotSatisfyRequirement(Req : Requirement, App : ApplicationInstance) { | ||
271 | * Requirement.instances(Req, App); | ||
272 | * neg find satisfyingInstance(Req, App); | ||
273 | * } | ||
274 | * </pre></code> | ||
275 | * | ||
276 | * @see Match | ||
277 | * @see InstanceDoesNotSatisfyRequirement | ||
278 | * | ||
279 | */ | ||
280 | public static class Matcher extends BaseMatcher<InstanceDoesNotSatisfyRequirement.Match> { | ||
281 | /** | ||
282 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
283 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
284 | * | ||
285 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
286 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
287 | * | ||
288 | */ | ||
289 | public static InstanceDoesNotSatisfyRequirement.Matcher on(final ViatraQueryEngine engine) { | ||
290 | // check if matcher already exists | ||
291 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
292 | if (matcher == null) { | ||
293 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
294 | } | ||
295 | return matcher; | ||
296 | } | ||
297 | |||
298 | /** | ||
299 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
300 | * @return an initialized matcher | ||
301 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
302 | * | ||
303 | */ | ||
304 | public static InstanceDoesNotSatisfyRequirement.Matcher create() { | ||
305 | return new Matcher(); | ||
306 | } | ||
307 | |||
308 | private static final int POSITION_REQ = 0; | ||
309 | |||
310 | private static final int POSITION_APP = 1; | ||
311 | |||
312 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(InstanceDoesNotSatisfyRequirement.Matcher.class); | ||
313 | |||
314 | /** | ||
315 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
316 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
317 | * | ||
318 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
319 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
320 | * | ||
321 | */ | ||
322 | private Matcher() { | ||
323 | super(querySpecification()); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
328 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
329 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
330 | * @return matches represented as a Match object. | ||
331 | * | ||
332 | */ | ||
333 | public Collection<InstanceDoesNotSatisfyRequirement.Match> getAllMatches(final Requirement pReq, final ApplicationInstance pApp) { | ||
334 | return rawStreamAllMatches(new Object[]{pReq, pApp}).collect(Collectors.toSet()); | ||
335 | } | ||
336 | |||
337 | /** | ||
338 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
339 | * </p> | ||
340 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
341 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
342 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
343 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
344 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
345 | * @return a stream of matches represented as a Match object. | ||
346 | * | ||
347 | */ | ||
348 | public Stream<InstanceDoesNotSatisfyRequirement.Match> streamAllMatches(final Requirement pReq, final ApplicationInstance pApp) { | ||
349 | return rawStreamAllMatches(new Object[]{pReq, pApp}); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
354 | * Neither determinism nor randomness of selection is guaranteed. | ||
355 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
356 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
357 | * @return a match represented as a Match object, or null if no match is found. | ||
358 | * | ||
359 | */ | ||
360 | public Optional<InstanceDoesNotSatisfyRequirement.Match> getOneArbitraryMatch(final Requirement pReq, final ApplicationInstance pApp) { | ||
361 | return rawGetOneArbitraryMatch(new Object[]{pReq, pApp}); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
366 | * under any possible substitution of the unspecified parameters (if any). | ||
367 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
368 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
369 | * @return true if the input is a valid (partial) match of the pattern. | ||
370 | * | ||
371 | */ | ||
372 | public boolean hasMatch(final Requirement pReq, final ApplicationInstance pApp) { | ||
373 | return rawHasMatch(new Object[]{pReq, pApp}); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
378 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
379 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
380 | * @return the number of pattern matches found. | ||
381 | * | ||
382 | */ | ||
383 | public int countMatches(final Requirement pReq, final ApplicationInstance pApp) { | ||
384 | return rawCountMatches(new Object[]{pReq, pApp}); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
389 | * Neither determinism nor randomness of selection is guaranteed. | ||
390 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
391 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
392 | * @param processor the action that will process the selected match. | ||
393 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
394 | * | ||
395 | */ | ||
396 | public boolean forOneArbitraryMatch(final Requirement pReq, final ApplicationInstance pApp, final Consumer<? super InstanceDoesNotSatisfyRequirement.Match> processor) { | ||
397 | return rawForOneArbitraryMatch(new Object[]{pReq, pApp}, processor); | ||
398 | } | ||
399 | |||
400 | /** | ||
401 | * Returns a new (partial) match. | ||
402 | * This can be used e.g. to call the matcher with a partial match. | ||
403 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
404 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
405 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
406 | * @return the (partial) match object. | ||
407 | * | ||
408 | */ | ||
409 | public InstanceDoesNotSatisfyRequirement.Match newMatch(final Requirement pReq, final ApplicationInstance pApp) { | ||
410 | return InstanceDoesNotSatisfyRequirement.Match.newMatch(pReq, pApp); | ||
411 | } | ||
412 | |||
413 | /** | ||
414 | * Retrieve the set of values that occur in matches for Req. | ||
415 | * @return the Set of all values or empty set if there are no matches | ||
416 | * | ||
417 | */ | ||
418 | protected Stream<Requirement> rawStreamAllValuesOfReq(final Object[] parameters) { | ||
419 | return rawStreamAllValues(POSITION_REQ, parameters).map(Requirement.class::cast); | ||
420 | } | ||
421 | |||
422 | /** | ||
423 | * Retrieve the set of values that occur in matches for Req. | ||
424 | * @return the Set of all values or empty set if there are no matches | ||
425 | * | ||
426 | */ | ||
427 | public Set<Requirement> getAllValuesOfReq() { | ||
428 | return rawStreamAllValuesOfReq(emptyArray()).collect(Collectors.toSet()); | ||
429 | } | ||
430 | |||
431 | /** | ||
432 | * Retrieve the set of values that occur in matches for Req. | ||
433 | * @return the Set of all values or empty set if there are no matches | ||
434 | * | ||
435 | */ | ||
436 | public Stream<Requirement> streamAllValuesOfReq() { | ||
437 | return rawStreamAllValuesOfReq(emptyArray()); | ||
438 | } | ||
439 | |||
440 | /** | ||
441 | * Retrieve the set of values that occur in matches for Req. | ||
442 | * </p> | ||
443 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
444 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
445 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
446 | * | ||
447 | * @return the Stream of all values or empty set if there are no matches | ||
448 | * | ||
449 | */ | ||
450 | public Stream<Requirement> streamAllValuesOfReq(final InstanceDoesNotSatisfyRequirement.Match partialMatch) { | ||
451 | return rawStreamAllValuesOfReq(partialMatch.toArray()); | ||
452 | } | ||
453 | |||
454 | /** | ||
455 | * Retrieve the set of values that occur in matches for Req. | ||
456 | * </p> | ||
457 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
458 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
459 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
460 | * | ||
461 | * @return the Stream of all values or empty set if there are no matches | ||
462 | * | ||
463 | */ | ||
464 | public Stream<Requirement> streamAllValuesOfReq(final ApplicationInstance pApp) { | ||
465 | return rawStreamAllValuesOfReq(new Object[]{null, pApp}); | ||
466 | } | ||
467 | |||
468 | /** | ||
469 | * Retrieve the set of values that occur in matches for Req. | ||
470 | * @return the Set of all values or empty set if there are no matches | ||
471 | * | ||
472 | */ | ||
473 | public Set<Requirement> getAllValuesOfReq(final InstanceDoesNotSatisfyRequirement.Match partialMatch) { | ||
474 | return rawStreamAllValuesOfReq(partialMatch.toArray()).collect(Collectors.toSet()); | ||
475 | } | ||
476 | |||
477 | /** | ||
478 | * Retrieve the set of values that occur in matches for Req. | ||
479 | * @return the Set of all values or empty set if there are no matches | ||
480 | * | ||
481 | */ | ||
482 | public Set<Requirement> getAllValuesOfReq(final ApplicationInstance pApp) { | ||
483 | return rawStreamAllValuesOfReq(new Object[]{null, pApp}).collect(Collectors.toSet()); | ||
484 | } | ||
485 | |||
486 | /** | ||
487 | * Retrieve the set of values that occur in matches for App. | ||
488 | * @return the Set of all values or empty set if there are no matches | ||
489 | * | ||
490 | */ | ||
491 | protected Stream<ApplicationInstance> rawStreamAllValuesOfApp(final Object[] parameters) { | ||
492 | return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast); | ||
493 | } | ||
494 | |||
495 | /** | ||
496 | * Retrieve the set of values that occur in matches for App. | ||
497 | * @return the Set of all values or empty set if there are no matches | ||
498 | * | ||
499 | */ | ||
500 | public Set<ApplicationInstance> getAllValuesOfApp() { | ||
501 | return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet()); | ||
502 | } | ||
503 | |||
504 | /** | ||
505 | * Retrieve the set of values that occur in matches for App. | ||
506 | * @return the Set of all values or empty set if there are no matches | ||
507 | * | ||
508 | */ | ||
509 | public Stream<ApplicationInstance> streamAllValuesOfApp() { | ||
510 | return rawStreamAllValuesOfApp(emptyArray()); | ||
511 | } | ||
512 | |||
513 | /** | ||
514 | * Retrieve the set of values that occur in matches for App. | ||
515 | * </p> | ||
516 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
517 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
518 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
519 | * | ||
520 | * @return the Stream of all values or empty set if there are no matches | ||
521 | * | ||
522 | */ | ||
523 | public Stream<ApplicationInstance> streamAllValuesOfApp(final InstanceDoesNotSatisfyRequirement.Match partialMatch) { | ||
524 | return rawStreamAllValuesOfApp(partialMatch.toArray()); | ||
525 | } | ||
526 | |||
527 | /** | ||
528 | * Retrieve the set of values that occur in matches for App. | ||
529 | * </p> | ||
530 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
531 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
532 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
533 | * | ||
534 | * @return the Stream of all values or empty set if there are no matches | ||
535 | * | ||
536 | */ | ||
537 | public Stream<ApplicationInstance> streamAllValuesOfApp(final Requirement pReq) { | ||
538 | return rawStreamAllValuesOfApp(new Object[]{pReq, null}); | ||
539 | } | ||
540 | |||
541 | /** | ||
542 | * Retrieve the set of values that occur in matches for App. | ||
543 | * @return the Set of all values or empty set if there are no matches | ||
544 | * | ||
545 | */ | ||
546 | public Set<ApplicationInstance> getAllValuesOfApp(final InstanceDoesNotSatisfyRequirement.Match partialMatch) { | ||
547 | return rawStreamAllValuesOfApp(partialMatch.toArray()).collect(Collectors.toSet()); | ||
548 | } | ||
549 | |||
550 | /** | ||
551 | * Retrieve the set of values that occur in matches for App. | ||
552 | * @return the Set of all values or empty set if there are no matches | ||
553 | * | ||
554 | */ | ||
555 | public Set<ApplicationInstance> getAllValuesOfApp(final Requirement pReq) { | ||
556 | return rawStreamAllValuesOfApp(new Object[]{pReq, null}).collect(Collectors.toSet()); | ||
557 | } | ||
558 | |||
559 | @Override | ||
560 | protected InstanceDoesNotSatisfyRequirement.Match tupleToMatch(final Tuple t) { | ||
561 | try { | ||
562 | return InstanceDoesNotSatisfyRequirement.Match.newMatch((Requirement) t.get(POSITION_REQ), (ApplicationInstance) t.get(POSITION_APP)); | ||
563 | } catch(ClassCastException e) { | ||
564 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
565 | return null; | ||
566 | } | ||
567 | } | ||
568 | |||
569 | @Override | ||
570 | protected InstanceDoesNotSatisfyRequirement.Match arrayToMatch(final Object[] match) { | ||
571 | try { | ||
572 | return InstanceDoesNotSatisfyRequirement.Match.newMatch((Requirement) match[POSITION_REQ], (ApplicationInstance) match[POSITION_APP]); | ||
573 | } catch(ClassCastException e) { | ||
574 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
575 | return null; | ||
576 | } | ||
577 | } | ||
578 | |||
579 | @Override | ||
580 | protected InstanceDoesNotSatisfyRequirement.Match arrayToMatchMutable(final Object[] match) { | ||
581 | try { | ||
582 | return InstanceDoesNotSatisfyRequirement.Match.newMutableMatch((Requirement) match[POSITION_REQ], (ApplicationInstance) match[POSITION_APP]); | ||
583 | } catch(ClassCastException e) { | ||
584 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
585 | return null; | ||
586 | } | ||
587 | } | ||
588 | |||
589 | /** | ||
590 | * @return the singleton instance of the query specification of this pattern | ||
591 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
592 | * | ||
593 | */ | ||
594 | public static IQuerySpecification<InstanceDoesNotSatisfyRequirement.Matcher> querySpecification() { | ||
595 | return InstanceDoesNotSatisfyRequirement.instance(); | ||
596 | } | ||
597 | } | ||
598 | |||
599 | private InstanceDoesNotSatisfyRequirement() { | ||
600 | super(GeneratedPQuery.INSTANCE); | ||
601 | } | ||
602 | |||
603 | /** | ||
604 | * @return the singleton instance of the query specification | ||
605 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
606 | * | ||
607 | */ | ||
608 | public static InstanceDoesNotSatisfyRequirement instance() { | ||
609 | try{ | ||
610 | return LazyHolder.INSTANCE; | ||
611 | } catch (ExceptionInInitializerError err) { | ||
612 | throw processInitializerError(err); | ||
613 | } | ||
614 | } | ||
615 | |||
616 | @Override | ||
617 | protected InstanceDoesNotSatisfyRequirement.Matcher instantiate(final ViatraQueryEngine engine) { | ||
618 | return InstanceDoesNotSatisfyRequirement.Matcher.on(engine); | ||
619 | } | ||
620 | |||
621 | @Override | ||
622 | public InstanceDoesNotSatisfyRequirement.Matcher instantiate() { | ||
623 | return InstanceDoesNotSatisfyRequirement.Matcher.create(); | ||
624 | } | ||
625 | |||
626 | @Override | ||
627 | public InstanceDoesNotSatisfyRequirement.Match newEmptyMatch() { | ||
628 | return InstanceDoesNotSatisfyRequirement.Match.newEmptyMatch(); | ||
629 | } | ||
630 | |||
631 | @Override | ||
632 | public InstanceDoesNotSatisfyRequirement.Match newMatch(final Object... parameters) { | ||
633 | return InstanceDoesNotSatisfyRequirement.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.Requirement) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[1]); | ||
634 | } | ||
635 | |||
636 | /** | ||
637 | * Inner class allowing the singleton instance of {@link InstanceDoesNotSatisfyRequirement} to be created | ||
638 | * <b>not</b> at the class load time of the outer class, | ||
639 | * but rather at the first call to {@link InstanceDoesNotSatisfyRequirement#instance()}. | ||
640 | * | ||
641 | * <p> This workaround is required e.g. to support recursion. | ||
642 | * | ||
643 | */ | ||
644 | private static class LazyHolder { | ||
645 | private static final InstanceDoesNotSatisfyRequirement INSTANCE = new InstanceDoesNotSatisfyRequirement(); | ||
646 | |||
647 | /** | ||
648 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
649 | * This initialization order is required to support indirect recursion. | ||
650 | * | ||
651 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
652 | * | ||
653 | */ | ||
654 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
655 | |||
656 | public static Object ensureInitialized() { | ||
657 | INSTANCE.ensureInitializedInternal(); | ||
658 | return null; | ||
659 | } | ||
660 | } | ||
661 | |||
662 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
663 | private static final InstanceDoesNotSatisfyRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
664 | |||
665 | private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.Requirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "Requirement")), PParameterDirection.INOUT); | ||
666 | |||
667 | private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); | ||
668 | |||
669 | private final List<PParameter> parameters = Arrays.asList(parameter_Req, parameter_App); | ||
670 | |||
671 | private GeneratedPQuery() { | ||
672 | super(PVisibility.PUBLIC); | ||
673 | } | ||
674 | |||
675 | @Override | ||
676 | public String getFullyQualifiedName() { | ||
677 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.instanceDoesNotSatisfyRequirement"; | ||
678 | } | ||
679 | |||
680 | @Override | ||
681 | public List<String> getParameterNames() { | ||
682 | return Arrays.asList("Req","App"); | ||
683 | } | ||
684 | |||
685 | @Override | ||
686 | public List<PParameter> getParameters() { | ||
687 | return parameters; | ||
688 | } | ||
689 | |||
690 | @Override | ||
691 | public Set<PBody> doGetContainedBodies() { | ||
692 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
693 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
694 | { | ||
695 | PBody body = new PBody(this); | ||
696 | PVariable var_Req = body.getOrCreateVariableByName("Req"); | ||
697 | PVariable var_App = body.getOrCreateVariableByName("App"); | ||
698 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); | ||
699 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
700 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
701 | new ExportedParameter(body, var_Req, parameter_Req), | ||
702 | new ExportedParameter(body, var_App, parameter_App) | ||
703 | )); | ||
704 | // Requirement.instances(Req, App) | ||
705 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); | ||
706 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
707 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "instances"))); | ||
708 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
709 | new Equality(body, var__virtual_0_, var_App); | ||
710 | // neg find satisfyingInstance(Req, App) | ||
711 | new NegativePatternCall(body, Tuples.flatTupleOf(var_Req, var_App), SatisfyingInstance.instance().getInternalQueryRepresentation()); | ||
712 | bodies.add(body); | ||
713 | } | ||
714 | { | ||
715 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
716 | annotation.addAttribute("severity", "error"); | ||
717 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
718 | new ParameterReference("Req"), | ||
719 | new ParameterReference("App") | ||
720 | })); | ||
721 | annotation.addAttribute("message", "Requirement must be satisfied by the required application type."); | ||
722 | addAnnotation(annotation); | ||
723 | } | ||
724 | return bodies; | ||
725 | } | ||
726 | } | ||
727 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java new file mode 100644 index 00000000..4077c103 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java | |||
@@ -0,0 +1,589 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
44 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
45 | |||
46 | /** | ||
47 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
48 | * | ||
49 | * <p>Original source: | ||
50 | * <code><pre> | ||
51 | * {@literal @}Constraint(severity = "error", key = {Host}, | ||
52 | * message = "Insufficient HDD available on host.") | ||
53 | * pattern notEnoughAvailableHdd(Host : HostInstance) { | ||
54 | * find availableHdd(Host, Hdd); | ||
55 | * check(Hdd {@literal <} 0); | ||
56 | * } | ||
57 | * </pre></code> | ||
58 | * | ||
59 | * @see Matcher | ||
60 | * @see Match | ||
61 | * | ||
62 | */ | ||
63 | @SuppressWarnings("all") | ||
64 | public final class NotEnoughAvailableHdd extends BaseGeneratedEMFQuerySpecification<NotEnoughAvailableHdd.Matcher> { | ||
65 | /** | ||
66 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableHdd pattern, | ||
67 | * to be used in conjunction with {@link Matcher}. | ||
68 | * | ||
69 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
70 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
71 | * usable to represent a match of the pattern in the result of a query, | ||
72 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
73 | * | ||
74 | * @see Matcher | ||
75 | * | ||
76 | */ | ||
77 | public static abstract class Match extends BasePatternMatch { | ||
78 | private HostInstance fHost; | ||
79 | |||
80 | private static List<String> parameterNames = makeImmutableList("Host"); | ||
81 | |||
82 | private Match(final HostInstance pHost) { | ||
83 | this.fHost = pHost; | ||
84 | } | ||
85 | |||
86 | @Override | ||
87 | public Object get(final String parameterName) { | ||
88 | switch(parameterName) { | ||
89 | case "Host": return this.fHost; | ||
90 | default: return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | @Override | ||
95 | public Object get(final int index) { | ||
96 | switch(index) { | ||
97 | case 0: return this.fHost; | ||
98 | default: return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public HostInstance getHost() { | ||
103 | return this.fHost; | ||
104 | } | ||
105 | |||
106 | @Override | ||
107 | public boolean set(final String parameterName, final Object newValue) { | ||
108 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
109 | if ("Host".equals(parameterName) ) { | ||
110 | this.fHost = (HostInstance) newValue; | ||
111 | return true; | ||
112 | } | ||
113 | return false; | ||
114 | } | ||
115 | |||
116 | public void setHost(final HostInstance pHost) { | ||
117 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
118 | this.fHost = pHost; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public String patternName() { | ||
123 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableHdd"; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public List<String> parameterNames() { | ||
128 | return NotEnoughAvailableHdd.Match.parameterNames; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public Object[] toArray() { | ||
133 | return new Object[]{fHost}; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public NotEnoughAvailableHdd.Match toImmutable() { | ||
138 | return isMutable() ? newMatch(fHost) : this; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public String prettyPrint() { | ||
143 | StringBuilder result = new StringBuilder(); | ||
144 | result.append("\"Host\"=" + prettyPrintValue(fHost)); | ||
145 | return result.toString(); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public int hashCode() { | ||
150 | return Objects.hash(fHost); | ||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public boolean equals(final Object obj) { | ||
155 | if (this == obj) | ||
156 | return true; | ||
157 | if (obj == null) { | ||
158 | return false; | ||
159 | } | ||
160 | if ((obj instanceof NotEnoughAvailableHdd.Match)) { | ||
161 | NotEnoughAvailableHdd.Match other = (NotEnoughAvailableHdd.Match) obj; | ||
162 | return Objects.equals(fHost, other.fHost); | ||
163 | } else { | ||
164 | // this should be infrequent | ||
165 | if (!(obj instanceof IPatternMatch)) { | ||
166 | return false; | ||
167 | } | ||
168 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
169 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | @Override | ||
174 | public NotEnoughAvailableHdd specification() { | ||
175 | return NotEnoughAvailableHdd.instance(); | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * Returns an empty, mutable match. | ||
180 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
181 | * | ||
182 | * @return the empty match. | ||
183 | * | ||
184 | */ | ||
185 | public static NotEnoughAvailableHdd.Match newEmptyMatch() { | ||
186 | return new Mutable(null); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * Returns a mutable (partial) match. | ||
191 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
192 | * | ||
193 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
194 | * @return the new, mutable (partial) match object. | ||
195 | * | ||
196 | */ | ||
197 | public static NotEnoughAvailableHdd.Match newMutableMatch(final HostInstance pHost) { | ||
198 | return new Mutable(pHost); | ||
199 | } | ||
200 | |||
201 | /** | ||
202 | * Returns a new (partial) match. | ||
203 | * This can be used e.g. to call the matcher with a partial match. | ||
204 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
205 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
206 | * @return the (partial) match object. | ||
207 | * | ||
208 | */ | ||
209 | public static NotEnoughAvailableHdd.Match newMatch(final HostInstance pHost) { | ||
210 | return new Immutable(pHost); | ||
211 | } | ||
212 | |||
213 | private static final class Mutable extends NotEnoughAvailableHdd.Match { | ||
214 | Mutable(final HostInstance pHost) { | ||
215 | super(pHost); | ||
216 | } | ||
217 | |||
218 | @Override | ||
219 | public boolean isMutable() { | ||
220 | return true; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | private static final class Immutable extends NotEnoughAvailableHdd.Match { | ||
225 | Immutable(final HostInstance pHost) { | ||
226 | super(pHost); | ||
227 | } | ||
228 | |||
229 | @Override | ||
230 | public boolean isMutable() { | ||
231 | return false; | ||
232 | } | ||
233 | } | ||
234 | } | ||
235 | |||
236 | /** | ||
237 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableHdd pattern, | ||
238 | * providing pattern-specific query methods. | ||
239 | * | ||
240 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
241 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
242 | * | ||
243 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
244 | * | ||
245 | * <p>Original source: | ||
246 | * <code><pre> | ||
247 | * {@literal @}Constraint(severity = "error", key = {Host}, | ||
248 | * message = "Insufficient HDD available on host.") | ||
249 | * pattern notEnoughAvailableHdd(Host : HostInstance) { | ||
250 | * find availableHdd(Host, Hdd); | ||
251 | * check(Hdd {@literal <} 0); | ||
252 | * } | ||
253 | * </pre></code> | ||
254 | * | ||
255 | * @see Match | ||
256 | * @see NotEnoughAvailableHdd | ||
257 | * | ||
258 | */ | ||
259 | public static class Matcher extends BaseMatcher<NotEnoughAvailableHdd.Match> { | ||
260 | /** | ||
261 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
262 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
263 | * | ||
264 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
265 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
266 | * | ||
267 | */ | ||
268 | public static NotEnoughAvailableHdd.Matcher on(final ViatraQueryEngine engine) { | ||
269 | // check if matcher already exists | ||
270 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
271 | if (matcher == null) { | ||
272 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
273 | } | ||
274 | return matcher; | ||
275 | } | ||
276 | |||
277 | /** | ||
278 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
279 | * @return an initialized matcher | ||
280 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
281 | * | ||
282 | */ | ||
283 | public static NotEnoughAvailableHdd.Matcher create() { | ||
284 | return new Matcher(); | ||
285 | } | ||
286 | |||
287 | private static final int POSITION_HOST = 0; | ||
288 | |||
289 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NotEnoughAvailableHdd.Matcher.class); | ||
290 | |||
291 | /** | ||
292 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
293 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
294 | * | ||
295 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
296 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
297 | * | ||
298 | */ | ||
299 | private Matcher() { | ||
300 | super(querySpecification()); | ||
301 | } | ||
302 | |||
303 | /** | ||
304 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
305 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
306 | * @return matches represented as a Match object. | ||
307 | * | ||
308 | */ | ||
309 | public Collection<NotEnoughAvailableHdd.Match> getAllMatches(final HostInstance pHost) { | ||
310 | return rawStreamAllMatches(new Object[]{pHost}).collect(Collectors.toSet()); | ||
311 | } | ||
312 | |||
313 | /** | ||
314 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
315 | * </p> | ||
316 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
317 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
318 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
319 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
320 | * @return a stream of matches represented as a Match object. | ||
321 | * | ||
322 | */ | ||
323 | public Stream<NotEnoughAvailableHdd.Match> streamAllMatches(final HostInstance pHost) { | ||
324 | return rawStreamAllMatches(new Object[]{pHost}); | ||
325 | } | ||
326 | |||
327 | /** | ||
328 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
329 | * Neither determinism nor randomness of selection is guaranteed. | ||
330 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
331 | * @return a match represented as a Match object, or null if no match is found. | ||
332 | * | ||
333 | */ | ||
334 | public Optional<NotEnoughAvailableHdd.Match> getOneArbitraryMatch(final HostInstance pHost) { | ||
335 | return rawGetOneArbitraryMatch(new Object[]{pHost}); | ||
336 | } | ||
337 | |||
338 | /** | ||
339 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
340 | * under any possible substitution of the unspecified parameters (if any). | ||
341 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
342 | * @return true if the input is a valid (partial) match of the pattern. | ||
343 | * | ||
344 | */ | ||
345 | public boolean hasMatch(final HostInstance pHost) { | ||
346 | return rawHasMatch(new Object[]{pHost}); | ||
347 | } | ||
348 | |||
349 | /** | ||
350 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
351 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
352 | * @return the number of pattern matches found. | ||
353 | * | ||
354 | */ | ||
355 | public int countMatches(final HostInstance pHost) { | ||
356 | return rawCountMatches(new Object[]{pHost}); | ||
357 | } | ||
358 | |||
359 | /** | ||
360 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
361 | * Neither determinism nor randomness of selection is guaranteed. | ||
362 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
363 | * @param processor the action that will process the selected match. | ||
364 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
365 | * | ||
366 | */ | ||
367 | public boolean forOneArbitraryMatch(final HostInstance pHost, final Consumer<? super NotEnoughAvailableHdd.Match> processor) { | ||
368 | return rawForOneArbitraryMatch(new Object[]{pHost}, processor); | ||
369 | } | ||
370 | |||
371 | /** | ||
372 | * Returns a new (partial) match. | ||
373 | * This can be used e.g. to call the matcher with a partial match. | ||
374 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
375 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
376 | * @return the (partial) match object. | ||
377 | * | ||
378 | */ | ||
379 | public NotEnoughAvailableHdd.Match newMatch(final HostInstance pHost) { | ||
380 | return NotEnoughAvailableHdd.Match.newMatch(pHost); | ||
381 | } | ||
382 | |||
383 | /** | ||
384 | * Retrieve the set of values that occur in matches for Host. | ||
385 | * @return the Set of all values or empty set if there are no matches | ||
386 | * | ||
387 | */ | ||
388 | protected Stream<HostInstance> rawStreamAllValuesOfHost(final Object[] parameters) { | ||
389 | return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); | ||
390 | } | ||
391 | |||
392 | /** | ||
393 | * Retrieve the set of values that occur in matches for Host. | ||
394 | * @return the Set of all values or empty set if there are no matches | ||
395 | * | ||
396 | */ | ||
397 | public Set<HostInstance> getAllValuesOfHost() { | ||
398 | return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); | ||
399 | } | ||
400 | |||
401 | /** | ||
402 | * Retrieve the set of values that occur in matches for Host. | ||
403 | * @return the Set of all values or empty set if there are no matches | ||
404 | * | ||
405 | */ | ||
406 | public Stream<HostInstance> streamAllValuesOfHost() { | ||
407 | return rawStreamAllValuesOfHost(emptyArray()); | ||
408 | } | ||
409 | |||
410 | @Override | ||
411 | protected NotEnoughAvailableHdd.Match tupleToMatch(final Tuple t) { | ||
412 | try { | ||
413 | return NotEnoughAvailableHdd.Match.newMatch((HostInstance) t.get(POSITION_HOST)); | ||
414 | } catch(ClassCastException e) { | ||
415 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
416 | return null; | ||
417 | } | ||
418 | } | ||
419 | |||
420 | @Override | ||
421 | protected NotEnoughAvailableHdd.Match arrayToMatch(final Object[] match) { | ||
422 | try { | ||
423 | return NotEnoughAvailableHdd.Match.newMatch((HostInstance) match[POSITION_HOST]); | ||
424 | } catch(ClassCastException e) { | ||
425 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
426 | return null; | ||
427 | } | ||
428 | } | ||
429 | |||
430 | @Override | ||
431 | protected NotEnoughAvailableHdd.Match arrayToMatchMutable(final Object[] match) { | ||
432 | try { | ||
433 | return NotEnoughAvailableHdd.Match.newMutableMatch((HostInstance) match[POSITION_HOST]); | ||
434 | } catch(ClassCastException e) { | ||
435 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
436 | return null; | ||
437 | } | ||
438 | } | ||
439 | |||
440 | /** | ||
441 | * @return the singleton instance of the query specification of this pattern | ||
442 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
443 | * | ||
444 | */ | ||
445 | public static IQuerySpecification<NotEnoughAvailableHdd.Matcher> querySpecification() { | ||
446 | return NotEnoughAvailableHdd.instance(); | ||
447 | } | ||
448 | } | ||
449 | |||
450 | private NotEnoughAvailableHdd() { | ||
451 | super(GeneratedPQuery.INSTANCE); | ||
452 | } | ||
453 | |||
454 | /** | ||
455 | * @return the singleton instance of the query specification | ||
456 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
457 | * | ||
458 | */ | ||
459 | public static NotEnoughAvailableHdd instance() { | ||
460 | try{ | ||
461 | return LazyHolder.INSTANCE; | ||
462 | } catch (ExceptionInInitializerError err) { | ||
463 | throw processInitializerError(err); | ||
464 | } | ||
465 | } | ||
466 | |||
467 | @Override | ||
468 | protected NotEnoughAvailableHdd.Matcher instantiate(final ViatraQueryEngine engine) { | ||
469 | return NotEnoughAvailableHdd.Matcher.on(engine); | ||
470 | } | ||
471 | |||
472 | @Override | ||
473 | public NotEnoughAvailableHdd.Matcher instantiate() { | ||
474 | return NotEnoughAvailableHdd.Matcher.create(); | ||
475 | } | ||
476 | |||
477 | @Override | ||
478 | public NotEnoughAvailableHdd.Match newEmptyMatch() { | ||
479 | return NotEnoughAvailableHdd.Match.newEmptyMatch(); | ||
480 | } | ||
481 | |||
482 | @Override | ||
483 | public NotEnoughAvailableHdd.Match newMatch(final Object... parameters) { | ||
484 | return NotEnoughAvailableHdd.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0]); | ||
485 | } | ||
486 | |||
487 | /** | ||
488 | * Inner class allowing the singleton instance of {@link NotEnoughAvailableHdd} to be created | ||
489 | * <b>not</b> at the class load time of the outer class, | ||
490 | * but rather at the first call to {@link NotEnoughAvailableHdd#instance()}. | ||
491 | * | ||
492 | * <p> This workaround is required e.g. to support recursion. | ||
493 | * | ||
494 | */ | ||
495 | private static class LazyHolder { | ||
496 | private static final NotEnoughAvailableHdd INSTANCE = new NotEnoughAvailableHdd(); | ||
497 | |||
498 | /** | ||
499 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
500 | * This initialization order is required to support indirect recursion. | ||
501 | * | ||
502 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
503 | * | ||
504 | */ | ||
505 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
506 | |||
507 | public static Object ensureInitialized() { | ||
508 | INSTANCE.ensureInitializedInternal(); | ||
509 | return null; | ||
510 | } | ||
511 | } | ||
512 | |||
513 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
514 | private static final NotEnoughAvailableHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
515 | |||
516 | private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
517 | |||
518 | private final List<PParameter> parameters = Arrays.asList(parameter_Host); | ||
519 | |||
520 | private GeneratedPQuery() { | ||
521 | super(PVisibility.PUBLIC); | ||
522 | } | ||
523 | |||
524 | @Override | ||
525 | public String getFullyQualifiedName() { | ||
526 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableHdd"; | ||
527 | } | ||
528 | |||
529 | @Override | ||
530 | public List<String> getParameterNames() { | ||
531 | return Arrays.asList("Host"); | ||
532 | } | ||
533 | |||
534 | @Override | ||
535 | public List<PParameter> getParameters() { | ||
536 | return parameters; | ||
537 | } | ||
538 | |||
539 | @Override | ||
540 | public Set<PBody> doGetContainedBodies() { | ||
541 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
542 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
543 | { | ||
544 | PBody body = new PBody(this); | ||
545 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
546 | PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); | ||
547 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
548 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
549 | new ExportedParameter(body, var_Host, parameter_Host) | ||
550 | )); | ||
551 | // find availableHdd(Host, Hdd) | ||
552 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Hdd), AvailableHdd.instance().getInternalQueryRepresentation()); | ||
553 | // check(Hdd < 0) | ||
554 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
555 | |||
556 | @Override | ||
557 | public String getShortDescription() { | ||
558 | return "Expression evaluation from pattern notEnoughAvailableHdd"; | ||
559 | } | ||
560 | |||
561 | @Override | ||
562 | public Iterable<String> getInputParameterNames() { | ||
563 | return Arrays.asList("Hdd");} | ||
564 | |||
565 | @Override | ||
566 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
567 | Integer Hdd = (Integer) provider.getValue("Hdd"); | ||
568 | return evaluateExpression_1_1(Hdd); | ||
569 | } | ||
570 | }, null); | ||
571 | bodies.add(body); | ||
572 | } | ||
573 | { | ||
574 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
575 | annotation.addAttribute("severity", "error"); | ||
576 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
577 | new ParameterReference("Host") | ||
578 | })); | ||
579 | annotation.addAttribute("message", "Insufficient HDD available on host."); | ||
580 | addAnnotation(annotation); | ||
581 | } | ||
582 | return bodies; | ||
583 | } | ||
584 | } | ||
585 | |||
586 | private static boolean evaluateExpression_1_1(final Integer Hdd) { | ||
587 | return ((Hdd).intValue() < 0); | ||
588 | } | ||
589 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java new file mode 100644 index 00000000..6e52bee8 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java | |||
@@ -0,0 +1,589 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
44 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
45 | |||
46 | /** | ||
47 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
48 | * | ||
49 | * <p>Original source: | ||
50 | * <code><pre> | ||
51 | * {@literal @}Constraint(severity = "error", key = {Host}, | ||
52 | * message = "Insufficient memory available on host.") | ||
53 | * pattern notEnoughAvailableMemory(Host : HostInstance) { | ||
54 | * find availableMemory(Host, Memory); | ||
55 | * check(Memory {@literal <} 0); | ||
56 | * } | ||
57 | * </pre></code> | ||
58 | * | ||
59 | * @see Matcher | ||
60 | * @see Match | ||
61 | * | ||
62 | */ | ||
63 | @SuppressWarnings("all") | ||
64 | public final class NotEnoughAvailableMemory extends BaseGeneratedEMFQuerySpecification<NotEnoughAvailableMemory.Matcher> { | ||
65 | /** | ||
66 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory pattern, | ||
67 | * to be used in conjunction with {@link Matcher}. | ||
68 | * | ||
69 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
70 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
71 | * usable to represent a match of the pattern in the result of a query, | ||
72 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
73 | * | ||
74 | * @see Matcher | ||
75 | * | ||
76 | */ | ||
77 | public static abstract class Match extends BasePatternMatch { | ||
78 | private HostInstance fHost; | ||
79 | |||
80 | private static List<String> parameterNames = makeImmutableList("Host"); | ||
81 | |||
82 | private Match(final HostInstance pHost) { | ||
83 | this.fHost = pHost; | ||
84 | } | ||
85 | |||
86 | @Override | ||
87 | public Object get(final String parameterName) { | ||
88 | switch(parameterName) { | ||
89 | case "Host": return this.fHost; | ||
90 | default: return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | @Override | ||
95 | public Object get(final int index) { | ||
96 | switch(index) { | ||
97 | case 0: return this.fHost; | ||
98 | default: return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public HostInstance getHost() { | ||
103 | return this.fHost; | ||
104 | } | ||
105 | |||
106 | @Override | ||
107 | public boolean set(final String parameterName, final Object newValue) { | ||
108 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
109 | if ("Host".equals(parameterName) ) { | ||
110 | this.fHost = (HostInstance) newValue; | ||
111 | return true; | ||
112 | } | ||
113 | return false; | ||
114 | } | ||
115 | |||
116 | public void setHost(final HostInstance pHost) { | ||
117 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
118 | this.fHost = pHost; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public String patternName() { | ||
123 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory"; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public List<String> parameterNames() { | ||
128 | return NotEnoughAvailableMemory.Match.parameterNames; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public Object[] toArray() { | ||
133 | return new Object[]{fHost}; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public NotEnoughAvailableMemory.Match toImmutable() { | ||
138 | return isMutable() ? newMatch(fHost) : this; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public String prettyPrint() { | ||
143 | StringBuilder result = new StringBuilder(); | ||
144 | result.append("\"Host\"=" + prettyPrintValue(fHost)); | ||
145 | return result.toString(); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public int hashCode() { | ||
150 | return Objects.hash(fHost); | ||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public boolean equals(final Object obj) { | ||
155 | if (this == obj) | ||
156 | return true; | ||
157 | if (obj == null) { | ||
158 | return false; | ||
159 | } | ||
160 | if ((obj instanceof NotEnoughAvailableMemory.Match)) { | ||
161 | NotEnoughAvailableMemory.Match other = (NotEnoughAvailableMemory.Match) obj; | ||
162 | return Objects.equals(fHost, other.fHost); | ||
163 | } else { | ||
164 | // this should be infrequent | ||
165 | if (!(obj instanceof IPatternMatch)) { | ||
166 | return false; | ||
167 | } | ||
168 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
169 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | @Override | ||
174 | public NotEnoughAvailableMemory specification() { | ||
175 | return NotEnoughAvailableMemory.instance(); | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * Returns an empty, mutable match. | ||
180 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
181 | * | ||
182 | * @return the empty match. | ||
183 | * | ||
184 | */ | ||
185 | public static NotEnoughAvailableMemory.Match newEmptyMatch() { | ||
186 | return new Mutable(null); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * Returns a mutable (partial) match. | ||
191 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
192 | * | ||
193 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
194 | * @return the new, mutable (partial) match object. | ||
195 | * | ||
196 | */ | ||
197 | public static NotEnoughAvailableMemory.Match newMutableMatch(final HostInstance pHost) { | ||
198 | return new Mutable(pHost); | ||
199 | } | ||
200 | |||
201 | /** | ||
202 | * Returns a new (partial) match. | ||
203 | * This can be used e.g. to call the matcher with a partial match. | ||
204 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
205 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
206 | * @return the (partial) match object. | ||
207 | * | ||
208 | */ | ||
209 | public static NotEnoughAvailableMemory.Match newMatch(final HostInstance pHost) { | ||
210 | return new Immutable(pHost); | ||
211 | } | ||
212 | |||
213 | private static final class Mutable extends NotEnoughAvailableMemory.Match { | ||
214 | Mutable(final HostInstance pHost) { | ||
215 | super(pHost); | ||
216 | } | ||
217 | |||
218 | @Override | ||
219 | public boolean isMutable() { | ||
220 | return true; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | private static final class Immutable extends NotEnoughAvailableMemory.Match { | ||
225 | Immutable(final HostInstance pHost) { | ||
226 | super(pHost); | ||
227 | } | ||
228 | |||
229 | @Override | ||
230 | public boolean isMutable() { | ||
231 | return false; | ||
232 | } | ||
233 | } | ||
234 | } | ||
235 | |||
236 | /** | ||
237 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory pattern, | ||
238 | * providing pattern-specific query methods. | ||
239 | * | ||
240 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
241 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
242 | * | ||
243 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
244 | * | ||
245 | * <p>Original source: | ||
246 | * <code><pre> | ||
247 | * {@literal @}Constraint(severity = "error", key = {Host}, | ||
248 | * message = "Insufficient memory available on host.") | ||
249 | * pattern notEnoughAvailableMemory(Host : HostInstance) { | ||
250 | * find availableMemory(Host, Memory); | ||
251 | * check(Memory {@literal <} 0); | ||
252 | * } | ||
253 | * </pre></code> | ||
254 | * | ||
255 | * @see Match | ||
256 | * @see NotEnoughAvailableMemory | ||
257 | * | ||
258 | */ | ||
259 | public static class Matcher extends BaseMatcher<NotEnoughAvailableMemory.Match> { | ||
260 | /** | ||
261 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
262 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
263 | * | ||
264 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
265 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
266 | * | ||
267 | */ | ||
268 | public static NotEnoughAvailableMemory.Matcher on(final ViatraQueryEngine engine) { | ||
269 | // check if matcher already exists | ||
270 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
271 | if (matcher == null) { | ||
272 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
273 | } | ||
274 | return matcher; | ||
275 | } | ||
276 | |||
277 | /** | ||
278 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
279 | * @return an initialized matcher | ||
280 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
281 | * | ||
282 | */ | ||
283 | public static NotEnoughAvailableMemory.Matcher create() { | ||
284 | return new Matcher(); | ||
285 | } | ||
286 | |||
287 | private static final int POSITION_HOST = 0; | ||
288 | |||
289 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NotEnoughAvailableMemory.Matcher.class); | ||
290 | |||
291 | /** | ||
292 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
293 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
294 | * | ||
295 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
296 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
297 | * | ||
298 | */ | ||
299 | private Matcher() { | ||
300 | super(querySpecification()); | ||
301 | } | ||
302 | |||
303 | /** | ||
304 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
305 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
306 | * @return matches represented as a Match object. | ||
307 | * | ||
308 | */ | ||
309 | public Collection<NotEnoughAvailableMemory.Match> getAllMatches(final HostInstance pHost) { | ||
310 | return rawStreamAllMatches(new Object[]{pHost}).collect(Collectors.toSet()); | ||
311 | } | ||
312 | |||
313 | /** | ||
314 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
315 | * </p> | ||
316 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
317 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
318 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
319 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
320 | * @return a stream of matches represented as a Match object. | ||
321 | * | ||
322 | */ | ||
323 | public Stream<NotEnoughAvailableMemory.Match> streamAllMatches(final HostInstance pHost) { | ||
324 | return rawStreamAllMatches(new Object[]{pHost}); | ||
325 | } | ||
326 | |||
327 | /** | ||
328 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
329 | * Neither determinism nor randomness of selection is guaranteed. | ||
330 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
331 | * @return a match represented as a Match object, or null if no match is found. | ||
332 | * | ||
333 | */ | ||
334 | public Optional<NotEnoughAvailableMemory.Match> getOneArbitraryMatch(final HostInstance pHost) { | ||
335 | return rawGetOneArbitraryMatch(new Object[]{pHost}); | ||
336 | } | ||
337 | |||
338 | /** | ||
339 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
340 | * under any possible substitution of the unspecified parameters (if any). | ||
341 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
342 | * @return true if the input is a valid (partial) match of the pattern. | ||
343 | * | ||
344 | */ | ||
345 | public boolean hasMatch(final HostInstance pHost) { | ||
346 | return rawHasMatch(new Object[]{pHost}); | ||
347 | } | ||
348 | |||
349 | /** | ||
350 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
351 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
352 | * @return the number of pattern matches found. | ||
353 | * | ||
354 | */ | ||
355 | public int countMatches(final HostInstance pHost) { | ||
356 | return rawCountMatches(new Object[]{pHost}); | ||
357 | } | ||
358 | |||
359 | /** | ||
360 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
361 | * Neither determinism nor randomness of selection is guaranteed. | ||
362 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
363 | * @param processor the action that will process the selected match. | ||
364 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
365 | * | ||
366 | */ | ||
367 | public boolean forOneArbitraryMatch(final HostInstance pHost, final Consumer<? super NotEnoughAvailableMemory.Match> processor) { | ||
368 | return rawForOneArbitraryMatch(new Object[]{pHost}, processor); | ||
369 | } | ||
370 | |||
371 | /** | ||
372 | * Returns a new (partial) match. | ||
373 | * This can be used e.g. to call the matcher with a partial match. | ||
374 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
375 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
376 | * @return the (partial) match object. | ||
377 | * | ||
378 | */ | ||
379 | public NotEnoughAvailableMemory.Match newMatch(final HostInstance pHost) { | ||
380 | return NotEnoughAvailableMemory.Match.newMatch(pHost); | ||
381 | } | ||
382 | |||
383 | /** | ||
384 | * Retrieve the set of values that occur in matches for Host. | ||
385 | * @return the Set of all values or empty set if there are no matches | ||
386 | * | ||
387 | */ | ||
388 | protected Stream<HostInstance> rawStreamAllValuesOfHost(final Object[] parameters) { | ||
389 | return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); | ||
390 | } | ||
391 | |||
392 | /** | ||
393 | * Retrieve the set of values that occur in matches for Host. | ||
394 | * @return the Set of all values or empty set if there are no matches | ||
395 | * | ||
396 | */ | ||
397 | public Set<HostInstance> getAllValuesOfHost() { | ||
398 | return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); | ||
399 | } | ||
400 | |||
401 | /** | ||
402 | * Retrieve the set of values that occur in matches for Host. | ||
403 | * @return the Set of all values or empty set if there are no matches | ||
404 | * | ||
405 | */ | ||
406 | public Stream<HostInstance> streamAllValuesOfHost() { | ||
407 | return rawStreamAllValuesOfHost(emptyArray()); | ||
408 | } | ||
409 | |||
410 | @Override | ||
411 | protected NotEnoughAvailableMemory.Match tupleToMatch(final Tuple t) { | ||
412 | try { | ||
413 | return NotEnoughAvailableMemory.Match.newMatch((HostInstance) t.get(POSITION_HOST)); | ||
414 | } catch(ClassCastException e) { | ||
415 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
416 | return null; | ||
417 | } | ||
418 | } | ||
419 | |||
420 | @Override | ||
421 | protected NotEnoughAvailableMemory.Match arrayToMatch(final Object[] match) { | ||
422 | try { | ||
423 | return NotEnoughAvailableMemory.Match.newMatch((HostInstance) match[POSITION_HOST]); | ||
424 | } catch(ClassCastException e) { | ||
425 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
426 | return null; | ||
427 | } | ||
428 | } | ||
429 | |||
430 | @Override | ||
431 | protected NotEnoughAvailableMemory.Match arrayToMatchMutable(final Object[] match) { | ||
432 | try { | ||
433 | return NotEnoughAvailableMemory.Match.newMutableMatch((HostInstance) match[POSITION_HOST]); | ||
434 | } catch(ClassCastException e) { | ||
435 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
436 | return null; | ||
437 | } | ||
438 | } | ||
439 | |||
440 | /** | ||
441 | * @return the singleton instance of the query specification of this pattern | ||
442 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
443 | * | ||
444 | */ | ||
445 | public static IQuerySpecification<NotEnoughAvailableMemory.Matcher> querySpecification() { | ||
446 | return NotEnoughAvailableMemory.instance(); | ||
447 | } | ||
448 | } | ||
449 | |||
450 | private NotEnoughAvailableMemory() { | ||
451 | super(GeneratedPQuery.INSTANCE); | ||
452 | } | ||
453 | |||
454 | /** | ||
455 | * @return the singleton instance of the query specification | ||
456 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
457 | * | ||
458 | */ | ||
459 | public static NotEnoughAvailableMemory instance() { | ||
460 | try{ | ||
461 | return LazyHolder.INSTANCE; | ||
462 | } catch (ExceptionInInitializerError err) { | ||
463 | throw processInitializerError(err); | ||
464 | } | ||
465 | } | ||
466 | |||
467 | @Override | ||
468 | protected NotEnoughAvailableMemory.Matcher instantiate(final ViatraQueryEngine engine) { | ||
469 | return NotEnoughAvailableMemory.Matcher.on(engine); | ||
470 | } | ||
471 | |||
472 | @Override | ||
473 | public NotEnoughAvailableMemory.Matcher instantiate() { | ||
474 | return NotEnoughAvailableMemory.Matcher.create(); | ||
475 | } | ||
476 | |||
477 | @Override | ||
478 | public NotEnoughAvailableMemory.Match newEmptyMatch() { | ||
479 | return NotEnoughAvailableMemory.Match.newEmptyMatch(); | ||
480 | } | ||
481 | |||
482 | @Override | ||
483 | public NotEnoughAvailableMemory.Match newMatch(final Object... parameters) { | ||
484 | return NotEnoughAvailableMemory.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0]); | ||
485 | } | ||
486 | |||
487 | /** | ||
488 | * Inner class allowing the singleton instance of {@link NotEnoughAvailableMemory} to be created | ||
489 | * <b>not</b> at the class load time of the outer class, | ||
490 | * but rather at the first call to {@link NotEnoughAvailableMemory#instance()}. | ||
491 | * | ||
492 | * <p> This workaround is required e.g. to support recursion. | ||
493 | * | ||
494 | */ | ||
495 | private static class LazyHolder { | ||
496 | private static final NotEnoughAvailableMemory INSTANCE = new NotEnoughAvailableMemory(); | ||
497 | |||
498 | /** | ||
499 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
500 | * This initialization order is required to support indirect recursion. | ||
501 | * | ||
502 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
503 | * | ||
504 | */ | ||
505 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
506 | |||
507 | public static Object ensureInitialized() { | ||
508 | INSTANCE.ensureInitializedInternal(); | ||
509 | return null; | ||
510 | } | ||
511 | } | ||
512 | |||
513 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
514 | private static final NotEnoughAvailableMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
515 | |||
516 | private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
517 | |||
518 | private final List<PParameter> parameters = Arrays.asList(parameter_Host); | ||
519 | |||
520 | private GeneratedPQuery() { | ||
521 | super(PVisibility.PUBLIC); | ||
522 | } | ||
523 | |||
524 | @Override | ||
525 | public String getFullyQualifiedName() { | ||
526 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory"; | ||
527 | } | ||
528 | |||
529 | @Override | ||
530 | public List<String> getParameterNames() { | ||
531 | return Arrays.asList("Host"); | ||
532 | } | ||
533 | |||
534 | @Override | ||
535 | public List<PParameter> getParameters() { | ||
536 | return parameters; | ||
537 | } | ||
538 | |||
539 | @Override | ||
540 | public Set<PBody> doGetContainedBodies() { | ||
541 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
542 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
543 | { | ||
544 | PBody body = new PBody(this); | ||
545 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
546 | PVariable var_Memory = body.getOrCreateVariableByName("Memory"); | ||
547 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
548 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
549 | new ExportedParameter(body, var_Host, parameter_Host) | ||
550 | )); | ||
551 | // find availableMemory(Host, Memory) | ||
552 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Memory), AvailableMemory.instance().getInternalQueryRepresentation()); | ||
553 | // check(Memory < 0) | ||
554 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
555 | |||
556 | @Override | ||
557 | public String getShortDescription() { | ||
558 | return "Expression evaluation from pattern notEnoughAvailableMemory"; | ||
559 | } | ||
560 | |||
561 | @Override | ||
562 | public Iterable<String> getInputParameterNames() { | ||
563 | return Arrays.asList("Memory");} | ||
564 | |||
565 | @Override | ||
566 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
567 | Integer Memory = (Integer) provider.getValue("Memory"); | ||
568 | return evaluateExpression_1_1(Memory); | ||
569 | } | ||
570 | }, null); | ||
571 | bodies.add(body); | ||
572 | } | ||
573 | { | ||
574 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
575 | annotation.addAttribute("severity", "error"); | ||
576 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
577 | new ParameterReference("Host") | ||
578 | })); | ||
579 | annotation.addAttribute("message", "Insufficient memory available on host."); | ||
580 | addAnnotation(annotation); | ||
581 | } | ||
582 | return bodies; | ||
583 | } | ||
584 | } | ||
585 | |||
586 | private static boolean evaluateExpression_1_1(final Integer Memory) { | ||
587 | return ((Memory).intValue() < 0); | ||
588 | } | ||
589 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RedundantInstancesOnSameHost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RedundantInstancesOnSameHost.java new file mode 100644 index 00000000..2a40ac57 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RedundantInstancesOnSameHost.java | |||
@@ -0,0 +1,597 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Objects; | ||
12 | import java.util.Optional; | ||
13 | import java.util.Set; | ||
14 | import java.util.function.Consumer; | ||
15 | import java.util.stream.Collectors; | ||
16 | import java.util.stream.Stream; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
42 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
43 | |||
44 | /** | ||
45 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
46 | * | ||
47 | * <p>Original source: | ||
48 | * <code><pre> | ||
49 | * {@literal @}Constraint(severity = "error", key = {Req}, | ||
50 | * message = "Redundant instances must not be allocated to the same host.") | ||
51 | * pattern redundantInstancesOnSameHost(Req : Requirement) { | ||
52 | * Requirement.instances(Req, App1); | ||
53 | * Requirement.instances(Req, App2); | ||
54 | * App1 != App2; | ||
55 | * ApplicationInstance.allocatedTo(App1, Host); | ||
56 | * ApplicationInstance.allocatedTo(App2, Host); | ||
57 | * } | ||
58 | * </pre></code> | ||
59 | * | ||
60 | * @see Matcher | ||
61 | * @see Match | ||
62 | * | ||
63 | */ | ||
64 | @SuppressWarnings("all") | ||
65 | public final class RedundantInstancesOnSameHost extends BaseGeneratedEMFQuerySpecification<RedundantInstancesOnSameHost.Matcher> { | ||
66 | /** | ||
67 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.redundantInstancesOnSameHost pattern, | ||
68 | * to be used in conjunction with {@link Matcher}. | ||
69 | * | ||
70 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
71 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
72 | * usable to represent a match of the pattern in the result of a query, | ||
73 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
74 | * | ||
75 | * @see Matcher | ||
76 | * | ||
77 | */ | ||
78 | public static abstract class Match extends BasePatternMatch { | ||
79 | private Requirement fReq; | ||
80 | |||
81 | private static List<String> parameterNames = makeImmutableList("Req"); | ||
82 | |||
83 | private Match(final Requirement pReq) { | ||
84 | this.fReq = pReq; | ||
85 | } | ||
86 | |||
87 | @Override | ||
88 | public Object get(final String parameterName) { | ||
89 | switch(parameterName) { | ||
90 | case "Req": return this.fReq; | ||
91 | default: return null; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | @Override | ||
96 | public Object get(final int index) { | ||
97 | switch(index) { | ||
98 | case 0: return this.fReq; | ||
99 | default: return null; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | public Requirement getReq() { | ||
104 | return this.fReq; | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public boolean set(final String parameterName, final Object newValue) { | ||
109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
110 | if ("Req".equals(parameterName) ) { | ||
111 | this.fReq = (Requirement) newValue; | ||
112 | return true; | ||
113 | } | ||
114 | return false; | ||
115 | } | ||
116 | |||
117 | public void setReq(final Requirement pReq) { | ||
118 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
119 | this.fReq = pReq; | ||
120 | } | ||
121 | |||
122 | @Override | ||
123 | public String patternName() { | ||
124 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.redundantInstancesOnSameHost"; | ||
125 | } | ||
126 | |||
127 | @Override | ||
128 | public List<String> parameterNames() { | ||
129 | return RedundantInstancesOnSameHost.Match.parameterNames; | ||
130 | } | ||
131 | |||
132 | @Override | ||
133 | public Object[] toArray() { | ||
134 | return new Object[]{fReq}; | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public RedundantInstancesOnSameHost.Match toImmutable() { | ||
139 | return isMutable() ? newMatch(fReq) : this; | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public String prettyPrint() { | ||
144 | StringBuilder result = new StringBuilder(); | ||
145 | result.append("\"Req\"=" + prettyPrintValue(fReq)); | ||
146 | return result.toString(); | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public int hashCode() { | ||
151 | return Objects.hash(fReq); | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public boolean equals(final Object obj) { | ||
156 | if (this == obj) | ||
157 | return true; | ||
158 | if (obj == null) { | ||
159 | return false; | ||
160 | } | ||
161 | if ((obj instanceof RedundantInstancesOnSameHost.Match)) { | ||
162 | RedundantInstancesOnSameHost.Match other = (RedundantInstancesOnSameHost.Match) obj; | ||
163 | return Objects.equals(fReq, other.fReq); | ||
164 | } else { | ||
165 | // this should be infrequent | ||
166 | if (!(obj instanceof IPatternMatch)) { | ||
167 | return false; | ||
168 | } | ||
169 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
170 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
171 | } | ||
172 | } | ||
173 | |||
174 | @Override | ||
175 | public RedundantInstancesOnSameHost specification() { | ||
176 | return RedundantInstancesOnSameHost.instance(); | ||
177 | } | ||
178 | |||
179 | /** | ||
180 | * Returns an empty, mutable match. | ||
181 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
182 | * | ||
183 | * @return the empty match. | ||
184 | * | ||
185 | */ | ||
186 | public static RedundantInstancesOnSameHost.Match newEmptyMatch() { | ||
187 | return new Mutable(null); | ||
188 | } | ||
189 | |||
190 | /** | ||
191 | * Returns a mutable (partial) match. | ||
192 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
193 | * | ||
194 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
195 | * @return the new, mutable (partial) match object. | ||
196 | * | ||
197 | */ | ||
198 | public static RedundantInstancesOnSameHost.Match newMutableMatch(final Requirement pReq) { | ||
199 | return new Mutable(pReq); | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * Returns a new (partial) match. | ||
204 | * This can be used e.g. to call the matcher with a partial match. | ||
205 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
206 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
207 | * @return the (partial) match object. | ||
208 | * | ||
209 | */ | ||
210 | public static RedundantInstancesOnSameHost.Match newMatch(final Requirement pReq) { | ||
211 | return new Immutable(pReq); | ||
212 | } | ||
213 | |||
214 | private static final class Mutable extends RedundantInstancesOnSameHost.Match { | ||
215 | Mutable(final Requirement pReq) { | ||
216 | super(pReq); | ||
217 | } | ||
218 | |||
219 | @Override | ||
220 | public boolean isMutable() { | ||
221 | return true; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | private static final class Immutable extends RedundantInstancesOnSameHost.Match { | ||
226 | Immutable(final Requirement pReq) { | ||
227 | super(pReq); | ||
228 | } | ||
229 | |||
230 | @Override | ||
231 | public boolean isMutable() { | ||
232 | return false; | ||
233 | } | ||
234 | } | ||
235 | } | ||
236 | |||
237 | /** | ||
238 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.redundantInstancesOnSameHost pattern, | ||
239 | * providing pattern-specific query methods. | ||
240 | * | ||
241 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
242 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
243 | * | ||
244 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
245 | * | ||
246 | * <p>Original source: | ||
247 | * <code><pre> | ||
248 | * {@literal @}Constraint(severity = "error", key = {Req}, | ||
249 | * message = "Redundant instances must not be allocated to the same host.") | ||
250 | * pattern redundantInstancesOnSameHost(Req : Requirement) { | ||
251 | * Requirement.instances(Req, App1); | ||
252 | * Requirement.instances(Req, App2); | ||
253 | * App1 != App2; | ||
254 | * ApplicationInstance.allocatedTo(App1, Host); | ||
255 | * ApplicationInstance.allocatedTo(App2, Host); | ||
256 | * } | ||
257 | * </pre></code> | ||
258 | * | ||
259 | * @see Match | ||
260 | * @see RedundantInstancesOnSameHost | ||
261 | * | ||
262 | */ | ||
263 | public static class Matcher extends BaseMatcher<RedundantInstancesOnSameHost.Match> { | ||
264 | /** | ||
265 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
266 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
267 | * | ||
268 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
269 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
270 | * | ||
271 | */ | ||
272 | public static RedundantInstancesOnSameHost.Matcher on(final ViatraQueryEngine engine) { | ||
273 | // check if matcher already exists | ||
274 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
275 | if (matcher == null) { | ||
276 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
277 | } | ||
278 | return matcher; | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
283 | * @return an initialized matcher | ||
284 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
285 | * | ||
286 | */ | ||
287 | public static RedundantInstancesOnSameHost.Matcher create() { | ||
288 | return new Matcher(); | ||
289 | } | ||
290 | |||
291 | private static final int POSITION_REQ = 0; | ||
292 | |||
293 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(RedundantInstancesOnSameHost.Matcher.class); | ||
294 | |||
295 | /** | ||
296 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
297 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
298 | * | ||
299 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
300 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
301 | * | ||
302 | */ | ||
303 | private Matcher() { | ||
304 | super(querySpecification()); | ||
305 | } | ||
306 | |||
307 | /** | ||
308 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
309 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
310 | * @return matches represented as a Match object. | ||
311 | * | ||
312 | */ | ||
313 | public Collection<RedundantInstancesOnSameHost.Match> getAllMatches(final Requirement pReq) { | ||
314 | return rawStreamAllMatches(new Object[]{pReq}).collect(Collectors.toSet()); | ||
315 | } | ||
316 | |||
317 | /** | ||
318 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
319 | * </p> | ||
320 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
321 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
322 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
323 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
324 | * @return a stream of matches represented as a Match object. | ||
325 | * | ||
326 | */ | ||
327 | public Stream<RedundantInstancesOnSameHost.Match> streamAllMatches(final Requirement pReq) { | ||
328 | return rawStreamAllMatches(new Object[]{pReq}); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
333 | * Neither determinism nor randomness of selection is guaranteed. | ||
334 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
335 | * @return a match represented as a Match object, or null if no match is found. | ||
336 | * | ||
337 | */ | ||
338 | public Optional<RedundantInstancesOnSameHost.Match> getOneArbitraryMatch(final Requirement pReq) { | ||
339 | return rawGetOneArbitraryMatch(new Object[]{pReq}); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
344 | * under any possible substitution of the unspecified parameters (if any). | ||
345 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
346 | * @return true if the input is a valid (partial) match of the pattern. | ||
347 | * | ||
348 | */ | ||
349 | public boolean hasMatch(final Requirement pReq) { | ||
350 | return rawHasMatch(new Object[]{pReq}); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
355 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
356 | * @return the number of pattern matches found. | ||
357 | * | ||
358 | */ | ||
359 | public int countMatches(final Requirement pReq) { | ||
360 | return rawCountMatches(new Object[]{pReq}); | ||
361 | } | ||
362 | |||
363 | /** | ||
364 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
365 | * Neither determinism nor randomness of selection is guaranteed. | ||
366 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
367 | * @param processor the action that will process the selected match. | ||
368 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
369 | * | ||
370 | */ | ||
371 | public boolean forOneArbitraryMatch(final Requirement pReq, final Consumer<? super RedundantInstancesOnSameHost.Match> processor) { | ||
372 | return rawForOneArbitraryMatch(new Object[]{pReq}, processor); | ||
373 | } | ||
374 | |||
375 | /** | ||
376 | * Returns a new (partial) match. | ||
377 | * This can be used e.g. to call the matcher with a partial match. | ||
378 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
379 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
380 | * @return the (partial) match object. | ||
381 | * | ||
382 | */ | ||
383 | public RedundantInstancesOnSameHost.Match newMatch(final Requirement pReq) { | ||
384 | return RedundantInstancesOnSameHost.Match.newMatch(pReq); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * Retrieve the set of values that occur in matches for Req. | ||
389 | * @return the Set of all values or empty set if there are no matches | ||
390 | * | ||
391 | */ | ||
392 | protected Stream<Requirement> rawStreamAllValuesOfReq(final Object[] parameters) { | ||
393 | return rawStreamAllValues(POSITION_REQ, parameters).map(Requirement.class::cast); | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * Retrieve the set of values that occur in matches for Req. | ||
398 | * @return the Set of all values or empty set if there are no matches | ||
399 | * | ||
400 | */ | ||
401 | public Set<Requirement> getAllValuesOfReq() { | ||
402 | return rawStreamAllValuesOfReq(emptyArray()).collect(Collectors.toSet()); | ||
403 | } | ||
404 | |||
405 | /** | ||
406 | * Retrieve the set of values that occur in matches for Req. | ||
407 | * @return the Set of all values or empty set if there are no matches | ||
408 | * | ||
409 | */ | ||
410 | public Stream<Requirement> streamAllValuesOfReq() { | ||
411 | return rawStreamAllValuesOfReq(emptyArray()); | ||
412 | } | ||
413 | |||
414 | @Override | ||
415 | protected RedundantInstancesOnSameHost.Match tupleToMatch(final Tuple t) { | ||
416 | try { | ||
417 | return RedundantInstancesOnSameHost.Match.newMatch((Requirement) t.get(POSITION_REQ)); | ||
418 | } catch(ClassCastException e) { | ||
419 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
420 | return null; | ||
421 | } | ||
422 | } | ||
423 | |||
424 | @Override | ||
425 | protected RedundantInstancesOnSameHost.Match arrayToMatch(final Object[] match) { | ||
426 | try { | ||
427 | return RedundantInstancesOnSameHost.Match.newMatch((Requirement) match[POSITION_REQ]); | ||
428 | } catch(ClassCastException e) { | ||
429 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
430 | return null; | ||
431 | } | ||
432 | } | ||
433 | |||
434 | @Override | ||
435 | protected RedundantInstancesOnSameHost.Match arrayToMatchMutable(final Object[] match) { | ||
436 | try { | ||
437 | return RedundantInstancesOnSameHost.Match.newMutableMatch((Requirement) match[POSITION_REQ]); | ||
438 | } catch(ClassCastException e) { | ||
439 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
440 | return null; | ||
441 | } | ||
442 | } | ||
443 | |||
444 | /** | ||
445 | * @return the singleton instance of the query specification of this pattern | ||
446 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
447 | * | ||
448 | */ | ||
449 | public static IQuerySpecification<RedundantInstancesOnSameHost.Matcher> querySpecification() { | ||
450 | return RedundantInstancesOnSameHost.instance(); | ||
451 | } | ||
452 | } | ||
453 | |||
454 | private RedundantInstancesOnSameHost() { | ||
455 | super(GeneratedPQuery.INSTANCE); | ||
456 | } | ||
457 | |||
458 | /** | ||
459 | * @return the singleton instance of the query specification | ||
460 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
461 | * | ||
462 | */ | ||
463 | public static RedundantInstancesOnSameHost instance() { | ||
464 | try{ | ||
465 | return LazyHolder.INSTANCE; | ||
466 | } catch (ExceptionInInitializerError err) { | ||
467 | throw processInitializerError(err); | ||
468 | } | ||
469 | } | ||
470 | |||
471 | @Override | ||
472 | protected RedundantInstancesOnSameHost.Matcher instantiate(final ViatraQueryEngine engine) { | ||
473 | return RedundantInstancesOnSameHost.Matcher.on(engine); | ||
474 | } | ||
475 | |||
476 | @Override | ||
477 | public RedundantInstancesOnSameHost.Matcher instantiate() { | ||
478 | return RedundantInstancesOnSameHost.Matcher.create(); | ||
479 | } | ||
480 | |||
481 | @Override | ||
482 | public RedundantInstancesOnSameHost.Match newEmptyMatch() { | ||
483 | return RedundantInstancesOnSameHost.Match.newEmptyMatch(); | ||
484 | } | ||
485 | |||
486 | @Override | ||
487 | public RedundantInstancesOnSameHost.Match newMatch(final Object... parameters) { | ||
488 | return RedundantInstancesOnSameHost.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.Requirement) parameters[0]); | ||
489 | } | ||
490 | |||
491 | /** | ||
492 | * Inner class allowing the singleton instance of {@link RedundantInstancesOnSameHost} to be created | ||
493 | * <b>not</b> at the class load time of the outer class, | ||
494 | * but rather at the first call to {@link RedundantInstancesOnSameHost#instance()}. | ||
495 | * | ||
496 | * <p> This workaround is required e.g. to support recursion. | ||
497 | * | ||
498 | */ | ||
499 | private static class LazyHolder { | ||
500 | private static final RedundantInstancesOnSameHost INSTANCE = new RedundantInstancesOnSameHost(); | ||
501 | |||
502 | /** | ||
503 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
504 | * This initialization order is required to support indirect recursion. | ||
505 | * | ||
506 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
507 | * | ||
508 | */ | ||
509 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
510 | |||
511 | public static Object ensureInitialized() { | ||
512 | INSTANCE.ensureInitializedInternal(); | ||
513 | return null; | ||
514 | } | ||
515 | } | ||
516 | |||
517 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
518 | private static final RedundantInstancesOnSameHost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
519 | |||
520 | private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.Requirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "Requirement")), PParameterDirection.INOUT); | ||
521 | |||
522 | private final List<PParameter> parameters = Arrays.asList(parameter_Req); | ||
523 | |||
524 | private GeneratedPQuery() { | ||
525 | super(PVisibility.PUBLIC); | ||
526 | } | ||
527 | |||
528 | @Override | ||
529 | public String getFullyQualifiedName() { | ||
530 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.redundantInstancesOnSameHost"; | ||
531 | } | ||
532 | |||
533 | @Override | ||
534 | public List<String> getParameterNames() { | ||
535 | return Arrays.asList("Req"); | ||
536 | } | ||
537 | |||
538 | @Override | ||
539 | public List<PParameter> getParameters() { | ||
540 | return parameters; | ||
541 | } | ||
542 | |||
543 | @Override | ||
544 | public Set<PBody> doGetContainedBodies() { | ||
545 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
546 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
547 | { | ||
548 | PBody body = new PBody(this); | ||
549 | PVariable var_Req = body.getOrCreateVariableByName("Req"); | ||
550 | PVariable var_App1 = body.getOrCreateVariableByName("App1"); | ||
551 | PVariable var_App2 = body.getOrCreateVariableByName("App2"); | ||
552 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
553 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); | ||
554 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
555 | new ExportedParameter(body, var_Req, parameter_Req) | ||
556 | )); | ||
557 | // Requirement.instances(Req, App1) | ||
558 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); | ||
559 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
560 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "instances"))); | ||
561 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
562 | new Equality(body, var__virtual_0_, var_App1); | ||
563 | // Requirement.instances(Req, App2) | ||
564 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); | ||
565 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
566 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "instances"))); | ||
567 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
568 | new Equality(body, var__virtual_1_, var_App2); | ||
569 | // App1 != App2 | ||
570 | new Inequality(body, var_App1, var_App2); | ||
571 | // ApplicationInstance.allocatedTo(App1, Host) | ||
572 | new TypeConstraint(body, Tuples.flatTupleOf(var_App1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
573 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
574 | new TypeConstraint(body, Tuples.flatTupleOf(var_App1, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); | ||
575 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
576 | new Equality(body, var__virtual_2_, var_Host); | ||
577 | // ApplicationInstance.allocatedTo(App2, Host) | ||
578 | new TypeConstraint(body, Tuples.flatTupleOf(var_App2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
579 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); | ||
580 | new TypeConstraint(body, Tuples.flatTupleOf(var_App2, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); | ||
581 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
582 | new Equality(body, var__virtual_3_, var_Host); | ||
583 | bodies.add(body); | ||
584 | } | ||
585 | { | ||
586 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
587 | annotation.addAttribute("severity", "error"); | ||
588 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
589 | new ParameterReference("Req") | ||
590 | })); | ||
591 | annotation.addAttribute("message", "Redundant instances must not be allocated to the same host."); | ||
592 | addAnnotation(annotation); | ||
593 | } | ||
594 | return bodies; | ||
595 | } | ||
596 | } | ||
597 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RemoveHostInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RemoveHostInstance.java new file mode 100644 index 00000000..ed3c903c --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RemoveHostInstance.java | |||
@@ -0,0 +1,589 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.Collections; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * pattern removeHostInstance(HostInstance : HostInstance) { | ||
49 | * neg HostInstance.applications(HostInstance, _); | ||
50 | * } | ||
51 | * </pre></code> | ||
52 | * | ||
53 | * @see Matcher | ||
54 | * @see Match | ||
55 | * | ||
56 | */ | ||
57 | @SuppressWarnings("all") | ||
58 | public final class RemoveHostInstance extends BaseGeneratedEMFQuerySpecification<RemoveHostInstance.Matcher> { | ||
59 | /** | ||
60 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.removeHostInstance pattern, | ||
61 | * to be used in conjunction with {@link Matcher}. | ||
62 | * | ||
63 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
64 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
65 | * usable to represent a match of the pattern in the result of a query, | ||
66 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
67 | * | ||
68 | * @see Matcher | ||
69 | * | ||
70 | */ | ||
71 | public static abstract class Match extends BasePatternMatch { | ||
72 | private HostInstance fHostInstance; | ||
73 | |||
74 | private static List<String> parameterNames = makeImmutableList("HostInstance"); | ||
75 | |||
76 | private Match(final HostInstance pHostInstance) { | ||
77 | this.fHostInstance = pHostInstance; | ||
78 | } | ||
79 | |||
80 | @Override | ||
81 | public Object get(final String parameterName) { | ||
82 | switch(parameterName) { | ||
83 | case "HostInstance": return this.fHostInstance; | ||
84 | default: return null; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | @Override | ||
89 | public Object get(final int index) { | ||
90 | switch(index) { | ||
91 | case 0: return this.fHostInstance; | ||
92 | default: return null; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public HostInstance getHostInstance() { | ||
97 | return this.fHostInstance; | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public boolean set(final String parameterName, final Object newValue) { | ||
102 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
103 | if ("HostInstance".equals(parameterName) ) { | ||
104 | this.fHostInstance = (HostInstance) newValue; | ||
105 | return true; | ||
106 | } | ||
107 | return false; | ||
108 | } | ||
109 | |||
110 | public void setHostInstance(final HostInstance pHostInstance) { | ||
111 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
112 | this.fHostInstance = pHostInstance; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public String patternName() { | ||
117 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.removeHostInstance"; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public List<String> parameterNames() { | ||
122 | return RemoveHostInstance.Match.parameterNames; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public Object[] toArray() { | ||
127 | return new Object[]{fHostInstance}; | ||
128 | } | ||
129 | |||
130 | @Override | ||
131 | public RemoveHostInstance.Match toImmutable() { | ||
132 | return isMutable() ? newMatch(fHostInstance) : this; | ||
133 | } | ||
134 | |||
135 | @Override | ||
136 | public String prettyPrint() { | ||
137 | StringBuilder result = new StringBuilder(); | ||
138 | result.append("\"HostInstance\"=" + prettyPrintValue(fHostInstance)); | ||
139 | return result.toString(); | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public int hashCode() { | ||
144 | return Objects.hash(fHostInstance); | ||
145 | } | ||
146 | |||
147 | @Override | ||
148 | public boolean equals(final Object obj) { | ||
149 | if (this == obj) | ||
150 | return true; | ||
151 | if (obj == null) { | ||
152 | return false; | ||
153 | } | ||
154 | if ((obj instanceof RemoveHostInstance.Match)) { | ||
155 | RemoveHostInstance.Match other = (RemoveHostInstance.Match) obj; | ||
156 | return Objects.equals(fHostInstance, other.fHostInstance); | ||
157 | } else { | ||
158 | // this should be infrequent | ||
159 | if (!(obj instanceof IPatternMatch)) { | ||
160 | return false; | ||
161 | } | ||
162 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
163 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public RemoveHostInstance specification() { | ||
169 | return RemoveHostInstance.instance(); | ||
170 | } | ||
171 | |||
172 | /** | ||
173 | * Returns an empty, mutable match. | ||
174 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
175 | * | ||
176 | * @return the empty match. | ||
177 | * | ||
178 | */ | ||
179 | public static RemoveHostInstance.Match newEmptyMatch() { | ||
180 | return new Mutable(null); | ||
181 | } | ||
182 | |||
183 | /** | ||
184 | * Returns a mutable (partial) match. | ||
185 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
186 | * | ||
187 | * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. | ||
188 | * @return the new, mutable (partial) match object. | ||
189 | * | ||
190 | */ | ||
191 | public static RemoveHostInstance.Match newMutableMatch(final HostInstance pHostInstance) { | ||
192 | return new Mutable(pHostInstance); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * Returns a new (partial) match. | ||
197 | * This can be used e.g. to call the matcher with a partial match. | ||
198 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
199 | * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. | ||
200 | * @return the (partial) match object. | ||
201 | * | ||
202 | */ | ||
203 | public static RemoveHostInstance.Match newMatch(final HostInstance pHostInstance) { | ||
204 | return new Immutable(pHostInstance); | ||
205 | } | ||
206 | |||
207 | private static final class Mutable extends RemoveHostInstance.Match { | ||
208 | Mutable(final HostInstance pHostInstance) { | ||
209 | super(pHostInstance); | ||
210 | } | ||
211 | |||
212 | @Override | ||
213 | public boolean isMutable() { | ||
214 | return true; | ||
215 | } | ||
216 | } | ||
217 | |||
218 | private static final class Immutable extends RemoveHostInstance.Match { | ||
219 | Immutable(final HostInstance pHostInstance) { | ||
220 | super(pHostInstance); | ||
221 | } | ||
222 | |||
223 | @Override | ||
224 | public boolean isMutable() { | ||
225 | return false; | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | |||
230 | /** | ||
231 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.removeHostInstance pattern, | ||
232 | * providing pattern-specific query methods. | ||
233 | * | ||
234 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
235 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
236 | * | ||
237 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
238 | * | ||
239 | * <p>Original source: | ||
240 | * <code><pre> | ||
241 | * pattern removeHostInstance(HostInstance : HostInstance) { | ||
242 | * neg HostInstance.applications(HostInstance, _); | ||
243 | * } | ||
244 | * </pre></code> | ||
245 | * | ||
246 | * @see Match | ||
247 | * @see RemoveHostInstance | ||
248 | * | ||
249 | */ | ||
250 | public static class Matcher extends BaseMatcher<RemoveHostInstance.Match> { | ||
251 | /** | ||
252 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
253 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
254 | * | ||
255 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
256 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
257 | * | ||
258 | */ | ||
259 | public static RemoveHostInstance.Matcher on(final ViatraQueryEngine engine) { | ||
260 | // check if matcher already exists | ||
261 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
262 | if (matcher == null) { | ||
263 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
264 | } | ||
265 | return matcher; | ||
266 | } | ||
267 | |||
268 | /** | ||
269 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
270 | * @return an initialized matcher | ||
271 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
272 | * | ||
273 | */ | ||
274 | public static RemoveHostInstance.Matcher create() { | ||
275 | return new Matcher(); | ||
276 | } | ||
277 | |||
278 | private static final int POSITION_HOSTINSTANCE = 0; | ||
279 | |||
280 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(RemoveHostInstance.Matcher.class); | ||
281 | |||
282 | /** | ||
283 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
284 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
285 | * | ||
286 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
287 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
288 | * | ||
289 | */ | ||
290 | private Matcher() { | ||
291 | super(querySpecification()); | ||
292 | } | ||
293 | |||
294 | /** | ||
295 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
296 | * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. | ||
297 | * @return matches represented as a Match object. | ||
298 | * | ||
299 | */ | ||
300 | public Collection<RemoveHostInstance.Match> getAllMatches(final HostInstance pHostInstance) { | ||
301 | return rawStreamAllMatches(new Object[]{pHostInstance}).collect(Collectors.toSet()); | ||
302 | } | ||
303 | |||
304 | /** | ||
305 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
306 | * </p> | ||
307 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
308 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
309 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
310 | * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. | ||
311 | * @return a stream of matches represented as a Match object. | ||
312 | * | ||
313 | */ | ||
314 | public Stream<RemoveHostInstance.Match> streamAllMatches(final HostInstance pHostInstance) { | ||
315 | return rawStreamAllMatches(new Object[]{pHostInstance}); | ||
316 | } | ||
317 | |||
318 | /** | ||
319 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
320 | * Neither determinism nor randomness of selection is guaranteed. | ||
321 | * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. | ||
322 | * @return a match represented as a Match object, or null if no match is found. | ||
323 | * | ||
324 | */ | ||
325 | public Optional<RemoveHostInstance.Match> getOneArbitraryMatch(final HostInstance pHostInstance) { | ||
326 | return rawGetOneArbitraryMatch(new Object[]{pHostInstance}); | ||
327 | } | ||
328 | |||
329 | /** | ||
330 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
331 | * under any possible substitution of the unspecified parameters (if any). | ||
332 | * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. | ||
333 | * @return true if the input is a valid (partial) match of the pattern. | ||
334 | * | ||
335 | */ | ||
336 | public boolean hasMatch(final HostInstance pHostInstance) { | ||
337 | return rawHasMatch(new Object[]{pHostInstance}); | ||
338 | } | ||
339 | |||
340 | /** | ||
341 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
342 | * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. | ||
343 | * @return the number of pattern matches found. | ||
344 | * | ||
345 | */ | ||
346 | public int countMatches(final HostInstance pHostInstance) { | ||
347 | return rawCountMatches(new Object[]{pHostInstance}); | ||
348 | } | ||
349 | |||
350 | /** | ||
351 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
352 | * Neither determinism nor randomness of selection is guaranteed. | ||
353 | * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. | ||
354 | * @param processor the action that will process the selected match. | ||
355 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
356 | * | ||
357 | */ | ||
358 | public boolean forOneArbitraryMatch(final HostInstance pHostInstance, final Consumer<? super RemoveHostInstance.Match> processor) { | ||
359 | return rawForOneArbitraryMatch(new Object[]{pHostInstance}, processor); | ||
360 | } | ||
361 | |||
362 | /** | ||
363 | * Returns a new (partial) match. | ||
364 | * This can be used e.g. to call the matcher with a partial match. | ||
365 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
366 | * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. | ||
367 | * @return the (partial) match object. | ||
368 | * | ||
369 | */ | ||
370 | public RemoveHostInstance.Match newMatch(final HostInstance pHostInstance) { | ||
371 | return RemoveHostInstance.Match.newMatch(pHostInstance); | ||
372 | } | ||
373 | |||
374 | /** | ||
375 | * Retrieve the set of values that occur in matches for HostInstance. | ||
376 | * @return the Set of all values or empty set if there are no matches | ||
377 | * | ||
378 | */ | ||
379 | protected Stream<HostInstance> rawStreamAllValuesOfHostInstance(final Object[] parameters) { | ||
380 | return rawStreamAllValues(POSITION_HOSTINSTANCE, parameters).map(HostInstance.class::cast); | ||
381 | } | ||
382 | |||
383 | /** | ||
384 | * Retrieve the set of values that occur in matches for HostInstance. | ||
385 | * @return the Set of all values or empty set if there are no matches | ||
386 | * | ||
387 | */ | ||
388 | public Set<HostInstance> getAllValuesOfHostInstance() { | ||
389 | return rawStreamAllValuesOfHostInstance(emptyArray()).collect(Collectors.toSet()); | ||
390 | } | ||
391 | |||
392 | /** | ||
393 | * Retrieve the set of values that occur in matches for HostInstance. | ||
394 | * @return the Set of all values or empty set if there are no matches | ||
395 | * | ||
396 | */ | ||
397 | public Stream<HostInstance> streamAllValuesOfHostInstance() { | ||
398 | return rawStreamAllValuesOfHostInstance(emptyArray()); | ||
399 | } | ||
400 | |||
401 | @Override | ||
402 | protected RemoveHostInstance.Match tupleToMatch(final Tuple t) { | ||
403 | try { | ||
404 | return RemoveHostInstance.Match.newMatch((HostInstance) t.get(POSITION_HOSTINSTANCE)); | ||
405 | } catch(ClassCastException e) { | ||
406 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
407 | return null; | ||
408 | } | ||
409 | } | ||
410 | |||
411 | @Override | ||
412 | protected RemoveHostInstance.Match arrayToMatch(final Object[] match) { | ||
413 | try { | ||
414 | return RemoveHostInstance.Match.newMatch((HostInstance) match[POSITION_HOSTINSTANCE]); | ||
415 | } catch(ClassCastException e) { | ||
416 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
417 | return null; | ||
418 | } | ||
419 | } | ||
420 | |||
421 | @Override | ||
422 | protected RemoveHostInstance.Match arrayToMatchMutable(final Object[] match) { | ||
423 | try { | ||
424 | return RemoveHostInstance.Match.newMutableMatch((HostInstance) match[POSITION_HOSTINSTANCE]); | ||
425 | } catch(ClassCastException e) { | ||
426 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
427 | return null; | ||
428 | } | ||
429 | } | ||
430 | |||
431 | /** | ||
432 | * @return the singleton instance of the query specification of this pattern | ||
433 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
434 | * | ||
435 | */ | ||
436 | public static IQuerySpecification<RemoveHostInstance.Matcher> querySpecification() { | ||
437 | return RemoveHostInstance.instance(); | ||
438 | } | ||
439 | } | ||
440 | |||
441 | private RemoveHostInstance() { | ||
442 | super(GeneratedPQuery.INSTANCE); | ||
443 | } | ||
444 | |||
445 | /** | ||
446 | * @return the singleton instance of the query specification | ||
447 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
448 | * | ||
449 | */ | ||
450 | public static RemoveHostInstance instance() { | ||
451 | try{ | ||
452 | return LazyHolder.INSTANCE; | ||
453 | } catch (ExceptionInInitializerError err) { | ||
454 | throw processInitializerError(err); | ||
455 | } | ||
456 | } | ||
457 | |||
458 | @Override | ||
459 | protected RemoveHostInstance.Matcher instantiate(final ViatraQueryEngine engine) { | ||
460 | return RemoveHostInstance.Matcher.on(engine); | ||
461 | } | ||
462 | |||
463 | @Override | ||
464 | public RemoveHostInstance.Matcher instantiate() { | ||
465 | return RemoveHostInstance.Matcher.create(); | ||
466 | } | ||
467 | |||
468 | @Override | ||
469 | public RemoveHostInstance.Match newEmptyMatch() { | ||
470 | return RemoveHostInstance.Match.newEmptyMatch(); | ||
471 | } | ||
472 | |||
473 | @Override | ||
474 | public RemoveHostInstance.Match newMatch(final Object... parameters) { | ||
475 | return RemoveHostInstance.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0]); | ||
476 | } | ||
477 | |||
478 | /** | ||
479 | * Inner class allowing the singleton instance of {@link RemoveHostInstance} to be created | ||
480 | * <b>not</b> at the class load time of the outer class, | ||
481 | * but rather at the first call to {@link RemoveHostInstance#instance()}. | ||
482 | * | ||
483 | * <p> This workaround is required e.g. to support recursion. | ||
484 | * | ||
485 | */ | ||
486 | private static class LazyHolder { | ||
487 | private static final RemoveHostInstance INSTANCE = new RemoveHostInstance(); | ||
488 | |||
489 | /** | ||
490 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
491 | * This initialization order is required to support indirect recursion. | ||
492 | * | ||
493 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
494 | * | ||
495 | */ | ||
496 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
497 | |||
498 | public static Object ensureInitialized() { | ||
499 | INSTANCE.ensureInitializedInternal(); | ||
500 | return null; | ||
501 | } | ||
502 | } | ||
503 | |||
504 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
505 | private static final RemoveHostInstance.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
506 | |||
507 | private final PParameter parameter_HostInstance = new PParameter("HostInstance", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
508 | |||
509 | private final List<PParameter> parameters = Arrays.asList(parameter_HostInstance); | ||
510 | |||
511 | private class Embedded_1_HostInstance_applications extends BaseGeneratedEMFPQuery { | ||
512 | private final PParameter parameter_p0 = new PParameter("p0", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
513 | |||
514 | private final PParameter parameter_p1 = new PParameter("p1", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); | ||
515 | |||
516 | private final List<PParameter> embeddedParameters = Arrays.asList(parameter_p0, parameter_p1); | ||
517 | |||
518 | public Embedded_1_HostInstance_applications() { | ||
519 | super(PVisibility.EMBEDDED); | ||
520 | } | ||
521 | |||
522 | @Override | ||
523 | public String getFullyQualifiedName() { | ||
524 | return GeneratedPQuery.this.getFullyQualifiedName() + "$Embedded_1_HostInstance_applications"; | ||
525 | } | ||
526 | |||
527 | @Override | ||
528 | public List<PParameter> getParameters() { | ||
529 | return embeddedParameters; | ||
530 | } | ||
531 | |||
532 | @Override | ||
533 | public Set<PBody> doGetContainedBodies() { | ||
534 | PBody body = new PBody(this); | ||
535 | PVariable var_p0 = body.getOrCreateVariableByName("p0"); | ||
536 | PVariable var_p1 = body.getOrCreateVariableByName("p1"); | ||
537 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
538 | new ExportedParameter(body, var_p0, parameter_p0), | ||
539 | new ExportedParameter(body, var_p1, parameter_p1) | ||
540 | )); | ||
541 | // HostInstance.applications(HostInstance, _) | ||
542 | new TypeConstraint(body, Tuples.flatTupleOf(var_p0), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
543 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
544 | new TypeConstraint(body, Tuples.flatTupleOf(var_p0, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "applications"))); | ||
545 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
546 | new Equality(body, var__virtual_0_, var_p1); | ||
547 | return Collections.singleton(body); | ||
548 | } | ||
549 | } | ||
550 | |||
551 | private GeneratedPQuery() { | ||
552 | super(PVisibility.PUBLIC); | ||
553 | } | ||
554 | |||
555 | @Override | ||
556 | public String getFullyQualifiedName() { | ||
557 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.removeHostInstance"; | ||
558 | } | ||
559 | |||
560 | @Override | ||
561 | public List<String> getParameterNames() { | ||
562 | return Arrays.asList("HostInstance"); | ||
563 | } | ||
564 | |||
565 | @Override | ||
566 | public List<PParameter> getParameters() { | ||
567 | return parameters; | ||
568 | } | ||
569 | |||
570 | @Override | ||
571 | public Set<PBody> doGetContainedBodies() { | ||
572 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
573 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
574 | { | ||
575 | PBody body = new PBody(this); | ||
576 | PVariable var_HostInstance = body.getOrCreateVariableByName("HostInstance"); | ||
577 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
578 | new TypeConstraint(body, Tuples.flatTupleOf(var_HostInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
579 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
580 | new ExportedParameter(body, var_HostInstance, parameter_HostInstance) | ||
581 | )); | ||
582 | // neg HostInstance.applications(HostInstance, _) | ||
583 | new NegativePatternCall(body, Tuples.flatTupleOf(var_HostInstance, var___0_), new RemoveHostInstance.GeneratedPQuery.Embedded_1_HostInstance_applications()); | ||
584 | bodies.add(body); | ||
585 | } | ||
586 | return bodies; | ||
587 | } | ||
588 | } | ||
589 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RequirementNotSatisfied.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RequirementNotSatisfied.java new file mode 100644 index 00000000..eaceec5f --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RequirementNotSatisfied.java | |||
@@ -0,0 +1,607 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.emf.ecore.EDataType; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
30 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
44 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
45 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
46 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
47 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
48 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
49 | |||
50 | /** | ||
51 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
52 | * | ||
53 | * <p>Original source: | ||
54 | * <code><pre> | ||
55 | * {@literal @}Constraint(severity = "error", key = {Req}, | ||
56 | * message = "Requirement is not satisfied by enough application instances.") | ||
57 | * pattern requirementNotSatisfied(Req : Requirement) { | ||
58 | * Instances == count find satisfyingInstance(Req, _); | ||
59 | * Requirement.count(Req, RequiredCount); | ||
60 | * check(Instances {@literal <} RequiredCount); | ||
61 | * } | ||
62 | * </pre></code> | ||
63 | * | ||
64 | * @see Matcher | ||
65 | * @see Match | ||
66 | * | ||
67 | */ | ||
68 | @SuppressWarnings("all") | ||
69 | public final class RequirementNotSatisfied extends BaseGeneratedEMFQuerySpecification<RequirementNotSatisfied.Matcher> { | ||
70 | /** | ||
71 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.requirementNotSatisfied pattern, | ||
72 | * to be used in conjunction with {@link Matcher}. | ||
73 | * | ||
74 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
75 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
76 | * usable to represent a match of the pattern in the result of a query, | ||
77 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
78 | * | ||
79 | * @see Matcher | ||
80 | * | ||
81 | */ | ||
82 | public static abstract class Match extends BasePatternMatch { | ||
83 | private Requirement fReq; | ||
84 | |||
85 | private static List<String> parameterNames = makeImmutableList("Req"); | ||
86 | |||
87 | private Match(final Requirement pReq) { | ||
88 | this.fReq = pReq; | ||
89 | } | ||
90 | |||
91 | @Override | ||
92 | public Object get(final String parameterName) { | ||
93 | switch(parameterName) { | ||
94 | case "Req": return this.fReq; | ||
95 | default: return null; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | @Override | ||
100 | public Object get(final int index) { | ||
101 | switch(index) { | ||
102 | case 0: return this.fReq; | ||
103 | default: return null; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | public Requirement getReq() { | ||
108 | return this.fReq; | ||
109 | } | ||
110 | |||
111 | @Override | ||
112 | public boolean set(final String parameterName, final Object newValue) { | ||
113 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
114 | if ("Req".equals(parameterName) ) { | ||
115 | this.fReq = (Requirement) newValue; | ||
116 | return true; | ||
117 | } | ||
118 | return false; | ||
119 | } | ||
120 | |||
121 | public void setReq(final Requirement pReq) { | ||
122 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
123 | this.fReq = pReq; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public String patternName() { | ||
128 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.requirementNotSatisfied"; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public List<String> parameterNames() { | ||
133 | return RequirementNotSatisfied.Match.parameterNames; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public Object[] toArray() { | ||
138 | return new Object[]{fReq}; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public RequirementNotSatisfied.Match toImmutable() { | ||
143 | return isMutable() ? newMatch(fReq) : this; | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public String prettyPrint() { | ||
148 | StringBuilder result = new StringBuilder(); | ||
149 | result.append("\"Req\"=" + prettyPrintValue(fReq)); | ||
150 | return result.toString(); | ||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public int hashCode() { | ||
155 | return Objects.hash(fReq); | ||
156 | } | ||
157 | |||
158 | @Override | ||
159 | public boolean equals(final Object obj) { | ||
160 | if (this == obj) | ||
161 | return true; | ||
162 | if (obj == null) { | ||
163 | return false; | ||
164 | } | ||
165 | if ((obj instanceof RequirementNotSatisfied.Match)) { | ||
166 | RequirementNotSatisfied.Match other = (RequirementNotSatisfied.Match) obj; | ||
167 | return Objects.equals(fReq, other.fReq); | ||
168 | } else { | ||
169 | // this should be infrequent | ||
170 | if (!(obj instanceof IPatternMatch)) { | ||
171 | return false; | ||
172 | } | ||
173 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
174 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
175 | } | ||
176 | } | ||
177 | |||
178 | @Override | ||
179 | public RequirementNotSatisfied specification() { | ||
180 | return RequirementNotSatisfied.instance(); | ||
181 | } | ||
182 | |||
183 | /** | ||
184 | * Returns an empty, mutable match. | ||
185 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
186 | * | ||
187 | * @return the empty match. | ||
188 | * | ||
189 | */ | ||
190 | public static RequirementNotSatisfied.Match newEmptyMatch() { | ||
191 | return new Mutable(null); | ||
192 | } | ||
193 | |||
194 | /** | ||
195 | * Returns a mutable (partial) match. | ||
196 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
197 | * | ||
198 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
199 | * @return the new, mutable (partial) match object. | ||
200 | * | ||
201 | */ | ||
202 | public static RequirementNotSatisfied.Match newMutableMatch(final Requirement pReq) { | ||
203 | return new Mutable(pReq); | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * Returns a new (partial) match. | ||
208 | * This can be used e.g. to call the matcher with a partial match. | ||
209 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
210 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
211 | * @return the (partial) match object. | ||
212 | * | ||
213 | */ | ||
214 | public static RequirementNotSatisfied.Match newMatch(final Requirement pReq) { | ||
215 | return new Immutable(pReq); | ||
216 | } | ||
217 | |||
218 | private static final class Mutable extends RequirementNotSatisfied.Match { | ||
219 | Mutable(final Requirement pReq) { | ||
220 | super(pReq); | ||
221 | } | ||
222 | |||
223 | @Override | ||
224 | public boolean isMutable() { | ||
225 | return true; | ||
226 | } | ||
227 | } | ||
228 | |||
229 | private static final class Immutable extends RequirementNotSatisfied.Match { | ||
230 | Immutable(final Requirement pReq) { | ||
231 | super(pReq); | ||
232 | } | ||
233 | |||
234 | @Override | ||
235 | public boolean isMutable() { | ||
236 | return false; | ||
237 | } | ||
238 | } | ||
239 | } | ||
240 | |||
241 | /** | ||
242 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.requirementNotSatisfied pattern, | ||
243 | * providing pattern-specific query methods. | ||
244 | * | ||
245 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
246 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
247 | * | ||
248 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
249 | * | ||
250 | * <p>Original source: | ||
251 | * <code><pre> | ||
252 | * {@literal @}Constraint(severity = "error", key = {Req}, | ||
253 | * message = "Requirement is not satisfied by enough application instances.") | ||
254 | * pattern requirementNotSatisfied(Req : Requirement) { | ||
255 | * Instances == count find satisfyingInstance(Req, _); | ||
256 | * Requirement.count(Req, RequiredCount); | ||
257 | * check(Instances {@literal <} RequiredCount); | ||
258 | * } | ||
259 | * </pre></code> | ||
260 | * | ||
261 | * @see Match | ||
262 | * @see RequirementNotSatisfied | ||
263 | * | ||
264 | */ | ||
265 | public static class Matcher extends BaseMatcher<RequirementNotSatisfied.Match> { | ||
266 | /** | ||
267 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
268 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
269 | * | ||
270 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
271 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
272 | * | ||
273 | */ | ||
274 | public static RequirementNotSatisfied.Matcher on(final ViatraQueryEngine engine) { | ||
275 | // check if matcher already exists | ||
276 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
277 | if (matcher == null) { | ||
278 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
279 | } | ||
280 | return matcher; | ||
281 | } | ||
282 | |||
283 | /** | ||
284 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
285 | * @return an initialized matcher | ||
286 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
287 | * | ||
288 | */ | ||
289 | public static RequirementNotSatisfied.Matcher create() { | ||
290 | return new Matcher(); | ||
291 | } | ||
292 | |||
293 | private static final int POSITION_REQ = 0; | ||
294 | |||
295 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(RequirementNotSatisfied.Matcher.class); | ||
296 | |||
297 | /** | ||
298 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
299 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
300 | * | ||
301 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
302 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
303 | * | ||
304 | */ | ||
305 | private Matcher() { | ||
306 | super(querySpecification()); | ||
307 | } | ||
308 | |||
309 | /** | ||
310 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
311 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
312 | * @return matches represented as a Match object. | ||
313 | * | ||
314 | */ | ||
315 | public Collection<RequirementNotSatisfied.Match> getAllMatches(final Requirement pReq) { | ||
316 | return rawStreamAllMatches(new Object[]{pReq}).collect(Collectors.toSet()); | ||
317 | } | ||
318 | |||
319 | /** | ||
320 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
321 | * </p> | ||
322 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
323 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
324 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
325 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
326 | * @return a stream of matches represented as a Match object. | ||
327 | * | ||
328 | */ | ||
329 | public Stream<RequirementNotSatisfied.Match> streamAllMatches(final Requirement pReq) { | ||
330 | return rawStreamAllMatches(new Object[]{pReq}); | ||
331 | } | ||
332 | |||
333 | /** | ||
334 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
335 | * Neither determinism nor randomness of selection is guaranteed. | ||
336 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
337 | * @return a match represented as a Match object, or null if no match is found. | ||
338 | * | ||
339 | */ | ||
340 | public Optional<RequirementNotSatisfied.Match> getOneArbitraryMatch(final Requirement pReq) { | ||
341 | return rawGetOneArbitraryMatch(new Object[]{pReq}); | ||
342 | } | ||
343 | |||
344 | /** | ||
345 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
346 | * under any possible substitution of the unspecified parameters (if any). | ||
347 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
348 | * @return true if the input is a valid (partial) match of the pattern. | ||
349 | * | ||
350 | */ | ||
351 | public boolean hasMatch(final Requirement pReq) { | ||
352 | return rawHasMatch(new Object[]{pReq}); | ||
353 | } | ||
354 | |||
355 | /** | ||
356 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
357 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
358 | * @return the number of pattern matches found. | ||
359 | * | ||
360 | */ | ||
361 | public int countMatches(final Requirement pReq) { | ||
362 | return rawCountMatches(new Object[]{pReq}); | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
367 | * Neither determinism nor randomness of selection is guaranteed. | ||
368 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
369 | * @param processor the action that will process the selected match. | ||
370 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
371 | * | ||
372 | */ | ||
373 | public boolean forOneArbitraryMatch(final Requirement pReq, final Consumer<? super RequirementNotSatisfied.Match> processor) { | ||
374 | return rawForOneArbitraryMatch(new Object[]{pReq}, processor); | ||
375 | } | ||
376 | |||
377 | /** | ||
378 | * Returns a new (partial) match. | ||
379 | * This can be used e.g. to call the matcher with a partial match. | ||
380 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
381 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
382 | * @return the (partial) match object. | ||
383 | * | ||
384 | */ | ||
385 | public RequirementNotSatisfied.Match newMatch(final Requirement pReq) { | ||
386 | return RequirementNotSatisfied.Match.newMatch(pReq); | ||
387 | } | ||
388 | |||
389 | /** | ||
390 | * Retrieve the set of values that occur in matches for Req. | ||
391 | * @return the Set of all values or empty set if there are no matches | ||
392 | * | ||
393 | */ | ||
394 | protected Stream<Requirement> rawStreamAllValuesOfReq(final Object[] parameters) { | ||
395 | return rawStreamAllValues(POSITION_REQ, parameters).map(Requirement.class::cast); | ||
396 | } | ||
397 | |||
398 | /** | ||
399 | * Retrieve the set of values that occur in matches for Req. | ||
400 | * @return the Set of all values or empty set if there are no matches | ||
401 | * | ||
402 | */ | ||
403 | public Set<Requirement> getAllValuesOfReq() { | ||
404 | return rawStreamAllValuesOfReq(emptyArray()).collect(Collectors.toSet()); | ||
405 | } | ||
406 | |||
407 | /** | ||
408 | * Retrieve the set of values that occur in matches for Req. | ||
409 | * @return the Set of all values or empty set if there are no matches | ||
410 | * | ||
411 | */ | ||
412 | public Stream<Requirement> streamAllValuesOfReq() { | ||
413 | return rawStreamAllValuesOfReq(emptyArray()); | ||
414 | } | ||
415 | |||
416 | @Override | ||
417 | protected RequirementNotSatisfied.Match tupleToMatch(final Tuple t) { | ||
418 | try { | ||
419 | return RequirementNotSatisfied.Match.newMatch((Requirement) t.get(POSITION_REQ)); | ||
420 | } catch(ClassCastException e) { | ||
421 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
422 | return null; | ||
423 | } | ||
424 | } | ||
425 | |||
426 | @Override | ||
427 | protected RequirementNotSatisfied.Match arrayToMatch(final Object[] match) { | ||
428 | try { | ||
429 | return RequirementNotSatisfied.Match.newMatch((Requirement) match[POSITION_REQ]); | ||
430 | } catch(ClassCastException e) { | ||
431 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
432 | return null; | ||
433 | } | ||
434 | } | ||
435 | |||
436 | @Override | ||
437 | protected RequirementNotSatisfied.Match arrayToMatchMutable(final Object[] match) { | ||
438 | try { | ||
439 | return RequirementNotSatisfied.Match.newMutableMatch((Requirement) match[POSITION_REQ]); | ||
440 | } catch(ClassCastException e) { | ||
441 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
442 | return null; | ||
443 | } | ||
444 | } | ||
445 | |||
446 | /** | ||
447 | * @return the singleton instance of the query specification of this pattern | ||
448 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
449 | * | ||
450 | */ | ||
451 | public static IQuerySpecification<RequirementNotSatisfied.Matcher> querySpecification() { | ||
452 | return RequirementNotSatisfied.instance(); | ||
453 | } | ||
454 | } | ||
455 | |||
456 | private RequirementNotSatisfied() { | ||
457 | super(GeneratedPQuery.INSTANCE); | ||
458 | } | ||
459 | |||
460 | /** | ||
461 | * @return the singleton instance of the query specification | ||
462 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
463 | * | ||
464 | */ | ||
465 | public static RequirementNotSatisfied instance() { | ||
466 | try{ | ||
467 | return LazyHolder.INSTANCE; | ||
468 | } catch (ExceptionInInitializerError err) { | ||
469 | throw processInitializerError(err); | ||
470 | } | ||
471 | } | ||
472 | |||
473 | @Override | ||
474 | protected RequirementNotSatisfied.Matcher instantiate(final ViatraQueryEngine engine) { | ||
475 | return RequirementNotSatisfied.Matcher.on(engine); | ||
476 | } | ||
477 | |||
478 | @Override | ||
479 | public RequirementNotSatisfied.Matcher instantiate() { | ||
480 | return RequirementNotSatisfied.Matcher.create(); | ||
481 | } | ||
482 | |||
483 | @Override | ||
484 | public RequirementNotSatisfied.Match newEmptyMatch() { | ||
485 | return RequirementNotSatisfied.Match.newEmptyMatch(); | ||
486 | } | ||
487 | |||
488 | @Override | ||
489 | public RequirementNotSatisfied.Match newMatch(final Object... parameters) { | ||
490 | return RequirementNotSatisfied.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.Requirement) parameters[0]); | ||
491 | } | ||
492 | |||
493 | /** | ||
494 | * Inner class allowing the singleton instance of {@link RequirementNotSatisfied} to be created | ||
495 | * <b>not</b> at the class load time of the outer class, | ||
496 | * but rather at the first call to {@link RequirementNotSatisfied#instance()}. | ||
497 | * | ||
498 | * <p> This workaround is required e.g. to support recursion. | ||
499 | * | ||
500 | */ | ||
501 | private static class LazyHolder { | ||
502 | private static final RequirementNotSatisfied INSTANCE = new RequirementNotSatisfied(); | ||
503 | |||
504 | /** | ||
505 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
506 | * This initialization order is required to support indirect recursion. | ||
507 | * | ||
508 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
509 | * | ||
510 | */ | ||
511 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
512 | |||
513 | public static Object ensureInitialized() { | ||
514 | INSTANCE.ensureInitializedInternal(); | ||
515 | return null; | ||
516 | } | ||
517 | } | ||
518 | |||
519 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
520 | private static final RequirementNotSatisfied.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
521 | |||
522 | private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.Requirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "Requirement")), PParameterDirection.INOUT); | ||
523 | |||
524 | private final List<PParameter> parameters = Arrays.asList(parameter_Req); | ||
525 | |||
526 | private GeneratedPQuery() { | ||
527 | super(PVisibility.PUBLIC); | ||
528 | } | ||
529 | |||
530 | @Override | ||
531 | public String getFullyQualifiedName() { | ||
532 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.requirementNotSatisfied"; | ||
533 | } | ||
534 | |||
535 | @Override | ||
536 | public List<String> getParameterNames() { | ||
537 | return Arrays.asList("Req"); | ||
538 | } | ||
539 | |||
540 | @Override | ||
541 | public List<PParameter> getParameters() { | ||
542 | return parameters; | ||
543 | } | ||
544 | |||
545 | @Override | ||
546 | public Set<PBody> doGetContainedBodies() { | ||
547 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
548 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
549 | { | ||
550 | PBody body = new PBody(this); | ||
551 | PVariable var_Req = body.getOrCreateVariableByName("Req"); | ||
552 | PVariable var_Instances = body.getOrCreateVariableByName("Instances"); | ||
553 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
554 | PVariable var_RequiredCount = body.getOrCreateVariableByName("RequiredCount"); | ||
555 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); | ||
556 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
557 | new ExportedParameter(body, var_Req, parameter_Req) | ||
558 | )); | ||
559 | // Instances == count find satisfyingInstance(Req, _) | ||
560 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
561 | new PatternMatchCounter(body, Tuples.flatTupleOf(var_Req, var___0_), SatisfyingInstance.instance().getInternalQueryRepresentation(), var__virtual_0_); | ||
562 | new Equality(body, var_Instances, var__virtual_0_); | ||
563 | // Requirement.count(Req, RequiredCount) | ||
564 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); | ||
565 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
566 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "count"))); | ||
567 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
568 | new Equality(body, var__virtual_1_, var_RequiredCount); | ||
569 | // check(Instances < RequiredCount) | ||
570 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
571 | |||
572 | @Override | ||
573 | public String getShortDescription() { | ||
574 | return "Expression evaluation from pattern requirementNotSatisfied"; | ||
575 | } | ||
576 | |||
577 | @Override | ||
578 | public Iterable<String> getInputParameterNames() { | ||
579 | return Arrays.asList("Instances", "RequiredCount");} | ||
580 | |||
581 | @Override | ||
582 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
583 | Integer Instances = (Integer) provider.getValue("Instances"); | ||
584 | Integer RequiredCount = (Integer) provider.getValue("RequiredCount"); | ||
585 | return evaluateExpression_1_1(Instances, RequiredCount); | ||
586 | } | ||
587 | }, null); | ||
588 | bodies.add(body); | ||
589 | } | ||
590 | { | ||
591 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
592 | annotation.addAttribute("severity", "error"); | ||
593 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
594 | new ParameterReference("Req") | ||
595 | })); | ||
596 | annotation.addAttribute("message", "Requirement is not satisfied by enough application instances."); | ||
597 | addAnnotation(annotation); | ||
598 | } | ||
599 | return bodies; | ||
600 | } | ||
601 | } | ||
602 | |||
603 | private static boolean evaluateExpression_1_1(final Integer Instances, final Integer RequiredCount) { | ||
604 | boolean _lessThan = (Instances.compareTo(RequiredCount) < 0); | ||
605 | return _lessThan; | ||
606 | } | ||
607 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/ResourceRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/ResourceRequirement.java new file mode 100644 index 00000000..23b578ea --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/ResourceRequirement.java | |||
@@ -0,0 +1,841 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern resourceRequirement(Host : HostInstance, App : ApplicationInstance, Req : ResourceRequirement) { | ||
48 | * ApplicationInstance.allocatedTo(App, Host); | ||
49 | * ApplicationInstance.type.requirements(App, Req); | ||
50 | * HostInstance.type(Host, HostType); | ||
51 | * ResourceRequirement.hostType(Req, HostType); | ||
52 | * } | ||
53 | * </pre></code> | ||
54 | * | ||
55 | * @see Matcher | ||
56 | * @see Match | ||
57 | * | ||
58 | */ | ||
59 | @SuppressWarnings("all") | ||
60 | public final class ResourceRequirement extends BaseGeneratedEMFQuerySpecification<ResourceRequirement.Matcher> { | ||
61 | /** | ||
62 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement pattern, | ||
63 | * to be used in conjunction with {@link Matcher}. | ||
64 | * | ||
65 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
66 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
67 | * usable to represent a match of the pattern in the result of a query, | ||
68 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
69 | * | ||
70 | * @see Matcher | ||
71 | * | ||
72 | */ | ||
73 | public static abstract class Match extends BasePatternMatch { | ||
74 | private HostInstance fHost; | ||
75 | |||
76 | private ApplicationInstance fApp; | ||
77 | |||
78 | private hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement fReq; | ||
79 | |||
80 | private static List<String> parameterNames = makeImmutableList("Host", "App", "Req"); | ||
81 | |||
82 | private Match(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
83 | this.fHost = pHost; | ||
84 | this.fApp = pApp; | ||
85 | this.fReq = pReq; | ||
86 | } | ||
87 | |||
88 | @Override | ||
89 | public Object get(final String parameterName) { | ||
90 | switch(parameterName) { | ||
91 | case "Host": return this.fHost; | ||
92 | case "App": return this.fApp; | ||
93 | case "Req": return this.fReq; | ||
94 | default: return null; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | @Override | ||
99 | public Object get(final int index) { | ||
100 | switch(index) { | ||
101 | case 0: return this.fHost; | ||
102 | case 1: return this.fApp; | ||
103 | case 2: return this.fReq; | ||
104 | default: return null; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | public HostInstance getHost() { | ||
109 | return this.fHost; | ||
110 | } | ||
111 | |||
112 | public ApplicationInstance getApp() { | ||
113 | return this.fApp; | ||
114 | } | ||
115 | |||
116 | public hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement getReq() { | ||
117 | return this.fReq; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public boolean set(final String parameterName, final Object newValue) { | ||
122 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
123 | if ("Host".equals(parameterName) ) { | ||
124 | this.fHost = (HostInstance) newValue; | ||
125 | return true; | ||
126 | } | ||
127 | if ("App".equals(parameterName) ) { | ||
128 | this.fApp = (ApplicationInstance) newValue; | ||
129 | return true; | ||
130 | } | ||
131 | if ("Req".equals(parameterName) ) { | ||
132 | this.fReq = (hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement) newValue; | ||
133 | return true; | ||
134 | } | ||
135 | return false; | ||
136 | } | ||
137 | |||
138 | public void setHost(final HostInstance pHost) { | ||
139 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
140 | this.fHost = pHost; | ||
141 | } | ||
142 | |||
143 | public void setApp(final ApplicationInstance pApp) { | ||
144 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
145 | this.fApp = pApp; | ||
146 | } | ||
147 | |||
148 | public void setReq(final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
149 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
150 | this.fReq = pReq; | ||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public String patternName() { | ||
155 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement"; | ||
156 | } | ||
157 | |||
158 | @Override | ||
159 | public List<String> parameterNames() { | ||
160 | return ResourceRequirement.Match.parameterNames; | ||
161 | } | ||
162 | |||
163 | @Override | ||
164 | public Object[] toArray() { | ||
165 | return new Object[]{fHost, fApp, fReq}; | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public ResourceRequirement.Match toImmutable() { | ||
170 | return isMutable() ? newMatch(fHost, fApp, fReq) : this; | ||
171 | } | ||
172 | |||
173 | @Override | ||
174 | public String prettyPrint() { | ||
175 | StringBuilder result = new StringBuilder(); | ||
176 | result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); | ||
177 | result.append("\"App\"=" + prettyPrintValue(fApp) + ", "); | ||
178 | result.append("\"Req\"=" + prettyPrintValue(fReq)); | ||
179 | return result.toString(); | ||
180 | } | ||
181 | |||
182 | @Override | ||
183 | public int hashCode() { | ||
184 | return Objects.hash(fHost, fApp, fReq); | ||
185 | } | ||
186 | |||
187 | @Override | ||
188 | public boolean equals(final Object obj) { | ||
189 | if (this == obj) | ||
190 | return true; | ||
191 | if (obj == null) { | ||
192 | return false; | ||
193 | } | ||
194 | if ((obj instanceof ResourceRequirement.Match)) { | ||
195 | ResourceRequirement.Match other = (ResourceRequirement.Match) obj; | ||
196 | return Objects.equals(fHost, other.fHost) && Objects.equals(fApp, other.fApp) && Objects.equals(fReq, other.fReq); | ||
197 | } else { | ||
198 | // this should be infrequent | ||
199 | if (!(obj instanceof IPatternMatch)) { | ||
200 | return false; | ||
201 | } | ||
202 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
203 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
204 | } | ||
205 | } | ||
206 | |||
207 | @Override | ||
208 | public ResourceRequirement specification() { | ||
209 | return ResourceRequirement.instance(); | ||
210 | } | ||
211 | |||
212 | /** | ||
213 | * Returns an empty, mutable match. | ||
214 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
215 | * | ||
216 | * @return the empty match. | ||
217 | * | ||
218 | */ | ||
219 | public static ResourceRequirement.Match newEmptyMatch() { | ||
220 | return new Mutable(null, null, null); | ||
221 | } | ||
222 | |||
223 | /** | ||
224 | * Returns a mutable (partial) match. | ||
225 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
226 | * | ||
227 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
228 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
229 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
230 | * @return the new, mutable (partial) match object. | ||
231 | * | ||
232 | */ | ||
233 | public static ResourceRequirement.Match newMutableMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
234 | return new Mutable(pHost, pApp, pReq); | ||
235 | } | ||
236 | |||
237 | /** | ||
238 | * Returns a new (partial) match. | ||
239 | * This can be used e.g. to call the matcher with a partial match. | ||
240 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
241 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
242 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
243 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
244 | * @return the (partial) match object. | ||
245 | * | ||
246 | */ | ||
247 | public static ResourceRequirement.Match newMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
248 | return new Immutable(pHost, pApp, pReq); | ||
249 | } | ||
250 | |||
251 | private static final class Mutable extends ResourceRequirement.Match { | ||
252 | Mutable(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
253 | super(pHost, pApp, pReq); | ||
254 | } | ||
255 | |||
256 | @Override | ||
257 | public boolean isMutable() { | ||
258 | return true; | ||
259 | } | ||
260 | } | ||
261 | |||
262 | private static final class Immutable extends ResourceRequirement.Match { | ||
263 | Immutable(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
264 | super(pHost, pApp, pReq); | ||
265 | } | ||
266 | |||
267 | @Override | ||
268 | public boolean isMutable() { | ||
269 | return false; | ||
270 | } | ||
271 | } | ||
272 | } | ||
273 | |||
274 | /** | ||
275 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement pattern, | ||
276 | * providing pattern-specific query methods. | ||
277 | * | ||
278 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
279 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
280 | * | ||
281 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
282 | * | ||
283 | * <p>Original source: | ||
284 | * <code><pre> | ||
285 | * pattern resourceRequirement(Host : HostInstance, App : ApplicationInstance, Req : ResourceRequirement) { | ||
286 | * ApplicationInstance.allocatedTo(App, Host); | ||
287 | * ApplicationInstance.type.requirements(App, Req); | ||
288 | * HostInstance.type(Host, HostType); | ||
289 | * ResourceRequirement.hostType(Req, HostType); | ||
290 | * } | ||
291 | * </pre></code> | ||
292 | * | ||
293 | * @see Match | ||
294 | * @see ResourceRequirement | ||
295 | * | ||
296 | */ | ||
297 | public static class Matcher extends BaseMatcher<ResourceRequirement.Match> { | ||
298 | /** | ||
299 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
300 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
301 | * | ||
302 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
303 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
304 | * | ||
305 | */ | ||
306 | public static ResourceRequirement.Matcher on(final ViatraQueryEngine engine) { | ||
307 | // check if matcher already exists | ||
308 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
309 | if (matcher == null) { | ||
310 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
311 | } | ||
312 | return matcher; | ||
313 | } | ||
314 | |||
315 | /** | ||
316 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
317 | * @return an initialized matcher | ||
318 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
319 | * | ||
320 | */ | ||
321 | public static ResourceRequirement.Matcher create() { | ||
322 | return new Matcher(); | ||
323 | } | ||
324 | |||
325 | private static final int POSITION_HOST = 0; | ||
326 | |||
327 | private static final int POSITION_APP = 1; | ||
328 | |||
329 | private static final int POSITION_REQ = 2; | ||
330 | |||
331 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ResourceRequirement.Matcher.class); | ||
332 | |||
333 | /** | ||
334 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
335 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
336 | * | ||
337 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
338 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
339 | * | ||
340 | */ | ||
341 | private Matcher() { | ||
342 | super(querySpecification()); | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
347 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
348 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
349 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
350 | * @return matches represented as a Match object. | ||
351 | * | ||
352 | */ | ||
353 | public Collection<ResourceRequirement.Match> getAllMatches(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
354 | return rawStreamAllMatches(new Object[]{pHost, pApp, pReq}).collect(Collectors.toSet()); | ||
355 | } | ||
356 | |||
357 | /** | ||
358 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
359 | * </p> | ||
360 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
361 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
362 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
363 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
364 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
365 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
366 | * @return a stream of matches represented as a Match object. | ||
367 | * | ||
368 | */ | ||
369 | public Stream<ResourceRequirement.Match> streamAllMatches(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
370 | return rawStreamAllMatches(new Object[]{pHost, pApp, pReq}); | ||
371 | } | ||
372 | |||
373 | /** | ||
374 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
375 | * Neither determinism nor randomness of selection is guaranteed. | ||
376 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
377 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
378 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
379 | * @return a match represented as a Match object, or null if no match is found. | ||
380 | * | ||
381 | */ | ||
382 | public Optional<ResourceRequirement.Match> getOneArbitraryMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
383 | return rawGetOneArbitraryMatch(new Object[]{pHost, pApp, pReq}); | ||
384 | } | ||
385 | |||
386 | /** | ||
387 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
388 | * under any possible substitution of the unspecified parameters (if any). | ||
389 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
390 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
391 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
392 | * @return true if the input is a valid (partial) match of the pattern. | ||
393 | * | ||
394 | */ | ||
395 | public boolean hasMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
396 | return rawHasMatch(new Object[]{pHost, pApp, pReq}); | ||
397 | } | ||
398 | |||
399 | /** | ||
400 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
401 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
402 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
403 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
404 | * @return the number of pattern matches found. | ||
405 | * | ||
406 | */ | ||
407 | public int countMatches(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
408 | return rawCountMatches(new Object[]{pHost, pApp, pReq}); | ||
409 | } | ||
410 | |||
411 | /** | ||
412 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
413 | * Neither determinism nor randomness of selection is guaranteed. | ||
414 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
415 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
416 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
417 | * @param processor the action that will process the selected match. | ||
418 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
419 | * | ||
420 | */ | ||
421 | public boolean forOneArbitraryMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq, final Consumer<? super ResourceRequirement.Match> processor) { | ||
422 | return rawForOneArbitraryMatch(new Object[]{pHost, pApp, pReq}, processor); | ||
423 | } | ||
424 | |||
425 | /** | ||
426 | * Returns a new (partial) match. | ||
427 | * This can be used e.g. to call the matcher with a partial match. | ||
428 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
429 | * @param pHost the fixed value of pattern parameter Host, or null if not bound. | ||
430 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
431 | * @param pReq the fixed value of pattern parameter Req, or null if not bound. | ||
432 | * @return the (partial) match object. | ||
433 | * | ||
434 | */ | ||
435 | public ResourceRequirement.Match newMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
436 | return ResourceRequirement.Match.newMatch(pHost, pApp, pReq); | ||
437 | } | ||
438 | |||
439 | /** | ||
440 | * Retrieve the set of values that occur in matches for Host. | ||
441 | * @return the Set of all values or empty set if there are no matches | ||
442 | * | ||
443 | */ | ||
444 | protected Stream<HostInstance> rawStreamAllValuesOfHost(final Object[] parameters) { | ||
445 | return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); | ||
446 | } | ||
447 | |||
448 | /** | ||
449 | * Retrieve the set of values that occur in matches for Host. | ||
450 | * @return the Set of all values or empty set if there are no matches | ||
451 | * | ||
452 | */ | ||
453 | public Set<HostInstance> getAllValuesOfHost() { | ||
454 | return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); | ||
455 | } | ||
456 | |||
457 | /** | ||
458 | * Retrieve the set of values that occur in matches for Host. | ||
459 | * @return the Set of all values or empty set if there are no matches | ||
460 | * | ||
461 | */ | ||
462 | public Stream<HostInstance> streamAllValuesOfHost() { | ||
463 | return rawStreamAllValuesOfHost(emptyArray()); | ||
464 | } | ||
465 | |||
466 | /** | ||
467 | * Retrieve the set of values that occur in matches for Host. | ||
468 | * </p> | ||
469 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
470 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
471 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
472 | * | ||
473 | * @return the Stream of all values or empty set if there are no matches | ||
474 | * | ||
475 | */ | ||
476 | public Stream<HostInstance> streamAllValuesOfHost(final ResourceRequirement.Match partialMatch) { | ||
477 | return rawStreamAllValuesOfHost(partialMatch.toArray()); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Retrieve the set of values that occur in matches for Host. | ||
482 | * </p> | ||
483 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
484 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
485 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
486 | * | ||
487 | * @return the Stream of all values or empty set if there are no matches | ||
488 | * | ||
489 | */ | ||
490 | public Stream<HostInstance> streamAllValuesOfHost(final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
491 | return rawStreamAllValuesOfHost(new Object[]{null, pApp, pReq}); | ||
492 | } | ||
493 | |||
494 | /** | ||
495 | * Retrieve the set of values that occur in matches for Host. | ||
496 | * @return the Set of all values or empty set if there are no matches | ||
497 | * | ||
498 | */ | ||
499 | public Set<HostInstance> getAllValuesOfHost(final ResourceRequirement.Match partialMatch) { | ||
500 | return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); | ||
501 | } | ||
502 | |||
503 | /** | ||
504 | * Retrieve the set of values that occur in matches for Host. | ||
505 | * @return the Set of all values or empty set if there are no matches | ||
506 | * | ||
507 | */ | ||
508 | public Set<HostInstance> getAllValuesOfHost(final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
509 | return rawStreamAllValuesOfHost(new Object[]{null, pApp, pReq}).collect(Collectors.toSet()); | ||
510 | } | ||
511 | |||
512 | /** | ||
513 | * Retrieve the set of values that occur in matches for App. | ||
514 | * @return the Set of all values or empty set if there are no matches | ||
515 | * | ||
516 | */ | ||
517 | protected Stream<ApplicationInstance> rawStreamAllValuesOfApp(final Object[] parameters) { | ||
518 | return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast); | ||
519 | } | ||
520 | |||
521 | /** | ||
522 | * Retrieve the set of values that occur in matches for App. | ||
523 | * @return the Set of all values or empty set if there are no matches | ||
524 | * | ||
525 | */ | ||
526 | public Set<ApplicationInstance> getAllValuesOfApp() { | ||
527 | return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet()); | ||
528 | } | ||
529 | |||
530 | /** | ||
531 | * Retrieve the set of values that occur in matches for App. | ||
532 | * @return the Set of all values or empty set if there are no matches | ||
533 | * | ||
534 | */ | ||
535 | public Stream<ApplicationInstance> streamAllValuesOfApp() { | ||
536 | return rawStreamAllValuesOfApp(emptyArray()); | ||
537 | } | ||
538 | |||
539 | /** | ||
540 | * Retrieve the set of values that occur in matches for App. | ||
541 | * </p> | ||
542 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
543 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
544 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
545 | * | ||
546 | * @return the Stream of all values or empty set if there are no matches | ||
547 | * | ||
548 | */ | ||
549 | public Stream<ApplicationInstance> streamAllValuesOfApp(final ResourceRequirement.Match partialMatch) { | ||
550 | return rawStreamAllValuesOfApp(partialMatch.toArray()); | ||
551 | } | ||
552 | |||
553 | /** | ||
554 | * Retrieve the set of values that occur in matches for App. | ||
555 | * </p> | ||
556 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
557 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
558 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
559 | * | ||
560 | * @return the Stream of all values or empty set if there are no matches | ||
561 | * | ||
562 | */ | ||
563 | public Stream<ApplicationInstance> streamAllValuesOfApp(final HostInstance pHost, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
564 | return rawStreamAllValuesOfApp(new Object[]{pHost, null, pReq}); | ||
565 | } | ||
566 | |||
567 | /** | ||
568 | * Retrieve the set of values that occur in matches for App. | ||
569 | * @return the Set of all values or empty set if there are no matches | ||
570 | * | ||
571 | */ | ||
572 | public Set<ApplicationInstance> getAllValuesOfApp(final ResourceRequirement.Match partialMatch) { | ||
573 | return rawStreamAllValuesOfApp(partialMatch.toArray()).collect(Collectors.toSet()); | ||
574 | } | ||
575 | |||
576 | /** | ||
577 | * Retrieve the set of values that occur in matches for App. | ||
578 | * @return the Set of all values or empty set if there are no matches | ||
579 | * | ||
580 | */ | ||
581 | public Set<ApplicationInstance> getAllValuesOfApp(final HostInstance pHost, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { | ||
582 | return rawStreamAllValuesOfApp(new Object[]{pHost, null, pReq}).collect(Collectors.toSet()); | ||
583 | } | ||
584 | |||
585 | /** | ||
586 | * Retrieve the set of values that occur in matches for Req. | ||
587 | * @return the Set of all values or empty set if there are no matches | ||
588 | * | ||
589 | */ | ||
590 | protected Stream<hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement> rawStreamAllValuesOfReq(final Object[] parameters) { | ||
591 | return rawStreamAllValues(POSITION_REQ, parameters).map(hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement.class::cast); | ||
592 | } | ||
593 | |||
594 | /** | ||
595 | * Retrieve the set of values that occur in matches for Req. | ||
596 | * @return the Set of all values or empty set if there are no matches | ||
597 | * | ||
598 | */ | ||
599 | public Set<hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement> getAllValuesOfReq() { | ||
600 | return rawStreamAllValuesOfReq(emptyArray()).collect(Collectors.toSet()); | ||
601 | } | ||
602 | |||
603 | /** | ||
604 | * Retrieve the set of values that occur in matches for Req. | ||
605 | * @return the Set of all values or empty set if there are no matches | ||
606 | * | ||
607 | */ | ||
608 | public Stream<hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement> streamAllValuesOfReq() { | ||
609 | return rawStreamAllValuesOfReq(emptyArray()); | ||
610 | } | ||
611 | |||
612 | /** | ||
613 | * Retrieve the set of values that occur in matches for Req. | ||
614 | * </p> | ||
615 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
616 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
617 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
618 | * | ||
619 | * @return the Stream of all values or empty set if there are no matches | ||
620 | * | ||
621 | */ | ||
622 | public Stream<hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement> streamAllValuesOfReq(final ResourceRequirement.Match partialMatch) { | ||
623 | return rawStreamAllValuesOfReq(partialMatch.toArray()); | ||
624 | } | ||
625 | |||
626 | /** | ||
627 | * Retrieve the set of values that occur in matches for Req. | ||
628 | * </p> | ||
629 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
630 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
631 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
632 | * | ||
633 | * @return the Stream of all values or empty set if there are no matches | ||
634 | * | ||
635 | */ | ||
636 | public Stream<hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement> streamAllValuesOfReq(final HostInstance pHost, final ApplicationInstance pApp) { | ||
637 | return rawStreamAllValuesOfReq(new Object[]{pHost, pApp, null}); | ||
638 | } | ||
639 | |||
640 | /** | ||
641 | * Retrieve the set of values that occur in matches for Req. | ||
642 | * @return the Set of all values or empty set if there are no matches | ||
643 | * | ||
644 | */ | ||
645 | public Set<hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement> getAllValuesOfReq(final ResourceRequirement.Match partialMatch) { | ||
646 | return rawStreamAllValuesOfReq(partialMatch.toArray()).collect(Collectors.toSet()); | ||
647 | } | ||
648 | |||
649 | /** | ||
650 | * Retrieve the set of values that occur in matches for Req. | ||
651 | * @return the Set of all values or empty set if there are no matches | ||
652 | * | ||
653 | */ | ||
654 | public Set<hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement> getAllValuesOfReq(final HostInstance pHost, final ApplicationInstance pApp) { | ||
655 | return rawStreamAllValuesOfReq(new Object[]{pHost, pApp, null}).collect(Collectors.toSet()); | ||
656 | } | ||
657 | |||
658 | @Override | ||
659 | protected ResourceRequirement.Match tupleToMatch(final Tuple t) { | ||
660 | try { | ||
661 | return ResourceRequirement.Match.newMatch((HostInstance) t.get(POSITION_HOST), (ApplicationInstance) t.get(POSITION_APP), (hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement) t.get(POSITION_REQ)); | ||
662 | } catch(ClassCastException e) { | ||
663 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
664 | return null; | ||
665 | } | ||
666 | } | ||
667 | |||
668 | @Override | ||
669 | protected ResourceRequirement.Match arrayToMatch(final Object[] match) { | ||
670 | try { | ||
671 | return ResourceRequirement.Match.newMatch((HostInstance) match[POSITION_HOST], (ApplicationInstance) match[POSITION_APP], (hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement) match[POSITION_REQ]); | ||
672 | } catch(ClassCastException e) { | ||
673 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
674 | return null; | ||
675 | } | ||
676 | } | ||
677 | |||
678 | @Override | ||
679 | protected ResourceRequirement.Match arrayToMatchMutable(final Object[] match) { | ||
680 | try { | ||
681 | return ResourceRequirement.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (ApplicationInstance) match[POSITION_APP], (hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement) match[POSITION_REQ]); | ||
682 | } catch(ClassCastException e) { | ||
683 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
684 | return null; | ||
685 | } | ||
686 | } | ||
687 | |||
688 | /** | ||
689 | * @return the singleton instance of the query specification of this pattern | ||
690 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
691 | * | ||
692 | */ | ||
693 | public static IQuerySpecification<ResourceRequirement.Matcher> querySpecification() { | ||
694 | return ResourceRequirement.instance(); | ||
695 | } | ||
696 | } | ||
697 | |||
698 | private ResourceRequirement() { | ||
699 | super(GeneratedPQuery.INSTANCE); | ||
700 | } | ||
701 | |||
702 | /** | ||
703 | * @return the singleton instance of the query specification | ||
704 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
705 | * | ||
706 | */ | ||
707 | public static ResourceRequirement instance() { | ||
708 | try{ | ||
709 | return LazyHolder.INSTANCE; | ||
710 | } catch (ExceptionInInitializerError err) { | ||
711 | throw processInitializerError(err); | ||
712 | } | ||
713 | } | ||
714 | |||
715 | @Override | ||
716 | protected ResourceRequirement.Matcher instantiate(final ViatraQueryEngine engine) { | ||
717 | return ResourceRequirement.Matcher.on(engine); | ||
718 | } | ||
719 | |||
720 | @Override | ||
721 | public ResourceRequirement.Matcher instantiate() { | ||
722 | return ResourceRequirement.Matcher.create(); | ||
723 | } | ||
724 | |||
725 | @Override | ||
726 | public ResourceRequirement.Match newEmptyMatch() { | ||
727 | return ResourceRequirement.Match.newEmptyMatch(); | ||
728 | } | ||
729 | |||
730 | @Override | ||
731 | public ResourceRequirement.Match newMatch(final Object... parameters) { | ||
732 | return ResourceRequirement.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[1], (hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement) parameters[2]); | ||
733 | } | ||
734 | |||
735 | /** | ||
736 | * Inner class allowing the singleton instance of {@link ResourceRequirement} to be created | ||
737 | * <b>not</b> at the class load time of the outer class, | ||
738 | * but rather at the first call to {@link ResourceRequirement#instance()}. | ||
739 | * | ||
740 | * <p> This workaround is required e.g. to support recursion. | ||
741 | * | ||
742 | */ | ||
743 | private static class LazyHolder { | ||
744 | private static final ResourceRequirement INSTANCE = new ResourceRequirement(); | ||
745 | |||
746 | /** | ||
747 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
748 | * This initialization order is required to support indirect recursion. | ||
749 | * | ||
750 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
751 | * | ||
752 | */ | ||
753 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
754 | |||
755 | public static Object ensureInitialized() { | ||
756 | INSTANCE.ensureInitializedInternal(); | ||
757 | return null; | ||
758 | } | ||
759 | } | ||
760 | |||
761 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
762 | private static final ResourceRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
763 | |||
764 | private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
765 | |||
766 | private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); | ||
767 | |||
768 | private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ResourceRequirement")), PParameterDirection.INOUT); | ||
769 | |||
770 | private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_App, parameter_Req); | ||
771 | |||
772 | private GeneratedPQuery() { | ||
773 | super(PVisibility.PUBLIC); | ||
774 | } | ||
775 | |||
776 | @Override | ||
777 | public String getFullyQualifiedName() { | ||
778 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement"; | ||
779 | } | ||
780 | |||
781 | @Override | ||
782 | public List<String> getParameterNames() { | ||
783 | return Arrays.asList("Host","App","Req"); | ||
784 | } | ||
785 | |||
786 | @Override | ||
787 | public List<PParameter> getParameters() { | ||
788 | return parameters; | ||
789 | } | ||
790 | |||
791 | @Override | ||
792 | public Set<PBody> doGetContainedBodies() { | ||
793 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
794 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
795 | { | ||
796 | PBody body = new PBody(this); | ||
797 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
798 | PVariable var_App = body.getOrCreateVariableByName("App"); | ||
799 | PVariable var_Req = body.getOrCreateVariableByName("Req"); | ||
800 | PVariable var_HostType = body.getOrCreateVariableByName("HostType"); | ||
801 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
802 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
803 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); | ||
804 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
805 | new ExportedParameter(body, var_Host, parameter_Host), | ||
806 | new ExportedParameter(body, var_App, parameter_App), | ||
807 | new ExportedParameter(body, var_Req, parameter_Req) | ||
808 | )); | ||
809 | // ApplicationInstance.allocatedTo(App, Host) | ||
810 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
811 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
812 | new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); | ||
813 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
814 | new Equality(body, var__virtual_0_, var_Host); | ||
815 | // ApplicationInstance.type.requirements(App, Req) | ||
816 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
817 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
818 | new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type"))); | ||
819 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); | ||
820 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
821 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "requirements"))); | ||
822 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); | ||
823 | new Equality(body, var__virtual_2_, var_Req); | ||
824 | // HostInstance.type(Host, HostType) | ||
825 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
826 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); | ||
827 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); | ||
828 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); | ||
829 | new Equality(body, var__virtual_3_, var_HostType); | ||
830 | // ResourceRequirement.hostType(Req, HostType) | ||
831 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); | ||
832 | PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}"); | ||
833 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "hostType"))); | ||
834 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); | ||
835 | new Equality(body, var__virtual_4_, var_HostType); | ||
836 | bodies.add(body); | ||
837 | } | ||
838 | return bodies; | ||
839 | } | ||
840 | } | ||
841 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/UnallocateAppInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/UnallocateAppInstance.java new file mode 100644 index 00000000..9f3d74b6 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/UnallocateAppInstance.java | |||
@@ -0,0 +1,551 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Objects; | ||
12 | import java.util.Optional; | ||
13 | import java.util.Set; | ||
14 | import java.util.function.Consumer; | ||
15 | import java.util.stream.Collectors; | ||
16 | import java.util.stream.Stream; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
40 | |||
41 | /** | ||
42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
43 | * | ||
44 | * <p>Original source: | ||
45 | * <code><pre> | ||
46 | * pattern unallocateAppInstance(App : ApplicationInstance) { | ||
47 | * ApplicationInstance.allocatedTo(App, _); | ||
48 | * } | ||
49 | * </pre></code> | ||
50 | * | ||
51 | * @see Matcher | ||
52 | * @see Match | ||
53 | * | ||
54 | */ | ||
55 | @SuppressWarnings("all") | ||
56 | public final class UnallocateAppInstance extends BaseGeneratedEMFQuerySpecification<UnallocateAppInstance.Matcher> { | ||
57 | /** | ||
58 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.unallocateAppInstance pattern, | ||
59 | * to be used in conjunction with {@link Matcher}. | ||
60 | * | ||
61 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
62 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
63 | * usable to represent a match of the pattern in the result of a query, | ||
64 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
65 | * | ||
66 | * @see Matcher | ||
67 | * | ||
68 | */ | ||
69 | public static abstract class Match extends BasePatternMatch { | ||
70 | private ApplicationInstance fApp; | ||
71 | |||
72 | private static List<String> parameterNames = makeImmutableList("App"); | ||
73 | |||
74 | private Match(final ApplicationInstance pApp) { | ||
75 | this.fApp = pApp; | ||
76 | } | ||
77 | |||
78 | @Override | ||
79 | public Object get(final String parameterName) { | ||
80 | switch(parameterName) { | ||
81 | case "App": return this.fApp; | ||
82 | default: return null; | ||
83 | } | ||
84 | } | ||
85 | |||
86 | @Override | ||
87 | public Object get(final int index) { | ||
88 | switch(index) { | ||
89 | case 0: return this.fApp; | ||
90 | default: return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | public ApplicationInstance getApp() { | ||
95 | return this.fApp; | ||
96 | } | ||
97 | |||
98 | @Override | ||
99 | public boolean set(final String parameterName, final Object newValue) { | ||
100 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
101 | if ("App".equals(parameterName) ) { | ||
102 | this.fApp = (ApplicationInstance) newValue; | ||
103 | return true; | ||
104 | } | ||
105 | return false; | ||
106 | } | ||
107 | |||
108 | public void setApp(final ApplicationInstance pApp) { | ||
109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
110 | this.fApp = pApp; | ||
111 | } | ||
112 | |||
113 | @Override | ||
114 | public String patternName() { | ||
115 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.unallocateAppInstance"; | ||
116 | } | ||
117 | |||
118 | @Override | ||
119 | public List<String> parameterNames() { | ||
120 | return UnallocateAppInstance.Match.parameterNames; | ||
121 | } | ||
122 | |||
123 | @Override | ||
124 | public Object[] toArray() { | ||
125 | return new Object[]{fApp}; | ||
126 | } | ||
127 | |||
128 | @Override | ||
129 | public UnallocateAppInstance.Match toImmutable() { | ||
130 | return isMutable() ? newMatch(fApp) : this; | ||
131 | } | ||
132 | |||
133 | @Override | ||
134 | public String prettyPrint() { | ||
135 | StringBuilder result = new StringBuilder(); | ||
136 | result.append("\"App\"=" + prettyPrintValue(fApp)); | ||
137 | return result.toString(); | ||
138 | } | ||
139 | |||
140 | @Override | ||
141 | public int hashCode() { | ||
142 | return Objects.hash(fApp); | ||
143 | } | ||
144 | |||
145 | @Override | ||
146 | public boolean equals(final Object obj) { | ||
147 | if (this == obj) | ||
148 | return true; | ||
149 | if (obj == null) { | ||
150 | return false; | ||
151 | } | ||
152 | if ((obj instanceof UnallocateAppInstance.Match)) { | ||
153 | UnallocateAppInstance.Match other = (UnallocateAppInstance.Match) obj; | ||
154 | return Objects.equals(fApp, other.fApp); | ||
155 | } else { | ||
156 | // this should be infrequent | ||
157 | if (!(obj instanceof IPatternMatch)) { | ||
158 | return false; | ||
159 | } | ||
160 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
161 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
162 | } | ||
163 | } | ||
164 | |||
165 | @Override | ||
166 | public UnallocateAppInstance specification() { | ||
167 | return UnallocateAppInstance.instance(); | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * Returns an empty, mutable match. | ||
172 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
173 | * | ||
174 | * @return the empty match. | ||
175 | * | ||
176 | */ | ||
177 | public static UnallocateAppInstance.Match newEmptyMatch() { | ||
178 | return new Mutable(null); | ||
179 | } | ||
180 | |||
181 | /** | ||
182 | * Returns a mutable (partial) match. | ||
183 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
184 | * | ||
185 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
186 | * @return the new, mutable (partial) match object. | ||
187 | * | ||
188 | */ | ||
189 | public static UnallocateAppInstance.Match newMutableMatch(final ApplicationInstance pApp) { | ||
190 | return new Mutable(pApp); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * Returns a new (partial) match. | ||
195 | * This can be used e.g. to call the matcher with a partial match. | ||
196 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
197 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
198 | * @return the (partial) match object. | ||
199 | * | ||
200 | */ | ||
201 | public static UnallocateAppInstance.Match newMatch(final ApplicationInstance pApp) { | ||
202 | return new Immutable(pApp); | ||
203 | } | ||
204 | |||
205 | private static final class Mutable extends UnallocateAppInstance.Match { | ||
206 | Mutable(final ApplicationInstance pApp) { | ||
207 | super(pApp); | ||
208 | } | ||
209 | |||
210 | @Override | ||
211 | public boolean isMutable() { | ||
212 | return true; | ||
213 | } | ||
214 | } | ||
215 | |||
216 | private static final class Immutable extends UnallocateAppInstance.Match { | ||
217 | Immutable(final ApplicationInstance pApp) { | ||
218 | super(pApp); | ||
219 | } | ||
220 | |||
221 | @Override | ||
222 | public boolean isMutable() { | ||
223 | return false; | ||
224 | } | ||
225 | } | ||
226 | } | ||
227 | |||
228 | /** | ||
229 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.unallocateAppInstance pattern, | ||
230 | * providing pattern-specific query methods. | ||
231 | * | ||
232 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
233 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
234 | * | ||
235 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
236 | * | ||
237 | * <p>Original source: | ||
238 | * <code><pre> | ||
239 | * pattern unallocateAppInstance(App : ApplicationInstance) { | ||
240 | * ApplicationInstance.allocatedTo(App, _); | ||
241 | * } | ||
242 | * </pre></code> | ||
243 | * | ||
244 | * @see Match | ||
245 | * @see UnallocateAppInstance | ||
246 | * | ||
247 | */ | ||
248 | public static class Matcher extends BaseMatcher<UnallocateAppInstance.Match> { | ||
249 | /** | ||
250 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
251 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
252 | * | ||
253 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
254 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
255 | * | ||
256 | */ | ||
257 | public static UnallocateAppInstance.Matcher on(final ViatraQueryEngine engine) { | ||
258 | // check if matcher already exists | ||
259 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
260 | if (matcher == null) { | ||
261 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
262 | } | ||
263 | return matcher; | ||
264 | } | ||
265 | |||
266 | /** | ||
267 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
268 | * @return an initialized matcher | ||
269 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
270 | * | ||
271 | */ | ||
272 | public static UnallocateAppInstance.Matcher create() { | ||
273 | return new Matcher(); | ||
274 | } | ||
275 | |||
276 | private static final int POSITION_APP = 0; | ||
277 | |||
278 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(UnallocateAppInstance.Matcher.class); | ||
279 | |||
280 | /** | ||
281 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
282 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
283 | * | ||
284 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
285 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
286 | * | ||
287 | */ | ||
288 | private Matcher() { | ||
289 | super(querySpecification()); | ||
290 | } | ||
291 | |||
292 | /** | ||
293 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
294 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
295 | * @return matches represented as a Match object. | ||
296 | * | ||
297 | */ | ||
298 | public Collection<UnallocateAppInstance.Match> getAllMatches(final ApplicationInstance pApp) { | ||
299 | return rawStreamAllMatches(new Object[]{pApp}).collect(Collectors.toSet()); | ||
300 | } | ||
301 | |||
302 | /** | ||
303 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
304 | * </p> | ||
305 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
306 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
307 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
308 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
309 | * @return a stream of matches represented as a Match object. | ||
310 | * | ||
311 | */ | ||
312 | public Stream<UnallocateAppInstance.Match> streamAllMatches(final ApplicationInstance pApp) { | ||
313 | return rawStreamAllMatches(new Object[]{pApp}); | ||
314 | } | ||
315 | |||
316 | /** | ||
317 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
318 | * Neither determinism nor randomness of selection is guaranteed. | ||
319 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
320 | * @return a match represented as a Match object, or null if no match is found. | ||
321 | * | ||
322 | */ | ||
323 | public Optional<UnallocateAppInstance.Match> getOneArbitraryMatch(final ApplicationInstance pApp) { | ||
324 | return rawGetOneArbitraryMatch(new Object[]{pApp}); | ||
325 | } | ||
326 | |||
327 | /** | ||
328 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
329 | * under any possible substitution of the unspecified parameters (if any). | ||
330 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
331 | * @return true if the input is a valid (partial) match of the pattern. | ||
332 | * | ||
333 | */ | ||
334 | public boolean hasMatch(final ApplicationInstance pApp) { | ||
335 | return rawHasMatch(new Object[]{pApp}); | ||
336 | } | ||
337 | |||
338 | /** | ||
339 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
340 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
341 | * @return the number of pattern matches found. | ||
342 | * | ||
343 | */ | ||
344 | public int countMatches(final ApplicationInstance pApp) { | ||
345 | return rawCountMatches(new Object[]{pApp}); | ||
346 | } | ||
347 | |||
348 | /** | ||
349 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
350 | * Neither determinism nor randomness of selection is guaranteed. | ||
351 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
352 | * @param processor the action that will process the selected match. | ||
353 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
354 | * | ||
355 | */ | ||
356 | public boolean forOneArbitraryMatch(final ApplicationInstance pApp, final Consumer<? super UnallocateAppInstance.Match> processor) { | ||
357 | return rawForOneArbitraryMatch(new Object[]{pApp}, processor); | ||
358 | } | ||
359 | |||
360 | /** | ||
361 | * Returns a new (partial) match. | ||
362 | * This can be used e.g. to call the matcher with a partial match. | ||
363 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
364 | * @param pApp the fixed value of pattern parameter App, or null if not bound. | ||
365 | * @return the (partial) match object. | ||
366 | * | ||
367 | */ | ||
368 | public UnallocateAppInstance.Match newMatch(final ApplicationInstance pApp) { | ||
369 | return UnallocateAppInstance.Match.newMatch(pApp); | ||
370 | } | ||
371 | |||
372 | /** | ||
373 | * Retrieve the set of values that occur in matches for App. | ||
374 | * @return the Set of all values or empty set if there are no matches | ||
375 | * | ||
376 | */ | ||
377 | protected Stream<ApplicationInstance> rawStreamAllValuesOfApp(final Object[] parameters) { | ||
378 | return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast); | ||
379 | } | ||
380 | |||
381 | /** | ||
382 | * Retrieve the set of values that occur in matches for App. | ||
383 | * @return the Set of all values or empty set if there are no matches | ||
384 | * | ||
385 | */ | ||
386 | public Set<ApplicationInstance> getAllValuesOfApp() { | ||
387 | return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet()); | ||
388 | } | ||
389 | |||
390 | /** | ||
391 | * Retrieve the set of values that occur in matches for App. | ||
392 | * @return the Set of all values or empty set if there are no matches | ||
393 | * | ||
394 | */ | ||
395 | public Stream<ApplicationInstance> streamAllValuesOfApp() { | ||
396 | return rawStreamAllValuesOfApp(emptyArray()); | ||
397 | } | ||
398 | |||
399 | @Override | ||
400 | protected UnallocateAppInstance.Match tupleToMatch(final Tuple t) { | ||
401 | try { | ||
402 | return UnallocateAppInstance.Match.newMatch((ApplicationInstance) t.get(POSITION_APP)); | ||
403 | } catch(ClassCastException e) { | ||
404 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
405 | return null; | ||
406 | } | ||
407 | } | ||
408 | |||
409 | @Override | ||
410 | protected UnallocateAppInstance.Match arrayToMatch(final Object[] match) { | ||
411 | try { | ||
412 | return UnallocateAppInstance.Match.newMatch((ApplicationInstance) match[POSITION_APP]); | ||
413 | } catch(ClassCastException e) { | ||
414 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
415 | return null; | ||
416 | } | ||
417 | } | ||
418 | |||
419 | @Override | ||
420 | protected UnallocateAppInstance.Match arrayToMatchMutable(final Object[] match) { | ||
421 | try { | ||
422 | return UnallocateAppInstance.Match.newMutableMatch((ApplicationInstance) match[POSITION_APP]); | ||
423 | } catch(ClassCastException e) { | ||
424 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
425 | return null; | ||
426 | } | ||
427 | } | ||
428 | |||
429 | /** | ||
430 | * @return the singleton instance of the query specification of this pattern | ||
431 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
432 | * | ||
433 | */ | ||
434 | public static IQuerySpecification<UnallocateAppInstance.Matcher> querySpecification() { | ||
435 | return UnallocateAppInstance.instance(); | ||
436 | } | ||
437 | } | ||
438 | |||
439 | private UnallocateAppInstance() { | ||
440 | super(GeneratedPQuery.INSTANCE); | ||
441 | } | ||
442 | |||
443 | /** | ||
444 | * @return the singleton instance of the query specification | ||
445 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
446 | * | ||
447 | */ | ||
448 | public static UnallocateAppInstance instance() { | ||
449 | try{ | ||
450 | return LazyHolder.INSTANCE; | ||
451 | } catch (ExceptionInInitializerError err) { | ||
452 | throw processInitializerError(err); | ||
453 | } | ||
454 | } | ||
455 | |||
456 | @Override | ||
457 | protected UnallocateAppInstance.Matcher instantiate(final ViatraQueryEngine engine) { | ||
458 | return UnallocateAppInstance.Matcher.on(engine); | ||
459 | } | ||
460 | |||
461 | @Override | ||
462 | public UnallocateAppInstance.Matcher instantiate() { | ||
463 | return UnallocateAppInstance.Matcher.create(); | ||
464 | } | ||
465 | |||
466 | @Override | ||
467 | public UnallocateAppInstance.Match newEmptyMatch() { | ||
468 | return UnallocateAppInstance.Match.newEmptyMatch(); | ||
469 | } | ||
470 | |||
471 | @Override | ||
472 | public UnallocateAppInstance.Match newMatch(final Object... parameters) { | ||
473 | return UnallocateAppInstance.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[0]); | ||
474 | } | ||
475 | |||
476 | /** | ||
477 | * Inner class allowing the singleton instance of {@link UnallocateAppInstance} to be created | ||
478 | * <b>not</b> at the class load time of the outer class, | ||
479 | * but rather at the first call to {@link UnallocateAppInstance#instance()}. | ||
480 | * | ||
481 | * <p> This workaround is required e.g. to support recursion. | ||
482 | * | ||
483 | */ | ||
484 | private static class LazyHolder { | ||
485 | private static final UnallocateAppInstance INSTANCE = new UnallocateAppInstance(); | ||
486 | |||
487 | /** | ||
488 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
489 | * This initialization order is required to support indirect recursion. | ||
490 | * | ||
491 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
492 | * | ||
493 | */ | ||
494 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
495 | |||
496 | public static Object ensureInitialized() { | ||
497 | INSTANCE.ensureInitializedInternal(); | ||
498 | return null; | ||
499 | } | ||
500 | } | ||
501 | |||
502 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
503 | private static final UnallocateAppInstance.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
504 | |||
505 | private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); | ||
506 | |||
507 | private final List<PParameter> parameters = Arrays.asList(parameter_App); | ||
508 | |||
509 | private GeneratedPQuery() { | ||
510 | super(PVisibility.PUBLIC); | ||
511 | } | ||
512 | |||
513 | @Override | ||
514 | public String getFullyQualifiedName() { | ||
515 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.unallocateAppInstance"; | ||
516 | } | ||
517 | |||
518 | @Override | ||
519 | public List<String> getParameterNames() { | ||
520 | return Arrays.asList("App"); | ||
521 | } | ||
522 | |||
523 | @Override | ||
524 | public List<PParameter> getParameters() { | ||
525 | return parameters; | ||
526 | } | ||
527 | |||
528 | @Override | ||
529 | public Set<PBody> doGetContainedBodies() { | ||
530 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
531 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
532 | { | ||
533 | PBody body = new PBody(this); | ||
534 | PVariable var_App = body.getOrCreateVariableByName("App"); | ||
535 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
536 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
537 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
538 | new ExportedParameter(body, var_App, parameter_App) | ||
539 | )); | ||
540 | // ApplicationInstance.allocatedTo(App, _) | ||
541 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
542 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
543 | new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); | ||
544 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
545 | new Equality(body, var__virtual_0_, var___0_); | ||
546 | bodies.add(body); | ||
547 | } | ||
548 | return bodies; | ||
549 | } | ||
550 | } | ||
551 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore new file mode 100644 index 00000000..a4f039d9 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore | |||
@@ -0,0 +1,36 @@ | |||
1 | /.CpsQueriesAll.java._trace | ||
2 | /.ResourceRequirement.java._trace | ||
3 | /.MemoryRequirement.java._trace | ||
4 | /.HddRequirement.java._trace | ||
5 | /.AllocationWithoutResourceRequirement.java._trace | ||
6 | /.RequiredType.java._trace | ||
7 | /.SatisfyingInstance.java._trace | ||
8 | /.FreeMemoryPercentage.java._trace | ||
9 | /.FreeHddPercentage.java._trace | ||
10 | /.ApplicationInstance.java._trace | ||
11 | /.HostInstanceCost.java._trace | ||
12 | /.AvailableHdd.java._trace | ||
13 | /.AvailableMemory.java._trace | ||
14 | /.CpsApplications.java._trace | ||
15 | /.CpsHosts.java._trace | ||
16 | /.TotalHdd.java._trace | ||
17 | /.TotalMemory.java._trace | ||
18 | /.RequiredAppInstances.java._trace | ||
19 | /.UnallocatedAppInstance.java._trace | ||
20 | /.NoHostToAllocateTo.java._trace | ||
21 | /AvailableHdd.java | ||
22 | /AvailableMemory.java | ||
23 | /CpsApplications.java | ||
24 | /CpsHosts.java | ||
25 | /CpsQueriesAll.java | ||
26 | /FreeHddPercentage.java | ||
27 | /FreeMemoryPercentage.java | ||
28 | /HddRequirement.java | ||
29 | /HostInstanceCost.java | ||
30 | /MemoryRequirement.java | ||
31 | /NoHostToAllocateTo.java | ||
32 | /RequiredAppInstances.java | ||
33 | /SatisfyingInstance.java | ||
34 | /TotalHdd.java | ||
35 | /TotalMemory.java | ||
36 | /UnallocatedAppInstance.java | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableHdd.java new file mode 100644 index 00000000..8a150288 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableHdd.java | |||
@@ -0,0 +1,178 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Set; | ||
12 | import org.eclipse.emf.ecore.EClass; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
14 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
34 | |||
35 | /** | ||
36 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
37 | * | ||
38 | * <p>Original source: | ||
39 | * <code><pre> | ||
40 | * private pattern availableHdd(Host : HostInstance, Hdd : java Integer) { | ||
41 | * find totalHdd(Host, TotalHdd); | ||
42 | * RequiredHdd == sum find hddRequirement(Host, _, #_); | ||
43 | * Hdd == eval(TotalHdd - RequiredHdd); | ||
44 | * } | ||
45 | * </pre></code> | ||
46 | * | ||
47 | * @see GenericPatternMatcher | ||
48 | * @see GenericPatternMatch | ||
49 | * | ||
50 | */ | ||
51 | @SuppressWarnings("all") | ||
52 | public final class AvailableHdd extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
53 | private AvailableHdd() { | ||
54 | super(GeneratedPQuery.INSTANCE); | ||
55 | } | ||
56 | |||
57 | /** | ||
58 | * @return the singleton instance of the query specification | ||
59 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
60 | * | ||
61 | */ | ||
62 | public static AvailableHdd instance() { | ||
63 | try{ | ||
64 | return LazyHolder.INSTANCE; | ||
65 | } catch (ExceptionInInitializerError err) { | ||
66 | throw processInitializerError(err); | ||
67 | } | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * Inner class allowing the singleton instance of {@link AvailableHdd} to be created | ||
72 | * <b>not</b> at the class load time of the outer class, | ||
73 | * but rather at the first call to {@link AvailableHdd#instance()}. | ||
74 | * | ||
75 | * <p> This workaround is required e.g. to support recursion. | ||
76 | * | ||
77 | */ | ||
78 | private static class LazyHolder { | ||
79 | private static final AvailableHdd INSTANCE = new AvailableHdd(); | ||
80 | |||
81 | /** | ||
82 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
83 | * This initialization order is required to support indirect recursion. | ||
84 | * | ||
85 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
86 | * | ||
87 | */ | ||
88 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
89 | |||
90 | public static Object ensureInitialized() { | ||
91 | INSTANCE.ensureInitializedInternal(); | ||
92 | return null; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
97 | private static final AvailableHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
98 | |||
99 | private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
100 | |||
101 | private final PParameter parameter_Hdd = new PParameter("Hdd", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); | ||
102 | |||
103 | private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_Hdd); | ||
104 | |||
105 | private GeneratedPQuery() { | ||
106 | super(PVisibility.PRIVATE); | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public String getFullyQualifiedName() { | ||
111 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd"; | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | public List<String> getParameterNames() { | ||
116 | return Arrays.asList("Host","Hdd"); | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public List<PParameter> getParameters() { | ||
121 | return parameters; | ||
122 | } | ||
123 | |||
124 | @Override | ||
125 | public Set<PBody> doGetContainedBodies() { | ||
126 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
127 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
128 | { | ||
129 | PBody body = new PBody(this); | ||
130 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
131 | PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); | ||
132 | PVariable var_TotalHdd = body.getOrCreateVariableByName("TotalHdd"); | ||
133 | PVariable var_RequiredHdd = body.getOrCreateVariableByName("RequiredHdd"); | ||
134 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
135 | PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); | ||
136 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
137 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Hdd), new JavaTransitiveInstancesKey(java.lang.Integer.class)); | ||
138 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
139 | new ExportedParameter(body, var_Host, parameter_Host), | ||
140 | new ExportedParameter(body, var_Hdd, parameter_Hdd) | ||
141 | )); | ||
142 | // find totalHdd(Host, TotalHdd) | ||
143 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_TotalHdd), TotalHdd.instance().getInternalQueryRepresentation()); | ||
144 | // RequiredHdd == sum find hddRequirement(Host, _, #_) | ||
145 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
146 | new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Host, var___0_, var___1_), HddRequirement.instance().getInternalQueryRepresentation(), var__virtual_0_, 2); | ||
147 | new Equality(body, var_RequiredHdd, var__virtual_0_); | ||
148 | // Hdd == eval(TotalHdd - RequiredHdd) | ||
149 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
150 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
151 | |||
152 | @Override | ||
153 | public String getShortDescription() { | ||
154 | return "Expression evaluation from pattern availableHdd"; | ||
155 | } | ||
156 | |||
157 | @Override | ||
158 | public Iterable<String> getInputParameterNames() { | ||
159 | return Arrays.asList("RequiredHdd", "TotalHdd");} | ||
160 | |||
161 | @Override | ||
162 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
163 | Integer RequiredHdd = (Integer) provider.getValue("RequiredHdd"); | ||
164 | Integer TotalHdd = (Integer) provider.getValue("TotalHdd"); | ||
165 | return evaluateExpression_1_1(RequiredHdd, TotalHdd); | ||
166 | } | ||
167 | }, var__virtual_1_ ); | ||
168 | new Equality(body, var_Hdd, var__virtual_1_); | ||
169 | bodies.add(body); | ||
170 | } | ||
171 | return bodies; | ||
172 | } | ||
173 | } | ||
174 | |||
175 | private static int evaluateExpression_1_1(final Integer RequiredHdd, final Integer TotalHdd) { | ||
176 | return ((TotalHdd).intValue() - (RequiredHdd).intValue()); | ||
177 | } | ||
178 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableMemory.java new file mode 100644 index 00000000..c89872e6 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableMemory.java | |||
@@ -0,0 +1,178 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Set; | ||
12 | import org.eclipse.emf.ecore.EClass; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
14 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
34 | |||
35 | /** | ||
36 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
37 | * | ||
38 | * <p>Original source: | ||
39 | * <code><pre> | ||
40 | * private pattern availableMemory(Host : HostInstance, Memory : java Integer) { | ||
41 | * find totalMemory(Host, TotalMemory); | ||
42 | * RequiredMemory == sum find memoryRequirement(Host, _, #_); | ||
43 | * Memory == eval(TotalMemory - RequiredMemory); | ||
44 | * } | ||
45 | * </pre></code> | ||
46 | * | ||
47 | * @see GenericPatternMatcher | ||
48 | * @see GenericPatternMatch | ||
49 | * | ||
50 | */ | ||
51 | @SuppressWarnings("all") | ||
52 | public final class AvailableMemory extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
53 | private AvailableMemory() { | ||
54 | super(GeneratedPQuery.INSTANCE); | ||
55 | } | ||
56 | |||
57 | /** | ||
58 | * @return the singleton instance of the query specification | ||
59 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
60 | * | ||
61 | */ | ||
62 | public static AvailableMemory instance() { | ||
63 | try{ | ||
64 | return LazyHolder.INSTANCE; | ||
65 | } catch (ExceptionInInitializerError err) { | ||
66 | throw processInitializerError(err); | ||
67 | } | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * Inner class allowing the singleton instance of {@link AvailableMemory} to be created | ||
72 | * <b>not</b> at the class load time of the outer class, | ||
73 | * but rather at the first call to {@link AvailableMemory#instance()}. | ||
74 | * | ||
75 | * <p> This workaround is required e.g. to support recursion. | ||
76 | * | ||
77 | */ | ||
78 | private static class LazyHolder { | ||
79 | private static final AvailableMemory INSTANCE = new AvailableMemory(); | ||
80 | |||
81 | /** | ||
82 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
83 | * This initialization order is required to support indirect recursion. | ||
84 | * | ||
85 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
86 | * | ||
87 | */ | ||
88 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
89 | |||
90 | public static Object ensureInitialized() { | ||
91 | INSTANCE.ensureInitializedInternal(); | ||
92 | return null; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
97 | private static final AvailableMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
98 | |||
99 | private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
100 | |||
101 | private final PParameter parameter_Memory = new PParameter("Memory", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); | ||
102 | |||
103 | private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_Memory); | ||
104 | |||
105 | private GeneratedPQuery() { | ||
106 | super(PVisibility.PRIVATE); | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public String getFullyQualifiedName() { | ||
111 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory"; | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | public List<String> getParameterNames() { | ||
116 | return Arrays.asList("Host","Memory"); | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public List<PParameter> getParameters() { | ||
121 | return parameters; | ||
122 | } | ||
123 | |||
124 | @Override | ||
125 | public Set<PBody> doGetContainedBodies() { | ||
126 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
127 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
128 | { | ||
129 | PBody body = new PBody(this); | ||
130 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
131 | PVariable var_Memory = body.getOrCreateVariableByName("Memory"); | ||
132 | PVariable var_TotalMemory = body.getOrCreateVariableByName("TotalMemory"); | ||
133 | PVariable var_RequiredMemory = body.getOrCreateVariableByName("RequiredMemory"); | ||
134 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
135 | PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); | ||
136 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
137 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Memory), new JavaTransitiveInstancesKey(java.lang.Integer.class)); | ||
138 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
139 | new ExportedParameter(body, var_Host, parameter_Host), | ||
140 | new ExportedParameter(body, var_Memory, parameter_Memory) | ||
141 | )); | ||
142 | // find totalMemory(Host, TotalMemory) | ||
143 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_TotalMemory), TotalMemory.instance().getInternalQueryRepresentation()); | ||
144 | // RequiredMemory == sum find memoryRequirement(Host, _, #_) | ||
145 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
146 | new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Host, var___0_, var___1_), MemoryRequirement.instance().getInternalQueryRepresentation(), var__virtual_0_, 2); | ||
147 | new Equality(body, var_RequiredMemory, var__virtual_0_); | ||
148 | // Memory == eval(TotalMemory - RequiredMemory) | ||
149 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
150 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
151 | |||
152 | @Override | ||
153 | public String getShortDescription() { | ||
154 | return "Expression evaluation from pattern availableMemory"; | ||
155 | } | ||
156 | |||
157 | @Override | ||
158 | public Iterable<String> getInputParameterNames() { | ||
159 | return Arrays.asList("RequiredMemory", "TotalMemory");} | ||
160 | |||
161 | @Override | ||
162 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
163 | Integer RequiredMemory = (Integer) provider.getValue("RequiredMemory"); | ||
164 | Integer TotalMemory = (Integer) provider.getValue("TotalMemory"); | ||
165 | return evaluateExpression_1_1(RequiredMemory, TotalMemory); | ||
166 | } | ||
167 | }, var__virtual_1_ ); | ||
168 | new Equality(body, var_Memory, var__virtual_1_); | ||
169 | bodies.add(body); | ||
170 | } | ||
171 | return bodies; | ||
172 | } | ||
173 | } | ||
174 | |||
175 | private static int evaluateExpression_1_1(final Integer RequiredMemory, final Integer TotalMemory) { | ||
176 | return ((TotalMemory).intValue() - (RequiredMemory).intValue()); | ||
177 | } | ||
178 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsApplications.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsApplications.java new file mode 100644 index 00000000..fe115086 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsApplications.java | |||
@@ -0,0 +1,141 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
13 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
25 | |||
26 | /** | ||
27 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
28 | * | ||
29 | * <p>Original source: | ||
30 | * <code><pre> | ||
31 | * private pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) { | ||
32 | * CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance); | ||
33 | * } | ||
34 | * </pre></code> | ||
35 | * | ||
36 | * @see GenericPatternMatcher | ||
37 | * @see GenericPatternMatch | ||
38 | * | ||
39 | */ | ||
40 | @SuppressWarnings("all") | ||
41 | public final class CpsApplications extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
42 | private CpsApplications() { | ||
43 | super(GeneratedPQuery.INSTANCE); | ||
44 | } | ||
45 | |||
46 | /** | ||
47 | * @return the singleton instance of the query specification | ||
48 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
49 | * | ||
50 | */ | ||
51 | public static CpsApplications instance() { | ||
52 | try{ | ||
53 | return LazyHolder.INSTANCE; | ||
54 | } catch (ExceptionInInitializerError err) { | ||
55 | throw processInitializerError(err); | ||
56 | } | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * Inner class allowing the singleton instance of {@link CpsApplications} to be created | ||
61 | * <b>not</b> at the class load time of the outer class, | ||
62 | * but rather at the first call to {@link CpsApplications#instance()}. | ||
63 | * | ||
64 | * <p> This workaround is required e.g. to support recursion. | ||
65 | * | ||
66 | */ | ||
67 | private static class LazyHolder { | ||
68 | private static final CpsApplications INSTANCE = new CpsApplications(); | ||
69 | |||
70 | /** | ||
71 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
72 | * This initialization order is required to support indirect recursion. | ||
73 | * | ||
74 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
75 | * | ||
76 | */ | ||
77 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
78 | |||
79 | public static Object ensureInitialized() { | ||
80 | INSTANCE.ensureInitializedInternal(); | ||
81 | return null; | ||
82 | } | ||
83 | } | ||
84 | |||
85 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
86 | private static final CpsApplications.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
87 | |||
88 | private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); | ||
89 | |||
90 | private final PParameter parameter_AppInstance = new PParameter("AppInstance", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); | ||
91 | |||
92 | private final List<PParameter> parameters = Arrays.asList(parameter_Cps, parameter_AppInstance); | ||
93 | |||
94 | private GeneratedPQuery() { | ||
95 | super(PVisibility.PRIVATE); | ||
96 | } | ||
97 | |||
98 | @Override | ||
99 | public String getFullyQualifiedName() { | ||
100 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications"; | ||
101 | } | ||
102 | |||
103 | @Override | ||
104 | public List<String> getParameterNames() { | ||
105 | return Arrays.asList("Cps","AppInstance"); | ||
106 | } | ||
107 | |||
108 | @Override | ||
109 | public List<PParameter> getParameters() { | ||
110 | return parameters; | ||
111 | } | ||
112 | |||
113 | @Override | ||
114 | public Set<PBody> doGetContainedBodies() { | ||
115 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
116 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
117 | { | ||
118 | PBody body = new PBody(this); | ||
119 | PVariable var_Cps = body.getOrCreateVariableByName("Cps"); | ||
120 | PVariable var_AppInstance = body.getOrCreateVariableByName("AppInstance"); | ||
121 | new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); | ||
122 | new TypeConstraint(body, Tuples.flatTupleOf(var_AppInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
123 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
124 | new ExportedParameter(body, var_Cps, parameter_Cps), | ||
125 | new ExportedParameter(body, var_AppInstance, parameter_AppInstance) | ||
126 | )); | ||
127 | // CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance) | ||
128 | new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); | ||
129 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Cps, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "CyberPhysicalSystem", "applicationTypes"))); | ||
131 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); | ||
132 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
133 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "instances"))); | ||
134 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
135 | new Equality(body, var__virtual_1_, var_AppInstance); | ||
136 | bodies.add(body); | ||
137 | } | ||
138 | return bodies; | ||
139 | } | ||
140 | } | ||
141 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsHosts.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsHosts.java new file mode 100644 index 00000000..cea8c097 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsHosts.java | |||
@@ -0,0 +1,141 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
13 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
25 | |||
26 | /** | ||
27 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
28 | * | ||
29 | * <p>Original source: | ||
30 | * <code><pre> | ||
31 | * private pattern cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) { | ||
32 | * CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance); | ||
33 | * } | ||
34 | * </pre></code> | ||
35 | * | ||
36 | * @see GenericPatternMatcher | ||
37 | * @see GenericPatternMatch | ||
38 | * | ||
39 | */ | ||
40 | @SuppressWarnings("all") | ||
41 | public final class CpsHosts extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
42 | private CpsHosts() { | ||
43 | super(GeneratedPQuery.INSTANCE); | ||
44 | } | ||
45 | |||
46 | /** | ||
47 | * @return the singleton instance of the query specification | ||
48 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
49 | * | ||
50 | */ | ||
51 | public static CpsHosts instance() { | ||
52 | try{ | ||
53 | return LazyHolder.INSTANCE; | ||
54 | } catch (ExceptionInInitializerError err) { | ||
55 | throw processInitializerError(err); | ||
56 | } | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * Inner class allowing the singleton instance of {@link CpsHosts} to be created | ||
61 | * <b>not</b> at the class load time of the outer class, | ||
62 | * but rather at the first call to {@link CpsHosts#instance()}. | ||
63 | * | ||
64 | * <p> This workaround is required e.g. to support recursion. | ||
65 | * | ||
66 | */ | ||
67 | private static class LazyHolder { | ||
68 | private static final CpsHosts INSTANCE = new CpsHosts(); | ||
69 | |||
70 | /** | ||
71 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
72 | * This initialization order is required to support indirect recursion. | ||
73 | * | ||
74 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
75 | * | ||
76 | */ | ||
77 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
78 | |||
79 | public static Object ensureInitialized() { | ||
80 | INSTANCE.ensureInitializedInternal(); | ||
81 | return null; | ||
82 | } | ||
83 | } | ||
84 | |||
85 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
86 | private static final CpsHosts.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
87 | |||
88 | private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); | ||
89 | |||
90 | private final PParameter parameter_HostInstance = new PParameter("HostInstance", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
91 | |||
92 | private final List<PParameter> parameters = Arrays.asList(parameter_Cps, parameter_HostInstance); | ||
93 | |||
94 | private GeneratedPQuery() { | ||
95 | super(PVisibility.PRIVATE); | ||
96 | } | ||
97 | |||
98 | @Override | ||
99 | public String getFullyQualifiedName() { | ||
100 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts"; | ||
101 | } | ||
102 | |||
103 | @Override | ||
104 | public List<String> getParameterNames() { | ||
105 | return Arrays.asList("Cps","HostInstance"); | ||
106 | } | ||
107 | |||
108 | @Override | ||
109 | public List<PParameter> getParameters() { | ||
110 | return parameters; | ||
111 | } | ||
112 | |||
113 | @Override | ||
114 | public Set<PBody> doGetContainedBodies() { | ||
115 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
116 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
117 | { | ||
118 | PBody body = new PBody(this); | ||
119 | PVariable var_Cps = body.getOrCreateVariableByName("Cps"); | ||
120 | PVariable var_HostInstance = body.getOrCreateVariableByName("HostInstance"); | ||
121 | new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); | ||
122 | new TypeConstraint(body, Tuples.flatTupleOf(var_HostInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
123 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
124 | new ExportedParameter(body, var_Cps, parameter_Cps), | ||
125 | new ExportedParameter(body, var_HostInstance, parameter_HostInstance) | ||
126 | )); | ||
127 | // CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance) | ||
128 | new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); | ||
129 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Cps, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "CyberPhysicalSystem", "hostTypes"))); | ||
131 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); | ||
132 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
133 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "instances"))); | ||
134 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
135 | new Equality(body, var__virtual_1_, var_HostInstance); | ||
136 | bodies.add(body); | ||
137 | } | ||
138 | return bodies; | ||
139 | } | ||
140 | } | ||
141 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java new file mode 100644 index 00000000..67f75e1d --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java | |||
@@ -0,0 +1,132 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric; | ||
10 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric; | ||
11 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost; | ||
12 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance; | ||
13 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective; | ||
14 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement; | ||
15 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd; | ||
16 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory; | ||
17 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RedundantInstancesOnSameHost; | ||
18 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RemoveHostInstance; | ||
19 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied; | ||
20 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement; | ||
21 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.UnallocateAppInstance; | ||
22 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd; | ||
23 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory; | ||
24 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsApplications; | ||
25 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsHosts; | ||
26 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage; | ||
27 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage; | ||
28 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement; | ||
29 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost; | ||
30 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement; | ||
31 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.NoHostToAllocateTo; | ||
32 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.RequiredAppInstances; | ||
33 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance; | ||
34 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd; | ||
35 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory; | ||
36 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance; | ||
37 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; | ||
38 | |||
39 | /** | ||
40 | * A pattern group formed of all patterns defined in CpsQueries.vql. | ||
41 | * | ||
42 | * <p>A private group that includes private patterns as well. Only intended use case is for pattern testing. | ||
43 | * | ||
44 | * <p> From package hu.bme.mit.inf.dslreasoner.domains.cps.queries, the group contains the definition of the following patterns: <ul> | ||
45 | * <li>cpsApplications</li> | ||
46 | * <li>cpsHosts</li> | ||
47 | * <li>totalMemory</li> | ||
48 | * <li>totalHdd</li> | ||
49 | * <li>availableMemory</li> | ||
50 | * <li>memoryRequirement</li> | ||
51 | * <li>availableHdd</li> | ||
52 | * <li>hddRequirement</li> | ||
53 | * <li>resourceRequirement</li> | ||
54 | * <li>allocationWithoutResourceRequirement</li> | ||
55 | * <li>notEnoughAvailableMemory</li> | ||
56 | * <li>notEnoughAvailableHdd</li> | ||
57 | * <li>instanceDoesNotSatisfyRequirement</li> | ||
58 | * <li>satisfyingInstance</li> | ||
59 | * <li>requirementNotSatisfied</li> | ||
60 | * <li>redundantInstancesOnSameHost</li> | ||
61 | * <li>averageFreeMemoryMetric</li> | ||
62 | * <li>freeMemoryPercentage</li> | ||
63 | * <li>averageFreeHddMetric</li> | ||
64 | * <li>freeHddPercentage</li> | ||
65 | * <li>costMetric</li> | ||
66 | * <li>cpsCost</li> | ||
67 | * <li>hostInstanceCost</li> | ||
68 | * <li>allocate</li> | ||
69 | * <li>unallocateAppInstance</li> | ||
70 | * <li>createHostInstance</li> | ||
71 | * <li>removeHostInstance</li> | ||
72 | * <li>unallocatedAppInstance</li> | ||
73 | * <li>requiredAppInstances</li> | ||
74 | * <li>noHostToAllocateTo</li> | ||
75 | * <li>guidanceObjective</li> | ||
76 | * </ul> | ||
77 | * | ||
78 | * @see IQueryGroup | ||
79 | * | ||
80 | */ | ||
81 | @SuppressWarnings("all") | ||
82 | public final class CpsQueriesAll extends BaseGeneratedPatternGroup { | ||
83 | /** | ||
84 | * Access the pattern group. | ||
85 | * | ||
86 | * @return the singleton instance of the group | ||
87 | * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications | ||
88 | * | ||
89 | */ | ||
90 | public static CpsQueriesAll instance() { | ||
91 | if (INSTANCE == null) { | ||
92 | INSTANCE = new CpsQueriesAll(); | ||
93 | } | ||
94 | return INSTANCE; | ||
95 | } | ||
96 | |||
97 | private static CpsQueriesAll INSTANCE; | ||
98 | |||
99 | private CpsQueriesAll() { | ||
100 | querySpecifications.add(CpsApplications.instance()); | ||
101 | querySpecifications.add(CpsHosts.instance()); | ||
102 | querySpecifications.add(TotalMemory.instance()); | ||
103 | querySpecifications.add(TotalHdd.instance()); | ||
104 | querySpecifications.add(AvailableMemory.instance()); | ||
105 | querySpecifications.add(MemoryRequirement.instance()); | ||
106 | querySpecifications.add(AvailableHdd.instance()); | ||
107 | querySpecifications.add(HddRequirement.instance()); | ||
108 | querySpecifications.add(ResourceRequirement.instance()); | ||
109 | querySpecifications.add(AllocationWithoutResourceRequirement.instance()); | ||
110 | querySpecifications.add(NotEnoughAvailableMemory.instance()); | ||
111 | querySpecifications.add(NotEnoughAvailableHdd.instance()); | ||
112 | querySpecifications.add(InstanceDoesNotSatisfyRequirement.instance()); | ||
113 | querySpecifications.add(SatisfyingInstance.instance()); | ||
114 | querySpecifications.add(RequirementNotSatisfied.instance()); | ||
115 | querySpecifications.add(RedundantInstancesOnSameHost.instance()); | ||
116 | querySpecifications.add(AverageFreeMemoryMetric.instance()); | ||
117 | querySpecifications.add(FreeMemoryPercentage.instance()); | ||
118 | querySpecifications.add(AverageFreeHddMetric.instance()); | ||
119 | querySpecifications.add(FreeHddPercentage.instance()); | ||
120 | querySpecifications.add(CostMetric.instance()); | ||
121 | querySpecifications.add(CpsCost.instance()); | ||
122 | querySpecifications.add(HostInstanceCost.instance()); | ||
123 | querySpecifications.add(Allocate.instance()); | ||
124 | querySpecifications.add(UnallocateAppInstance.instance()); | ||
125 | querySpecifications.add(CreateHostInstance.instance()); | ||
126 | querySpecifications.add(RemoveHostInstance.instance()); | ||
127 | querySpecifications.add(UnallocatedAppInstance.instance()); | ||
128 | querySpecifications.add(RequiredAppInstances.instance()); | ||
129 | querySpecifications.add(NoHostToAllocateTo.instance()); | ||
130 | querySpecifications.add(GuidanceObjective.instance()); | ||
131 | } | ||
132 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java new file mode 100644 index 00000000..ed5c9cda --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java | |||
@@ -0,0 +1,172 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Set; | ||
12 | import org.eclipse.emf.ecore.EClass; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
14 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
32 | |||
33 | /** | ||
34 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
35 | * | ||
36 | * <p>Original source: | ||
37 | * <code><pre> | ||
38 | * private pattern freeHddPercentage(Host : HostInstance, Free : java Double) { | ||
39 | * find totalHdd(Host, Total); | ||
40 | * find availableHdd(Host, Available); | ||
41 | * Free == eval((Available as double) / Total); | ||
42 | * } | ||
43 | * </pre></code> | ||
44 | * | ||
45 | * @see GenericPatternMatcher | ||
46 | * @see GenericPatternMatch | ||
47 | * | ||
48 | */ | ||
49 | @SuppressWarnings("all") | ||
50 | public final class FreeHddPercentage extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
51 | private FreeHddPercentage() { | ||
52 | super(GeneratedPQuery.INSTANCE); | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * @return the singleton instance of the query specification | ||
57 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
58 | * | ||
59 | */ | ||
60 | public static FreeHddPercentage instance() { | ||
61 | try{ | ||
62 | return LazyHolder.INSTANCE; | ||
63 | } catch (ExceptionInInitializerError err) { | ||
64 | throw processInitializerError(err); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * Inner class allowing the singleton instance of {@link FreeHddPercentage} to be created | ||
70 | * <b>not</b> at the class load time of the outer class, | ||
71 | * but rather at the first call to {@link FreeHddPercentage#instance()}. | ||
72 | * | ||
73 | * <p> This workaround is required e.g. to support recursion. | ||
74 | * | ||
75 | */ | ||
76 | private static class LazyHolder { | ||
77 | private static final FreeHddPercentage INSTANCE = new FreeHddPercentage(); | ||
78 | |||
79 | /** | ||
80 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
81 | * This initialization order is required to support indirect recursion. | ||
82 | * | ||
83 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
84 | * | ||
85 | */ | ||
86 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
87 | |||
88 | public static Object ensureInitialized() { | ||
89 | INSTANCE.ensureInitializedInternal(); | ||
90 | return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
95 | private static final FreeHddPercentage.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
96 | |||
97 | private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
98 | |||
99 | private final PParameter parameter_Free = new PParameter("Free", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
100 | |||
101 | private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_Free); | ||
102 | |||
103 | private GeneratedPQuery() { | ||
104 | super(PVisibility.PRIVATE); | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public String getFullyQualifiedName() { | ||
109 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.freeHddPercentage"; | ||
110 | } | ||
111 | |||
112 | @Override | ||
113 | public List<String> getParameterNames() { | ||
114 | return Arrays.asList("Host","Free"); | ||
115 | } | ||
116 | |||
117 | @Override | ||
118 | public List<PParameter> getParameters() { | ||
119 | return parameters; | ||
120 | } | ||
121 | |||
122 | @Override | ||
123 | public Set<PBody> doGetContainedBodies() { | ||
124 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
125 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
126 | { | ||
127 | PBody body = new PBody(this); | ||
128 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
129 | PVariable var_Free = body.getOrCreateVariableByName("Free"); | ||
130 | PVariable var_Total = body.getOrCreateVariableByName("Total"); | ||
131 | PVariable var_Available = body.getOrCreateVariableByName("Available"); | ||
132 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
133 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Free), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
134 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
135 | new ExportedParameter(body, var_Host, parameter_Host), | ||
136 | new ExportedParameter(body, var_Free, parameter_Free) | ||
137 | )); | ||
138 | // find totalHdd(Host, Total) | ||
139 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Total), TotalHdd.instance().getInternalQueryRepresentation()); | ||
140 | // find availableHdd(Host, Available) | ||
141 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Available), AvailableHdd.instance().getInternalQueryRepresentation()); | ||
142 | // Free == eval((Available as double) / Total) | ||
143 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
144 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
145 | |||
146 | @Override | ||
147 | public String getShortDescription() { | ||
148 | return "Expression evaluation from pattern freeHddPercentage"; | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public Iterable<String> getInputParameterNames() { | ||
153 | return Arrays.asList("Available", "Total");} | ||
154 | |||
155 | @Override | ||
156 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
157 | Integer Available = (Integer) provider.getValue("Available"); | ||
158 | Integer Total = (Integer) provider.getValue("Total"); | ||
159 | return evaluateExpression_1_1(Available, Total); | ||
160 | } | ||
161 | }, var__virtual_0_ ); | ||
162 | new Equality(body, var_Free, var__virtual_0_); | ||
163 | bodies.add(body); | ||
164 | } | ||
165 | return bodies; | ||
166 | } | ||
167 | } | ||
168 | |||
169 | private static double evaluateExpression_1_1(final Integer Available, final Integer Total) { | ||
170 | return (((double) (Available).intValue()) / (Total).intValue()); | ||
171 | } | ||
172 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java new file mode 100644 index 00000000..b5923ba9 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java | |||
@@ -0,0 +1,172 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Set; | ||
12 | import org.eclipse.emf.ecore.EClass; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
14 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
32 | |||
33 | /** | ||
34 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
35 | * | ||
36 | * <p>Original source: | ||
37 | * <code><pre> | ||
38 | * private pattern freeMemoryPercentage(Host : HostInstance, Free : java Double) { | ||
39 | * find totalMemory(Host, Total); | ||
40 | * find availableMemory(Host, Available); | ||
41 | * Free == eval((Available as double) / Total); | ||
42 | * } | ||
43 | * </pre></code> | ||
44 | * | ||
45 | * @see GenericPatternMatcher | ||
46 | * @see GenericPatternMatch | ||
47 | * | ||
48 | */ | ||
49 | @SuppressWarnings("all") | ||
50 | public final class FreeMemoryPercentage extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
51 | private FreeMemoryPercentage() { | ||
52 | super(GeneratedPQuery.INSTANCE); | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * @return the singleton instance of the query specification | ||
57 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
58 | * | ||
59 | */ | ||
60 | public static FreeMemoryPercentage instance() { | ||
61 | try{ | ||
62 | return LazyHolder.INSTANCE; | ||
63 | } catch (ExceptionInInitializerError err) { | ||
64 | throw processInitializerError(err); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * Inner class allowing the singleton instance of {@link FreeMemoryPercentage} to be created | ||
70 | * <b>not</b> at the class load time of the outer class, | ||
71 | * but rather at the first call to {@link FreeMemoryPercentage#instance()}. | ||
72 | * | ||
73 | * <p> This workaround is required e.g. to support recursion. | ||
74 | * | ||
75 | */ | ||
76 | private static class LazyHolder { | ||
77 | private static final FreeMemoryPercentage INSTANCE = new FreeMemoryPercentage(); | ||
78 | |||
79 | /** | ||
80 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
81 | * This initialization order is required to support indirect recursion. | ||
82 | * | ||
83 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
84 | * | ||
85 | */ | ||
86 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
87 | |||
88 | public static Object ensureInitialized() { | ||
89 | INSTANCE.ensureInitializedInternal(); | ||
90 | return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
95 | private static final FreeMemoryPercentage.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
96 | |||
97 | private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
98 | |||
99 | private final PParameter parameter_Free = new PParameter("Free", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
100 | |||
101 | private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_Free); | ||
102 | |||
103 | private GeneratedPQuery() { | ||
104 | super(PVisibility.PRIVATE); | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public String getFullyQualifiedName() { | ||
109 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.freeMemoryPercentage"; | ||
110 | } | ||
111 | |||
112 | @Override | ||
113 | public List<String> getParameterNames() { | ||
114 | return Arrays.asList("Host","Free"); | ||
115 | } | ||
116 | |||
117 | @Override | ||
118 | public List<PParameter> getParameters() { | ||
119 | return parameters; | ||
120 | } | ||
121 | |||
122 | @Override | ||
123 | public Set<PBody> doGetContainedBodies() { | ||
124 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
125 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
126 | { | ||
127 | PBody body = new PBody(this); | ||
128 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
129 | PVariable var_Free = body.getOrCreateVariableByName("Free"); | ||
130 | PVariable var_Total = body.getOrCreateVariableByName("Total"); | ||
131 | PVariable var_Available = body.getOrCreateVariableByName("Available"); | ||
132 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
133 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Free), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
134 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
135 | new ExportedParameter(body, var_Host, parameter_Host), | ||
136 | new ExportedParameter(body, var_Free, parameter_Free) | ||
137 | )); | ||
138 | // find totalMemory(Host, Total) | ||
139 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Total), TotalMemory.instance().getInternalQueryRepresentation()); | ||
140 | // find availableMemory(Host, Available) | ||
141 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Available), AvailableMemory.instance().getInternalQueryRepresentation()); | ||
142 | // Free == eval((Available as double) / Total) | ||
143 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
144 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
145 | |||
146 | @Override | ||
147 | public String getShortDescription() { | ||
148 | return "Expression evaluation from pattern freeMemoryPercentage"; | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public Iterable<String> getInputParameterNames() { | ||
153 | return Arrays.asList("Available", "Total");} | ||
154 | |||
155 | @Override | ||
156 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
157 | Integer Available = (Integer) provider.getValue("Available"); | ||
158 | Integer Total = (Integer) provider.getValue("Total"); | ||
159 | return evaluateExpression_1_1(Available, Total); | ||
160 | } | ||
161 | }, var__virtual_0_ ); | ||
162 | new Equality(body, var_Free, var__virtual_0_); | ||
163 | bodies.add(body); | ||
164 | } | ||
165 | return bodies; | ||
166 | } | ||
167 | } | ||
168 | |||
169 | private static double evaluateExpression_1_1(final Integer Available, final Integer Total) { | ||
170 | return (((double) (Available).intValue()) / (Total).intValue()); | ||
171 | } | ||
172 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java new file mode 100644 index 00000000..4e6a2d10 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java | |||
@@ -0,0 +1,151 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.emf.ecore.EDataType; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
14 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
17 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
29 | |||
30 | /** | ||
31 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
32 | * | ||
33 | * <p>Original source: | ||
34 | * <code><pre> | ||
35 | * private pattern hddRequirement(Host : HostInstance, App : ApplicationInstance, Hdd : EInt) { | ||
36 | * find resourceRequirement(Host, App, Req); | ||
37 | * ResourceRequirement.requiredHdd(Req, Hdd); | ||
38 | * } | ||
39 | * </pre></code> | ||
40 | * | ||
41 | * @see GenericPatternMatcher | ||
42 | * @see GenericPatternMatch | ||
43 | * | ||
44 | */ | ||
45 | @SuppressWarnings("all") | ||
46 | public final class HddRequirement extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
47 | private HddRequirement() { | ||
48 | super(GeneratedPQuery.INSTANCE); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * @return the singleton instance of the query specification | ||
53 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
54 | * | ||
55 | */ | ||
56 | public static HddRequirement instance() { | ||
57 | try{ | ||
58 | return LazyHolder.INSTANCE; | ||
59 | } catch (ExceptionInInitializerError err) { | ||
60 | throw processInitializerError(err); | ||
61 | } | ||
62 | } | ||
63 | |||
64 | /** | ||
65 | * Inner class allowing the singleton instance of {@link HddRequirement} to be created | ||
66 | * <b>not</b> at the class load time of the outer class, | ||
67 | * but rather at the first call to {@link HddRequirement#instance()}. | ||
68 | * | ||
69 | * <p> This workaround is required e.g. to support recursion. | ||
70 | * | ||
71 | */ | ||
72 | private static class LazyHolder { | ||
73 | private static final HddRequirement INSTANCE = new HddRequirement(); | ||
74 | |||
75 | /** | ||
76 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
77 | * This initialization order is required to support indirect recursion. | ||
78 | * | ||
79 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
80 | * | ||
81 | */ | ||
82 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
83 | |||
84 | public static Object ensureInitialized() { | ||
85 | INSTANCE.ensureInitializedInternal(); | ||
86 | return null; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
91 | private static final HddRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
92 | |||
93 | private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
94 | |||
95 | private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); | ||
96 | |||
97 | private final PParameter parameter_Hdd = new PParameter("Hdd", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); | ||
98 | |||
99 | private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_App, parameter_Hdd); | ||
100 | |||
101 | private GeneratedPQuery() { | ||
102 | super(PVisibility.PRIVATE); | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public String getFullyQualifiedName() { | ||
107 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.hddRequirement"; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public List<String> getParameterNames() { | ||
112 | return Arrays.asList("Host","App","Hdd"); | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public List<PParameter> getParameters() { | ||
117 | return parameters; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public Set<PBody> doGetContainedBodies() { | ||
122 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
123 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
124 | { | ||
125 | PBody body = new PBody(this); | ||
126 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
127 | PVariable var_App = body.getOrCreateVariableByName("App"); | ||
128 | PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); | ||
129 | PVariable var_Req = body.getOrCreateVariableByName("Req"); | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
131 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
132 | new TypeConstraint(body, Tuples.flatTupleOf(var_Hdd), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
133 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
134 | new ExportedParameter(body, var_Host, parameter_Host), | ||
135 | new ExportedParameter(body, var_App, parameter_App), | ||
136 | new ExportedParameter(body, var_Hdd, parameter_Hdd) | ||
137 | )); | ||
138 | // find resourceRequirement(Host, App, Req) | ||
139 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_App, var_Req), ResourceRequirement.instance().getInternalQueryRepresentation()); | ||
140 | // ResourceRequirement.requiredHdd(Req, Hdd) | ||
141 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); | ||
142 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
143 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "requiredHdd"))); | ||
144 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
145 | new Equality(body, var__virtual_0_, var_Hdd); | ||
146 | bodies.add(body); | ||
147 | } | ||
148 | return bodies; | ||
149 | } | ||
150 | } | ||
151 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java new file mode 100644 index 00000000..429817ce --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java | |||
@@ -0,0 +1,153 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsHosts; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.emf.ecore.EDataType; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
14 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
17 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
29 | |||
30 | /** | ||
31 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
32 | * | ||
33 | * <p>Original source: | ||
34 | * <code><pre> | ||
35 | * private pattern hostInstanceCost(Cps : CyberPhysicalSystem, Host : HostInstance, Cost : EInt) { | ||
36 | * find cpsHosts(Cps, Host); | ||
37 | * HostInstance.type.cost(Host, Cost); | ||
38 | * } | ||
39 | * </pre></code> | ||
40 | * | ||
41 | * @see GenericPatternMatcher | ||
42 | * @see GenericPatternMatch | ||
43 | * | ||
44 | */ | ||
45 | @SuppressWarnings("all") | ||
46 | public final class HostInstanceCost extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
47 | private HostInstanceCost() { | ||
48 | super(GeneratedPQuery.INSTANCE); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * @return the singleton instance of the query specification | ||
53 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
54 | * | ||
55 | */ | ||
56 | public static HostInstanceCost instance() { | ||
57 | try{ | ||
58 | return LazyHolder.INSTANCE; | ||
59 | } catch (ExceptionInInitializerError err) { | ||
60 | throw processInitializerError(err); | ||
61 | } | ||
62 | } | ||
63 | |||
64 | /** | ||
65 | * Inner class allowing the singleton instance of {@link HostInstanceCost} to be created | ||
66 | * <b>not</b> at the class load time of the outer class, | ||
67 | * but rather at the first call to {@link HostInstanceCost#instance()}. | ||
68 | * | ||
69 | * <p> This workaround is required e.g. to support recursion. | ||
70 | * | ||
71 | */ | ||
72 | private static class LazyHolder { | ||
73 | private static final HostInstanceCost INSTANCE = new HostInstanceCost(); | ||
74 | |||
75 | /** | ||
76 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
77 | * This initialization order is required to support indirect recursion. | ||
78 | * | ||
79 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
80 | * | ||
81 | */ | ||
82 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
83 | |||
84 | public static Object ensureInitialized() { | ||
85 | INSTANCE.ensureInitializedInternal(); | ||
86 | return null; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
91 | private static final HostInstanceCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
92 | |||
93 | private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); | ||
94 | |||
95 | private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
96 | |||
97 | private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); | ||
98 | |||
99 | private final List<PParameter> parameters = Arrays.asList(parameter_Cps, parameter_Host, parameter_Cost); | ||
100 | |||
101 | private GeneratedPQuery() { | ||
102 | super(PVisibility.PRIVATE); | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public String getFullyQualifiedName() { | ||
107 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.hostInstanceCost"; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public List<String> getParameterNames() { | ||
112 | return Arrays.asList("Cps","Host","Cost"); | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public List<PParameter> getParameters() { | ||
117 | return parameters; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public Set<PBody> doGetContainedBodies() { | ||
122 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
123 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
124 | { | ||
125 | PBody body = new PBody(this); | ||
126 | PVariable var_Cps = body.getOrCreateVariableByName("Cps"); | ||
127 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
128 | PVariable var_Cost = body.getOrCreateVariableByName("Cost"); | ||
129 | new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
131 | new TypeConstraint(body, Tuples.flatTupleOf(var_Cost), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
132 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
133 | new ExportedParameter(body, var_Cps, parameter_Cps), | ||
134 | new ExportedParameter(body, var_Host, parameter_Host), | ||
135 | new ExportedParameter(body, var_Cost, parameter_Cost) | ||
136 | )); | ||
137 | // find cpsHosts(Cps, Host) | ||
138 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Cps, var_Host), CpsHosts.instance().getInternalQueryRepresentation()); | ||
139 | // HostInstance.type.cost(Host, Cost) | ||
140 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
141 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
142 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); | ||
143 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); | ||
144 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
145 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "cost"))); | ||
146 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
147 | new Equality(body, var__virtual_1_, var_Cost); | ||
148 | bodies.add(body); | ||
149 | } | ||
150 | return bodies; | ||
151 | } | ||
152 | } | ||
153 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java new file mode 100644 index 00000000..98924467 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java | |||
@@ -0,0 +1,151 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.emf.ecore.EDataType; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
14 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
17 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
29 | |||
30 | /** | ||
31 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
32 | * | ||
33 | * <p>Original source: | ||
34 | * <code><pre> | ||
35 | * private pattern memoryRequirement(Host : HostInstance, App : ApplicationInstance, Memory : EInt) { | ||
36 | * find resourceRequirement(Host, App, Req); | ||
37 | * ResourceRequirement.requiredMemory(Req, Memory); | ||
38 | * } | ||
39 | * </pre></code> | ||
40 | * | ||
41 | * @see GenericPatternMatcher | ||
42 | * @see GenericPatternMatch | ||
43 | * | ||
44 | */ | ||
45 | @SuppressWarnings("all") | ||
46 | public final class MemoryRequirement extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
47 | private MemoryRequirement() { | ||
48 | super(GeneratedPQuery.INSTANCE); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * @return the singleton instance of the query specification | ||
53 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
54 | * | ||
55 | */ | ||
56 | public static MemoryRequirement instance() { | ||
57 | try{ | ||
58 | return LazyHolder.INSTANCE; | ||
59 | } catch (ExceptionInInitializerError err) { | ||
60 | throw processInitializerError(err); | ||
61 | } | ||
62 | } | ||
63 | |||
64 | /** | ||
65 | * Inner class allowing the singleton instance of {@link MemoryRequirement} to be created | ||
66 | * <b>not</b> at the class load time of the outer class, | ||
67 | * but rather at the first call to {@link MemoryRequirement#instance()}. | ||
68 | * | ||
69 | * <p> This workaround is required e.g. to support recursion. | ||
70 | * | ||
71 | */ | ||
72 | private static class LazyHolder { | ||
73 | private static final MemoryRequirement INSTANCE = new MemoryRequirement(); | ||
74 | |||
75 | /** | ||
76 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
77 | * This initialization order is required to support indirect recursion. | ||
78 | * | ||
79 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
80 | * | ||
81 | */ | ||
82 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
83 | |||
84 | public static Object ensureInitialized() { | ||
85 | INSTANCE.ensureInitializedInternal(); | ||
86 | return null; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
91 | private static final MemoryRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
92 | |||
93 | private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
94 | |||
95 | private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); | ||
96 | |||
97 | private final PParameter parameter_Memory = new PParameter("Memory", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); | ||
98 | |||
99 | private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_App, parameter_Memory); | ||
100 | |||
101 | private GeneratedPQuery() { | ||
102 | super(PVisibility.PRIVATE); | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public String getFullyQualifiedName() { | ||
107 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.memoryRequirement"; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public List<String> getParameterNames() { | ||
112 | return Arrays.asList("Host","App","Memory"); | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public List<PParameter> getParameters() { | ||
117 | return parameters; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public Set<PBody> doGetContainedBodies() { | ||
122 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
123 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
124 | { | ||
125 | PBody body = new PBody(this); | ||
126 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
127 | PVariable var_App = body.getOrCreateVariableByName("App"); | ||
128 | PVariable var_Memory = body.getOrCreateVariableByName("Memory"); | ||
129 | PVariable var_Req = body.getOrCreateVariableByName("Req"); | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
131 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
132 | new TypeConstraint(body, Tuples.flatTupleOf(var_Memory), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
133 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
134 | new ExportedParameter(body, var_Host, parameter_Host), | ||
135 | new ExportedParameter(body, var_App, parameter_App), | ||
136 | new ExportedParameter(body, var_Memory, parameter_Memory) | ||
137 | )); | ||
138 | // find resourceRequirement(Host, App, Req) | ||
139 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_App, var_Req), ResourceRequirement.instance().getInternalQueryRepresentation()); | ||
140 | // ResourceRequirement.requiredMemory(Req, Memory) | ||
141 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); | ||
142 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
143 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "requiredMemory"))); | ||
144 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
145 | new Equality(body, var__virtual_0_, var_Memory); | ||
146 | bodies.add(body); | ||
147 | } | ||
148 | return bodies; | ||
149 | } | ||
150 | } | ||
151 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/NoHostToAllocateTo.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/NoHostToAllocateTo.java new file mode 100644 index 00000000..155ed09b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/NoHostToAllocateTo.java | |||
@@ -0,0 +1,135 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Set; | ||
12 | import org.eclipse.emf.ecore.EClass; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
14 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
27 | |||
28 | /** | ||
29 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
30 | * | ||
31 | * <p>Original source: | ||
32 | * <code><pre> | ||
33 | * private pattern noHostToAllocateTo(App : ApplicationInstance) { | ||
34 | * find unallocatedAppInstance(App); | ||
35 | * neg find allocate(App, _); | ||
36 | * } | ||
37 | * </pre></code> | ||
38 | * | ||
39 | * @see GenericPatternMatcher | ||
40 | * @see GenericPatternMatch | ||
41 | * | ||
42 | */ | ||
43 | @SuppressWarnings("all") | ||
44 | public final class NoHostToAllocateTo extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
45 | private NoHostToAllocateTo() { | ||
46 | super(GeneratedPQuery.INSTANCE); | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * @return the singleton instance of the query specification | ||
51 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
52 | * | ||
53 | */ | ||
54 | public static NoHostToAllocateTo instance() { | ||
55 | try{ | ||
56 | return LazyHolder.INSTANCE; | ||
57 | } catch (ExceptionInInitializerError err) { | ||
58 | throw processInitializerError(err); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * Inner class allowing the singleton instance of {@link NoHostToAllocateTo} to be created | ||
64 | * <b>not</b> at the class load time of the outer class, | ||
65 | * but rather at the first call to {@link NoHostToAllocateTo#instance()}. | ||
66 | * | ||
67 | * <p> This workaround is required e.g. to support recursion. | ||
68 | * | ||
69 | */ | ||
70 | private static class LazyHolder { | ||
71 | private static final NoHostToAllocateTo INSTANCE = new NoHostToAllocateTo(); | ||
72 | |||
73 | /** | ||
74 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
75 | * This initialization order is required to support indirect recursion. | ||
76 | * | ||
77 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
78 | * | ||
79 | */ | ||
80 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
81 | |||
82 | public static Object ensureInitialized() { | ||
83 | INSTANCE.ensureInitializedInternal(); | ||
84 | return null; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
89 | private static final NoHostToAllocateTo.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
90 | |||
91 | private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); | ||
92 | |||
93 | private final List<PParameter> parameters = Arrays.asList(parameter_App); | ||
94 | |||
95 | private GeneratedPQuery() { | ||
96 | super(PVisibility.PRIVATE); | ||
97 | } | ||
98 | |||
99 | @Override | ||
100 | public String getFullyQualifiedName() { | ||
101 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.noHostToAllocateTo"; | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public List<String> getParameterNames() { | ||
106 | return Arrays.asList("App"); | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public List<PParameter> getParameters() { | ||
111 | return parameters; | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | public Set<PBody> doGetContainedBodies() { | ||
116 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
117 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
118 | { | ||
119 | PBody body = new PBody(this); | ||
120 | PVariable var_App = body.getOrCreateVariableByName("App"); | ||
121 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
122 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
123 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
124 | new ExportedParameter(body, var_App, parameter_App) | ||
125 | )); | ||
126 | // find unallocatedAppInstance(App) | ||
127 | new PositivePatternCall(body, Tuples.flatTupleOf(var_App), UnallocatedAppInstance.instance().getInternalQueryRepresentation()); | ||
128 | // neg find allocate(App, _) | ||
129 | new NegativePatternCall(body, Tuples.flatTupleOf(var_App, var___0_), Allocate.instance().getInternalQueryRepresentation()); | ||
130 | bodies.add(body); | ||
131 | } | ||
132 | return bodies; | ||
133 | } | ||
134 | } | ||
135 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/RequiredAppInstances.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/RequiredAppInstances.java new file mode 100644 index 00000000..ffce9148 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/RequiredAppInstances.java | |||
@@ -0,0 +1,181 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.emf.ecore.EDataType; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
14 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
17 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
34 | |||
35 | /** | ||
36 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
37 | * | ||
38 | * <p>Original source: | ||
39 | * <code><pre> | ||
40 | * private pattern requiredAppInstances(Req : Requirement, Remaining : java Integer) { | ||
41 | * Instances == count find satisfyingInstance(Req, _); | ||
42 | * Requirement.count(Req, RequiredCount); | ||
43 | * Remaining == eval(RequiredCount - Instances); | ||
44 | * } | ||
45 | * </pre></code> | ||
46 | * | ||
47 | * @see GenericPatternMatcher | ||
48 | * @see GenericPatternMatch | ||
49 | * | ||
50 | */ | ||
51 | @SuppressWarnings("all") | ||
52 | public final class RequiredAppInstances extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
53 | private RequiredAppInstances() { | ||
54 | super(GeneratedPQuery.INSTANCE); | ||
55 | } | ||
56 | |||
57 | /** | ||
58 | * @return the singleton instance of the query specification | ||
59 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
60 | * | ||
61 | */ | ||
62 | public static RequiredAppInstances instance() { | ||
63 | try{ | ||
64 | return LazyHolder.INSTANCE; | ||
65 | } catch (ExceptionInInitializerError err) { | ||
66 | throw processInitializerError(err); | ||
67 | } | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * Inner class allowing the singleton instance of {@link RequiredAppInstances} to be created | ||
72 | * <b>not</b> at the class load time of the outer class, | ||
73 | * but rather at the first call to {@link RequiredAppInstances#instance()}. | ||
74 | * | ||
75 | * <p> This workaround is required e.g. to support recursion. | ||
76 | * | ||
77 | */ | ||
78 | private static class LazyHolder { | ||
79 | private static final RequiredAppInstances INSTANCE = new RequiredAppInstances(); | ||
80 | |||
81 | /** | ||
82 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
83 | * This initialization order is required to support indirect recursion. | ||
84 | * | ||
85 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
86 | * | ||
87 | */ | ||
88 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
89 | |||
90 | public static Object ensureInitialized() { | ||
91 | INSTANCE.ensureInitializedInternal(); | ||
92 | return null; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
97 | private static final RequiredAppInstances.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
98 | |||
99 | private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.Requirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "Requirement")), PParameterDirection.INOUT); | ||
100 | |||
101 | private final PParameter parameter_Remaining = new PParameter("Remaining", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); | ||
102 | |||
103 | private final List<PParameter> parameters = Arrays.asList(parameter_Req, parameter_Remaining); | ||
104 | |||
105 | private GeneratedPQuery() { | ||
106 | super(PVisibility.PRIVATE); | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public String getFullyQualifiedName() { | ||
111 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.requiredAppInstances"; | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | public List<String> getParameterNames() { | ||
116 | return Arrays.asList("Req","Remaining"); | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public List<PParameter> getParameters() { | ||
121 | return parameters; | ||
122 | } | ||
123 | |||
124 | @Override | ||
125 | public Set<PBody> doGetContainedBodies() { | ||
126 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
127 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
128 | { | ||
129 | PBody body = new PBody(this); | ||
130 | PVariable var_Req = body.getOrCreateVariableByName("Req"); | ||
131 | PVariable var_Remaining = body.getOrCreateVariableByName("Remaining"); | ||
132 | PVariable var_Instances = body.getOrCreateVariableByName("Instances"); | ||
133 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
134 | PVariable var_RequiredCount = body.getOrCreateVariableByName("RequiredCount"); | ||
135 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); | ||
136 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Remaining), new JavaTransitiveInstancesKey(java.lang.Integer.class)); | ||
137 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
138 | new ExportedParameter(body, var_Req, parameter_Req), | ||
139 | new ExportedParameter(body, var_Remaining, parameter_Remaining) | ||
140 | )); | ||
141 | // Instances == count find satisfyingInstance(Req, _) | ||
142 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
143 | new PatternMatchCounter(body, Tuples.flatTupleOf(var_Req, var___0_), SatisfyingInstance.instance().getInternalQueryRepresentation(), var__virtual_0_); | ||
144 | new Equality(body, var_Instances, var__virtual_0_); | ||
145 | // Requirement.count(Req, RequiredCount) | ||
146 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); | ||
147 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
148 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "count"))); | ||
149 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
150 | new Equality(body, var__virtual_1_, var_RequiredCount); | ||
151 | // Remaining == eval(RequiredCount - Instances) | ||
152 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
153 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
154 | |||
155 | @Override | ||
156 | public String getShortDescription() { | ||
157 | return "Expression evaluation from pattern requiredAppInstances"; | ||
158 | } | ||
159 | |||
160 | @Override | ||
161 | public Iterable<String> getInputParameterNames() { | ||
162 | return Arrays.asList("Instances", "RequiredCount");} | ||
163 | |||
164 | @Override | ||
165 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
166 | Integer Instances = (Integer) provider.getValue("Instances"); | ||
167 | Integer RequiredCount = (Integer) provider.getValue("RequiredCount"); | ||
168 | return evaluateExpression_1_1(Instances, RequiredCount); | ||
169 | } | ||
170 | }, var__virtual_2_ ); | ||
171 | new Equality(body, var_Remaining, var__virtual_2_); | ||
172 | bodies.add(body); | ||
173 | } | ||
174 | return bodies; | ||
175 | } | ||
176 | } | ||
177 | |||
178 | private static int evaluateExpression_1_1(final Integer Instances, final Integer RequiredCount) { | ||
179 | return ((RequiredCount).intValue() - (Instances).intValue()); | ||
180 | } | ||
181 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/SatisfyingInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/SatisfyingInstance.java new file mode 100644 index 00000000..dea68f94 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/SatisfyingInstance.java | |||
@@ -0,0 +1,153 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
13 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
25 | |||
26 | /** | ||
27 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
28 | * | ||
29 | * <p>Original source: | ||
30 | * <code><pre> | ||
31 | * private pattern satisfyingInstance(Req : Requirement, App : ApplicationInstance) { | ||
32 | * Requirement.instances(Req, App); | ||
33 | * Requirement.type(Req, Type); | ||
34 | * ApplicationInstance.type(App, Type); | ||
35 | * } | ||
36 | * </pre></code> | ||
37 | * | ||
38 | * @see GenericPatternMatcher | ||
39 | * @see GenericPatternMatch | ||
40 | * | ||
41 | */ | ||
42 | @SuppressWarnings("all") | ||
43 | public final class SatisfyingInstance extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
44 | private SatisfyingInstance() { | ||
45 | super(GeneratedPQuery.INSTANCE); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * @return the singleton instance of the query specification | ||
50 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
51 | * | ||
52 | */ | ||
53 | public static SatisfyingInstance instance() { | ||
54 | try{ | ||
55 | return LazyHolder.INSTANCE; | ||
56 | } catch (ExceptionInInitializerError err) { | ||
57 | throw processInitializerError(err); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * Inner class allowing the singleton instance of {@link SatisfyingInstance} to be created | ||
63 | * <b>not</b> at the class load time of the outer class, | ||
64 | * but rather at the first call to {@link SatisfyingInstance#instance()}. | ||
65 | * | ||
66 | * <p> This workaround is required e.g. to support recursion. | ||
67 | * | ||
68 | */ | ||
69 | private static class LazyHolder { | ||
70 | private static final SatisfyingInstance INSTANCE = new SatisfyingInstance(); | ||
71 | |||
72 | /** | ||
73 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
74 | * This initialization order is required to support indirect recursion. | ||
75 | * | ||
76 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
77 | * | ||
78 | */ | ||
79 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
80 | |||
81 | public static Object ensureInitialized() { | ||
82 | INSTANCE.ensureInitializedInternal(); | ||
83 | return null; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
88 | private static final SatisfyingInstance.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
89 | |||
90 | private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.Requirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "Requirement")), PParameterDirection.INOUT); | ||
91 | |||
92 | private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); | ||
93 | |||
94 | private final List<PParameter> parameters = Arrays.asList(parameter_Req, parameter_App); | ||
95 | |||
96 | private GeneratedPQuery() { | ||
97 | super(PVisibility.PRIVATE); | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public String getFullyQualifiedName() { | ||
102 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.satisfyingInstance"; | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public List<String> getParameterNames() { | ||
107 | return Arrays.asList("Req","App"); | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public List<PParameter> getParameters() { | ||
112 | return parameters; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public Set<PBody> doGetContainedBodies() { | ||
117 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
118 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
119 | { | ||
120 | PBody body = new PBody(this); | ||
121 | PVariable var_Req = body.getOrCreateVariableByName("Req"); | ||
122 | PVariable var_App = body.getOrCreateVariableByName("App"); | ||
123 | PVariable var_Type = body.getOrCreateVariableByName("Type"); | ||
124 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); | ||
125 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
126 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
127 | new ExportedParameter(body, var_Req, parameter_Req), | ||
128 | new ExportedParameter(body, var_App, parameter_App) | ||
129 | )); | ||
130 | // Requirement.instances(Req, App) | ||
131 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); | ||
132 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
133 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "instances"))); | ||
134 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
135 | new Equality(body, var__virtual_0_, var_App); | ||
136 | // Requirement.type(Req, Type) | ||
137 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); | ||
138 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
139 | new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "type"))); | ||
140 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); | ||
141 | new Equality(body, var__virtual_1_, var_Type); | ||
142 | // ApplicationInstance.type(App, Type) | ||
143 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
144 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
145 | new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type"))); | ||
146 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); | ||
147 | new Equality(body, var__virtual_2_, var_Type); | ||
148 | bodies.add(body); | ||
149 | } | ||
150 | return bodies; | ||
151 | } | ||
152 | } | ||
153 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalHdd.java new file mode 100644 index 00000000..efa13033 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalHdd.java | |||
@@ -0,0 +1,143 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.emf.ecore.EDataType; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
27 | |||
28 | /** | ||
29 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
30 | * | ||
31 | * <p>Original source: | ||
32 | * <code><pre> | ||
33 | * private pattern totalHdd(Host : HostInstance, Hdd : EInt) { | ||
34 | * HostInstance.type.defaultHdd(Host, Hdd); | ||
35 | * } | ||
36 | * </pre></code> | ||
37 | * | ||
38 | * @see GenericPatternMatcher | ||
39 | * @see GenericPatternMatch | ||
40 | * | ||
41 | */ | ||
42 | @SuppressWarnings("all") | ||
43 | public final class TotalHdd extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
44 | private TotalHdd() { | ||
45 | super(GeneratedPQuery.INSTANCE); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * @return the singleton instance of the query specification | ||
50 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
51 | * | ||
52 | */ | ||
53 | public static TotalHdd instance() { | ||
54 | try{ | ||
55 | return LazyHolder.INSTANCE; | ||
56 | } catch (ExceptionInInitializerError err) { | ||
57 | throw processInitializerError(err); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * Inner class allowing the singleton instance of {@link TotalHdd} to be created | ||
63 | * <b>not</b> at the class load time of the outer class, | ||
64 | * but rather at the first call to {@link TotalHdd#instance()}. | ||
65 | * | ||
66 | * <p> This workaround is required e.g. to support recursion. | ||
67 | * | ||
68 | */ | ||
69 | private static class LazyHolder { | ||
70 | private static final TotalHdd INSTANCE = new TotalHdd(); | ||
71 | |||
72 | /** | ||
73 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
74 | * This initialization order is required to support indirect recursion. | ||
75 | * | ||
76 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
77 | * | ||
78 | */ | ||
79 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
80 | |||
81 | public static Object ensureInitialized() { | ||
82 | INSTANCE.ensureInitializedInternal(); | ||
83 | return null; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
88 | private static final TotalHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
89 | |||
90 | private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
91 | |||
92 | private final PParameter parameter_Hdd = new PParameter("Hdd", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); | ||
93 | |||
94 | private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_Hdd); | ||
95 | |||
96 | private GeneratedPQuery() { | ||
97 | super(PVisibility.PRIVATE); | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public String getFullyQualifiedName() { | ||
102 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd"; | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public List<String> getParameterNames() { | ||
107 | return Arrays.asList("Host","Hdd"); | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public List<PParameter> getParameters() { | ||
112 | return parameters; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public Set<PBody> doGetContainedBodies() { | ||
117 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
118 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
119 | { | ||
120 | PBody body = new PBody(this); | ||
121 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
122 | PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); | ||
123 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
124 | new TypeConstraint(body, Tuples.flatTupleOf(var_Hdd), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
125 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
126 | new ExportedParameter(body, var_Host, parameter_Host), | ||
127 | new ExportedParameter(body, var_Hdd, parameter_Hdd) | ||
128 | )); | ||
129 | // HostInstance.type.defaultHdd(Host, Hdd) | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
131 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
132 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); | ||
133 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); | ||
134 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
135 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "defaultHdd"))); | ||
136 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
137 | new Equality(body, var__virtual_1_, var_Hdd); | ||
138 | bodies.add(body); | ||
139 | } | ||
140 | return bodies; | ||
141 | } | ||
142 | } | ||
143 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalMemory.java new file mode 100644 index 00000000..2fe3e741 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalMemory.java | |||
@@ -0,0 +1,143 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.emf.ecore.EDataType; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
27 | |||
28 | /** | ||
29 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
30 | * | ||
31 | * <p>Original source: | ||
32 | * <code><pre> | ||
33 | * private pattern totalMemory(Host : HostInstance, Memory : EInt) { | ||
34 | * HostInstance.type.defaultMemory(Host, Memory); | ||
35 | * } | ||
36 | * </pre></code> | ||
37 | * | ||
38 | * @see GenericPatternMatcher | ||
39 | * @see GenericPatternMatch | ||
40 | * | ||
41 | */ | ||
42 | @SuppressWarnings("all") | ||
43 | public final class TotalMemory extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
44 | private TotalMemory() { | ||
45 | super(GeneratedPQuery.INSTANCE); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * @return the singleton instance of the query specification | ||
50 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
51 | * | ||
52 | */ | ||
53 | public static TotalMemory instance() { | ||
54 | try{ | ||
55 | return LazyHolder.INSTANCE; | ||
56 | } catch (ExceptionInInitializerError err) { | ||
57 | throw processInitializerError(err); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * Inner class allowing the singleton instance of {@link TotalMemory} to be created | ||
63 | * <b>not</b> at the class load time of the outer class, | ||
64 | * but rather at the first call to {@link TotalMemory#instance()}. | ||
65 | * | ||
66 | * <p> This workaround is required e.g. to support recursion. | ||
67 | * | ||
68 | */ | ||
69 | private static class LazyHolder { | ||
70 | private static final TotalMemory INSTANCE = new TotalMemory(); | ||
71 | |||
72 | /** | ||
73 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
74 | * This initialization order is required to support indirect recursion. | ||
75 | * | ||
76 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
77 | * | ||
78 | */ | ||
79 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
80 | |||
81 | public static Object ensureInitialized() { | ||
82 | INSTANCE.ensureInitializedInternal(); | ||
83 | return null; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
88 | private static final TotalMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
89 | |||
90 | private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
91 | |||
92 | private final PParameter parameter_Memory = new PParameter("Memory", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); | ||
93 | |||
94 | private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_Memory); | ||
95 | |||
96 | private GeneratedPQuery() { | ||
97 | super(PVisibility.PRIVATE); | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public String getFullyQualifiedName() { | ||
102 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory"; | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public List<String> getParameterNames() { | ||
107 | return Arrays.asList("Host","Memory"); | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public List<PParameter> getParameters() { | ||
112 | return parameters; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public Set<PBody> doGetContainedBodies() { | ||
117 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
118 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
119 | { | ||
120 | PBody body = new PBody(this); | ||
121 | PVariable var_Host = body.getOrCreateVariableByName("Host"); | ||
122 | PVariable var_Memory = body.getOrCreateVariableByName("Memory"); | ||
123 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
124 | new TypeConstraint(body, Tuples.flatTupleOf(var_Memory), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
125 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
126 | new ExportedParameter(body, var_Host, parameter_Host), | ||
127 | new ExportedParameter(body, var_Memory, parameter_Memory) | ||
128 | )); | ||
129 | // HostInstance.type.defaultMemory(Host, Memory) | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
131 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
132 | new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); | ||
133 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); | ||
134 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
135 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "defaultMemory"))); | ||
136 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
137 | new Equality(body, var__virtual_1_, var_Memory); | ||
138 | bodies.add(body); | ||
139 | } | ||
140 | return bodies; | ||
141 | } | ||
142 | } | ||
143 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/UnallocatedAppInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/UnallocatedAppInstance.java new file mode 100644 index 00000000..66b315f4 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/UnallocatedAppInstance.java | |||
@@ -0,0 +1,172 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collections; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
27 | |||
28 | /** | ||
29 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
30 | * | ||
31 | * <p>Original source: | ||
32 | * <code><pre> | ||
33 | * private pattern unallocatedAppInstance(App : ApplicationInstance) { | ||
34 | * neg ApplicationInstance.allocatedTo(App, _); | ||
35 | * } | ||
36 | * </pre></code> | ||
37 | * | ||
38 | * @see GenericPatternMatcher | ||
39 | * @see GenericPatternMatch | ||
40 | * | ||
41 | */ | ||
42 | @SuppressWarnings("all") | ||
43 | public final class UnallocatedAppInstance extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
44 | private UnallocatedAppInstance() { | ||
45 | super(GeneratedPQuery.INSTANCE); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * @return the singleton instance of the query specification | ||
50 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
51 | * | ||
52 | */ | ||
53 | public static UnallocatedAppInstance instance() { | ||
54 | try{ | ||
55 | return LazyHolder.INSTANCE; | ||
56 | } catch (ExceptionInInitializerError err) { | ||
57 | throw processInitializerError(err); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * Inner class allowing the singleton instance of {@link UnallocatedAppInstance} to be created | ||
63 | * <b>not</b> at the class load time of the outer class, | ||
64 | * but rather at the first call to {@link UnallocatedAppInstance#instance()}. | ||
65 | * | ||
66 | * <p> This workaround is required e.g. to support recursion. | ||
67 | * | ||
68 | */ | ||
69 | private static class LazyHolder { | ||
70 | private static final UnallocatedAppInstance INSTANCE = new UnallocatedAppInstance(); | ||
71 | |||
72 | /** | ||
73 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
74 | * This initialization order is required to support indirect recursion. | ||
75 | * | ||
76 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
77 | * | ||
78 | */ | ||
79 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
80 | |||
81 | public static Object ensureInitialized() { | ||
82 | INSTANCE.ensureInitializedInternal(); | ||
83 | return null; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
88 | private static final UnallocatedAppInstance.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
89 | |||
90 | private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); | ||
91 | |||
92 | private final List<PParameter> parameters = Arrays.asList(parameter_App); | ||
93 | |||
94 | private class Embedded_1_ApplicationInstance_allocatedTo extends BaseGeneratedEMFPQuery { | ||
95 | private final PParameter parameter_p0 = new PParameter("p0", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); | ||
96 | |||
97 | private final PParameter parameter_p1 = new PParameter("p1", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); | ||
98 | |||
99 | private final List<PParameter> embeddedParameters = Arrays.asList(parameter_p0, parameter_p1); | ||
100 | |||
101 | public Embedded_1_ApplicationInstance_allocatedTo() { | ||
102 | super(PVisibility.EMBEDDED); | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public String getFullyQualifiedName() { | ||
107 | return GeneratedPQuery.this.getFullyQualifiedName() + "$Embedded_1_ApplicationInstance_allocatedTo"; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public List<PParameter> getParameters() { | ||
112 | return embeddedParameters; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public Set<PBody> doGetContainedBodies() { | ||
117 | PBody body = new PBody(this); | ||
118 | PVariable var_p0 = body.getOrCreateVariableByName("p0"); | ||
119 | PVariable var_p1 = body.getOrCreateVariableByName("p1"); | ||
120 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
121 | new ExportedParameter(body, var_p0, parameter_p0), | ||
122 | new ExportedParameter(body, var_p1, parameter_p1) | ||
123 | )); | ||
124 | // ApplicationInstance.allocatedTo(App, _) | ||
125 | new TypeConstraint(body, Tuples.flatTupleOf(var_p0), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
126 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
127 | new TypeConstraint(body, Tuples.flatTupleOf(var_p0, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); | ||
128 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); | ||
129 | new Equality(body, var__virtual_0_, var_p1); | ||
130 | return Collections.singleton(body); | ||
131 | } | ||
132 | } | ||
133 | |||
134 | private GeneratedPQuery() { | ||
135 | super(PVisibility.PRIVATE); | ||
136 | } | ||
137 | |||
138 | @Override | ||
139 | public String getFullyQualifiedName() { | ||
140 | return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.unallocatedAppInstance"; | ||
141 | } | ||
142 | |||
143 | @Override | ||
144 | public List<String> getParameterNames() { | ||
145 | return Arrays.asList("App"); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public List<PParameter> getParameters() { | ||
150 | return parameters; | ||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public Set<PBody> doGetContainedBodies() { | ||
155 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
156 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
157 | { | ||
158 | PBody body = new PBody(this); | ||
159 | PVariable var_App = body.getOrCreateVariableByName("App"); | ||
160 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
161 | new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); | ||
162 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
163 | new ExportedParameter(body, var_App, parameter_App) | ||
164 | )); | ||
165 | // neg ApplicationInstance.allocatedTo(App, _) | ||
166 | new NegativePatternCall(body, Tuples.flatTupleOf(var_App, var___0_), new UnallocatedAppInstance.GeneratedPQuery.Embedded_1_ApplicationInstance_allocatedTo()); | ||
167 | bodies.add(body); | ||
168 | } | ||
169 | return bodies; | ||
170 | } | ||
171 | } | ||
172 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.xtend new file mode 100644 index 00000000..1a07e26e --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.xtend | |||
@@ -0,0 +1,67 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.cplex | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.generator.CpsGenerator | ||
5 | import java.io.BufferedReader | ||
6 | import java.io.BufferedWriter | ||
7 | import java.io.FileReader | ||
8 | import java.io.FileWriter | ||
9 | import java.util.concurrent.TimeUnit | ||
10 | import java.util.regex.Pattern | ||
11 | import org.eclipse.emf.ecore.EPackage | ||
12 | import org.eclipse.emf.ecore.resource.Resource | ||
13 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | ||
14 | |||
15 | class CbcCpsMain { | ||
16 | static val PROBLEM_FILE = "problem.lp" | ||
17 | static val SOLUTION_FILE = "solution.txt" | ||
18 | static val VALUE_REGEX = Pattern.compile("Optimal - objective value\\s*([0-9]+(\\.[0-9]+)?)") | ||
19 | |||
20 | private new() { | ||
21 | new IllegalStateException("This is a static utility class and should not be instantiated directly.") | ||
22 | } | ||
23 | |||
24 | public static def void main(String[] args) { | ||
25 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, | ||
26 | new XMIResourceFactoryImpl) | ||
27 | EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, CpsPackage.eINSTANCE) | ||
28 | val generator = new CpsGenerator(1, 4, 1) | ||
29 | val problem = generator.generateCpsProblem | ||
30 | val toLp = new CpsToLpTranslator(problem, 10, true) | ||
31 | val lp = toLp.lpProblem | ||
32 | val writer = new BufferedWriter(new FileWriter(PROBLEM_FILE)) | ||
33 | try { | ||
34 | writer.append(lp) | ||
35 | } finally { | ||
36 | writer.close | ||
37 | } | ||
38 | val process = new ProcessBuilder().inheritIO.command("cbc", PROBLEM_FILE, "solve", "solu", SOLUTION_FILE).start | ||
39 | if (!process.waitFor(120, TimeUnit.SECONDS)) { | ||
40 | System.err.println("Timeout reached") | ||
41 | process.destroyForcibly | ||
42 | System.exit(-1) | ||
43 | } | ||
44 | if (process.exitValue != 0) { | ||
45 | System.err.println("Unexpected exit value " + process.exitValue) | ||
46 | System.exit(-1) | ||
47 | } | ||
48 | val reader = new BufferedReader(new FileReader(SOLUTION_FILE)) | ||
49 | var double value = Double.NaN | ||
50 | try { | ||
51 | var String line | ||
52 | while ((line = reader.readLine) !== null) { | ||
53 | println(line) | ||
54 | val matcher = VALUE_REGEX.matcher(line) | ||
55 | if (matcher.matches) { | ||
56 | value = Double.parseDouble(matcher.group(1)) | ||
57 | } | ||
58 | } | ||
59 | } finally { | ||
60 | reader.close | ||
61 | } | ||
62 | val applicationCost = problem.requests.flatMap[requirements.map[count]].reduce[p1, p2|p1 + p2] * 5 | ||
63 | val cost = applicationCost + value | ||
64 | println | ||
65 | println("Cost: " + cost) | ||
66 | } | ||
67 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CpsToLpTranslator.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CpsToLpTranslator.xtend new file mode 100644 index 00000000..c38af3a0 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CpsToLpTranslator.xtend | |||
@@ -0,0 +1,171 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.cplex | ||
2 | |||
3 | import com.google.common.collect.ImmutableList | ||
4 | import com.google.common.collect.ImmutableMap | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement | ||
9 | import java.util.List | ||
10 | import java.util.Map | ||
11 | |||
12 | class CpsToLpTranslator { | ||
13 | static val MINIMUM_MEMORY_USAGE = 0.25 | ||
14 | static val MINIMUM_HDD_USAGE = 0.25 | ||
15 | |||
16 | val CyberPhysicalSystem cps | ||
17 | val Map<Requirement, ? extends List<String>> appInstances | ||
18 | val Map<HostType, ? extends List<String>> hostInstances | ||
19 | val boolean breakSymmetry | ||
20 | |||
21 | new(CyberPhysicalSystem cps, int hostInstanceCount, boolean breakSymmetry) { | ||
22 | this.cps = cps | ||
23 | appInstances = createAppInstances | ||
24 | hostInstances = createHostInstances(hostInstanceCount) | ||
25 | this.breakSymmetry = breakSymmetry | ||
26 | } | ||
27 | |||
28 | private def createAppInstances() { | ||
29 | val builder = ImmutableMap.builder | ||
30 | var int i = 0 | ||
31 | for (req : requirements) { | ||
32 | val listBuilder = ImmutableList.builder | ||
33 | for (var int j = 0; j < req.count; j++) { | ||
34 | listBuilder.add('''r«i»a«j»''') | ||
35 | } | ||
36 | builder.put(req, listBuilder.build) | ||
37 | i++ | ||
38 | } | ||
39 | builder.build | ||
40 | } | ||
41 | |||
42 | private def createHostInstances(int hostInstanceCount) { | ||
43 | val builder = ImmutableMap.builder | ||
44 | var int i = 0 | ||
45 | for (hostType : cps.hostTypes) { | ||
46 | val listBuilder = ImmutableList.builder | ||
47 | for (var int j = 0; j < hostInstanceCount; j++) { | ||
48 | listBuilder.add('''h«i»i«j»''') | ||
49 | } | ||
50 | builder.put(hostType, listBuilder.build) | ||
51 | i++ | ||
52 | } | ||
53 | builder.build | ||
54 | } | ||
55 | |||
56 | def getLpProblem() { | ||
57 | ''' | ||
58 | Minimize | ||
59 | total_cost: «objective» | ||
60 | Subject To | ||
61 | «constraints» | ||
62 | Bounds | ||
63 | «bounds» | ||
64 | Binary | ||
65 | «binaryVariables» | ||
66 | End | ||
67 | ''' | ||
68 | } | ||
69 | |||
70 | private def getObjective() { | ||
71 | '''«FOR pair : hostInstancesWithType SEPARATOR " + "»«pair.key.cost» «pair.value.existsVariable»«ENDFOR»''' | ||
72 | } | ||
73 | |||
74 | private def getConstraints() { | ||
75 | ''' | ||
76 | «FOR appPair : appInstancesWithType» | ||
77 | «appPair.value»_allocated: «FOR host : appPair.key.possibleHostInstances SEPARATOR " + "»«getAllocatedToVariable(appPair.value, host)»«ENDFOR» = 1 | ||
78 | «FOR host : appPair.key.possibleHostInstances» | ||
79 | «appPair.value»_to_«host»_exists: «host.existsVariable» - «getAllocatedToVariable(appPair.value, host)» >= 0 | ||
80 | «ENDFOR» | ||
81 | «ENDFOR» | ||
82 | «FOR hostPair : hostInstancesWithType» | ||
83 | «hostPair.value»_mem_use: «FOR appPair : hostPair.key.possibleAppInstancesWithRequirements SEPARATOR " + "»«appPair.key.requiredMemory» «getAllocatedToVariable(appPair.value, hostPair.value)»«ENDFOR» - «hostPair.key.defaultMemory» «hostPair.value.memoryUsageVariable» = 0 | ||
84 | «hostPair.value»_hdd_use: «FOR appPair : hostPair.key.possibleAppInstancesWithRequirements SEPARATOR " + "»«appPair.key.requiredHdd» «getAllocatedToVariable(appPair.value, hostPair.value)»«ENDFOR» - «hostPair.key.defaultHdd» «hostPair.value.hddUsageVariable» = 0 | ||
85 | «ENDFOR» | ||
86 | average_mem: «FOR host : allHostInstances SEPARATOR " + "»«host.memoryUsageVariable» - «MINIMUM_MEMORY_USAGE» «host.existsVariable»«ENDFOR» >= 0 | ||
87 | average_hdd: «FOR host : allHostInstances SEPARATOR " + "»«host.memoryUsageVariable» - «MINIMUM_HDD_USAGE» «host.existsVariable»«ENDFOR» >= 0 | ||
88 | «FOR reqPair : requirements.filter[count > 1].indexed» | ||
89 | «FOR host : reqPair.value.type.requirements.flatMap[hostInstances.get(hostType)]» | ||
90 | r«reqPair.key»_«host»_redundant: «FOR app : appInstances.get(reqPair.value) SEPARATOR " + "»«getAllocatedToVariable(app, host)»«ENDFOR» <= 1 | ||
91 | «ENDFOR» | ||
92 | «ENDFOR» | ||
93 | «IF breakSymmetry» | ||
94 | «FOR hosts : hostInstances.values» | ||
95 | «FOR i : 0 ..< (hosts.size - 1)» | ||
96 | «hosts.get(i + 1)»_after_«hosts.get(i)»: «hosts.get(i).existsVariable» - «hosts.get(i + 1).existsVariable» >= 0 | ||
97 | «ENDFOR» | ||
98 | «ENDFOR» | ||
99 | «ENDIF» | ||
100 | ''' | ||
101 | } | ||
102 | |||
103 | private def getBounds() { | ||
104 | ''' | ||
105 | «FOR host : allHostInstances» | ||
106 | 0 <= «host.memoryUsageVariable» <= 1 | ||
107 | 0 <= «host.hddUsageVariable» <= 1 | ||
108 | «ENDFOR» | ||
109 | ''' | ||
110 | } | ||
111 | |||
112 | private def getBinaryVariables() { | ||
113 | ''' | ||
114 | «FOR host : allHostInstances» | ||
115 | «host.existsVariable» | ||
116 | «ENDFOR» | ||
117 | «FOR appPair : appInstancesWithType» | ||
118 | «FOR host : appPair.key.possibleHostInstances» | ||
119 | «getAllocatedToVariable(appPair.value, host)» | ||
120 | «ENDFOR» | ||
121 | «ENDFOR» | ||
122 | ''' | ||
123 | } | ||
124 | |||
125 | private def getRequirements() { | ||
126 | cps.requests.flatMap[requirements] | ||
127 | } | ||
128 | |||
129 | private def getAllHostInstances() { | ||
130 | hostInstances.values.flatMap[it] | ||
131 | } | ||
132 | |||
133 | private def getHostInstancesWithType() { | ||
134 | hostInstances.entrySet.flatMap[pair|pair.value.map[pair.key -> it]] | ||
135 | } | ||
136 | |||
137 | private def getAppInstancesWithType() { | ||
138 | appInstances.entrySet.flatMap[pair|pair.value.map[pair.key.type -> it]] | ||
139 | } | ||
140 | |||
141 | private def getPossibleHostInstances(ApplicationType appType) { | ||
142 | appType.requirements.flatMap[req|hostInstances.get(req.hostType)] | ||
143 | } | ||
144 | |||
145 | private def getPossibleAppInstancesWithRequirements(HostType hostType) { | ||
146 | appInstances.entrySet.flatMap [ pair | | ||
147 | val resourceReq = pair.key.type.requirements.findFirst[it.hostType == hostType] | ||
148 | if (resourceReq === null) { | ||
149 | emptyList | ||
150 | } else { | ||
151 | pair.value.map[resourceReq -> it] | ||
152 | } | ||
153 | ] | ||
154 | } | ||
155 | |||
156 | private def getExistsVariable(String hostInstance) { | ||
157 | '''«hostInstance»_exists''' | ||
158 | } | ||
159 | |||
160 | private def getMemoryUsageVariable(String hostInstance) { | ||
161 | '''«hostInstance»_mem''' | ||
162 | } | ||
163 | |||
164 | private def getHddUsageVariable(String hostInstance) { | ||
165 | '''«hostInstance»_hdd''' | ||
166 | } | ||
167 | |||
168 | private def getAllocatedToVariable(String appInstance, String hostInstance) { | ||
169 | '''«appInstance»_to_«hostInstance»''' | ||
170 | } | ||
171 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.xtend new file mode 100644 index 00000000..223cee03 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.xtend | |||
@@ -0,0 +1,134 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.dse | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.Request | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement | ||
9 | import org.eclipse.emf.common.notify.Notifier | ||
10 | import org.eclipse.emf.ecore.resource.Resource | ||
11 | import org.eclipse.emf.ecore.resource.ResourceSet | ||
12 | import org.eclipse.viatra.dse.statecode.IStateCoder | ||
13 | import org.eclipse.viatra.dse.statecode.IStateCoderFactory | ||
14 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | ||
15 | import org.eclipse.xtend2.lib.StringConcatenationClient | ||
16 | |||
17 | class CpsStateCoder implements IStateCoder { | ||
18 | CyberPhysicalSystem cps | ||
19 | |||
20 | protected new() { | ||
21 | } | ||
22 | |||
23 | override init(Notifier notifier) { | ||
24 | cps = switch (notifier) { | ||
25 | ResourceSet: getCpsFromResourceSet(notifier) | ||
26 | Resource: getCpsFromResource(notifier) | ||
27 | CyberPhysicalSystem: notifier | ||
28 | default: throw new IllegalArgumentException("notifier is not a CyberPhysicalSystem") | ||
29 | } | ||
30 | } | ||
31 | |||
32 | private def getCpsFromResourceSet(ResourceSet resourceSet) { | ||
33 | if (resourceSet.resources.empty) { | ||
34 | throw new IllegalArgumentException("No Resource in ResourceSet") | ||
35 | } | ||
36 | val resource = resourceSet.resources.head | ||
37 | getCpsFromResource(resource) | ||
38 | } | ||
39 | |||
40 | private def getCpsFromResource(Resource resource) { | ||
41 | if (resource.contents.empty) { | ||
42 | throw new IllegalArgumentException("No EObject in Resource") | ||
43 | } | ||
44 | val cps = resource.contents.head | ||
45 | if (cps instanceof CyberPhysicalSystem) { | ||
46 | cps | ||
47 | } else { | ||
48 | throw new IllegalArgumentException("EObject in Resource is not a CyberPhysicalSystem") | ||
49 | } | ||
50 | } | ||
51 | |||
52 | override String createStateCode() { | ||
53 | '''«createRequestsCode»«createHostTypesCode»''' | ||
54 | } | ||
55 | |||
56 | private def StringConcatenationClient createRequestsCode() { | ||
57 | '''«FOR request : cps.requests»«createRequestCode(request)»«ENDFOR»''' | ||
58 | } | ||
59 | |||
60 | private def StringConcatenationClient createRequestCode(Request request) { | ||
61 | '''[«FOR requirement : request.requirements»«createRequirementCode(requirement)»«ENDFOR»]''' | ||
62 | } | ||
63 | |||
64 | private def StringConcatenationClient createRequirementCode(Requirement requirement) { | ||
65 | '''[«FOR app : requirement.instances SEPARATOR ","»«createAppCode(app)»«ENDFOR»]''' | ||
66 | } | ||
67 | |||
68 | private def createAppCode(ApplicationInstance app) { | ||
69 | if (app.allocatedTo === null) { | ||
70 | "-" | ||
71 | } else { | ||
72 | createMatchArgumentCode(app.allocatedTo) | ||
73 | } | ||
74 | } | ||
75 | |||
76 | private def createHostTypesCode() { | ||
77 | '''(«FOR hostType : cps.hostTypes SEPARATOR ","»«hostType.instances.size»«ENDFOR»)''' | ||
78 | } | ||
79 | |||
80 | override String createActivationCode(IPatternMatch match) { | ||
81 | '''«match.specification.simpleName»(«FOR arg : match.toArray SEPARATOR ","»«createMatchArgumentCode(arg)»«ENDFOR»)''' | ||
82 | } | ||
83 | |||
84 | protected dispatch def String createMatchArgumentCode(Requirement requirement) { | ||
85 | val request = requirement.eContainer | ||
86 | if (request instanceof Request) { | ||
87 | if (request.eContainer != cps) { | ||
88 | throw new IllegalArgumentException("Request is not contained in the CPS") | ||
89 | } | ||
90 | val requestIndex = cps.requests.indexOf(request) | ||
91 | val requirementIndex = request.requirements.indexOf(requirement) | ||
92 | requestIndex + "." + requirementIndex | ||
93 | } else { | ||
94 | throw new IllegalArgumentException("Requirement is not contained in a request") | ||
95 | } | ||
96 | } | ||
97 | |||
98 | protected dispatch def String createMatchArgumentCode(ApplicationInstance app) { | ||
99 | val requirement = app.requirement | ||
100 | if (requirement === null) { | ||
101 | throw new IllegalArgumentException("Application instance is not associated with a requirement") | ||
102 | } | ||
103 | val instanceIndex = requirement.instances.indexOf(app) | ||
104 | createMatchArgumentCode(requirement) + "." + instanceIndex | ||
105 | } | ||
106 | |||
107 | protected dispatch def String createMatchArgumentCode(HostInstance host) { | ||
108 | val hostType = host.eContainer | ||
109 | if (hostType instanceof HostType) { | ||
110 | val hostIndex = hostType.instances.indexOf(host) | ||
111 | createMatchArgumentCode(hostType) + "." + hostIndex | ||
112 | } else { | ||
113 | throw new IllegalArgumentException("Host is not contained in a host type") | ||
114 | } | ||
115 | } | ||
116 | |||
117 | protected dispatch def String createMatchArgumentCode(HostType hostType) { | ||
118 | if (hostType.eContainer != cps) { | ||
119 | throw new IllegalArgumentException("Host type is not contained in the CPS") | ||
120 | } | ||
121 | val hostTypeIndex = cps.hostTypes.indexOf(hostType) | ||
122 | hostTypeIndex.toString | ||
123 | } | ||
124 | |||
125 | protected dispatch def createMatchArgumentCode(Object object) { | ||
126 | throw new IllegalArgumentException("Unknown match argument: ") | ||
127 | } | ||
128 | |||
129 | static class Factory implements IStateCoderFactory { | ||
130 | override createStateCoder() { | ||
131 | new CpsStateCoder | ||
132 | } | ||
133 | } | ||
134 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.xtend new file mode 100644 index 00000000..35b3b1df --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.xtend | |||
@@ -0,0 +1,39 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.dse | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.generator.CpsGenerator | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsQueries | ||
6 | import org.eclipse.emf.ecore.EPackage | ||
7 | import org.eclipse.emf.ecore.EStructuralFeature | ||
8 | import org.eclipse.emf.ecore.resource.Resource | ||
9 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | ||
10 | import org.eclipse.viatra.addon.querybasedfeatures.runtime.QueryBasedFeatureSettingDelegateFactory | ||
11 | import org.eclipse.viatra.addon.querybasedfeatures.runtime.handler.QueryBasedFeatures | ||
12 | import org.eclipse.viatra.dse.api.DesignSpaceExplorer | ||
13 | import org.eclipse.viatra.dse.api.DesignSpaceExplorer.DseLoggingLevel | ||
14 | import org.eclipse.viatra.query.runtime.extensibility.SingletonQueryGroupProvider | ||
15 | import org.eclipse.viatra.query.runtime.registry.QuerySpecificationRegistry | ||
16 | import org.eclipse.viatra.query.runtime.registry.connector.QueryGroupProviderSourceConnector | ||
17 | |||
18 | class RuleBasedCpsMain { | ||
19 | private new() { | ||
20 | new IllegalStateException("This is a static utility class and should not be instantiated directly.") | ||
21 | } | ||
22 | |||
23 | public static def void main(String[] args) { | ||
24 | DesignSpaceExplorer.turnOnLogging(DseLoggingLevel.VERBOSE_FULL) | ||
25 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, | ||
26 | new XMIResourceFactoryImpl) | ||
27 | EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put(QueryBasedFeatures.ANNOTATION_SOURCE, | ||
28 | new QueryBasedFeatureSettingDelegateFactory) | ||
29 | EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, CpsPackage.eINSTANCE) | ||
30 | QuerySpecificationRegistry.instance.addSource( | ||
31 | new QueryGroupProviderSourceConnector("CpsQueries", new SingletonQueryGroupProvider(CpsQueries.instance), | ||
32 | true)) | ||
33 | val generator = new CpsGenerator(1, 4, 1) | ||
34 | val problem = generator.generateCpsProblem | ||
35 | // problem.eResource.save(emptyMap) | ||
36 | val solver = new RuleBasedCpsSolver | ||
37 | solver.solve(problem) | ||
38 | } | ||
39 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend new file mode 100644 index 00000000..503c06ea --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend | |||
@@ -0,0 +1,74 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.dse | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric | ||
10 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance | ||
11 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective | ||
12 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied | ||
13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CompositeDirectionalThresholdObjective | ||
14 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind | ||
15 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold | ||
16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.QueryBasedObjective | ||
17 | import org.eclipse.viatra.dse.api.DesignSpaceExplorer | ||
18 | import org.eclipse.viatra.dse.evolutionary.EvolutionaryStrategyBuilder | ||
19 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRuleFactory | ||
20 | |||
21 | class RuleBasedCpsSolver { | ||
22 | extension val BatchTransformationRuleFactory = new BatchTransformationRuleFactory | ||
23 | extension val CpsFactory = CpsFactory.eINSTANCE | ||
24 | |||
25 | def solve(CyberPhysicalSystem problem) { | ||
26 | // for (request : problem.requests) { | ||
27 | // for (req : request.requirements) { | ||
28 | // for (i : 0 ..< req.count) { | ||
29 | // val app = createApplicationInstance | ||
30 | // req.type.instances += app | ||
31 | // req.instances += app | ||
32 | // } | ||
33 | // } | ||
34 | // } | ||
35 | val dse = new DesignSpaceExplorer | ||
36 | dse.addMetaModelPackage(CpsPackage.eINSTANCE) | ||
37 | dse.initialModel = problem.eResource.resourceSet | ||
38 | dse.addTransformationRule(createRule.precondition(RequirementNotSatisfied.instance).action [ | ||
39 | val app = createApplicationInstance | ||
40 | req.type.instances += app | ||
41 | req.instances += app | ||
42 | ].build) | ||
43 | dse.addTransformationRule(createRule.precondition(Allocate.instance).action [ | ||
44 | app.allocatedTo = host | ||
45 | ].build) | ||
46 | // dse.addTransformationRule(createRule(UnallocateAppInstance.instance).action [ | ||
47 | // app.allocatedTo = null | ||
48 | // ].build) | ||
49 | dse.addTransformationRule(createRule.precondition(CreateHostInstance.instance).action [ | ||
50 | hostType.instances += createHostInstance | ||
51 | ].build) | ||
52 | // dse.addTransformationRule(createRule(RemoveHostInstance.instance).action [ | ||
53 | // hostInstance.type.instances -= hostInstance | ||
54 | // ].build) | ||
55 | dse.addObjective( | ||
56 | new CompositeDirectionalThresholdObjective("Composite", | ||
57 | new QueryBasedObjective(GuidanceObjective.instance, ObjectiveKind.LOWER_IS_BETTER, | ||
58 | new ObjectiveThreshold.Inclusive(0), 0), | ||
59 | new QueryBasedObjective(AverageFreeMemoryMetric.instance, ObjectiveKind.LOWER_IS_BETTER, | ||
60 | new ObjectiveThreshold.Inclusive(0.75), 0), | ||
61 | new QueryBasedObjective(AverageFreeHddMetric.instance, ObjectiveKind.LOWER_IS_BETTER, | ||
62 | new ObjectiveThreshold.Inclusive(0.75), 0))) | ||
63 | dse.addObjective( | ||
64 | new QueryBasedObjective(CostMetric.instance, ObjectiveKind.LOWER_IS_BETTER, | ||
65 | ObjectiveThreshold.NO_THRESHOLD, 0)) | ||
66 | dse.maxNumberOfThreads = 1 | ||
67 | dse.stateCoderFactory = new CpsStateCoder.Factory | ||
68 | val strategy = EvolutionaryStrategyBuilder.createNsga2Strategy(25) | ||
69 | dse.startExplorationWithTimeout(strategy, 2 * 60 * 1000) | ||
70 | for (solution : dse.solutions) { | ||
71 | println("Found solution: " + solution.stateCode + " " + solution.arbitraryTrajectory.fitness) | ||
72 | } | ||
73 | } | ||
74 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.xtend new file mode 100644 index 00000000..e8d29949 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.xtend | |||
@@ -0,0 +1,117 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.generator | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType | ||
6 | import java.util.Collection | ||
7 | import java.util.Random | ||
8 | import org.eclipse.emf.common.util.URI | ||
9 | import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl | ||
10 | |||
11 | class CpsGenerator { | ||
12 | extension val CpsFactory = CpsFactory.eINSTANCE | ||
13 | |||
14 | static val MIN_MEMORY = 1 | ||
15 | static val MAX_MEMORY = 6 | ||
16 | static val MIN_HDD = 1 | ||
17 | static val MAX_HDD = 30 | ||
18 | static val HIGH_CPU_FRACTION = 4 | ||
19 | static val MIN_REPLICAS = 1 | ||
20 | static val MAX_REPLICAS = 4 | ||
21 | |||
22 | val Random random | ||
23 | val int applicationTypeCount | ||
24 | val int demandFactor | ||
25 | val boolean populateAppInstances | ||
26 | |||
27 | new(long randomSeed, int applicationTypeCount, int demandFactor) { | ||
28 | this(randomSeed, applicationTypeCount, demandFactor, false) | ||
29 | } | ||
30 | |||
31 | new(long randomSeed, int applicationTypeCount, int demandFactor, boolean populateAppInstances) { | ||
32 | this.random = new Random(randomSeed) | ||
33 | this.applicationTypeCount = applicationTypeCount | ||
34 | this.demandFactor = demandFactor | ||
35 | this.populateAppInstances = populateAppInstances | ||
36 | } | ||
37 | |||
38 | def generateCpsProblem() { | ||
39 | val resourceSet = new ResourceSetImpl | ||
40 | val resource = resourceSet.createResource(URI.createFileURI("dummy.dummyext")) | ||
41 | createCyberPhysicalSystem => [ | ||
42 | val cps = it | ||
43 | resource.contents += cps | ||
44 | createLowCpuHostTypes | ||
45 | val highCpuHostTypes = createHighCpuHostTypes | ||
46 | for (var int i = 0; i < applicationTypeCount; i++) { | ||
47 | if (i % HIGH_CPU_FRACTION == 0) { | ||
48 | createRandomApplicationType(highCpuHostTypes) | ||
49 | } else { | ||
50 | createRandomApplicationType(hostTypes) | ||
51 | } | ||
52 | } | ||
53 | for (var int i = 0; i < demandFactor; i++) { | ||
54 | requests += createRequest => [ | ||
55 | for (appType : cps.applicationTypes) { | ||
56 | requirements += createRequirement => [ | ||
57 | count = nextInt(CpsGenerator.MIN_REPLICAS, CpsGenerator.MAX_REPLICAS) | ||
58 | type = appType | ||
59 | if (populateAppInstances) { | ||
60 | for (j : 0 ..< count) { | ||
61 | val app = createApplicationInstance | ||
62 | app.type = appType | ||
63 | appType.instances += app | ||
64 | instances += app | ||
65 | } | ||
66 | } | ||
67 | ] | ||
68 | } | ||
69 | ] | ||
70 | } | ||
71 | ] | ||
72 | } | ||
73 | |||
74 | private def void createRandomApplicationType(CyberPhysicalSystem it, Collection<HostType> allowedHostTypes) { | ||
75 | val appType = createApplicationType | ||
76 | val memory = nextInt(MIN_MEMORY, MAX_MEMORY) | ||
77 | val hdd = nextInt(MIN_HDD, MAX_HDD) | ||
78 | for (hostType : allowedHostTypes) { | ||
79 | appType.requirements += createResourceRequirement => [ | ||
80 | it.hostType = hostType | ||
81 | requiredMemory = memory | ||
82 | requiredHdd = hdd | ||
83 | ] | ||
84 | } | ||
85 | applicationTypes += appType | ||
86 | } | ||
87 | |||
88 | private def createLowCpuHostTypes(CyberPhysicalSystem it) { | ||
89 | #[ | ||
90 | createHostType(2, 8, 75), // m5d.large | ||
91 | createHostType(4, 16, 150), // m5d.xlarge | ||
92 | createHostType(3, 16, 75), // r5d.large | ||
93 | createHostType(6, 32, 150) // r5d.xlarge | ||
94 | ] | ||
95 | } | ||
96 | |||
97 | private def createHighCpuHostTypes(CyberPhysicalSystem it) { | ||
98 | #[ | ||
99 | createHostType(2, 4, 50), // c5d.large | ||
100 | createHostType(4, 8, 100) // c5d.xlarge | ||
101 | ] | ||
102 | } | ||
103 | |||
104 | private def createHostType(CyberPhysicalSystem it, int cost, int memory, int hdd) { | ||
105 | val hostType = createHostType => [ | ||
106 | it.cost = cost | ||
107 | defaultMemory = memory | ||
108 | defaultHdd = hdd | ||
109 | ] | ||
110 | hostTypes += hostType | ||
111 | hostType | ||
112 | } | ||
113 | |||
114 | private def nextInt(int lower, int upper) { | ||
115 | lower + random.nextInt(upper - lower + 1) | ||
116 | } | ||
117 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql new file mode 100644 index 00000000..aa78dc38 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql | |||
@@ -0,0 +1,198 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.queries | ||
2 | |||
3 | import "http://www.eclipse.org/emf/2002/Ecore" | ||
4 | import "http://www.example.org/cps" | ||
5 | |||
6 | private pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) { | ||
7 | CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance); | ||
8 | } | ||
9 | |||
10 | private pattern cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) { | ||
11 | CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance); | ||
12 | } | ||
13 | |||
14 | private pattern totalMemory(Host : HostInstance, Memory : EInt) { | ||
15 | HostInstance.type.defaultMemory(Host, Memory); | ||
16 | } | ||
17 | |||
18 | private pattern totalHdd(Host : HostInstance, Hdd : EInt) { | ||
19 | HostInstance.type.defaultHdd(Host, Hdd); | ||
20 | } | ||
21 | |||
22 | private pattern availableMemory(Host : HostInstance, Memory : java Integer) { | ||
23 | find totalMemory(Host, TotalMemory); | ||
24 | RequiredMemory == sum find memoryRequirement(Host, _, #_); | ||
25 | Memory == eval(TotalMemory - RequiredMemory); | ||
26 | } | ||
27 | |||
28 | private pattern memoryRequirement(Host : HostInstance, App : ApplicationInstance, Memory : EInt) { | ||
29 | find resourceRequirement(Host, App, Req); | ||
30 | ResourceRequirement.requiredMemory(Req, Memory); | ||
31 | } | ||
32 | |||
33 | private pattern availableHdd(Host : HostInstance, Hdd : java Integer) { | ||
34 | find totalHdd(Host, TotalHdd); | ||
35 | RequiredHdd == sum find hddRequirement(Host, _, #_); | ||
36 | Hdd == eval(TotalHdd - RequiredHdd); | ||
37 | } | ||
38 | |||
39 | private pattern hddRequirement(Host : HostInstance, App : ApplicationInstance, Hdd : EInt) { | ||
40 | find resourceRequirement(Host, App, Req); | ||
41 | ResourceRequirement.requiredHdd(Req, Hdd); | ||
42 | } | ||
43 | |||
44 | pattern resourceRequirement(Host : HostInstance, App : ApplicationInstance, Req : ResourceRequirement) { | ||
45 | ApplicationInstance.allocatedTo(App, Host); | ||
46 | ApplicationInstance.type.requirements(App, Req); | ||
47 | HostInstance.type(Host, HostType); | ||
48 | ResourceRequirement.hostType(Req, HostType); | ||
49 | } | ||
50 | |||
51 | @Constraint(severity = "error", key = {Host, App}, | ||
52 | message = "Application instance must be allocated to a supported host type.") | ||
53 | pattern allocationWithoutResourceRequirement(Host : HostInstance, App : ApplicationInstance) { | ||
54 | ApplicationInstance.allocatedTo(App, Host); | ||
55 | neg find resourceRequirement(Host, App, _); | ||
56 | } | ||
57 | |||
58 | @Constraint(severity = "error", key = {Host}, | ||
59 | message = "Insufficient memory available on host.") | ||
60 | pattern notEnoughAvailableMemory(Host : HostInstance) { | ||
61 | find availableMemory(Host, Memory); | ||
62 | check(Memory < 0); | ||
63 | } | ||
64 | |||
65 | @Constraint(severity = "error", key = {Host}, | ||
66 | message = "Insufficient HDD available on host.") | ||
67 | pattern notEnoughAvailableHdd(Host : HostInstance) { | ||
68 | find availableHdd(Host, Hdd); | ||
69 | check(Hdd < 0); | ||
70 | } | ||
71 | |||
72 | @Constraint(severity = "error", key = {Req, App}, | ||
73 | message = "Requirement must be satisfied by the required application type.") | ||
74 | pattern instanceDoesNotSatisfyRequirement(Req : Requirement, App : ApplicationInstance) { | ||
75 | Requirement.instances(Req, App); | ||
76 | neg find satisfyingInstance(Req, App); | ||
77 | } | ||
78 | |||
79 | private pattern satisfyingInstance(Req : Requirement, App : ApplicationInstance) { | ||
80 | Requirement.instances(Req, App); | ||
81 | Requirement.type(Req, Type); | ||
82 | ApplicationInstance.type(App, Type); | ||
83 | } | ||
84 | |||
85 | @Constraint(severity = "error", key = {Req}, | ||
86 | message = "Requirement is not satisfied by enough application instances.") | ||
87 | pattern requirementNotSatisfied(Req : Requirement) { | ||
88 | Instances == count find satisfyingInstance(Req, _); | ||
89 | Requirement.count(Req, RequiredCount); | ||
90 | check(Instances < RequiredCount); | ||
91 | } | ||
92 | |||
93 | @Constraint(severity = "error", key = {Req}, | ||
94 | message = "Redundant instances must not be allocated to the same host.") | ||
95 | pattern redundantInstancesOnSameHost(Req : Requirement) { | ||
96 | Requirement.instances(Req, App1); | ||
97 | Requirement.instances(Req, App2); | ||
98 | App1 != App2; | ||
99 | ApplicationInstance.allocatedTo(App1, Host); | ||
100 | ApplicationInstance.allocatedTo(App2, Host); | ||
101 | } | ||
102 | |||
103 | // | ||
104 | // Metrics | ||
105 | // | ||
106 | |||
107 | // Free memory | ||
108 | |||
109 | pattern averageFreeMemoryMetric(Average : java Double) { | ||
110 | Average == avg find freeMemoryPercentage(_, #_); | ||
111 | } | ||
112 | |||
113 | private pattern freeMemoryPercentage(Host : HostInstance, Free : java Double) { | ||
114 | find totalMemory(Host, Total); | ||
115 | find availableMemory(Host, Available); | ||
116 | Free == eval((Available as double) / Total); | ||
117 | } | ||
118 | |||
119 | // Free HDD | ||
120 | |||
121 | pattern averageFreeHddMetric(Average : java Double) { | ||
122 | Average == avg find freeHddPercentage(_, #_); | ||
123 | } | ||
124 | |||
125 | private pattern freeHddPercentage(Host : HostInstance, Free : java Double) { | ||
126 | find totalHdd(Host, Total); | ||
127 | find availableHdd(Host, Available); | ||
128 | Free == eval((Available as double) / Total); | ||
129 | } | ||
130 | |||
131 | // Total cost | ||
132 | |||
133 | pattern costMetric(Cost : java Integer) { | ||
134 | Cost == sum find cpsCost(_, #_); | ||
135 | } | ||
136 | |||
137 | pattern cpsCost(Cps : CyberPhysicalSystem, Cost : java Integer) { | ||
138 | AppCount == count find cpsApplications(Cps, _); | ||
139 | HostCost == sum find hostInstanceCost(Cps, _, #_); | ||
140 | Cost == eval(5 * AppCount + HostCost); | ||
141 | } | ||
142 | |||
143 | private pattern hostInstanceCost(Cps : CyberPhysicalSystem, Host : HostInstance, Cost : EInt) { | ||
144 | find cpsHosts(Cps, Host); | ||
145 | HostInstance.type.cost(Host, Cost); | ||
146 | } | ||
147 | |||
148 | // | ||
149 | // Transformation rule preconditions for rule-based DSE | ||
150 | // | ||
151 | |||
152 | pattern allocate(App : ApplicationInstance, Host : HostInstance) { | ||
153 | ApplicationInstance.type.requirements(App, Req); | ||
154 | ResourceRequirement.hostType.instances(Req, Host); | ||
155 | find unallocatedAppInstance(App); | ||
156 | find availableMemory(Host, AvailableMem); | ||
157 | find availableHdd(Host, AvailableHdd); | ||
158 | ResourceRequirement.requiredMemory(Req, RequiredMem); | ||
159 | ResourceRequirement.requiredHdd(Req, RequiredHdd); | ||
160 | check(AvailableMem >= RequiredMem); | ||
161 | check(AvailableHdd >= RequiredHdd); | ||
162 | neg ApplicationInstance.requirement.instances.allocatedTo(App, Host); | ||
163 | } | ||
164 | |||
165 | pattern unallocateAppInstance(App : ApplicationInstance) { | ||
166 | ApplicationInstance.allocatedTo(App, _); | ||
167 | } | ||
168 | |||
169 | pattern createHostInstance(HostType : HostType) { | ||
170 | find unallocatedAppInstance(App); | ||
171 | ApplicationInstance.type.requirements.hostType(App, HostType); | ||
172 | } | ||
173 | |||
174 | pattern removeHostInstance(HostInstance : HostInstance) { | ||
175 | neg HostInstance.applications(HostInstance, _); | ||
176 | } | ||
177 | |||
178 | private pattern unallocatedAppInstance(App : ApplicationInstance) { | ||
179 | neg ApplicationInstance.allocatedTo(App, _); | ||
180 | } | ||
181 | |||
182 | private pattern requiredAppInstances(Req : Requirement, Remaining : java Integer) { | ||
183 | Instances == count find satisfyingInstance(Req, _); | ||
184 | Requirement.count(Req, RequiredCount); | ||
185 | Remaining == eval(RequiredCount - Instances); | ||
186 | } | ||
187 | |||
188 | private pattern noHostToAllocateTo(App : ApplicationInstance) { | ||
189 | find unallocatedAppInstance(App); | ||
190 | neg find allocate(App, _); | ||
191 | } | ||
192 | |||
193 | pattern guidanceObjective(Value : java Integer) { | ||
194 | UnallocatedInstances == count find unallocatedAppInstance(_); | ||
195 | RequiredInstances == sum find requiredAppInstances(_, #_); | ||
196 | NoHostToAllocate == count find noHostToAllocateTo(_); | ||
197 | Value == eval(2 * UnallocatedInstances + 4 * RequiredInstances + NoHostToAllocate); | ||
198 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF index 81ee8677..2666dc5e 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF | |||
@@ -9,8 +9,7 @@ Bundle-Localization: plugin | |||
9 | Export-Package: hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm, | 9 | Export-Package: hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm, |
10 | hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.impl, | 10 | hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.impl, |
11 | hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.util, | 11 | hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.util, |
12 | hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu, | 12 | hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu |
13 | hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated | ||
14 | Require-Bundle: org.eclipse.viatra.query.runtime, | 13 | Require-Bundle: org.eclipse.viatra.query.runtime, |
15 | org.eclipse.core.runtime, | 14 | org.eclipse.core.runtime, |
16 | org.eclipse.emf.ecore;visibility:=reexport, | 15 | org.eclipse.emf.ecore;visibility:=reexport, |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/CompositeElementImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/CompositeElementImpl.java index 0e298b95..96c642fb 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/CompositeElementImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/CompositeElementImpl.java | |||
@@ -68,6 +68,7 @@ public abstract class CompositeElementImpl extends MinimalEObjectImpl.Container | |||
68 | * <!-- end-user-doc --> | 68 | * <!-- end-user-doc --> |
69 | * @generated | 69 | * @generated |
70 | */ | 70 | */ |
71 | @Override | ||
71 | public EList<Region> getRegions() { | 72 | public EList<Region> getRegions() { |
72 | if (regions == null) { | 73 | if (regions == null) { |
73 | regions = new EObjectContainmentEList<Region>(Region.class, this, YakindummPackage.COMPOSITE_ELEMENT__REGIONS); | 74 | regions = new EObjectContainmentEList<Region>(Region.class, this, YakindummPackage.COMPOSITE_ELEMENT__REGIONS); |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/RegionImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/RegionImpl.java index 232e5ab6..06ae652a 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/RegionImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/RegionImpl.java | |||
@@ -68,6 +68,7 @@ public class RegionImpl extends MinimalEObjectImpl.Container implements Region { | |||
68 | * <!-- end-user-doc --> | 68 | * <!-- end-user-doc --> |
69 | * @generated | 69 | * @generated |
70 | */ | 70 | */ |
71 | @Override | ||
71 | public EList<Vertex> getVertices() { | 72 | public EList<Vertex> getVertices() { |
72 | if (vertices == null) { | 73 | if (vertices == null) { |
73 | vertices = new EObjectContainmentEList<Vertex>(Vertex.class, this, YakindummPackage.REGION__VERTICES); | 74 | vertices = new EObjectContainmentEList<Vertex>(Vertex.class, this, YakindummPackage.REGION__VERTICES); |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/StateImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/StateImpl.java index 6da0caec..bb1715f8 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/StateImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/StateImpl.java | |||
@@ -67,6 +67,7 @@ public class StateImpl extends RegularStateImpl implements State { | |||
67 | * <!-- end-user-doc --> | 67 | * <!-- end-user-doc --> |
68 | * @generated | 68 | * @generated |
69 | */ | 69 | */ |
70 | @Override | ||
70 | public EList<Region> getRegions() { | 71 | public EList<Region> getRegions() { |
71 | if (regions == null) { | 72 | if (regions == null) { |
72 | regions = new EObjectContainmentEList<Region>(Region.class, this, YakindummPackage.STATE__REGIONS); | 73 | regions = new EObjectContainmentEList<Region>(Region.class, this, YakindummPackage.STATE__REGIONS); |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/TransitionImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/TransitionImpl.java index ff957869..1a7a275b 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/TransitionImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/TransitionImpl.java | |||
@@ -66,6 +66,7 @@ public class TransitionImpl extends MinimalEObjectImpl.Container implements Tran | |||
66 | * <!-- end-user-doc --> | 66 | * <!-- end-user-doc --> |
67 | * @generated | 67 | * @generated |
68 | */ | 68 | */ |
69 | @Override | ||
69 | public Vertex getTarget() { | 70 | public Vertex getTarget() { |
70 | if (target != null && target.eIsProxy()) { | 71 | if (target != null && target.eIsProxy()) { |
71 | InternalEObject oldTarget = (InternalEObject)target; | 72 | InternalEObject oldTarget = (InternalEObject)target; |
@@ -107,6 +108,7 @@ public class TransitionImpl extends MinimalEObjectImpl.Container implements Tran | |||
107 | * <!-- end-user-doc --> | 108 | * <!-- end-user-doc --> |
108 | * @generated | 109 | * @generated |
109 | */ | 110 | */ |
111 | @Override | ||
110 | public void setTarget(Vertex newTarget) { | 112 | public void setTarget(Vertex newTarget) { |
111 | if (newTarget != target) { | 113 | if (newTarget != target) { |
112 | NotificationChain msgs = null; | 114 | NotificationChain msgs = null; |
@@ -126,6 +128,7 @@ public class TransitionImpl extends MinimalEObjectImpl.Container implements Tran | |||
126 | * <!-- end-user-doc --> | 128 | * <!-- end-user-doc --> |
127 | * @generated | 129 | * @generated |
128 | */ | 130 | */ |
131 | @Override | ||
129 | public Vertex getSource() { | 132 | public Vertex getSource() { |
130 | if (eContainerFeatureID() != YakindummPackage.TRANSITION__SOURCE) return null; | 133 | if (eContainerFeatureID() != YakindummPackage.TRANSITION__SOURCE) return null; |
131 | return (Vertex)eInternalContainer(); | 134 | return (Vertex)eInternalContainer(); |
@@ -146,6 +149,7 @@ public class TransitionImpl extends MinimalEObjectImpl.Container implements Tran | |||
146 | * <!-- end-user-doc --> | 149 | * <!-- end-user-doc --> |
147 | * @generated | 150 | * @generated |
148 | */ | 151 | */ |
152 | @Override | ||
149 | public void setSource(Vertex newSource) { | 153 | public void setSource(Vertex newSource) { |
150 | if (newSource != eInternalContainer() || (eContainerFeatureID() != YakindummPackage.TRANSITION__SOURCE && newSource != null)) { | 154 | if (newSource != eInternalContainer() || (eContainerFeatureID() != YakindummPackage.TRANSITION__SOURCE && newSource != null)) { |
151 | if (EcoreUtil.isAncestor(this, newSource)) | 155 | if (EcoreUtil.isAncestor(this, newSource)) |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/VertexImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/VertexImpl.java index 13df20ee..a2989ade 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/VertexImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/VertexImpl.java | |||
@@ -80,6 +80,7 @@ public abstract class VertexImpl extends MinimalEObjectImpl.Container implements | |||
80 | * <!-- end-user-doc --> | 80 | * <!-- end-user-doc --> |
81 | * @generated | 81 | * @generated |
82 | */ | 82 | */ |
83 | @Override | ||
83 | public EList<Transition> getIncomingTransitions() { | 84 | public EList<Transition> getIncomingTransitions() { |
84 | if (incomingTransitions == null) { | 85 | if (incomingTransitions == null) { |
85 | incomingTransitions = new EObjectWithInverseResolvingEList<Transition>(Transition.class, this, YakindummPackage.VERTEX__INCOMING_TRANSITIONS, YakindummPackage.TRANSITION__TARGET); | 86 | incomingTransitions = new EObjectWithInverseResolvingEList<Transition>(Transition.class, this, YakindummPackage.VERTEX__INCOMING_TRANSITIONS, YakindummPackage.TRANSITION__TARGET); |
@@ -92,6 +93,7 @@ public abstract class VertexImpl extends MinimalEObjectImpl.Container implements | |||
92 | * <!-- end-user-doc --> | 93 | * <!-- end-user-doc --> |
93 | * @generated | 94 | * @generated |
94 | */ | 95 | */ |
96 | @Override | ||
95 | public EList<Transition> getOutgoingTransitions() { | 97 | public EList<Transition> getOutgoingTransitions() { |
96 | if (outgoingTransitions == null) { | 98 | if (outgoingTransitions == null) { |
97 | outgoingTransitions = new EObjectContainmentWithInverseEList<Transition>(Transition.class, this, YakindummPackage.VERTEX__OUTGOING_TRANSITIONS, YakindummPackage.TRANSITION__SOURCE); | 99 | outgoingTransitions = new EObjectContainmentWithInverseEList<Transition>(Transition.class, this, YakindummPackage.VERTEX__OUTGOING_TRANSITIONS, YakindummPackage.TRANSITION__SOURCE); |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/YakindummFactoryImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/YakindummFactoryImpl.java index 9c4fc4f1..79dd5b80 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/YakindummFactoryImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/YakindummFactoryImpl.java | |||
@@ -75,6 +75,7 @@ public class YakindummFactoryImpl extends EFactoryImpl implements YakindummFacto | |||
75 | * <!-- end-user-doc --> | 75 | * <!-- end-user-doc --> |
76 | * @generated | 76 | * @generated |
77 | */ | 77 | */ |
78 | @Override | ||
78 | public Region createRegion() { | 79 | public Region createRegion() { |
79 | RegionImpl region = new RegionImpl(); | 80 | RegionImpl region = new RegionImpl(); |
80 | return region; | 81 | return region; |
@@ -85,6 +86,7 @@ public class YakindummFactoryImpl extends EFactoryImpl implements YakindummFacto | |||
85 | * <!-- end-user-doc --> | 86 | * <!-- end-user-doc --> |
86 | * @generated | 87 | * @generated |
87 | */ | 88 | */ |
89 | @Override | ||
88 | public Transition createTransition() { | 90 | public Transition createTransition() { |
89 | TransitionImpl transition = new TransitionImpl(); | 91 | TransitionImpl transition = new TransitionImpl(); |
90 | return transition; | 92 | return transition; |
@@ -95,6 +97,7 @@ public class YakindummFactoryImpl extends EFactoryImpl implements YakindummFacto | |||
95 | * <!-- end-user-doc --> | 97 | * <!-- end-user-doc --> |
96 | * @generated | 98 | * @generated |
97 | */ | 99 | */ |
100 | @Override | ||
98 | public Statechart createStatechart() { | 101 | public Statechart createStatechart() { |
99 | StatechartImpl statechart = new StatechartImpl(); | 102 | StatechartImpl statechart = new StatechartImpl(); |
100 | return statechart; | 103 | return statechart; |
@@ -105,6 +108,7 @@ public class YakindummFactoryImpl extends EFactoryImpl implements YakindummFacto | |||
105 | * <!-- end-user-doc --> | 108 | * <!-- end-user-doc --> |
106 | * @generated | 109 | * @generated |
107 | */ | 110 | */ |
111 | @Override | ||
108 | public Entry createEntry() { | 112 | public Entry createEntry() { |
109 | EntryImpl entry = new EntryImpl(); | 113 | EntryImpl entry = new EntryImpl(); |
110 | return entry; | 114 | return entry; |
@@ -115,6 +119,7 @@ public class YakindummFactoryImpl extends EFactoryImpl implements YakindummFacto | |||
115 | * <!-- end-user-doc --> | 119 | * <!-- end-user-doc --> |
116 | * @generated | 120 | * @generated |
117 | */ | 121 | */ |
122 | @Override | ||
118 | public Synchronization createSynchronization() { | 123 | public Synchronization createSynchronization() { |
119 | SynchronizationImpl synchronization = new SynchronizationImpl(); | 124 | SynchronizationImpl synchronization = new SynchronizationImpl(); |
120 | return synchronization; | 125 | return synchronization; |
@@ -125,6 +130,7 @@ public class YakindummFactoryImpl extends EFactoryImpl implements YakindummFacto | |||
125 | * <!-- end-user-doc --> | 130 | * <!-- end-user-doc --> |
126 | * @generated | 131 | * @generated |
127 | */ | 132 | */ |
133 | @Override | ||
128 | public State createState() { | 134 | public State createState() { |
129 | StateImpl state = new StateImpl(); | 135 | StateImpl state = new StateImpl(); |
130 | return state; | 136 | return state; |
@@ -135,6 +141,7 @@ public class YakindummFactoryImpl extends EFactoryImpl implements YakindummFacto | |||
135 | * <!-- end-user-doc --> | 141 | * <!-- end-user-doc --> |
136 | * @generated | 142 | * @generated |
137 | */ | 143 | */ |
144 | @Override | ||
138 | public Choice createChoice() { | 145 | public Choice createChoice() { |
139 | ChoiceImpl choice = new ChoiceImpl(); | 146 | ChoiceImpl choice = new ChoiceImpl(); |
140 | return choice; | 147 | return choice; |
@@ -145,6 +152,7 @@ public class YakindummFactoryImpl extends EFactoryImpl implements YakindummFacto | |||
145 | * <!-- end-user-doc --> | 152 | * <!-- end-user-doc --> |
146 | * @generated | 153 | * @generated |
147 | */ | 154 | */ |
155 | @Override | ||
148 | public Exit createExit() { | 156 | public Exit createExit() { |
149 | ExitImpl exit = new ExitImpl(); | 157 | ExitImpl exit = new ExitImpl(); |
150 | return exit; | 158 | return exit; |
@@ -155,6 +163,7 @@ public class YakindummFactoryImpl extends EFactoryImpl implements YakindummFacto | |||
155 | * <!-- end-user-doc --> | 163 | * <!-- end-user-doc --> |
156 | * @generated | 164 | * @generated |
157 | */ | 165 | */ |
166 | @Override | ||
158 | public FinalState createFinalState() { | 167 | public FinalState createFinalState() { |
159 | FinalStateImpl finalState = new FinalStateImpl(); | 168 | FinalStateImpl finalState = new FinalStateImpl(); |
160 | return finalState; | 169 | return finalState; |
@@ -165,6 +174,7 @@ public class YakindummFactoryImpl extends EFactoryImpl implements YakindummFacto | |||
165 | * <!-- end-user-doc --> | 174 | * <!-- end-user-doc --> |
166 | * @generated | 175 | * @generated |
167 | */ | 176 | */ |
177 | @Override | ||
168 | public YakindummPackage getYakindummPackage() { | 178 | public YakindummPackage getYakindummPackage() { |
169 | return (YakindummPackage)getEPackage(); | 179 | return (YakindummPackage)getEPackage(); |
170 | } | 180 | } |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/YakindummPackageImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/YakindummPackageImpl.java index 77092c17..ccb5cb6a 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/YakindummPackageImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/yakindu/sgraph/yakindumm/impl/YakindummPackageImpl.java | |||
@@ -150,7 +150,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
150 | 150 | ||
151 | /** | 151 | /** |
152 | * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. | 152 | * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. |
153 | * | 153 | * |
154 | * <p>This method is used to initialize {@link YakindummPackage#eINSTANCE} when that field is accessed. | 154 | * <p>This method is used to initialize {@link YakindummPackage#eINSTANCE} when that field is accessed. |
155 | * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. | 155 | * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. |
156 | * <!-- begin-user-doc --> | 156 | * <!-- begin-user-doc --> |
@@ -164,7 +164,8 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
164 | if (isInited) return (YakindummPackage)EPackage.Registry.INSTANCE.getEPackage(YakindummPackage.eNS_URI); | 164 | if (isInited) return (YakindummPackage)EPackage.Registry.INSTANCE.getEPackage(YakindummPackage.eNS_URI); |
165 | 165 | ||
166 | // Obtain or create and register package | 166 | // Obtain or create and register package |
167 | YakindummPackageImpl theYakindummPackage = (YakindummPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof YakindummPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new YakindummPackageImpl()); | 167 | Object registeredYakindummPackage = EPackage.Registry.INSTANCE.get(eNS_URI); |
168 | YakindummPackageImpl theYakindummPackage = registeredYakindummPackage instanceof YakindummPackageImpl ? (YakindummPackageImpl)registeredYakindummPackage : new YakindummPackageImpl(); | ||
168 | 169 | ||
169 | isInited = true; | 170 | isInited = true; |
170 | 171 | ||
@@ -177,7 +178,6 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
177 | // Mark meta-data to indicate it can't be changed | 178 | // Mark meta-data to indicate it can't be changed |
178 | theYakindummPackage.freeze(); | 179 | theYakindummPackage.freeze(); |
179 | 180 | ||
180 | |||
181 | // Update the registry and return the package | 181 | // Update the registry and return the package |
182 | EPackage.Registry.INSTANCE.put(YakindummPackage.eNS_URI, theYakindummPackage); | 182 | EPackage.Registry.INSTANCE.put(YakindummPackage.eNS_URI, theYakindummPackage); |
183 | return theYakindummPackage; | 183 | return theYakindummPackage; |
@@ -188,6 +188,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
188 | * <!-- end-user-doc --> | 188 | * <!-- end-user-doc --> |
189 | * @generated | 189 | * @generated |
190 | */ | 190 | */ |
191 | @Override | ||
191 | public EClass getPseudostate() { | 192 | public EClass getPseudostate() { |
192 | return pseudostateEClass; | 193 | return pseudostateEClass; |
193 | } | 194 | } |
@@ -197,6 +198,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
197 | * <!-- end-user-doc --> | 198 | * <!-- end-user-doc --> |
198 | * @generated | 199 | * @generated |
199 | */ | 200 | */ |
201 | @Override | ||
200 | public EClass getVertex() { | 202 | public EClass getVertex() { |
201 | return vertexEClass; | 203 | return vertexEClass; |
202 | } | 204 | } |
@@ -206,6 +208,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
206 | * <!-- end-user-doc --> | 208 | * <!-- end-user-doc --> |
207 | * @generated | 209 | * @generated |
208 | */ | 210 | */ |
211 | @Override | ||
209 | public EReference getVertex_IncomingTransitions() { | 212 | public EReference getVertex_IncomingTransitions() { |
210 | return (EReference)vertexEClass.getEStructuralFeatures().get(0); | 213 | return (EReference)vertexEClass.getEStructuralFeatures().get(0); |
211 | } | 214 | } |
@@ -215,6 +218,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
215 | * <!-- end-user-doc --> | 218 | * <!-- end-user-doc --> |
216 | * @generated | 219 | * @generated |
217 | */ | 220 | */ |
221 | @Override | ||
218 | public EReference getVertex_OutgoingTransitions() { | 222 | public EReference getVertex_OutgoingTransitions() { |
219 | return (EReference)vertexEClass.getEStructuralFeatures().get(1); | 223 | return (EReference)vertexEClass.getEStructuralFeatures().get(1); |
220 | } | 224 | } |
@@ -224,6 +228,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
224 | * <!-- end-user-doc --> | 228 | * <!-- end-user-doc --> |
225 | * @generated | 229 | * @generated |
226 | */ | 230 | */ |
231 | @Override | ||
227 | public EClass getRegion() { | 232 | public EClass getRegion() { |
228 | return regionEClass; | 233 | return regionEClass; |
229 | } | 234 | } |
@@ -233,6 +238,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
233 | * <!-- end-user-doc --> | 238 | * <!-- end-user-doc --> |
234 | * @generated | 239 | * @generated |
235 | */ | 240 | */ |
241 | @Override | ||
236 | public EReference getRegion_Vertices() { | 242 | public EReference getRegion_Vertices() { |
237 | return (EReference)regionEClass.getEStructuralFeatures().get(0); | 243 | return (EReference)regionEClass.getEStructuralFeatures().get(0); |
238 | } | 244 | } |
@@ -242,6 +248,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
242 | * <!-- end-user-doc --> | 248 | * <!-- end-user-doc --> |
243 | * @generated | 249 | * @generated |
244 | */ | 250 | */ |
251 | @Override | ||
245 | public EClass getTransition() { | 252 | public EClass getTransition() { |
246 | return transitionEClass; | 253 | return transitionEClass; |
247 | } | 254 | } |
@@ -251,6 +258,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
251 | * <!-- end-user-doc --> | 258 | * <!-- end-user-doc --> |
252 | * @generated | 259 | * @generated |
253 | */ | 260 | */ |
261 | @Override | ||
254 | public EReference getTransition_Target() { | 262 | public EReference getTransition_Target() { |
255 | return (EReference)transitionEClass.getEStructuralFeatures().get(0); | 263 | return (EReference)transitionEClass.getEStructuralFeatures().get(0); |
256 | } | 264 | } |
@@ -260,6 +268,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
260 | * <!-- end-user-doc --> | 268 | * <!-- end-user-doc --> |
261 | * @generated | 269 | * @generated |
262 | */ | 270 | */ |
271 | @Override | ||
263 | public EReference getTransition_Source() { | 272 | public EReference getTransition_Source() { |
264 | return (EReference)transitionEClass.getEStructuralFeatures().get(1); | 273 | return (EReference)transitionEClass.getEStructuralFeatures().get(1); |
265 | } | 274 | } |
@@ -269,6 +278,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
269 | * <!-- end-user-doc --> | 278 | * <!-- end-user-doc --> |
270 | * @generated | 279 | * @generated |
271 | */ | 280 | */ |
281 | @Override | ||
272 | public EClass getStatechart() { | 282 | public EClass getStatechart() { |
273 | return statechartEClass; | 283 | return statechartEClass; |
274 | } | 284 | } |
@@ -278,6 +288,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
278 | * <!-- end-user-doc --> | 288 | * <!-- end-user-doc --> |
279 | * @generated | 289 | * @generated |
280 | */ | 290 | */ |
291 | @Override | ||
281 | public EClass getEntry() { | 292 | public EClass getEntry() { |
282 | return entryEClass; | 293 | return entryEClass; |
283 | } | 294 | } |
@@ -287,6 +298,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
287 | * <!-- end-user-doc --> | 298 | * <!-- end-user-doc --> |
288 | * @generated | 299 | * @generated |
289 | */ | 300 | */ |
301 | @Override | ||
290 | public EClass getSynchronization() { | 302 | public EClass getSynchronization() { |
291 | return synchronizationEClass; | 303 | return synchronizationEClass; |
292 | } | 304 | } |
@@ -296,6 +308,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
296 | * <!-- end-user-doc --> | 308 | * <!-- end-user-doc --> |
297 | * @generated | 309 | * @generated |
298 | */ | 310 | */ |
311 | @Override | ||
299 | public EClass getState() { | 312 | public EClass getState() { |
300 | return stateEClass; | 313 | return stateEClass; |
301 | } | 314 | } |
@@ -305,6 +318,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
305 | * <!-- end-user-doc --> | 318 | * <!-- end-user-doc --> |
306 | * @generated | 319 | * @generated |
307 | */ | 320 | */ |
321 | @Override | ||
308 | public EClass getRegularState() { | 322 | public EClass getRegularState() { |
309 | return regularStateEClass; | 323 | return regularStateEClass; |
310 | } | 324 | } |
@@ -314,6 +328,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
314 | * <!-- end-user-doc --> | 328 | * <!-- end-user-doc --> |
315 | * @generated | 329 | * @generated |
316 | */ | 330 | */ |
331 | @Override | ||
317 | public EClass getCompositeElement() { | 332 | public EClass getCompositeElement() { |
318 | return compositeElementEClass; | 333 | return compositeElementEClass; |
319 | } | 334 | } |
@@ -323,6 +338,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
323 | * <!-- end-user-doc --> | 338 | * <!-- end-user-doc --> |
324 | * @generated | 339 | * @generated |
325 | */ | 340 | */ |
341 | @Override | ||
326 | public EReference getCompositeElement_Regions() { | 342 | public EReference getCompositeElement_Regions() { |
327 | return (EReference)compositeElementEClass.getEStructuralFeatures().get(0); | 343 | return (EReference)compositeElementEClass.getEStructuralFeatures().get(0); |
328 | } | 344 | } |
@@ -332,6 +348,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
332 | * <!-- end-user-doc --> | 348 | * <!-- end-user-doc --> |
333 | * @generated | 349 | * @generated |
334 | */ | 350 | */ |
351 | @Override | ||
335 | public EClass getChoice() { | 352 | public EClass getChoice() { |
336 | return choiceEClass; | 353 | return choiceEClass; |
337 | } | 354 | } |
@@ -341,6 +358,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
341 | * <!-- end-user-doc --> | 358 | * <!-- end-user-doc --> |
342 | * @generated | 359 | * @generated |
343 | */ | 360 | */ |
361 | @Override | ||
344 | public EClass getExit() { | 362 | public EClass getExit() { |
345 | return exitEClass; | 363 | return exitEClass; |
346 | } | 364 | } |
@@ -350,6 +368,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
350 | * <!-- end-user-doc --> | 368 | * <!-- end-user-doc --> |
351 | * @generated | 369 | * @generated |
352 | */ | 370 | */ |
371 | @Override | ||
353 | public EClass getFinalState() { | 372 | public EClass getFinalState() { |
354 | return finalStateEClass; | 373 | return finalStateEClass; |
355 | } | 374 | } |
@@ -359,6 +378,7 @@ public class YakindummPackageImpl extends EPackageImpl implements YakindummPacka | |||
359 | * <!-- end-user-doc --> | 378 | * <!-- end-user-doc --> |
360 | * @generated | 379 | * @generated |
361 | */ | 380 | */ |
381 | @Override | ||
362 | public YakindummFactory getYakindummFactory() { | 382 | public YakindummFactory getYakindummFactory() { |
363 | return (YakindummFactory)getEFactoryInstance(); | 383 | return (YakindummFactory)getEFactoryInstance(); |
364 | } | 384 | } |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/model/yakindu_simplified.genmodel b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/model/yakindu_simplified.genmodel index 4e34cf1d..0a658e2c 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/model/yakindu_simplified.genmodel +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/model/yakindu_simplified.genmodel | |||
@@ -29,5 +29,6 @@ | |||
29 | </genClasses> | 29 | </genClasses> |
30 | <genClasses ecoreClass="yakindu_simplified.ecore#//Choice"/> | 30 | <genClasses ecoreClass="yakindu_simplified.ecore#//Choice"/> |
31 | <genClasses ecoreClass="yakindu_simplified.ecore#//Exit"/> | 31 | <genClasses ecoreClass="yakindu_simplified.ecore#//Exit"/> |
32 | <genClasses ecoreClass="yakindu_simplified.ecore#//FinalState"/> | ||
32 | </genPackages> | 33 | </genPackages> |
33 | </genmodel:GenModel> | 34 | </genmodel:GenModel> |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml index 5fd865dc..6941efca 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml | |||
@@ -22,72 +22,4 @@ | |||
22 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.hasMultipleRegions"/> | 22 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.hasMultipleRegions"/> |
23 | </group> | 23 | </group> |
24 | </extension> | 24 | </extension> |
25 | <extension id="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.Mutated" point="org.eclipse.viatra.query.runtime.queryspecification"> | ||
26 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.Mutated" id="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.Mutated"> | ||
27 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.entryInRegion_M0"/> | ||
28 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.entryInRegion_M1"/> | ||
29 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.entryInRegion_M2"/> | ||
30 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M0"/> | ||
31 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M1"/> | ||
32 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M2"/> | ||
33 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M3"/> | ||
34 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M4"/> | ||
35 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M5"/> | ||
36 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M0"/> | ||
37 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M1"/> | ||
38 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M2"/> | ||
39 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M3"/> | ||
40 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M4"/> | ||
41 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M5"/> | ||
42 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M0"/> | ||
43 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M1"/> | ||
44 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M2"/> | ||
45 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M3"/> | ||
46 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M4"/> | ||
47 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_M0"/> | ||
48 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_1"/> | ||
49 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_2"/> | ||
50 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_3"/> | ||
51 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_4"/> | ||
52 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_5"/> | ||
53 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M0"/> | ||
54 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M1"/> | ||
55 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M2"/> | ||
56 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M3"/> | ||
57 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M4"/> | ||
58 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M5"/> | ||
59 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M0"/> | ||
60 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M1"/> | ||
61 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M2"/> | ||
62 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M3"/> | ||
63 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M4"/> | ||
64 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromExit_M0"/> | ||
65 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromExit_M1"/> | ||
66 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromExit_M2"/> | ||
67 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromFinal_M0"/> | ||
68 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromFinal_M1"/> | ||
69 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromFinal_M2"/> | ||
70 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M0"/> | ||
71 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M1"/> | ||
72 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M2"/> | ||
73 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M3"/> | ||
74 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.StateInRegion_M0"/> | ||
75 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.StateInRegion_M1"/> | ||
76 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.StateInRegion_M2"/> | ||
77 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M0"/> | ||
78 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M1"/> | ||
79 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M2"/> | ||
80 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M3"/> | ||
81 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M4"/> | ||
82 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M5"/> | ||
83 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M6"/> | ||
84 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M0"/> | ||
85 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M1"/> | ||
86 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M2"/> | ||
87 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M3"/> | ||
88 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M4"/> | ||
89 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M5"/> | ||
90 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M6"/> | ||
91 | </group> | ||
92 | </extension> | ||
93 | </plugin> | 25 | </plugin> |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/mutated/mutated.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/mutated/mutated.vql deleted file mode 100644 index 58f66fe2..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/mutated/mutated.vql +++ /dev/null | |||
@@ -1,270 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated | ||
2 | |||
3 | import epackage "hu.bme.mit.inf.yakindumm" | ||
4 | |||
5 | ///////// | ||
6 | // Entry | ||
7 | ///////// | ||
8 | |||
9 | pattern entryInRegion_M0(r1 : Region, e1 : Entry) { | ||
10 | Region.vertices(r1, e1); | ||
11 | } | ||
12 | pattern entryInRegion_M1(r1 : Region, e1) { | ||
13 | Region.vertices(r1, e1); | ||
14 | } | ||
15 | pattern entryInRegion_M2(r1 : Region, e1: Entry) { | ||
16 | // For positive constraint | ||
17 | Region(r1);Entry(e1); | ||
18 | } | ||
19 | |||
20 | |||
21 | //@Constraint(severity="error", message="error", key = {r1}) | ||
22 | pattern noEntryInRegion_M0(r1 : Region) { | ||
23 | neg find entryInRegion_M0(r1, _); | ||
24 | } | ||
25 | pattern noEntryInRegion_M1(r1 : Region) { | ||
26 | neg find entryInRegion_M1(r1, _); | ||
27 | } | ||
28 | pattern noEntryInRegion_M2(r1 : Region) { | ||
29 | neg find entryInRegion_M2(r1, _); | ||
30 | } | ||
31 | pattern noEntryInRegion_M3(r1 : Region) { | ||
32 | find entryInRegion_M0(r1, _); | ||
33 | } | ||
34 | pattern noEntryInRegion_M4(r1 : Region) { | ||
35 | find entryInRegion_M1(r1, _); | ||
36 | } | ||
37 | pattern noEntryInRegion_M5(r1 : Region) { | ||
38 | find entryInRegion_M2(r1, _); | ||
39 | } | ||
40 | |||
41 | //@Constraint(severity="error", message="error", key = {r}) | ||
42 | pattern multipleEntryInRegion_M0(r : Region) { | ||
43 | find entryInRegion_M0(r, e1); | ||
44 | find entryInRegion_M0(r, e2); | ||
45 | e1 != e2; | ||
46 | } | ||
47 | pattern multipleEntryInRegion_M1(r : Region) { | ||
48 | find entryInRegion_M1(r, e1); | ||
49 | find entryInRegion_M0(r, e2); | ||
50 | e1 != e2; | ||
51 | } | ||
52 | pattern multipleEntryInRegion_M2(r : Region) { | ||
53 | find entryInRegion_M2(r, e1); | ||
54 | find entryInRegion_M0(r, e2); | ||
55 | e1 != e2; | ||
56 | } | ||
57 | pattern multipleEntryInRegion_M3(r : Region) { | ||
58 | find entryInRegion_M0(r, e1); | ||
59 | find entryInRegion_M1(r, e2); | ||
60 | e1 != e2; | ||
61 | } | ||
62 | pattern multipleEntryInRegion_M4(r : Region) { | ||
63 | find entryInRegion_M2(r, e1); | ||
64 | find entryInRegion_M2(r, e2); | ||
65 | e1 != e2; | ||
66 | } | ||
67 | pattern multipleEntryInRegion_M5(r : Region) { | ||
68 | find entryInRegion_M0(r, e1); | ||
69 | find entryInRegion_M0(r, e2); | ||
70 | } | ||
71 | |||
72 | |||
73 | pattern transition_M0(t : Transition, src : Vertex, trg : Vertex) { | ||
74 | Transition.source(t, src); | ||
75 | Transition.target(t, trg); | ||
76 | } | ||
77 | pattern transition_M1(t : Transition, src : Vertex, trg : Vertex) { | ||
78 | Transition.source(t, src); | ||
79 | Vertex(trg); | ||
80 | } | ||
81 | pattern transition_M2(t : Transition, src : Vertex, trg : Vertex) { | ||
82 | Vertex(src); | ||
83 | Transition.target(t, trg); | ||
84 | } | ||
85 | pattern transition_M3(t : Transition, src : Vertex, trg : Vertex) { | ||
86 | Transition.source(t_x, src); | ||
87 | Transition.target(t, trg); | ||
88 | } | ||
89 | pattern transition_M4(t : Transition, src : Vertex, trg : Vertex) { | ||
90 | Transition.source(t, src); | ||
91 | Transition.target(t_x, trg); | ||
92 | } | ||
93 | |||
94 | //@Constraint(severity="error", message="error", key = {e}) | ||
95 | pattern incomingToEntry_M0(t : Transition, e : Entry) { | ||
96 | find transition_M0(t, _, e); | ||
97 | } | ||
98 | pattern incomingToEntry_1(t : Transition, e) { | ||
99 | find transition_M0(t, _, e); | ||
100 | } | ||
101 | pattern incomingToEntry_2(t : Transition, e : Entry) { | ||
102 | find transition_M1(t, _, e); | ||
103 | } | ||
104 | pattern incomingToEntry_3(t : Transition, e : Entry) { | ||
105 | find transition_M2(t, _, e); | ||
106 | } | ||
107 | pattern incomingToEntry_4(t : Transition, e : Entry) { | ||
108 | find transition_M3(t, _, e); | ||
109 | } | ||
110 | pattern incomingToEntry_5(t : Transition, e : Entry) { | ||
111 | find transition_M4(t, _, e); | ||
112 | } | ||
113 | |||
114 | pattern noOutgoingTransitionFromEntry_M0(e : Entry) { | ||
115 | neg find transition_M0(_, e, _); | ||
116 | } | ||
117 | |||
118 | pattern noOutgoingTransitionFromEntry_M1(e) { | ||
119 | Vertex(e); | ||
120 | neg find transition_M0(_, e, _); | ||
121 | } | ||
122 | pattern noOutgoingTransitionFromEntry_M2(e : Entry) { | ||
123 | neg find transition_M1(_, e, _); | ||
124 | } | ||
125 | pattern noOutgoingTransitionFromEntry_M3(e : Entry) { | ||
126 | neg find transition_M2(_, e, _); | ||
127 | } | ||
128 | pattern noOutgoingTransitionFromEntry_M4(e : Entry) { | ||
129 | neg find transition_M3(_, e, _); | ||
130 | } | ||
131 | pattern noOutgoingTransitionFromEntry_M5(e : Entry) { | ||
132 | neg find transition_M4(_, e, _); | ||
133 | } | ||
134 | |||
135 | |||
136 | //@Constraint(severity="error", message="error", key = {e}) | ||
137 | pattern multipleTransitionFromEntry_M0(e : Entry, t1 : Transition, t2: Transition) { | ||
138 | Entry.outgoingTransitions(e,t1); | ||
139 | Entry.outgoingTransitions(e,t2); | ||
140 | t1!=t2; | ||
141 | } | ||
142 | pattern multipleTransitionFromEntry_M1(e, t1 : Transition, t2: Transition) { | ||
143 | Entry.outgoingTransitions(e,t1); | ||
144 | Entry.outgoingTransitions(e,t2); | ||
145 | t1!=t2; | ||
146 | } | ||
147 | pattern multipleTransitionFromEntry_M2(e : Entry, t1 : Transition, t2: Transition) { | ||
148 | Transition(t1); | ||
149 | Entry.outgoingTransitions(e,t2); | ||
150 | t1!=t2; | ||
151 | } | ||
152 | pattern multipleTransitionFromEntry_M3(e : Entry, t1 : Transition, t2: Transition) { | ||
153 | Entry.outgoingTransitions(e,t1); | ||
154 | Transition(t2); | ||
155 | t1!=t2; | ||
156 | } | ||
157 | pattern multipleTransitionFromEntry_M4(e : Entry, t1 : Transition, t2: Transition) { | ||
158 | Entry.outgoingTransitions(e,t1); | ||
159 | Entry.outgoingTransitions(e,t2); | ||
160 | } | ||
161 | |||
162 | ///////// | ||
163 | // Exit | ||
164 | ///////// | ||
165 | |||
166 | //@Constraint(severity="error", message="error", key = {e}) | ||
167 | pattern outgoingFromExit_M0(t : Transition, e : Exit) { | ||
168 | Exit.outgoingTransitions(e,t); | ||
169 | } | ||
170 | pattern outgoingFromExit_M1(t : Transition, e) { | ||
171 | Vertex.outgoingTransitions(e,t); | ||
172 | } | ||
173 | pattern outgoingFromExit_M2(t : Transition, e : Exit) { | ||
174 | Transition(t); | ||
175 | Exit(e); | ||
176 | } | ||
177 | |||
178 | ///////// | ||
179 | // Final | ||
180 | ///////// | ||
181 | |||
182 | //@Constraint(severity="error", message="error", key = {f}) | ||
183 | pattern outgoingFromFinal_M0(t : Transition, f : FinalState) { | ||
184 | FinalState.outgoingTransitions(f,t); | ||
185 | } | ||
186 | pattern outgoingFromFinal_M1(t : Transition, f) { | ||
187 | Vertex.outgoingTransitions(f,t); | ||
188 | } | ||
189 | pattern outgoingFromFinal_M2(t : Transition, f : FinalState) { | ||
190 | Transition(t); | ||
191 | FinalState(f); | ||
192 | } | ||
193 | |||
194 | ///////// | ||
195 | // State vs Region | ||
196 | ///////// | ||
197 | |||
198 | //@Constraint(severity="error", message="error", key = {region}) | ||
199 | pattern noStateInRegion_M0(region: Region) { | ||
200 | neg find StateInRegion_M0(region,_); | ||
201 | } | ||
202 | pattern noStateInRegion_M1(region: Region) { | ||
203 | neg find StateInRegion_M1(region,_); | ||
204 | } | ||
205 | pattern noStateInRegion_M2(region: Region) { | ||
206 | neg find StateInRegion_M2(region,_); | ||
207 | } | ||
208 | pattern noStateInRegion_M3(region: Region) { | ||
209 | find StateInRegion_M0(region,_); | ||
210 | } | ||
211 | |||
212 | pattern StateInRegion_M0(region: Region, state: State) { | ||
213 | Region.vertices(region,state); | ||
214 | } | ||
215 | pattern StateInRegion_M1(region: Region, state) { | ||
216 | Region.vertices(region,state); | ||
217 | } | ||
218 | pattern StateInRegion_M2(region: Region, state:State) { | ||
219 | Region(region);State(state); | ||
220 | } | ||
221 | |||
222 | ///////// | ||
223 | // Choice | ||
224 | ///////// | ||
225 | |||
226 | @Constraint(severity="error", message="error", key = {c}) | ||
227 | pattern choiceHasNoOutgoing_M0(c : Choice) { | ||
228 | neg find transition_M0(_, c, _); | ||
229 | } | ||
230 | pattern choiceHasNoOutgoing_M1(c:Vertex) { | ||
231 | neg find transition_M0(_, c, _); | ||
232 | } | ||
233 | pattern choiceHasNoOutgoing_M2(c : Choice) { | ||
234 | neg find transition_M1(_, c, _); | ||
235 | } | ||
236 | pattern choiceHasNoOutgoing_M3(c : Choice) { | ||
237 | neg find transition_M2(_, c, _); | ||
238 | } | ||
239 | pattern choiceHasNoOutgoing_M4(c : Choice) { | ||
240 | neg find transition_M3(_, c, _); | ||
241 | } | ||
242 | pattern choiceHasNoOutgoing_M5(c : Choice) { | ||
243 | neg find transition_M4(_, c, _); | ||
244 | } | ||
245 | pattern choiceHasNoOutgoing_M6(c : Choice) { | ||
246 | find transition_M0(_, c, _); | ||
247 | } | ||
248 | |||
249 | @Constraint(severity="error", message="error", key = {c}) | ||
250 | pattern choiceHasNoIncoming_M0(c: Choice) { | ||
251 | neg find transition_M0(_, _, c); | ||
252 | } | ||
253 | pattern choiceHasNoIncoming_M1(c:Vertex) { | ||
254 | neg find transition_M0(_, _, c); | ||
255 | } | ||
256 | pattern choiceHasNoIncoming_M2(c: Choice) { | ||
257 | neg find transition_M1(_, _, c); | ||
258 | } | ||
259 | pattern choiceHasNoIncoming_M3(c: Choice) { | ||
260 | neg find transition_M2(_, _, c); | ||
261 | } | ||
262 | pattern choiceHasNoIncoming_M4(c: Choice) { | ||
263 | neg find transition_M3(_, _, c); | ||
264 | } | ||
265 | pattern choiceHasNoIncoming_M5(c: Choice) { | ||
266 | neg find transition_M4(_, _, c); | ||
267 | } | ||
268 | pattern choiceHasNoIncoming_M6(c: Choice) { | ||
269 | find transition_M0(_, _, c); | ||
270 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql index 69689899..82b908b3 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql | |||
@@ -1,5 +1,4 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu | 1 | package hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu |
2 | |||
3 | import epackage "hu.bme.mit.inf.yakindumm" | 2 | import epackage "hu.bme.mit.inf.yakindumm" |
4 | 3 | ||
5 | ///////// | 4 | ///////// |
@@ -122,7 +121,7 @@ pattern choiceHasNoIncoming(c: Choice) { | |||
122 | // neg find hasMultipleOutgoingTrainsition(s); | 121 | // neg find hasMultipleOutgoingTrainsition(s); |
123 | // neg find hasMultipleIncomingTrainsition(s); | 122 | // neg find hasMultipleIncomingTrainsition(s); |
124 | //} | 123 | //} |
125 | // | 124 | |
126 | //pattern hasMultipleOutgoingTrainsition(v : Synchronization) { | 125 | //pattern hasMultipleOutgoingTrainsition(v : Synchronization) { |
127 | // find transition(_, v, trg1); | 126 | // find transition(_, v, trg1); |
128 | // find transition(_, v, trg2); | 127 | // find transition(_, v, trg2); |
@@ -203,10 +202,10 @@ pattern hasMultipleRegions(composite: CompositeElement) { | |||
203 | // t2!=t3; | 202 | // t2!=t3; |
204 | // t1!=t3; | 203 | // t1!=t3; |
205 | //} | 204 | //} |
206 | // | 205 | |
207 | ///** | 206 | /** |
208 | // * Simplifying model generation | 207 | * Simplifying model generation |
209 | // */ | 208 | */ |
210 | //@Constraint(severity="error", message="error", key = {s1,s2}) | 209 | //@Constraint(severity="error", message="error", key = {s1,s2}) |
211 | //pattern twoSynch(s1 : Synchronization, s2 : Synchronization) { | 210 | //pattern twoSynch(s1 : Synchronization, s2 : Synchronization) { |
212 | // Synchronization(s1); | 211 | // Synchronization(s1); |