aboutsummaryrefslogtreecommitdiffstats
path: root/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kris7topher@gmail.com>2019-05-21 17:00:01 -0400
committerLibravatar Kristóf Marussy <kris7topher@gmail.com>2019-05-21 17:00:01 -0400
commitfd3684b5440dacca0c4bf4be15930555a79e2100 (patch)
tree24120a5c7fdae1532529fa0c4687dc1078cd1cde /Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf
parentInterval hull aggregation operator (diff)
downloadVIATRA-Generator-fd3684b5440dacca0c4bf4be15930555a79e2100.tar.gz
VIATRA-Generator-fd3684b5440dacca0c4bf4be15930555a79e2100.tar.zst
VIATRA-Generator-fd3684b5440dacca0c4bf4be15930555a79e2100.zip
VIATRA DSE and COIN-OR CBC implementations of CPS case study
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf')
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore10
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/Allocate.java862
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java2
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java743
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java743
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java4
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java12
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java4
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java705
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java2
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java124
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CreateHostInstance.java553
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/GuidanceObjective.java591
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java2
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java2
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RemoveHostInstance.java (renamed from Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java)370
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/ResourceRequirement.java829
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java706
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java706
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/UnallocateAppInstance.java541
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore9
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableHdd.java178
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableMemory.java178
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsApplications.java141
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsHosts.java141
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java38
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java4
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java4
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java2
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java2
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java2
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/NoHostToAllocateTo.java135
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/RequiredAppInstances.java181
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java168
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalHdd.java143
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalMemory.java143
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/UnallocatedAppInstance.java172
37 files changed, 5053 insertions, 4099 deletions
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
index b634f74b..4e059848 100644
--- 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
@@ -15,3 +15,13 @@
15/.CostMetric.java._trace 15/.CostMetric.java._trace
16/.CpsCost.java._trace 16/.CpsCost.java._trace
17/.RedundantInstancesOnSameHost.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
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..830dc8a0
--- /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,862 @@
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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance;
7import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance;
8import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd;
9import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory;
10import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance;
11import java.util.Arrays;
12import java.util.Collection;
13import java.util.Collections;
14import java.util.LinkedHashSet;
15import java.util.List;
16import java.util.Objects;
17import java.util.Optional;
18import java.util.Set;
19import java.util.function.Consumer;
20import java.util.stream.Collectors;
21import java.util.stream.Stream;
22import org.apache.log4j.Logger;
23import org.eclipse.emf.ecore.EClass;
24import org.eclipse.emf.ecore.EDataType;
25import org.eclipse.viatra.query.runtime.api.IPatternMatch;
26import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
27import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
28import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
29import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
30import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
31import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
32import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
33import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
34import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
35import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
36import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
37import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
38import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
39import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
40import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
41import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
42import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
43import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
44import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
45import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
46import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
47import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
48import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
49import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
50import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
51import 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")
81public 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 if ("App".equals(parameterName)) return this.fApp;
109 if ("Host".equals(parameterName)) return this.fHost;
110 return null;
111 }
112
113 public ApplicationInstance getApp() {
114 return this.fApp;
115 }
116
117 public HostInstance getHost() {
118 return this.fHost;
119 }
120
121 @Override
122 public boolean set(final String parameterName, final Object newValue) {
123 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
124 if ("App".equals(parameterName) ) {
125 this.fApp = (ApplicationInstance) newValue;
126 return true;
127 }
128 if ("Host".equals(parameterName) ) {
129 this.fHost = (HostInstance) newValue;
130 return true;
131 }
132 return false;
133 }
134
135 public void setApp(final ApplicationInstance pApp) {
136 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
137 this.fApp = pApp;
138 }
139
140 public void setHost(final HostInstance pHost) {
141 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
142 this.fHost = pHost;
143 }
144
145 @Override
146 public String patternName() {
147 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocate";
148 }
149
150 @Override
151 public List<String> parameterNames() {
152 return Allocate.Match.parameterNames;
153 }
154
155 @Override
156 public Object[] toArray() {
157 return new Object[]{fApp, fHost};
158 }
159
160 @Override
161 public Allocate.Match toImmutable() {
162 return isMutable() ? newMatch(fApp, fHost) : this;
163 }
164
165 @Override
166 public String prettyPrint() {
167 StringBuilder result = new StringBuilder();
168 result.append("\"App\"=" + prettyPrintValue(fApp) + ", ");
169 result.append("\"Host\"=" + prettyPrintValue(fHost));
170 return result.toString();
171 }
172
173 @Override
174 public int hashCode() {
175 return Objects.hash(fApp, fHost);
176 }
177
178 @Override
179 public boolean equals(final Object obj) {
180 if (this == obj)
181 return true;
182 if (obj == null) {
183 return false;
184 }
185 if ((obj instanceof Allocate.Match)) {
186 Allocate.Match other = (Allocate.Match) obj;
187 return Objects.equals(fApp, other.fApp) && Objects.equals(fHost, other.fHost);
188 } else {
189 // this should be infrequent
190 if (!(obj instanceof IPatternMatch)) {
191 return false;
192 }
193 IPatternMatch otherSig = (IPatternMatch) obj;
194 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
195 }
196 }
197
198 @Override
199 public Allocate specification() {
200 return Allocate.instance();
201 }
202
203 /**
204 * Returns an empty, mutable match.
205 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
206 *
207 * @return the empty match.
208 *
209 */
210 public static Allocate.Match newEmptyMatch() {
211 return new Mutable(null, null);
212 }
213
214 /**
215 * Returns a mutable (partial) match.
216 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
217 *
218 * @param pApp the fixed value of pattern parameter App, or null if not bound.
219 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
220 * @return the new, mutable (partial) match object.
221 *
222 */
223 public static Allocate.Match newMutableMatch(final ApplicationInstance pApp, final HostInstance pHost) {
224 return new Mutable(pApp, pHost);
225 }
226
227 /**
228 * Returns a new (partial) match.
229 * This can be used e.g. to call the matcher with a partial match.
230 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
231 * @param pApp the fixed value of pattern parameter App, or null if not bound.
232 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
233 * @return the (partial) match object.
234 *
235 */
236 public static Allocate.Match newMatch(final ApplicationInstance pApp, final HostInstance pHost) {
237 return new Immutable(pApp, pHost);
238 }
239
240 private static final class Mutable extends Allocate.Match {
241 Mutable(final ApplicationInstance pApp, final HostInstance pHost) {
242 super(pApp, pHost);
243 }
244
245 @Override
246 public boolean isMutable() {
247 return true;
248 }
249 }
250
251 private static final class Immutable extends Allocate.Match {
252 Immutable(final ApplicationInstance pApp, final HostInstance pHost) {
253 super(pApp, pHost);
254 }
255
256 @Override
257 public boolean isMutable() {
258 return false;
259 }
260 }
261 }
262
263 /**
264 * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocate pattern,
265 * providing pattern-specific query methods.
266 *
267 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
268 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
269 *
270 * <p>Matches of the pattern will be represented as {@link Match}.
271 *
272 * <p>Original source:
273 * <code><pre>
274 * //
275 * // Transformation rule preconditions for rule-based DSE
276 * //
277 *
278 * pattern allocate(App : ApplicationInstance, Host : HostInstance) {
279 * ApplicationInstance.type.requirements(App, Req);
280 * ResourceRequirement.hostType.instances(Req, Host);
281 * find unallocatedAppInstance(App);
282 * find availableMemory(Host, AvailableMem);
283 * find availableHdd(Host, AvailableHdd);
284 * ResourceRequirement.requiredMemory(Req, RequiredMem);
285 * ResourceRequirement.requiredHdd(Req, RequiredHdd);
286 * check(AvailableMem {@literal >}= RequiredMem);
287 * check(AvailableHdd {@literal >}= RequiredHdd);
288 * neg ApplicationInstance.requirement.instances.allocatedTo(App, Host);
289 * }
290 * </pre></code>
291 *
292 * @see Match
293 * @see Allocate
294 *
295 */
296 public static class Matcher extends BaseMatcher<Allocate.Match> {
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 public static Allocate.Matcher on(final ViatraQueryEngine engine) {
306 // check if matcher already exists
307 Matcher matcher = engine.getExistingMatcher(querySpecification());
308 if (matcher == null) {
309 matcher = (Matcher)engine.getMatcher(querySpecification());
310 }
311 return matcher;
312 }
313
314 /**
315 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
316 * @return an initialized matcher
317 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
318 *
319 */
320 public static Allocate.Matcher create() {
321 return new Matcher();
322 }
323
324 private static final int POSITION_APP = 0;
325
326 private static final int POSITION_HOST = 1;
327
328 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Allocate.Matcher.class);
329
330 /**
331 * Initializes the pattern matcher within an existing VIATRA Query engine.
332 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
333 *
334 * @param engine the existing VIATRA Query engine in which this matcher will be created.
335 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
336 *
337 */
338 private Matcher() {
339 super(querySpecification());
340 }
341
342 /**
343 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
344 * @param pApp the fixed value of pattern parameter App, or null if not bound.
345 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
346 * @return matches represented as a Match object.
347 *
348 */
349 public Collection<Allocate.Match> getAllMatches(final ApplicationInstance pApp, final HostInstance pHost) {
350 return rawStreamAllMatches(new Object[]{pApp, pHost}).collect(Collectors.toSet());
351 }
352
353 /**
354 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
355 * </p>
356 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
357 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
358 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
359 * @param pApp the fixed value of pattern parameter App, or null if not bound.
360 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
361 * @return a stream of matches represented as a Match object.
362 *
363 */
364 public Stream<Allocate.Match> streamAllMatches(final ApplicationInstance pApp, final HostInstance pHost) {
365 return rawStreamAllMatches(new Object[]{pApp, pHost});
366 }
367
368 /**
369 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
370 * Neither determinism nor randomness of selection is guaranteed.
371 * @param pApp the fixed value of pattern parameter App, or null if not bound.
372 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
373 * @return a match represented as a Match object, or null if no match is found.
374 *
375 */
376 public Optional<Allocate.Match> getOneArbitraryMatch(final ApplicationInstance pApp, final HostInstance pHost) {
377 return rawGetOneArbitraryMatch(new Object[]{pApp, pHost});
378 }
379
380 /**
381 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
382 * under any possible substitution of the unspecified parameters (if any).
383 * @param pApp the fixed value of pattern parameter App, or null if not bound.
384 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
385 * @return true if the input is a valid (partial) match of the pattern.
386 *
387 */
388 public boolean hasMatch(final ApplicationInstance pApp, final HostInstance pHost) {
389 return rawHasMatch(new Object[]{pApp, pHost});
390 }
391
392 /**
393 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
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 the number of pattern matches found.
397 *
398 */
399 public int countMatches(final ApplicationInstance pApp, final HostInstance pHost) {
400 return rawCountMatches(new Object[]{pApp, pHost});
401 }
402
403 /**
404 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
405 * Neither determinism nor randomness of selection is guaranteed.
406 * @param pApp the fixed value of pattern parameter App, or null if not bound.
407 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
408 * @param processor the action that will process the selected match.
409 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
410 *
411 */
412 public boolean forOneArbitraryMatch(final ApplicationInstance pApp, final HostInstance pHost, final Consumer<? super Allocate.Match> processor) {
413 return rawForOneArbitraryMatch(new Object[]{pApp, pHost}, processor);
414 }
415
416 /**
417 * Returns a new (partial) match.
418 * This can be used e.g. to call the matcher with a partial match.
419 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
420 * @param pApp the fixed value of pattern parameter App, or null if not bound.
421 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
422 * @return the (partial) match object.
423 *
424 */
425 public Allocate.Match newMatch(final ApplicationInstance pApp, final HostInstance pHost) {
426 return Allocate.Match.newMatch(pApp, pHost);
427 }
428
429 /**
430 * Retrieve the set of values that occur in matches for App.
431 * @return the Set of all values or empty set if there are no matches
432 *
433 */
434 protected Stream<ApplicationInstance> rawStreamAllValuesOfApp(final Object[] parameters) {
435 return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast);
436 }
437
438 /**
439 * Retrieve the set of values that occur in matches for App.
440 * @return the Set of all values or empty set if there are no matches
441 *
442 */
443 public Set<ApplicationInstance> getAllValuesOfApp() {
444 return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet());
445 }
446
447 /**
448 * Retrieve the set of values that occur in matches for App.
449 * @return the Set of all values or empty set if there are no matches
450 *
451 */
452 public Stream<ApplicationInstance> streamAllValuesOfApp() {
453 return rawStreamAllValuesOfApp(emptyArray());
454 }
455
456 /**
457 * Retrieve the set of values that occur in matches for App.
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<ApplicationInstance> streamAllValuesOfApp(final Allocate.Match partialMatch) {
467 return rawStreamAllValuesOfApp(partialMatch.toArray());
468 }
469
470 /**
471 * Retrieve the set of values that occur in matches for App.
472 * </p>
473 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
474 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
475 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
476 *
477 * @return the Stream of all values or empty set if there are no matches
478 *
479 */
480 public Stream<ApplicationInstance> streamAllValuesOfApp(final HostInstance pHost) {
481 return rawStreamAllValuesOfApp(new Object[]{null, pHost});
482 }
483
484 /**
485 * Retrieve the set of values that occur in matches for App.
486 * @return the Set of all values or empty set if there are no matches
487 *
488 */
489 public Set<ApplicationInstance> getAllValuesOfApp(final Allocate.Match partialMatch) {
490 return rawStreamAllValuesOfApp(partialMatch.toArray()).collect(Collectors.toSet());
491 }
492
493 /**
494 * Retrieve the set of values that occur in matches for App.
495 * @return the Set of all values or empty set if there are no matches
496 *
497 */
498 public Set<ApplicationInstance> getAllValuesOfApp(final HostInstance pHost) {
499 return rawStreamAllValuesOfApp(new Object[]{null, pHost}).collect(Collectors.toSet());
500 }
501
502 /**
503 * Retrieve the set of values that occur in matches for Host.
504 * @return the Set of all values or empty set if there are no matches
505 *
506 */
507 protected Stream<HostInstance> rawStreamAllValuesOfHost(final Object[] parameters) {
508 return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast);
509 }
510
511 /**
512 * Retrieve the set of values that occur in matches for Host.
513 * @return the Set of all values or empty set if there are no matches
514 *
515 */
516 public Set<HostInstance> getAllValuesOfHost() {
517 return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet());
518 }
519
520 /**
521 * Retrieve the set of values that occur in matches for Host.
522 * @return the Set of all values or empty set if there are no matches
523 *
524 */
525 public Stream<HostInstance> streamAllValuesOfHost() {
526 return rawStreamAllValuesOfHost(emptyArray());
527 }
528
529 /**
530 * Retrieve the set of values that occur in matches for Host.
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<HostInstance> streamAllValuesOfHost(final Allocate.Match partialMatch) {
540 return rawStreamAllValuesOfHost(partialMatch.toArray());
541 }
542
543 /**
544 * Retrieve the set of values that occur in matches for Host.
545 * </p>
546 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
547 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
548 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
549 *
550 * @return the Stream of all values or empty set if there are no matches
551 *
552 */
553 public Stream<HostInstance> streamAllValuesOfHost(final ApplicationInstance pApp) {
554 return rawStreamAllValuesOfHost(new Object[]{pApp, null});
555 }
556
557 /**
558 * Retrieve the set of values that occur in matches for Host.
559 * @return the Set of all values or empty set if there are no matches
560 *
561 */
562 public Set<HostInstance> getAllValuesOfHost(final Allocate.Match partialMatch) {
563 return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet());
564 }
565
566 /**
567 * Retrieve the set of values that occur in matches for Host.
568 * @return the Set of all values or empty set if there are no matches
569 *
570 */
571 public Set<HostInstance> getAllValuesOfHost(final ApplicationInstance pApp) {
572 return rawStreamAllValuesOfHost(new Object[]{pApp, null}).collect(Collectors.toSet());
573 }
574
575 @Override
576 protected Allocate.Match tupleToMatch(final Tuple t) {
577 try {
578 return Allocate.Match.newMatch((ApplicationInstance) t.get(POSITION_APP), (HostInstance) t.get(POSITION_HOST));
579 } catch(ClassCastException e) {
580 LOGGER.error("Element(s) in tuple not properly typed!",e);
581 return null;
582 }
583 }
584
585 @Override
586 protected Allocate.Match arrayToMatch(final Object[] match) {
587 try {
588 return Allocate.Match.newMatch((ApplicationInstance) match[POSITION_APP], (HostInstance) match[POSITION_HOST]);
589 } catch(ClassCastException e) {
590 LOGGER.error("Element(s) in array not properly typed!",e);
591 return null;
592 }
593 }
594
595 @Override
596 protected Allocate.Match arrayToMatchMutable(final Object[] match) {
597 try {
598 return Allocate.Match.newMutableMatch((ApplicationInstance) match[POSITION_APP], (HostInstance) match[POSITION_HOST]);
599 } catch(ClassCastException e) {
600 LOGGER.error("Element(s) in array not properly typed!",e);
601 return null;
602 }
603 }
604
605 /**
606 * @return the singleton instance of the query specification of this pattern
607 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
608 *
609 */
610 public static IQuerySpecification<Allocate.Matcher> querySpecification() {
611 return Allocate.instance();
612 }
613 }
614
615 private Allocate() {
616 super(GeneratedPQuery.INSTANCE);
617 }
618
619 /**
620 * @return the singleton instance of the query specification
621 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
622 *
623 */
624 public static Allocate instance() {
625 try{
626 return LazyHolder.INSTANCE;
627 } catch (ExceptionInInitializerError err) {
628 throw processInitializerError(err);
629 }
630 }
631
632 @Override
633 protected Allocate.Matcher instantiate(final ViatraQueryEngine engine) {
634 return Allocate.Matcher.on(engine);
635 }
636
637 @Override
638 public Allocate.Matcher instantiate() {
639 return Allocate.Matcher.create();
640 }
641
642 @Override
643 public Allocate.Match newEmptyMatch() {
644 return Allocate.Match.newEmptyMatch();
645 }
646
647 @Override
648 public Allocate.Match newMatch(final Object... parameters) {
649 return Allocate.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[1]);
650 }
651
652 /**
653 * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate (visibility: PUBLIC, simpleName: Allocate, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
654 * <b>not</b> at the class load time of the outer class,
655 * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate (visibility: PUBLIC, simpleName: Allocate, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
656 *
657 * <p> This workaround is required e.g. to support recursion.
658 *
659 */
660 private static class LazyHolder {
661 private static final Allocate INSTANCE = new Allocate();
662
663 /**
664 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
665 * This initialization order is required to support indirect recursion.
666 *
667 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
668 *
669 */
670 private static final Object STATIC_INITIALIZER = ensureInitialized();
671
672 public static Object ensureInitialized() {
673 INSTANCE.ensureInitializedInternal();
674 return null;
675 }
676 }
677
678 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
679 private static final Allocate.GeneratedPQuery INSTANCE = new GeneratedPQuery();
680
681 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);
682
683 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);
684
685 private final List<PParameter> parameters = Arrays.asList(parameter_App, parameter_Host);
686
687 private class Embedded_1_ApplicationInstance_requirement_instances_allocatedTo extends BaseGeneratedEMFPQuery {
688 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);
689
690 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);
691
692 private final List<PParameter> embeddedParameters = Arrays.asList(parameter_p0, parameter_p1);
693
694 public Embedded_1_ApplicationInstance_requirement_instances_allocatedTo() {
695 super(PVisibility.EMBEDDED);
696 }
697
698 @Override
699 public String getFullyQualifiedName() {
700 return GeneratedPQuery.this.getFullyQualifiedName() + "$Embedded_1_ApplicationInstance_requirement_instances_allocatedTo";
701 }
702
703 @Override
704 public List<PParameter> getParameters() {
705 return embeddedParameters;
706 }
707
708 @Override
709 public Set<PBody> doGetContainedBodies() {
710 PBody body = new PBody(this);
711 PVariable var_p0 = body.getOrCreateVariableByName("p0");
712 PVariable var_p1 = body.getOrCreateVariableByName("p1");
713 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
714 new ExportedParameter(body, var_p0, parameter_p0),
715 new ExportedParameter(body, var_p1, parameter_p1)
716 ));
717 // ApplicationInstance.requirement.instances.allocatedTo(App, Host)
718 new TypeConstraint(body, Tuples.flatTupleOf(var_p0), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
719 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
720 new TypeConstraint(body, Tuples.flatTupleOf(var_p0, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "requirement")));
721 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement")));
722 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
723 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "instances")));
724 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
725 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
726 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo")));
727 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
728 new Equality(body, var__virtual_2_, var_p1);
729 return Collections.singleton(body);
730 }
731 }
732
733 private GeneratedPQuery() {
734 super(PVisibility.PUBLIC);
735 }
736
737 @Override
738 public String getFullyQualifiedName() {
739 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocate";
740 }
741
742 @Override
743 public List<String> getParameterNames() {
744 return Arrays.asList("App","Host");
745 }
746
747 @Override
748 public List<PParameter> getParameters() {
749 return parameters;
750 }
751
752 @Override
753 public Set<PBody> doGetContainedBodies() {
754 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
755 Set<PBody> bodies = new LinkedHashSet<>();
756 {
757 PBody body = new PBody(this);
758 PVariable var_App = body.getOrCreateVariableByName("App");
759 PVariable var_Host = body.getOrCreateVariableByName("Host");
760 PVariable var_Req = body.getOrCreateVariableByName("Req");
761 PVariable var_AvailableMem = body.getOrCreateVariableByName("AvailableMem");
762 PVariable var_AvailableHdd = body.getOrCreateVariableByName("AvailableHdd");
763 PVariable var_RequiredMem = body.getOrCreateVariableByName("RequiredMem");
764 PVariable var_RequiredHdd = body.getOrCreateVariableByName("RequiredHdd");
765 new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
766 new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
767 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
768 new ExportedParameter(body, var_App, parameter_App),
769 new ExportedParameter(body, var_Host, parameter_Host)
770 ));
771 // ApplicationInstance.type.requirements(App, Req)
772 new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
773 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
774 new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type")));
775 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType")));
776 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
777 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "requirements")));
778 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
779 new Equality(body, var__virtual_1_, var_Req);
780 // ResourceRequirement.hostType.instances(Req, Host)
781 new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
782 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
783 new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "hostType")));
784 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType")));
785 PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}");
786 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "instances")));
787 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
788 new Equality(body, var__virtual_3_, var_Host);
789 // find unallocatedAppInstance(App)
790 new PositivePatternCall(body, Tuples.flatTupleOf(var_App), UnallocatedAppInstance.instance().getInternalQueryRepresentation());
791 // find availableMemory(Host, AvailableMem)
792 new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_AvailableMem), AvailableMemory.instance().getInternalQueryRepresentation());
793 // find availableHdd(Host, AvailableHdd)
794 new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_AvailableHdd), AvailableHdd.instance().getInternalQueryRepresentation());
795 // ResourceRequirement.requiredMemory(Req, RequiredMem)
796 new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
797 PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}");
798 new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "requiredMemory")));
799 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt")));
800 new Equality(body, var__virtual_4_, var_RequiredMem);
801 // ResourceRequirement.requiredHdd(Req, RequiredHdd)
802 new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
803 PVariable var__virtual_5_ = body.getOrCreateVariableByName(".virtual{5}");
804 new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_5_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "requiredHdd")));
805 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_5_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt")));
806 new Equality(body, var__virtual_5_, var_RequiredHdd);
807 // check(AvailableMem >= RequiredMem)
808 new ExpressionEvaluation(body, new IExpressionEvaluator() {
809
810 @Override
811 public String getShortDescription() {
812 return "Expression evaluation from pattern allocate";
813 }
814
815 @Override
816 public Iterable<String> getInputParameterNames() {
817 return Arrays.asList("AvailableMem", "RequiredMem");}
818
819 @Override
820 public Object evaluateExpression(IValueProvider provider) throws Exception {
821 Integer AvailableMem = (Integer) provider.getValue("AvailableMem");
822 Integer RequiredMem = (Integer) provider.getValue("RequiredMem");
823 return evaluateExpression_1_1(AvailableMem, RequiredMem);
824 }
825 }, null);
826 // check(AvailableHdd >= RequiredHdd)
827 new ExpressionEvaluation(body, new IExpressionEvaluator() {
828
829 @Override
830 public String getShortDescription() {
831 return "Expression evaluation from pattern allocate";
832 }
833
834 @Override
835 public Iterable<String> getInputParameterNames() {
836 return Arrays.asList("AvailableHdd", "RequiredHdd");}
837
838 @Override
839 public Object evaluateExpression(IValueProvider provider) throws Exception {
840 Integer AvailableHdd = (Integer) provider.getValue("AvailableHdd");
841 Integer RequiredHdd = (Integer) provider.getValue("RequiredHdd");
842 return evaluateExpression_1_2(AvailableHdd, RequiredHdd);
843 }
844 }, null);
845 // neg ApplicationInstance.requirement.instances.allocatedTo(App, Host)
846 new NegativePatternCall(body, Tuples.flatTupleOf(var_App, var_Host), new Allocate.GeneratedPQuery.Embedded_1_ApplicationInstance_requirement_instances_allocatedTo());
847 bodies.add(body);
848 }
849 return bodies;
850 }
851 }
852
853 private static boolean evaluateExpression_1_1(final Integer AvailableMem, final Integer RequiredMem) {
854 boolean _greaterEqualsThan = (AvailableMem.compareTo(RequiredMem) >= 0);
855 return _greaterEqualsThan;
856 }
857
858 private static boolean evaluateExpression_1_2(final Integer AvailableHdd, final Integer RequiredHdd) {
859 boolean _greaterEqualsThan = (AvailableHdd.compareTo(RequiredHdd) >= 0);
860 return _greaterEqualsThan;
861 }
862}
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
index be7488b6..6da5f76d 100644
--- 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
@@ -5,7 +5,7 @@ package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5 5
6import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; 6import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance;
7import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; 7import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance;
8import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; 8import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement;
9import java.util.Arrays; 9import java.util.Arrays;
10import java.util.Collection; 10import java.util.Collection;
11import java.util.LinkedHashSet; 11import java.util.LinkedHashSet;
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java
deleted file mode 100644
index 22821c4a..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java
+++ /dev/null
@@ -1,743 +0,0 @@
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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd;
8import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement;
9import java.util.Arrays;
10import java.util.Collection;
11import java.util.LinkedHashSet;
12import java.util.List;
13import java.util.Objects;
14import java.util.Optional;
15import java.util.Set;
16import java.util.function.Consumer;
17import java.util.stream.Collectors;
18import java.util.stream.Stream;
19import org.apache.log4j.Logger;
20import org.eclipse.emf.ecore.EClass;
21import org.eclipse.viatra.query.runtime.api.IPatternMatch;
22import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
23import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
25import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
26import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
27import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
28import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
29import org.eclipse.viatra.query.runtime.matchers.aggregators.sum;
30import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
31import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey;
32import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
33import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
34import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
35import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
36import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
39import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
40import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
41import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint;
42import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
43import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
44import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
45import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
46import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
47import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
48import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
49import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
50
51/**
52 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
53 *
54 * <p>Original source:
55 * <code><pre>
56 * {@literal @}QueryBasedFeature(feature = "availableHdd")
57 * pattern availableHdd(Host : HostInstance, Hdd : java Integer) {
58 * find totalHdd(Host, TotalHdd);
59 * RequiredHdd == sum find hddRequirement(Host, _, #_);
60 * Hdd == eval(TotalHdd - RequiredHdd);
61 * }
62 * </pre></code>
63 *
64 * @see Matcher
65 * @see Match
66 *
67 */
68@SuppressWarnings("all")
69public final class AvailableHdd extends BaseGeneratedEMFQuerySpecification<AvailableHdd.Matcher> {
70 /**
71 * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd 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 HostInstance fHost;
84
85 private Integer fHdd;
86
87 private static List<String> parameterNames = makeImmutableList("Host", "Hdd");
88
89 private Match(final HostInstance pHost, final Integer pHdd) {
90 this.fHost = pHost;
91 this.fHdd = pHdd;
92 }
93
94 @Override
95 public Object get(final String parameterName) {
96 if ("Host".equals(parameterName)) return this.fHost;
97 if ("Hdd".equals(parameterName)) return this.fHdd;
98 return null;
99 }
100
101 public HostInstance getHost() {
102 return this.fHost;
103 }
104
105 public Integer getHdd() {
106 return this.fHdd;
107 }
108
109 @Override
110 public boolean set(final String parameterName, final Object newValue) {
111 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
112 if ("Host".equals(parameterName) ) {
113 this.fHost = (HostInstance) newValue;
114 return true;
115 }
116 if ("Hdd".equals(parameterName) ) {
117 this.fHdd = (Integer) newValue;
118 return true;
119 }
120 return false;
121 }
122
123 public void setHost(final HostInstance pHost) {
124 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
125 this.fHost = pHost;
126 }
127
128 public void setHdd(final Integer pHdd) {
129 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
130 this.fHdd = pHdd;
131 }
132
133 @Override
134 public String patternName() {
135 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd";
136 }
137
138 @Override
139 public List<String> parameterNames() {
140 return AvailableHdd.Match.parameterNames;
141 }
142
143 @Override
144 public Object[] toArray() {
145 return new Object[]{fHost, fHdd};
146 }
147
148 @Override
149 public AvailableHdd.Match toImmutable() {
150 return isMutable() ? newMatch(fHost, fHdd) : this;
151 }
152
153 @Override
154 public String prettyPrint() {
155 StringBuilder result = new StringBuilder();
156 result.append("\"Host\"=" + prettyPrintValue(fHost) + ", ");
157 result.append("\"Hdd\"=" + prettyPrintValue(fHdd));
158 return result.toString();
159 }
160
161 @Override
162 public int hashCode() {
163 return Objects.hash(fHost, fHdd);
164 }
165
166 @Override
167 public boolean equals(final Object obj) {
168 if (this == obj)
169 return true;
170 if (obj == null) {
171 return false;
172 }
173 if ((obj instanceof AvailableHdd.Match)) {
174 AvailableHdd.Match other = (AvailableHdd.Match) obj;
175 return Objects.equals(fHost, other.fHost) && Objects.equals(fHdd, other.fHdd);
176 } else {
177 // this should be infrequent
178 if (!(obj instanceof IPatternMatch)) {
179 return false;
180 }
181 IPatternMatch otherSig = (IPatternMatch) obj;
182 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
183 }
184 }
185
186 @Override
187 public AvailableHdd specification() {
188 return AvailableHdd.instance();
189 }
190
191 /**
192 * Returns an empty, mutable match.
193 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
194 *
195 * @return the empty match.
196 *
197 */
198 public static AvailableHdd.Match newEmptyMatch() {
199 return new Mutable(null, null);
200 }
201
202 /**
203 * Returns a mutable (partial) match.
204 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
205 *
206 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
207 * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound.
208 * @return the new, mutable (partial) match object.
209 *
210 */
211 public static AvailableHdd.Match newMutableMatch(final HostInstance pHost, final Integer pHdd) {
212 return new Mutable(pHost, pHdd);
213 }
214
215 /**
216 * Returns a new (partial) match.
217 * This can be used e.g. to call the matcher with a partial match.
218 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
219 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
220 * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound.
221 * @return the (partial) match object.
222 *
223 */
224 public static AvailableHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) {
225 return new Immutable(pHost, pHdd);
226 }
227
228 private static final class Mutable extends AvailableHdd.Match {
229 Mutable(final HostInstance pHost, final Integer pHdd) {
230 super(pHost, pHdd);
231 }
232
233 @Override
234 public boolean isMutable() {
235 return true;
236 }
237 }
238
239 private static final class Immutable extends AvailableHdd.Match {
240 Immutable(final HostInstance pHost, final Integer pHdd) {
241 super(pHost, pHdd);
242 }
243
244 @Override
245 public boolean isMutable() {
246 return false;
247 }
248 }
249 }
250
251 /**
252 * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd pattern,
253 * providing pattern-specific query methods.
254 *
255 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
256 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
257 *
258 * <p>Matches of the pattern will be represented as {@link Match}.
259 *
260 * <p>Original source:
261 * <code><pre>
262 * {@literal @}QueryBasedFeature(feature = "availableHdd")
263 * pattern availableHdd(Host : HostInstance, Hdd : java Integer) {
264 * find totalHdd(Host, TotalHdd);
265 * RequiredHdd == sum find hddRequirement(Host, _, #_);
266 * Hdd == eval(TotalHdd - RequiredHdd);
267 * }
268 * </pre></code>
269 *
270 * @see Match
271 * @see AvailableHdd
272 *
273 */
274 public static class Matcher extends BaseMatcher<AvailableHdd.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 AvailableHdd.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 AvailableHdd.Matcher create() {
299 return new Matcher();
300 }
301
302 private static final int POSITION_HOST = 0;
303
304 private static final int POSITION_HDD = 1;
305
306 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AvailableHdd.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 pHost the fixed value of pattern parameter Host, or null if not bound.
323 * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound.
324 * @return matches represented as a Match object.
325 *
326 */
327 public Collection<AvailableHdd.Match> getAllMatches(final HostInstance pHost, final Integer pHdd) {
328 return rawStreamAllMatches(new Object[]{pHost, pHdd}).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 pHost the fixed value of pattern parameter Host, or null if not bound.
338 * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound.
339 * @return a stream of matches represented as a Match object.
340 *
341 */
342 public Stream<AvailableHdd.Match> streamAllMatches(final HostInstance pHost, final Integer pHdd) {
343 return rawStreamAllMatches(new Object[]{pHost, pHdd});
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 pHost the fixed value of pattern parameter Host, or null if not bound.
350 * @param pHdd the fixed value of pattern parameter Hdd, 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<AvailableHdd.Match> getOneArbitraryMatch(final HostInstance pHost, final Integer pHdd) {
355 return rawGetOneArbitraryMatch(new Object[]{pHost, pHdd});
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 pHost the fixed value of pattern parameter Host, or null if not bound.
362 * @param pHdd the fixed value of pattern parameter Hdd, 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 HostInstance pHost, final Integer pHdd) {
367 return rawHasMatch(new Object[]{pHost, pHdd});
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 pHost the fixed value of pattern parameter Host, or null if not bound.
373 * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound.
374 * @return the number of pattern matches found.
375 *
376 */
377 public int countMatches(final HostInstance pHost, final Integer pHdd) {
378 return rawCountMatches(new Object[]{pHost, pHdd});
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 pHost the fixed value of pattern parameter Host, or null if not bound.
385 * @param pHdd the fixed value of pattern parameter Hdd, 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 HostInstance pHost, final Integer pHdd, final Consumer<? super AvailableHdd.Match> processor) {
391 return rawForOneArbitraryMatch(new Object[]{pHost, pHdd}, 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 pHost the fixed value of pattern parameter Host, or null if not bound.
399 * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound.
400 * @return the (partial) match object.
401 *
402 */
403 public AvailableHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) {
404 return AvailableHdd.Match.newMatch(pHost, pHdd);
405 }
406
407 /**
408 * Retrieve the set of values that occur in matches for Host.
409 * @return the Set of all values or empty set if there are no matches
410 *
411 */
412 protected Stream<HostInstance> rawStreamAllValuesOfHost(final Object[] parameters) {
413 return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast);
414 }
415
416 /**
417 * Retrieve the set of values that occur in matches for Host.
418 * @return the Set of all values or empty set if there are no matches
419 *
420 */
421 public Set<HostInstance> getAllValuesOfHost() {
422 return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet());
423 }
424
425 /**
426 * Retrieve the set of values that occur in matches for Host.
427 * @return the Set of all values or empty set if there are no matches
428 *
429 */
430 public Stream<HostInstance> streamAllValuesOfHost() {
431 return rawStreamAllValuesOfHost(emptyArray());
432 }
433
434 /**
435 * Retrieve the set of values that occur in matches for Host.
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<HostInstance> streamAllValuesOfHost(final AvailableHdd.Match partialMatch) {
445 return rawStreamAllValuesOfHost(partialMatch.toArray());
446 }
447
448 /**
449 * Retrieve the set of values that occur in matches for Host.
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<HostInstance> streamAllValuesOfHost(final Integer pHdd) {
459 return rawStreamAllValuesOfHost(new Object[]{null, pHdd});
460 }
461
462 /**
463 * Retrieve the set of values that occur in matches for Host.
464 * @return the Set of all values or empty set if there are no matches
465 *
466 */
467 public Set<HostInstance> getAllValuesOfHost(final AvailableHdd.Match partialMatch) {
468 return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet());
469 }
470
471 /**
472 * Retrieve the set of values that occur in matches for Host.
473 * @return the Set of all values or empty set if there are no matches
474 *
475 */
476 public Set<HostInstance> getAllValuesOfHost(final Integer pHdd) {
477 return rawStreamAllValuesOfHost(new Object[]{null, pHdd}).collect(Collectors.toSet());
478 }
479
480 /**
481 * Retrieve the set of values that occur in matches for Hdd.
482 * @return the Set of all values or empty set if there are no matches
483 *
484 */
485 protected Stream<Integer> rawStreamAllValuesOfHdd(final Object[] parameters) {
486 return rawStreamAllValues(POSITION_HDD, parameters).map(Integer.class::cast);
487 }
488
489 /**
490 * Retrieve the set of values that occur in matches for Hdd.
491 * @return the Set of all values or empty set if there are no matches
492 *
493 */
494 public Set<Integer> getAllValuesOfHdd() {
495 return rawStreamAllValuesOfHdd(emptyArray()).collect(Collectors.toSet());
496 }
497
498 /**
499 * Retrieve the set of values that occur in matches for Hdd.
500 * @return the Set of all values or empty set if there are no matches
501 *
502 */
503 public Stream<Integer> streamAllValuesOfHdd() {
504 return rawStreamAllValuesOfHdd(emptyArray());
505 }
506
507 /**
508 * Retrieve the set of values that occur in matches for Hdd.
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<Integer> streamAllValuesOfHdd(final AvailableHdd.Match partialMatch) {
518 return rawStreamAllValuesOfHdd(partialMatch.toArray());
519 }
520
521 /**
522 * Retrieve the set of values that occur in matches for Hdd.
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<Integer> streamAllValuesOfHdd(final HostInstance pHost) {
532 return rawStreamAllValuesOfHdd(new Object[]{pHost, null});
533 }
534
535 /**
536 * Retrieve the set of values that occur in matches for Hdd.
537 * @return the Set of all values or empty set if there are no matches
538 *
539 */
540 public Set<Integer> getAllValuesOfHdd(final AvailableHdd.Match partialMatch) {
541 return rawStreamAllValuesOfHdd(partialMatch.toArray()).collect(Collectors.toSet());
542 }
543
544 /**
545 * Retrieve the set of values that occur in matches for Hdd.
546 * @return the Set of all values or empty set if there are no matches
547 *
548 */
549 public Set<Integer> getAllValuesOfHdd(final HostInstance pHost) {
550 return rawStreamAllValuesOfHdd(new Object[]{pHost, null}).collect(Collectors.toSet());
551 }
552
553 @Override
554 protected AvailableHdd.Match tupleToMatch(final Tuple t) {
555 try {
556 return AvailableHdd.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_HDD));
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 AvailableHdd.Match arrayToMatch(final Object[] match) {
565 try {
566 return AvailableHdd.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]);
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 AvailableHdd.Match arrayToMatchMutable(final Object[] match) {
575 try {
576 return AvailableHdd.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]);
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<AvailableHdd.Matcher> querySpecification() {
589 return AvailableHdd.instance();
590 }
591 }
592
593 private AvailableHdd() {
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 AvailableHdd instance() {
603 try{
604 return LazyHolder.INSTANCE;
605 } catch (ExceptionInInitializerError err) {
606 throw processInitializerError(err);
607 }
608 }
609
610 @Override
611 protected AvailableHdd.Matcher instantiate(final ViatraQueryEngine engine) {
612 return AvailableHdd.Matcher.on(engine);
613 }
614
615 @Override
616 public AvailableHdd.Matcher instantiate() {
617 return AvailableHdd.Matcher.create();
618 }
619
620 @Override
621 public AvailableHdd.Match newEmptyMatch() {
622 return AvailableHdd.Match.newEmptyMatch();
623 }
624
625 @Override
626 public AvailableHdd.Match newMatch(final Object... parameters) {
627 return AvailableHdd.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]);
628 }
629
630 /**
631 * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd (visibility: PUBLIC, simpleName: AvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd (visibility: PUBLIC, simpleName: AvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
634 *
635 * <p> This workaround is required e.g. to support recursion.
636 *
637 */
638 private static class LazyHolder {
639 private static final AvailableHdd INSTANCE = new AvailableHdd();
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 AvailableHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery();
658
659 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);
660
661 private final PParameter parameter_Hdd = new PParameter("Hdd", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT);
662
663 private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_Hdd);
664
665 private GeneratedPQuery() {
666 super(PVisibility.PUBLIC);
667 }
668
669 @Override
670 public String getFullyQualifiedName() {
671 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd";
672 }
673
674 @Override
675 public List<String> getParameterNames() {
676 return Arrays.asList("Host","Hdd");
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_Host = body.getOrCreateVariableByName("Host");
691 PVariable var_Hdd = body.getOrCreateVariableByName("Hdd");
692 PVariable var_TotalHdd = body.getOrCreateVariableByName("TotalHdd");
693 PVariable var_RequiredHdd = body.getOrCreateVariableByName("RequiredHdd");
694 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
695 PVariable var___1_ = body.getOrCreateVariableByName("_<1>");
696 new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
697 new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Hdd), new JavaTransitiveInstancesKey(java.lang.Integer.class));
698 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
699 new ExportedParameter(body, var_Host, parameter_Host),
700 new ExportedParameter(body, var_Hdd, parameter_Hdd)
701 ));
702 // find totalHdd(Host, TotalHdd)
703 new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_TotalHdd), TotalHdd.instance().getInternalQueryRepresentation());
704 // RequiredHdd == sum find hddRequirement(Host, _, #_)
705 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
706 new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Host, var___0_, var___1_), HddRequirement.instance().getInternalQueryRepresentation(), var__virtual_0_, 2);
707 new Equality(body, var_RequiredHdd, var__virtual_0_);
708 // Hdd == eval(TotalHdd - RequiredHdd)
709 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
710 new ExpressionEvaluation(body, new IExpressionEvaluator() {
711
712 @Override
713 public String getShortDescription() {
714 return "Expression evaluation from pattern availableHdd";
715 }
716
717 @Override
718 public Iterable<String> getInputParameterNames() {
719 return Arrays.asList("RequiredHdd", "TotalHdd");}
720
721 @Override
722 public Object evaluateExpression(IValueProvider provider) throws Exception {
723 Integer RequiredHdd = (Integer) provider.getValue("RequiredHdd");
724 Integer TotalHdd = (Integer) provider.getValue("TotalHdd");
725 return evaluateExpression_1_1(RequiredHdd, TotalHdd);
726 }
727 }, var__virtual_1_ );
728 new Equality(body, var_Hdd, var__virtual_1_);
729 bodies.add(body);
730 }
731 {
732 PAnnotation annotation = new PAnnotation("QueryBasedFeature");
733 annotation.addAttribute("feature", "availableHdd");
734 addAnnotation(annotation);
735 }
736 return bodies;
737 }
738 }
739
740 private static int evaluateExpression_1_1(final Integer RequiredHdd, final Integer TotalHdd) {
741 return ((TotalHdd).intValue() - (RequiredHdd).intValue());
742 }
743}
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java
deleted file mode 100644
index 930a24ba..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java
+++ /dev/null
@@ -1,743 +0,0 @@
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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory;
8import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement;
9import java.util.Arrays;
10import java.util.Collection;
11import java.util.LinkedHashSet;
12import java.util.List;
13import java.util.Objects;
14import java.util.Optional;
15import java.util.Set;
16import java.util.function.Consumer;
17import java.util.stream.Collectors;
18import java.util.stream.Stream;
19import org.apache.log4j.Logger;
20import org.eclipse.emf.ecore.EClass;
21import org.eclipse.viatra.query.runtime.api.IPatternMatch;
22import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
23import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
25import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
26import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
27import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
28import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
29import org.eclipse.viatra.query.runtime.matchers.aggregators.sum;
30import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
31import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey;
32import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
33import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
34import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
35import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
36import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
39import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
40import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
41import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint;
42import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
43import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
44import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
45import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
46import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
47import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
48import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
49import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
50
51/**
52 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
53 *
54 * <p>Original source:
55 * <code><pre>
56 * {@literal @}QueryBasedFeature(feature = "availableMemory")
57 * pattern availableMemory(Host : HostInstance, Memory : java Integer) {
58 * find totalMemory(Host, TotalMemory);
59 * RequiredMemory == sum find memoryRequirement(Host, _, #_);
60 * Memory == eval(TotalMemory - RequiredMemory);
61 * }
62 * </pre></code>
63 *
64 * @see Matcher
65 * @see Match
66 *
67 */
68@SuppressWarnings("all")
69public final class AvailableMemory extends BaseGeneratedEMFQuerySpecification<AvailableMemory.Matcher> {
70 /**
71 * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory 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 HostInstance fHost;
84
85 private Integer fMemory;
86
87 private static List<String> parameterNames = makeImmutableList("Host", "Memory");
88
89 private Match(final HostInstance pHost, final Integer pMemory) {
90 this.fHost = pHost;
91 this.fMemory = pMemory;
92 }
93
94 @Override
95 public Object get(final String parameterName) {
96 if ("Host".equals(parameterName)) return this.fHost;
97 if ("Memory".equals(parameterName)) return this.fMemory;
98 return null;
99 }
100
101 public HostInstance getHost() {
102 return this.fHost;
103 }
104
105 public Integer getMemory() {
106 return this.fMemory;
107 }
108
109 @Override
110 public boolean set(final String parameterName, final Object newValue) {
111 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
112 if ("Host".equals(parameterName) ) {
113 this.fHost = (HostInstance) newValue;
114 return true;
115 }
116 if ("Memory".equals(parameterName) ) {
117 this.fMemory = (Integer) newValue;
118 return true;
119 }
120 return false;
121 }
122
123 public void setHost(final HostInstance pHost) {
124 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
125 this.fHost = pHost;
126 }
127
128 public void setMemory(final Integer pMemory) {
129 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
130 this.fMemory = pMemory;
131 }
132
133 @Override
134 public String patternName() {
135 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory";
136 }
137
138 @Override
139 public List<String> parameterNames() {
140 return AvailableMemory.Match.parameterNames;
141 }
142
143 @Override
144 public Object[] toArray() {
145 return new Object[]{fHost, fMemory};
146 }
147
148 @Override
149 public AvailableMemory.Match toImmutable() {
150 return isMutable() ? newMatch(fHost, fMemory) : this;
151 }
152
153 @Override
154 public String prettyPrint() {
155 StringBuilder result = new StringBuilder();
156 result.append("\"Host\"=" + prettyPrintValue(fHost) + ", ");
157 result.append("\"Memory\"=" + prettyPrintValue(fMemory));
158 return result.toString();
159 }
160
161 @Override
162 public int hashCode() {
163 return Objects.hash(fHost, fMemory);
164 }
165
166 @Override
167 public boolean equals(final Object obj) {
168 if (this == obj)
169 return true;
170 if (obj == null) {
171 return false;
172 }
173 if ((obj instanceof AvailableMemory.Match)) {
174 AvailableMemory.Match other = (AvailableMemory.Match) obj;
175 return Objects.equals(fHost, other.fHost) && Objects.equals(fMemory, other.fMemory);
176 } else {
177 // this should be infrequent
178 if (!(obj instanceof IPatternMatch)) {
179 return false;
180 }
181 IPatternMatch otherSig = (IPatternMatch) obj;
182 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
183 }
184 }
185
186 @Override
187 public AvailableMemory specification() {
188 return AvailableMemory.instance();
189 }
190
191 /**
192 * Returns an empty, mutable match.
193 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
194 *
195 * @return the empty match.
196 *
197 */
198 public static AvailableMemory.Match newEmptyMatch() {
199 return new Mutable(null, null);
200 }
201
202 /**
203 * Returns a mutable (partial) match.
204 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
205 *
206 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
207 * @param pMemory the fixed value of pattern parameter Memory, or null if not bound.
208 * @return the new, mutable (partial) match object.
209 *
210 */
211 public static AvailableMemory.Match newMutableMatch(final HostInstance pHost, final Integer pMemory) {
212 return new Mutable(pHost, pMemory);
213 }
214
215 /**
216 * Returns a new (partial) match.
217 * This can be used e.g. to call the matcher with a partial match.
218 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
219 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
220 * @param pMemory the fixed value of pattern parameter Memory, or null if not bound.
221 * @return the (partial) match object.
222 *
223 */
224 public static AvailableMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) {
225 return new Immutable(pHost, pMemory);
226 }
227
228 private static final class Mutable extends AvailableMemory.Match {
229 Mutable(final HostInstance pHost, final Integer pMemory) {
230 super(pHost, pMemory);
231 }
232
233 @Override
234 public boolean isMutable() {
235 return true;
236 }
237 }
238
239 private static final class Immutable extends AvailableMemory.Match {
240 Immutable(final HostInstance pHost, final Integer pMemory) {
241 super(pHost, pMemory);
242 }
243
244 @Override
245 public boolean isMutable() {
246 return false;
247 }
248 }
249 }
250
251 /**
252 * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory pattern,
253 * providing pattern-specific query methods.
254 *
255 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
256 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
257 *
258 * <p>Matches of the pattern will be represented as {@link Match}.
259 *
260 * <p>Original source:
261 * <code><pre>
262 * {@literal @}QueryBasedFeature(feature = "availableMemory")
263 * pattern availableMemory(Host : HostInstance, Memory : java Integer) {
264 * find totalMemory(Host, TotalMemory);
265 * RequiredMemory == sum find memoryRequirement(Host, _, #_);
266 * Memory == eval(TotalMemory - RequiredMemory);
267 * }
268 * </pre></code>
269 *
270 * @see Match
271 * @see AvailableMemory
272 *
273 */
274 public static class Matcher extends BaseMatcher<AvailableMemory.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 AvailableMemory.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 AvailableMemory.Matcher create() {
299 return new Matcher();
300 }
301
302 private static final int POSITION_HOST = 0;
303
304 private static final int POSITION_MEMORY = 1;
305
306 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AvailableMemory.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 pHost the fixed value of pattern parameter Host, or null if not bound.
323 * @param pMemory the fixed value of pattern parameter Memory, or null if not bound.
324 * @return matches represented as a Match object.
325 *
326 */
327 public Collection<AvailableMemory.Match> getAllMatches(final HostInstance pHost, final Integer pMemory) {
328 return rawStreamAllMatches(new Object[]{pHost, pMemory}).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 pHost the fixed value of pattern parameter Host, or null if not bound.
338 * @param pMemory the fixed value of pattern parameter Memory, or null if not bound.
339 * @return a stream of matches represented as a Match object.
340 *
341 */
342 public Stream<AvailableMemory.Match> streamAllMatches(final HostInstance pHost, final Integer pMemory) {
343 return rawStreamAllMatches(new Object[]{pHost, pMemory});
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 pHost the fixed value of pattern parameter Host, or null if not bound.
350 * @param pMemory the fixed value of pattern parameter Memory, 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<AvailableMemory.Match> getOneArbitraryMatch(final HostInstance pHost, final Integer pMemory) {
355 return rawGetOneArbitraryMatch(new Object[]{pHost, pMemory});
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 pHost the fixed value of pattern parameter Host, or null if not bound.
362 * @param pMemory the fixed value of pattern parameter Memory, 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 HostInstance pHost, final Integer pMemory) {
367 return rawHasMatch(new Object[]{pHost, pMemory});
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 pHost the fixed value of pattern parameter Host, or null if not bound.
373 * @param pMemory the fixed value of pattern parameter Memory, or null if not bound.
374 * @return the number of pattern matches found.
375 *
376 */
377 public int countMatches(final HostInstance pHost, final Integer pMemory) {
378 return rawCountMatches(new Object[]{pHost, pMemory});
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 pHost the fixed value of pattern parameter Host, or null if not bound.
385 * @param pMemory the fixed value of pattern parameter Memory, 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 HostInstance pHost, final Integer pMemory, final Consumer<? super AvailableMemory.Match> processor) {
391 return rawForOneArbitraryMatch(new Object[]{pHost, pMemory}, 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 pHost the fixed value of pattern parameter Host, or null if not bound.
399 * @param pMemory the fixed value of pattern parameter Memory, or null if not bound.
400 * @return the (partial) match object.
401 *
402 */
403 public AvailableMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) {
404 return AvailableMemory.Match.newMatch(pHost, pMemory);
405 }
406
407 /**
408 * Retrieve the set of values that occur in matches for Host.
409 * @return the Set of all values or empty set if there are no matches
410 *
411 */
412 protected Stream<HostInstance> rawStreamAllValuesOfHost(final Object[] parameters) {
413 return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast);
414 }
415
416 /**
417 * Retrieve the set of values that occur in matches for Host.
418 * @return the Set of all values or empty set if there are no matches
419 *
420 */
421 public Set<HostInstance> getAllValuesOfHost() {
422 return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet());
423 }
424
425 /**
426 * Retrieve the set of values that occur in matches for Host.
427 * @return the Set of all values or empty set if there are no matches
428 *
429 */
430 public Stream<HostInstance> streamAllValuesOfHost() {
431 return rawStreamAllValuesOfHost(emptyArray());
432 }
433
434 /**
435 * Retrieve the set of values that occur in matches for Host.
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<HostInstance> streamAllValuesOfHost(final AvailableMemory.Match partialMatch) {
445 return rawStreamAllValuesOfHost(partialMatch.toArray());
446 }
447
448 /**
449 * Retrieve the set of values that occur in matches for Host.
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<HostInstance> streamAllValuesOfHost(final Integer pMemory) {
459 return rawStreamAllValuesOfHost(new Object[]{null, pMemory});
460 }
461
462 /**
463 * Retrieve the set of values that occur in matches for Host.
464 * @return the Set of all values or empty set if there are no matches
465 *
466 */
467 public Set<HostInstance> getAllValuesOfHost(final AvailableMemory.Match partialMatch) {
468 return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet());
469 }
470
471 /**
472 * Retrieve the set of values that occur in matches for Host.
473 * @return the Set of all values or empty set if there are no matches
474 *
475 */
476 public Set<HostInstance> getAllValuesOfHost(final Integer pMemory) {
477 return rawStreamAllValuesOfHost(new Object[]{null, pMemory}).collect(Collectors.toSet());
478 }
479
480 /**
481 * Retrieve the set of values that occur in matches for Memory.
482 * @return the Set of all values or empty set if there are no matches
483 *
484 */
485 protected Stream<Integer> rawStreamAllValuesOfMemory(final Object[] parameters) {
486 return rawStreamAllValues(POSITION_MEMORY, parameters).map(Integer.class::cast);
487 }
488
489 /**
490 * Retrieve the set of values that occur in matches for Memory.
491 * @return the Set of all values or empty set if there are no matches
492 *
493 */
494 public Set<Integer> getAllValuesOfMemory() {
495 return rawStreamAllValuesOfMemory(emptyArray()).collect(Collectors.toSet());
496 }
497
498 /**
499 * Retrieve the set of values that occur in matches for Memory.
500 * @return the Set of all values or empty set if there are no matches
501 *
502 */
503 public Stream<Integer> streamAllValuesOfMemory() {
504 return rawStreamAllValuesOfMemory(emptyArray());
505 }
506
507 /**
508 * Retrieve the set of values that occur in matches for Memory.
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<Integer> streamAllValuesOfMemory(final AvailableMemory.Match partialMatch) {
518 return rawStreamAllValuesOfMemory(partialMatch.toArray());
519 }
520
521 /**
522 * Retrieve the set of values that occur in matches for Memory.
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<Integer> streamAllValuesOfMemory(final HostInstance pHost) {
532 return rawStreamAllValuesOfMemory(new Object[]{pHost, null});
533 }
534
535 /**
536 * Retrieve the set of values that occur in matches for Memory.
537 * @return the Set of all values or empty set if there are no matches
538 *
539 */
540 public Set<Integer> getAllValuesOfMemory(final AvailableMemory.Match partialMatch) {
541 return rawStreamAllValuesOfMemory(partialMatch.toArray()).collect(Collectors.toSet());
542 }
543
544 /**
545 * Retrieve the set of values that occur in matches for Memory.
546 * @return the Set of all values or empty set if there are no matches
547 *
548 */
549 public Set<Integer> getAllValuesOfMemory(final HostInstance pHost) {
550 return rawStreamAllValuesOfMemory(new Object[]{pHost, null}).collect(Collectors.toSet());
551 }
552
553 @Override
554 protected AvailableMemory.Match tupleToMatch(final Tuple t) {
555 try {
556 return AvailableMemory.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_MEMORY));
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 AvailableMemory.Match arrayToMatch(final Object[] match) {
565 try {
566 return AvailableMemory.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]);
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 AvailableMemory.Match arrayToMatchMutable(final Object[] match) {
575 try {
576 return AvailableMemory.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]);
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<AvailableMemory.Matcher> querySpecification() {
589 return AvailableMemory.instance();
590 }
591 }
592
593 private AvailableMemory() {
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 AvailableMemory instance() {
603 try{
604 return LazyHolder.INSTANCE;
605 } catch (ExceptionInInitializerError err) {
606 throw processInitializerError(err);
607 }
608 }
609
610 @Override
611 protected AvailableMemory.Matcher instantiate(final ViatraQueryEngine engine) {
612 return AvailableMemory.Matcher.on(engine);
613 }
614
615 @Override
616 public AvailableMemory.Matcher instantiate() {
617 return AvailableMemory.Matcher.create();
618 }
619
620 @Override
621 public AvailableMemory.Match newEmptyMatch() {
622 return AvailableMemory.Match.newEmptyMatch();
623 }
624
625 @Override
626 public AvailableMemory.Match newMatch(final Object... parameters) {
627 return AvailableMemory.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]);
628 }
629
630 /**
631 * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory (visibility: PUBLIC, simpleName: AvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory (visibility: PUBLIC, simpleName: AvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
634 *
635 * <p> This workaround is required e.g. to support recursion.
636 *
637 */
638 private static class LazyHolder {
639 private static final AvailableMemory INSTANCE = new AvailableMemory();
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 AvailableMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery();
658
659 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);
660
661 private final PParameter parameter_Memory = new PParameter("Memory", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT);
662
663 private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_Memory);
664
665 private GeneratedPQuery() {
666 super(PVisibility.PUBLIC);
667 }
668
669 @Override
670 public String getFullyQualifiedName() {
671 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory";
672 }
673
674 @Override
675 public List<String> getParameterNames() {
676 return Arrays.asList("Host","Memory");
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_Host = body.getOrCreateVariableByName("Host");
691 PVariable var_Memory = body.getOrCreateVariableByName("Memory");
692 PVariable var_TotalMemory = body.getOrCreateVariableByName("TotalMemory");
693 PVariable var_RequiredMemory = body.getOrCreateVariableByName("RequiredMemory");
694 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
695 PVariable var___1_ = body.getOrCreateVariableByName("_<1>");
696 new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
697 new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Memory), new JavaTransitiveInstancesKey(java.lang.Integer.class));
698 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
699 new ExportedParameter(body, var_Host, parameter_Host),
700 new ExportedParameter(body, var_Memory, parameter_Memory)
701 ));
702 // find totalMemory(Host, TotalMemory)
703 new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_TotalMemory), TotalMemory.instance().getInternalQueryRepresentation());
704 // RequiredMemory == sum find memoryRequirement(Host, _, #_)
705 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
706 new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Host, var___0_, var___1_), MemoryRequirement.instance().getInternalQueryRepresentation(), var__virtual_0_, 2);
707 new Equality(body, var_RequiredMemory, var__virtual_0_);
708 // Memory == eval(TotalMemory - RequiredMemory)
709 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
710 new ExpressionEvaluation(body, new IExpressionEvaluator() {
711
712 @Override
713 public String getShortDescription() {
714 return "Expression evaluation from pattern availableMemory";
715 }
716
717 @Override
718 public Iterable<String> getInputParameterNames() {
719 return Arrays.asList("RequiredMemory", "TotalMemory");}
720
721 @Override
722 public Object evaluateExpression(IValueProvider provider) throws Exception {
723 Integer RequiredMemory = (Integer) provider.getValue("RequiredMemory");
724 Integer TotalMemory = (Integer) provider.getValue("TotalMemory");
725 return evaluateExpression_1_1(RequiredMemory, TotalMemory);
726 }
727 }, var__virtual_1_ );
728 new Equality(body, var_Memory, var__virtual_1_);
729 bodies.add(body);
730 }
731 {
732 PAnnotation annotation = new PAnnotation("QueryBasedFeature");
733 annotation.addAttribute("feature", "availableMemory");
734 addAnnotation(annotation);
735 }
736 return bodies;
737 }
738 }
739
740 private static int evaluateExpression_1_1(final Integer RequiredMemory, final Integer TotalMemory) {
741 return ((TotalMemory).intValue() - (RequiredMemory).intValue());
742 }
743}
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
index 59d4ad27..bc38b60b 100644
--- 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
@@ -43,6 +43,8 @@ import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
43 * 43 *
44 * <p>Original source: 44 * <p>Original source:
45 * <code><pre> 45 * <code><pre>
46 * // Free HDD
47 *
46 * pattern averageFreeHddMetric(Average : java Double) { 48 * pattern averageFreeHddMetric(Average : java Double) {
47 * Average == avg find freeHddPercentage(_, #_); 49 * Average == avg find freeHddPercentage(_, #_);
48 * } 50 * }
@@ -226,6 +228,8 @@ public final class AverageFreeHddMetric extends BaseGeneratedEMFQuerySpecificati
226 * 228 *
227 * <p>Original source: 229 * <p>Original source:
228 * <code><pre> 230 * <code><pre>
231 * // Free HDD
232 *
229 * pattern averageFreeHddMetric(Average : java Double) { 233 * pattern averageFreeHddMetric(Average : java Double) {
230 * Average == avg find freeHddPercentage(_, #_); 234 * Average == avg find freeHddPercentage(_, #_);
231 * } 235 * }
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
index a0d087f4..98974ea5 100644
--- 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
@@ -43,6 +43,12 @@ import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
43 * 43 *
44 * <p>Original source: 44 * <p>Original source:
45 * <code><pre> 45 * <code><pre>
46 * //
47 * // Metrics
48 * //
49 *
50 * // Free memory
51 *
46 * pattern averageFreeMemoryMetric(Average : java Double) { 52 * pattern averageFreeMemoryMetric(Average : java Double) {
47 * Average == avg find freeMemoryPercentage(_, #_); 53 * Average == avg find freeMemoryPercentage(_, #_);
48 * } 54 * }
@@ -226,6 +232,12 @@ public final class AverageFreeMemoryMetric extends BaseGeneratedEMFQuerySpecific
226 * 232 *
227 * <p>Original source: 233 * <p>Original source:
228 * <code><pre> 234 * <code><pre>
235 * //
236 * // Metrics
237 * //
238 *
239 * // Free memory
240 *
229 * pattern averageFreeMemoryMetric(Average : java Double) { 241 * pattern averageFreeMemoryMetric(Average : java Double) {
230 * Average == avg find freeMemoryPercentage(_, #_); 242 * Average == avg find freeMemoryPercentage(_, #_);
231 * } 243 * }
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
index 4d8ca4cc..bf886ec0 100644
--- 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
@@ -43,6 +43,8 @@ import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
43 * 43 *
44 * <p>Original source: 44 * <p>Original source:
45 * <code><pre> 45 * <code><pre>
46 * // Total cost
47 *
46 * pattern costMetric(Cost : java Integer) { 48 * pattern costMetric(Cost : java Integer) {
47 * Cost == sum find cpsCost(_, #_); 49 * Cost == sum find cpsCost(_, #_);
48 * } 50 * }
@@ -226,6 +228,8 @@ public final class CostMetric extends BaseGeneratedEMFQuerySpecification<CostMet
226 * 228 *
227 * <p>Original source: 229 * <p>Original source:
228 * <code><pre> 230 * <code><pre>
231 * // Total cost
232 *
229 * pattern costMetric(Cost : java Integer) { 233 * pattern costMetric(Cost : java Integer) {
230 * Cost == sum find cpsCost(_, #_); 234 * Cost == sum find cpsCost(_, #_);
231 * } 235 * }
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java
deleted file mode 100644
index 2c20b38e..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java
+++ /dev/null
@@ -1,705 +0,0 @@
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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance;
7import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem;
8import java.util.Arrays;
9import java.util.Collection;
10import java.util.LinkedHashSet;
11import java.util.List;
12import java.util.Objects;
13import java.util.Optional;
14import java.util.Set;
15import java.util.function.Consumer;
16import java.util.stream.Collectors;
17import java.util.stream.Stream;
18import org.apache.log4j.Logger;
19import org.eclipse.emf.ecore.EClass;
20import org.eclipse.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
29import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
31import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
32import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
36import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
38import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
39import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
40import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
41import 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 @}QueryBasedFeature(feature = "applications")
49 * pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) {
50 * CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance);
51 * }
52 * </pre></code>
53 *
54 * @see Matcher
55 * @see Match
56 *
57 */
58@SuppressWarnings("all")
59public final class CpsApplications extends BaseGeneratedEMFQuerySpecification<CpsApplications.Matcher> {
60 /**
61 * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications 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 CyberPhysicalSystem fCps;
74
75 private ApplicationInstance fAppInstance;
76
77 private static List<String> parameterNames = makeImmutableList("Cps", "AppInstance");
78
79 private Match(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
80 this.fCps = pCps;
81 this.fAppInstance = pAppInstance;
82 }
83
84 @Override
85 public Object get(final String parameterName) {
86 if ("Cps".equals(parameterName)) return this.fCps;
87 if ("AppInstance".equals(parameterName)) return this.fAppInstance;
88 return null;
89 }
90
91 public CyberPhysicalSystem getCps() {
92 return this.fCps;
93 }
94
95 public ApplicationInstance getAppInstance() {
96 return this.fAppInstance;
97 }
98
99 @Override
100 public boolean set(final String parameterName, final Object newValue) {
101 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
102 if ("Cps".equals(parameterName) ) {
103 this.fCps = (CyberPhysicalSystem) newValue;
104 return true;
105 }
106 if ("AppInstance".equals(parameterName) ) {
107 this.fAppInstance = (ApplicationInstance) newValue;
108 return true;
109 }
110 return false;
111 }
112
113 public void setCps(final CyberPhysicalSystem pCps) {
114 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
115 this.fCps = pCps;
116 }
117
118 public void setAppInstance(final ApplicationInstance pAppInstance) {
119 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
120 this.fAppInstance = pAppInstance;
121 }
122
123 @Override
124 public String patternName() {
125 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications";
126 }
127
128 @Override
129 public List<String> parameterNames() {
130 return CpsApplications.Match.parameterNames;
131 }
132
133 @Override
134 public Object[] toArray() {
135 return new Object[]{fCps, fAppInstance};
136 }
137
138 @Override
139 public CpsApplications.Match toImmutable() {
140 return isMutable() ? newMatch(fCps, fAppInstance) : this;
141 }
142
143 @Override
144 public String prettyPrint() {
145 StringBuilder result = new StringBuilder();
146 result.append("\"Cps\"=" + prettyPrintValue(fCps) + ", ");
147 result.append("\"AppInstance\"=" + prettyPrintValue(fAppInstance));
148 return result.toString();
149 }
150
151 @Override
152 public int hashCode() {
153 return Objects.hash(fCps, fAppInstance);
154 }
155
156 @Override
157 public boolean equals(final Object obj) {
158 if (this == obj)
159 return true;
160 if (obj == null) {
161 return false;
162 }
163 if ((obj instanceof CpsApplications.Match)) {
164 CpsApplications.Match other = (CpsApplications.Match) obj;
165 return Objects.equals(fCps, other.fCps) && Objects.equals(fAppInstance, other.fAppInstance);
166 } else {
167 // this should be infrequent
168 if (!(obj instanceof IPatternMatch)) {
169 return false;
170 }
171 IPatternMatch otherSig = (IPatternMatch) obj;
172 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
173 }
174 }
175
176 @Override
177 public CpsApplications specification() {
178 return CpsApplications.instance();
179 }
180
181 /**
182 * Returns an empty, mutable match.
183 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
184 *
185 * @return the empty match.
186 *
187 */
188 public static CpsApplications.Match newEmptyMatch() {
189 return new Mutable(null, null);
190 }
191
192 /**
193 * Returns a mutable (partial) match.
194 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
195 *
196 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
197 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
198 * @return the new, mutable (partial) match object.
199 *
200 */
201 public static CpsApplications.Match newMutableMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
202 return new Mutable(pCps, pAppInstance);
203 }
204
205 /**
206 * Returns a new (partial) match.
207 * This can be used e.g. to call the matcher with a partial match.
208 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
209 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
210 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
211 * @return the (partial) match object.
212 *
213 */
214 public static CpsApplications.Match newMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
215 return new Immutable(pCps, pAppInstance);
216 }
217
218 private static final class Mutable extends CpsApplications.Match {
219 Mutable(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
220 super(pCps, pAppInstance);
221 }
222
223 @Override
224 public boolean isMutable() {
225 return true;
226 }
227 }
228
229 private static final class Immutable extends CpsApplications.Match {
230 Immutable(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
231 super(pCps, pAppInstance);
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.cpsApplications 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 @}QueryBasedFeature(feature = "applications")
253 * pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) {
254 * CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance);
255 * }
256 * </pre></code>
257 *
258 * @see Match
259 * @see CpsApplications
260 *
261 */
262 public static class Matcher extends BaseMatcher<CpsApplications.Match> {
263 /**
264 * Initializes the pattern matcher within an existing VIATRA Query engine.
265 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
266 *
267 * @param engine the existing VIATRA Query engine in which this matcher will be created.
268 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
269 *
270 */
271 public static CpsApplications.Matcher on(final ViatraQueryEngine engine) {
272 // check if matcher already exists
273 Matcher matcher = engine.getExistingMatcher(querySpecification());
274 if (matcher == null) {
275 matcher = (Matcher)engine.getMatcher(querySpecification());
276 }
277 return matcher;
278 }
279
280 /**
281 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
282 * @return an initialized matcher
283 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
284 *
285 */
286 public static CpsApplications.Matcher create() {
287 return new Matcher();
288 }
289
290 private static final int POSITION_CPS = 0;
291
292 private static final int POSITION_APPINSTANCE = 1;
293
294 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CpsApplications.Matcher.class);
295
296 /**
297 * Initializes the pattern matcher within an existing VIATRA Query engine.
298 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
299 *
300 * @param engine the existing VIATRA Query engine in which this matcher will be created.
301 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
302 *
303 */
304 private Matcher() {
305 super(querySpecification());
306 }
307
308 /**
309 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
310 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
311 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
312 * @return matches represented as a Match object.
313 *
314 */
315 public Collection<CpsApplications.Match> getAllMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
316 return rawStreamAllMatches(new Object[]{pCps, pAppInstance}).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 pCps the fixed value of pattern parameter Cps, or null if not bound.
326 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
327 * @return a stream of matches represented as a Match object.
328 *
329 */
330 public Stream<CpsApplications.Match> streamAllMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
331 return rawStreamAllMatches(new Object[]{pCps, pAppInstance});
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 pCps the fixed value of pattern parameter Cps, or null if not bound.
338 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
339 * @return a match represented as a Match object, or null if no match is found.
340 *
341 */
342 public Optional<CpsApplications.Match> getOneArbitraryMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
343 return rawGetOneArbitraryMatch(new Object[]{pCps, pAppInstance});
344 }
345
346 /**
347 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
348 * under any possible substitution of the unspecified parameters (if any).
349 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
350 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
351 * @return true if the input is a valid (partial) match of the pattern.
352 *
353 */
354 public boolean hasMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
355 return rawHasMatch(new Object[]{pCps, pAppInstance});
356 }
357
358 /**
359 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
360 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
361 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
362 * @return the number of pattern matches found.
363 *
364 */
365 public int countMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
366 return rawCountMatches(new Object[]{pCps, pAppInstance});
367 }
368
369 /**
370 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
371 * Neither determinism nor randomness of selection is guaranteed.
372 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
373 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
374 * @param processor the action that will process the selected match.
375 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
376 *
377 */
378 public boolean forOneArbitraryMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance, final Consumer<? super CpsApplications.Match> processor) {
379 return rawForOneArbitraryMatch(new Object[]{pCps, pAppInstance}, processor);
380 }
381
382 /**
383 * Returns a new (partial) match.
384 * This can be used e.g. to call the matcher with a partial match.
385 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
386 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
387 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
388 * @return the (partial) match object.
389 *
390 */
391 public CpsApplications.Match newMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
392 return CpsApplications.Match.newMatch(pCps, pAppInstance);
393 }
394
395 /**
396 * Retrieve the set of values that occur in matches for Cps.
397 * @return the Set of all values or empty set if there are no matches
398 *
399 */
400 protected Stream<CyberPhysicalSystem> rawStreamAllValuesOfCps(final Object[] parameters) {
401 return rawStreamAllValues(POSITION_CPS, parameters).map(CyberPhysicalSystem.class::cast);
402 }
403
404 /**
405 * Retrieve the set of values that occur in matches for Cps.
406 * @return the Set of all values or empty set if there are no matches
407 *
408 */
409 public Set<CyberPhysicalSystem> getAllValuesOfCps() {
410 return rawStreamAllValuesOfCps(emptyArray()).collect(Collectors.toSet());
411 }
412
413 /**
414 * Retrieve the set of values that occur in matches for Cps.
415 * @return the Set of all values or empty set if there are no matches
416 *
417 */
418 public Stream<CyberPhysicalSystem> streamAllValuesOfCps() {
419 return rawStreamAllValuesOfCps(emptyArray());
420 }
421
422 /**
423 * Retrieve the set of values that occur in matches for Cps.
424 * </p>
425 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
426 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
427 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
428 *
429 * @return the Stream of all values or empty set if there are no matches
430 *
431 */
432 public Stream<CyberPhysicalSystem> streamAllValuesOfCps(final CpsApplications.Match partialMatch) {
433 return rawStreamAllValuesOfCps(partialMatch.toArray());
434 }
435
436 /**
437 * Retrieve the set of values that occur in matches for Cps.
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<CyberPhysicalSystem> streamAllValuesOfCps(final ApplicationInstance pAppInstance) {
447 return rawStreamAllValuesOfCps(new Object[]{null, pAppInstance});
448 }
449
450 /**
451 * Retrieve the set of values that occur in matches for Cps.
452 * @return the Set of all values or empty set if there are no matches
453 *
454 */
455 public Set<CyberPhysicalSystem> getAllValuesOfCps(final CpsApplications.Match partialMatch) {
456 return rawStreamAllValuesOfCps(partialMatch.toArray()).collect(Collectors.toSet());
457 }
458
459 /**
460 * Retrieve the set of values that occur in matches for Cps.
461 * @return the Set of all values or empty set if there are no matches
462 *
463 */
464 public Set<CyberPhysicalSystem> getAllValuesOfCps(final ApplicationInstance pAppInstance) {
465 return rawStreamAllValuesOfCps(new Object[]{null, pAppInstance}).collect(Collectors.toSet());
466 }
467
468 /**
469 * Retrieve the set of values that occur in matches for AppInstance.
470 * @return the Set of all values or empty set if there are no matches
471 *
472 */
473 protected Stream<ApplicationInstance> rawStreamAllValuesOfAppInstance(final Object[] parameters) {
474 return rawStreamAllValues(POSITION_APPINSTANCE, parameters).map(ApplicationInstance.class::cast);
475 }
476
477 /**
478 * Retrieve the set of values that occur in matches for AppInstance.
479 * @return the Set of all values or empty set if there are no matches
480 *
481 */
482 public Set<ApplicationInstance> getAllValuesOfAppInstance() {
483 return rawStreamAllValuesOfAppInstance(emptyArray()).collect(Collectors.toSet());
484 }
485
486 /**
487 * Retrieve the set of values that occur in matches for AppInstance.
488 * @return the Set of all values or empty set if there are no matches
489 *
490 */
491 public Stream<ApplicationInstance> streamAllValuesOfAppInstance() {
492 return rawStreamAllValuesOfAppInstance(emptyArray());
493 }
494
495 /**
496 * Retrieve the set of values that occur in matches for AppInstance.
497 * </p>
498 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
499 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
500 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
501 *
502 * @return the Stream of all values or empty set if there are no matches
503 *
504 */
505 public Stream<ApplicationInstance> streamAllValuesOfAppInstance(final CpsApplications.Match partialMatch) {
506 return rawStreamAllValuesOfAppInstance(partialMatch.toArray());
507 }
508
509 /**
510 * Retrieve the set of values that occur in matches for AppInstance.
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<ApplicationInstance> streamAllValuesOfAppInstance(final CyberPhysicalSystem pCps) {
520 return rawStreamAllValuesOfAppInstance(new Object[]{pCps, null});
521 }
522
523 /**
524 * Retrieve the set of values that occur in matches for AppInstance.
525 * @return the Set of all values or empty set if there are no matches
526 *
527 */
528 public Set<ApplicationInstance> getAllValuesOfAppInstance(final CpsApplications.Match partialMatch) {
529 return rawStreamAllValuesOfAppInstance(partialMatch.toArray()).collect(Collectors.toSet());
530 }
531
532 /**
533 * Retrieve the set of values that occur in matches for AppInstance.
534 * @return the Set of all values or empty set if there are no matches
535 *
536 */
537 public Set<ApplicationInstance> getAllValuesOfAppInstance(final CyberPhysicalSystem pCps) {
538 return rawStreamAllValuesOfAppInstance(new Object[]{pCps, null}).collect(Collectors.toSet());
539 }
540
541 @Override
542 protected CpsApplications.Match tupleToMatch(final Tuple t) {
543 try {
544 return CpsApplications.Match.newMatch((CyberPhysicalSystem) t.get(POSITION_CPS), (ApplicationInstance) t.get(POSITION_APPINSTANCE));
545 } catch(ClassCastException e) {
546 LOGGER.error("Element(s) in tuple not properly typed!",e);
547 return null;
548 }
549 }
550
551 @Override
552 protected CpsApplications.Match arrayToMatch(final Object[] match) {
553 try {
554 return CpsApplications.Match.newMatch((CyberPhysicalSystem) match[POSITION_CPS], (ApplicationInstance) match[POSITION_APPINSTANCE]);
555 } catch(ClassCastException e) {
556 LOGGER.error("Element(s) in array not properly typed!",e);
557 return null;
558 }
559 }
560
561 @Override
562 protected CpsApplications.Match arrayToMatchMutable(final Object[] match) {
563 try {
564 return CpsApplications.Match.newMutableMatch((CyberPhysicalSystem) match[POSITION_CPS], (ApplicationInstance) match[POSITION_APPINSTANCE]);
565 } catch(ClassCastException e) {
566 LOGGER.error("Element(s) in array not properly typed!",e);
567 return null;
568 }
569 }
570
571 /**
572 * @return the singleton instance of the query specification of this pattern
573 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
574 *
575 */
576 public static IQuerySpecification<CpsApplications.Matcher> querySpecification() {
577 return CpsApplications.instance();
578 }
579 }
580
581 private CpsApplications() {
582 super(GeneratedPQuery.INSTANCE);
583 }
584
585 /**
586 * @return the singleton instance of the query specification
587 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
588 *
589 */
590 public static CpsApplications instance() {
591 try{
592 return LazyHolder.INSTANCE;
593 } catch (ExceptionInInitializerError err) {
594 throw processInitializerError(err);
595 }
596 }
597
598 @Override
599 protected CpsApplications.Matcher instantiate(final ViatraQueryEngine engine) {
600 return CpsApplications.Matcher.on(engine);
601 }
602
603 @Override
604 public CpsApplications.Matcher instantiate() {
605 return CpsApplications.Matcher.create();
606 }
607
608 @Override
609 public CpsApplications.Match newEmptyMatch() {
610 return CpsApplications.Match.newEmptyMatch();
611 }
612
613 @Override
614 public CpsApplications.Match newMatch(final Object... parameters) {
615 return CpsApplications.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[1]);
616 }
617
618 /**
619 * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications (visibility: PUBLIC, simpleName: CpsApplications, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
620 * <b>not</b> at the class load time of the outer class,
621 * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications (visibility: PUBLIC, simpleName: CpsApplications, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
622 *
623 * <p> This workaround is required e.g. to support recursion.
624 *
625 */
626 private static class LazyHolder {
627 private static final CpsApplications INSTANCE = new CpsApplications();
628
629 /**
630 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
631 * This initialization order is required to support indirect recursion.
632 *
633 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
634 *
635 */
636 private static final Object STATIC_INITIALIZER = ensureInitialized();
637
638 public static Object ensureInitialized() {
639 INSTANCE.ensureInitializedInternal();
640 return null;
641 }
642 }
643
644 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
645 private static final CpsApplications.GeneratedPQuery INSTANCE = new GeneratedPQuery();
646
647 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);
648
649 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);
650
651 private final List<PParameter> parameters = Arrays.asList(parameter_Cps, parameter_AppInstance);
652
653 private GeneratedPQuery() {
654 super(PVisibility.PUBLIC);
655 }
656
657 @Override
658 public String getFullyQualifiedName() {
659 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications";
660 }
661
662 @Override
663 public List<String> getParameterNames() {
664 return Arrays.asList("Cps","AppInstance");
665 }
666
667 @Override
668 public List<PParameter> getParameters() {
669 return parameters;
670 }
671
672 @Override
673 public Set<PBody> doGetContainedBodies() {
674 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
675 Set<PBody> bodies = new LinkedHashSet<>();
676 {
677 PBody body = new PBody(this);
678 PVariable var_Cps = body.getOrCreateVariableByName("Cps");
679 PVariable var_AppInstance = body.getOrCreateVariableByName("AppInstance");
680 new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem")));
681 new TypeConstraint(body, Tuples.flatTupleOf(var_AppInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
682 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
683 new ExportedParameter(body, var_Cps, parameter_Cps),
684 new ExportedParameter(body, var_AppInstance, parameter_AppInstance)
685 ));
686 // CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance)
687 new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem")));
688 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
689 new TypeConstraint(body, Tuples.flatTupleOf(var_Cps, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "CyberPhysicalSystem", "applicationTypes")));
690 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType")));
691 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
692 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "instances")));
693 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
694 new Equality(body, var__virtual_1_, var_AppInstance);
695 bodies.add(body);
696 }
697 {
698 PAnnotation annotation = new PAnnotation("QueryBasedFeature");
699 annotation.addAttribute("feature", "applications");
700 addAnnotation(annotation);
701 }
702 return bodies;
703 }
704 }
705}
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
index 169a30e5..fc90ef12 100644
--- 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
@@ -4,7 +4,7 @@
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries; 4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5 5
6import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; 6import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications; 7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsApplications;
8import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost; 8import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost;
9import java.util.Arrays; 9import java.util.Arrays;
10import java.util.Collection; 10import java.util.Collection;
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
index 916f35f7..c889fbe0 100644
--- 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
@@ -3,22 +3,22 @@
3 */ 3 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries; 4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5 5
6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate;
6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement; 7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd;
8import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory;
9import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric; 8import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric;
10import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric; 9import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric;
11import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric; 10import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric;
12import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications;
13import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost; 11import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost;
14import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts; 12import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance;
13import hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective;
15import hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement; 14import hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement;
16import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd; 15import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd;
17import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory; 16import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory;
18import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RedundantInstancesOnSameHost; 17import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RedundantInstancesOnSameHost;
18import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RemoveHostInstance;
19import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied; 19import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied;
20import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; 20import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement;
21import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; 21import hu.bme.mit.inf.dslreasoner.domains.cps.queries.UnallocateAppInstance;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; 22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; 23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
24 24
@@ -30,12 +30,7 @@ import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
30 * in order to achieve better performance than one-by-one on-demand matcher initialization. 30 * in order to achieve better performance than one-by-one on-demand matcher initialization.
31 * 31 *
32 * <p> From package hu.bme.mit.inf.dslreasoner.domains.cps.queries, the group contains the definition of the following patterns: <ul> 32 * <p> From package hu.bme.mit.inf.dslreasoner.domains.cps.queries, the group contains the definition of the following patterns: <ul>
33 * <li>cpsApplications</li> 33 * <li>resourceRequirement</li>
34 * <li>cpsHosts</li>
35 * <li>totalMemory</li>
36 * <li>totalHdd</li>
37 * <li>availableMemory</li>
38 * <li>availableHdd</li>
39 * <li>allocationWithoutResourceRequirement</li> 34 * <li>allocationWithoutResourceRequirement</li>
40 * <li>notEnoughAvailableMemory</li> 35 * <li>notEnoughAvailableMemory</li>
41 * <li>notEnoughAvailableHdd</li> 36 * <li>notEnoughAvailableHdd</li>
@@ -46,6 +41,11 @@ import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
46 * <li>averageFreeHddMetric</li> 41 * <li>averageFreeHddMetric</li>
47 * <li>costMetric</li> 42 * <li>costMetric</li>
48 * <li>cpsCost</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> 49 * </ul>
50 * 50 *
51 * @see IQueryGroup 51 * @see IQueryGroup
@@ -70,12 +70,7 @@ public final class CpsQueries extends BaseGeneratedPatternGroup {
70 private static CpsQueries INSTANCE; 70 private static CpsQueries INSTANCE;
71 71
72 private CpsQueries() { 72 private CpsQueries() {
73 querySpecifications.add(CpsApplications.instance()); 73 querySpecifications.add(ResourceRequirement.instance());
74 querySpecifications.add(CpsHosts.instance());
75 querySpecifications.add(TotalMemory.instance());
76 querySpecifications.add(TotalHdd.instance());
77 querySpecifications.add(AvailableMemory.instance());
78 querySpecifications.add(AvailableHdd.instance());
79 querySpecifications.add(AllocationWithoutResourceRequirement.instance()); 74 querySpecifications.add(AllocationWithoutResourceRequirement.instance());
80 querySpecifications.add(NotEnoughAvailableMemory.instance()); 75 querySpecifications.add(NotEnoughAvailableMemory.instance());
81 querySpecifications.add(NotEnoughAvailableHdd.instance()); 76 querySpecifications.add(NotEnoughAvailableHdd.instance());
@@ -86,54 +81,19 @@ public final class CpsQueries extends BaseGeneratedPatternGroup {
86 querySpecifications.add(AverageFreeHddMetric.instance()); 81 querySpecifications.add(AverageFreeHddMetric.instance());
87 querySpecifications.add(CostMetric.instance()); 82 querySpecifications.add(CostMetric.instance());
88 querySpecifications.add(CpsCost.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 } 89 }
90 90
91 public CpsApplications getCpsApplications() { 91 public ResourceRequirement getResourceRequirement() {
92 return CpsApplications.instance(); 92 return ResourceRequirement.instance();
93 } 93 }
94 94
95 public CpsApplications.Matcher getCpsApplications(final ViatraQueryEngine engine) { 95 public ResourceRequirement.Matcher getResourceRequirement(final ViatraQueryEngine engine) {
96 return CpsApplications.Matcher.on(engine); 96 return ResourceRequirement.Matcher.on(engine);
97 }
98
99 public CpsHosts getCpsHosts() {
100 return CpsHosts.instance();
101 }
102
103 public CpsHosts.Matcher getCpsHosts(final ViatraQueryEngine engine) {
104 return CpsHosts.Matcher.on(engine);
105 }
106
107 public TotalMemory getTotalMemory() {
108 return TotalMemory.instance();
109 }
110
111 public TotalMemory.Matcher getTotalMemory(final ViatraQueryEngine engine) {
112 return TotalMemory.Matcher.on(engine);
113 }
114
115 public TotalHdd getTotalHdd() {
116 return TotalHdd.instance();
117 }
118
119 public TotalHdd.Matcher getTotalHdd(final ViatraQueryEngine engine) {
120 return TotalHdd.Matcher.on(engine);
121 }
122
123 public AvailableMemory getAvailableMemory() {
124 return AvailableMemory.instance();
125 }
126
127 public AvailableMemory.Matcher getAvailableMemory(final ViatraQueryEngine engine) {
128 return AvailableMemory.Matcher.on(engine);
129 }
130
131 public AvailableHdd getAvailableHdd() {
132 return AvailableHdd.instance();
133 }
134
135 public AvailableHdd.Matcher getAvailableHdd(final ViatraQueryEngine engine) {
136 return AvailableHdd.Matcher.on(engine);
137 } 97 }
138 98
139 public AllocationWithoutResourceRequirement getAllocationWithoutResourceRequirement() { 99 public AllocationWithoutResourceRequirement getAllocationWithoutResourceRequirement() {
@@ -215,4 +175,44 @@ public final class CpsQueries extends BaseGeneratedPatternGroup {
215 public CpsCost.Matcher getCpsCost(final ViatraQueryEngine engine) { 175 public CpsCost.Matcher getCpsCost(final ViatraQueryEngine engine) {
216 return CpsCost.Matcher.on(engine); 176 return CpsCost.Matcher.on(engine);
217 } 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} 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..f475c9e9
--- /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,553 @@
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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.HostType;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance;
8import java.util.Arrays;
9import java.util.Collection;
10import java.util.LinkedHashSet;
11import java.util.List;
12import java.util.Objects;
13import java.util.Optional;
14import java.util.Set;
15import java.util.function.Consumer;
16import java.util.stream.Collectors;
17import java.util.stream.Stream;
18import org.apache.log4j.Logger;
19import org.eclipse.emf.ecore.EClass;
20import org.eclipse.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
29import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
31import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
32import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
36import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
38import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
39import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
40import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
41import 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")
59public 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 if ("HostType".equals(parameterName)) return this.fHostType;
84 return null;
85 }
86
87 public HostType getHostType() {
88 return this.fHostType;
89 }
90
91 @Override
92 public boolean set(final String parameterName, final Object newValue) {
93 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
94 if ("HostType".equals(parameterName) ) {
95 this.fHostType = (HostType) newValue;
96 return true;
97 }
98 return false;
99 }
100
101 public void setHostType(final HostType pHostType) {
102 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
103 this.fHostType = pHostType;
104 }
105
106 @Override
107 public String patternName() {
108 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.createHostInstance";
109 }
110
111 @Override
112 public List<String> parameterNames() {
113 return CreateHostInstance.Match.parameterNames;
114 }
115
116 @Override
117 public Object[] toArray() {
118 return new Object[]{fHostType};
119 }
120
121 @Override
122 public CreateHostInstance.Match toImmutable() {
123 return isMutable() ? newMatch(fHostType) : this;
124 }
125
126 @Override
127 public String prettyPrint() {
128 StringBuilder result = new StringBuilder();
129 result.append("\"HostType\"=" + prettyPrintValue(fHostType));
130 return result.toString();
131 }
132
133 @Override
134 public int hashCode() {
135 return Objects.hash(fHostType);
136 }
137
138 @Override
139 public boolean equals(final Object obj) {
140 if (this == obj)
141 return true;
142 if (obj == null) {
143 return false;
144 }
145 if ((obj instanceof CreateHostInstance.Match)) {
146 CreateHostInstance.Match other = (CreateHostInstance.Match) obj;
147 return Objects.equals(fHostType, other.fHostType);
148 } else {
149 // this should be infrequent
150 if (!(obj instanceof IPatternMatch)) {
151 return false;
152 }
153 IPatternMatch otherSig = (IPatternMatch) obj;
154 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
155 }
156 }
157
158 @Override
159 public CreateHostInstance specification() {
160 return CreateHostInstance.instance();
161 }
162
163 /**
164 * Returns an empty, mutable match.
165 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
166 *
167 * @return the empty match.
168 *
169 */
170 public static CreateHostInstance.Match newEmptyMatch() {
171 return new Mutable(null);
172 }
173
174 /**
175 * Returns a mutable (partial) match.
176 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
177 *
178 * @param pHostType the fixed value of pattern parameter HostType, or null if not bound.
179 * @return the new, mutable (partial) match object.
180 *
181 */
182 public static CreateHostInstance.Match newMutableMatch(final HostType pHostType) {
183 return new Mutable(pHostType);
184 }
185
186 /**
187 * Returns a new (partial) match.
188 * This can be used e.g. to call the matcher with a partial match.
189 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
190 * @param pHostType the fixed value of pattern parameter HostType, or null if not bound.
191 * @return the (partial) match object.
192 *
193 */
194 public static CreateHostInstance.Match newMatch(final HostType pHostType) {
195 return new Immutable(pHostType);
196 }
197
198 private static final class Mutable extends CreateHostInstance.Match {
199 Mutable(final HostType pHostType) {
200 super(pHostType);
201 }
202
203 @Override
204 public boolean isMutable() {
205 return true;
206 }
207 }
208
209 private static final class Immutable extends CreateHostInstance.Match {
210 Immutable(final HostType pHostType) {
211 super(pHostType);
212 }
213
214 @Override
215 public boolean isMutable() {
216 return false;
217 }
218 }
219 }
220
221 /**
222 * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.createHostInstance pattern,
223 * providing pattern-specific query methods.
224 *
225 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
226 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
227 *
228 * <p>Matches of the pattern will be represented as {@link Match}.
229 *
230 * <p>Original source:
231 * <code><pre>
232 * pattern createHostInstance(HostType : HostType) {
233 * find unallocatedAppInstance(App);
234 * ApplicationInstance.type.requirements.hostType(App, HostType);
235 * }
236 * </pre></code>
237 *
238 * @see Match
239 * @see CreateHostInstance
240 *
241 */
242 public static class Matcher extends BaseMatcher<CreateHostInstance.Match> {
243 /**
244 * Initializes the pattern matcher within an existing VIATRA Query engine.
245 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
246 *
247 * @param engine the existing VIATRA Query engine in which this matcher will be created.
248 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
249 *
250 */
251 public static CreateHostInstance.Matcher on(final ViatraQueryEngine engine) {
252 // check if matcher already exists
253 Matcher matcher = engine.getExistingMatcher(querySpecification());
254 if (matcher == null) {
255 matcher = (Matcher)engine.getMatcher(querySpecification());
256 }
257 return matcher;
258 }
259
260 /**
261 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
262 * @return an initialized matcher
263 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
264 *
265 */
266 public static CreateHostInstance.Matcher create() {
267 return new Matcher();
268 }
269
270 private static final int POSITION_HOSTTYPE = 0;
271
272 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CreateHostInstance.Matcher.class);
273
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 private Matcher() {
283 super(querySpecification());
284 }
285
286 /**
287 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
288 * @param pHostType the fixed value of pattern parameter HostType, or null if not bound.
289 * @return matches represented as a Match object.
290 *
291 */
292 public Collection<CreateHostInstance.Match> getAllMatches(final HostType pHostType) {
293 return rawStreamAllMatches(new Object[]{pHostType}).collect(Collectors.toSet());
294 }
295
296 /**
297 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
298 * </p>
299 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
300 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
301 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
302 * @param pHostType the fixed value of pattern parameter HostType, or null if not bound.
303 * @return a stream of matches represented as a Match object.
304 *
305 */
306 public Stream<CreateHostInstance.Match> streamAllMatches(final HostType pHostType) {
307 return rawStreamAllMatches(new Object[]{pHostType});
308 }
309
310 /**
311 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
312 * Neither determinism nor randomness of selection is guaranteed.
313 * @param pHostType the fixed value of pattern parameter HostType, or null if not bound.
314 * @return a match represented as a Match object, or null if no match is found.
315 *
316 */
317 public Optional<CreateHostInstance.Match> getOneArbitraryMatch(final HostType pHostType) {
318 return rawGetOneArbitraryMatch(new Object[]{pHostType});
319 }
320
321 /**
322 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
323 * under any possible substitution of the unspecified parameters (if any).
324 * @param pHostType the fixed value of pattern parameter HostType, or null if not bound.
325 * @return true if the input is a valid (partial) match of the pattern.
326 *
327 */
328 public boolean hasMatch(final HostType pHostType) {
329 return rawHasMatch(new Object[]{pHostType});
330 }
331
332 /**
333 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
334 * @param pHostType the fixed value of pattern parameter HostType, or null if not bound.
335 * @return the number of pattern matches found.
336 *
337 */
338 public int countMatches(final HostType pHostType) {
339 return rawCountMatches(new Object[]{pHostType});
340 }
341
342 /**
343 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
344 * Neither determinism nor randomness of selection is guaranteed.
345 * @param pHostType the fixed value of pattern parameter HostType, or null if not bound.
346 * @param processor the action that will process the selected match.
347 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
348 *
349 */
350 public boolean forOneArbitraryMatch(final HostType pHostType, final Consumer<? super CreateHostInstance.Match> processor) {
351 return rawForOneArbitraryMatch(new Object[]{pHostType}, processor);
352 }
353
354 /**
355 * Returns a new (partial) match.
356 * This can be used e.g. to call the matcher with a partial match.
357 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
358 * @param pHostType the fixed value of pattern parameter HostType, or null if not bound.
359 * @return the (partial) match object.
360 *
361 */
362 public CreateHostInstance.Match newMatch(final HostType pHostType) {
363 return CreateHostInstance.Match.newMatch(pHostType);
364 }
365
366 /**
367 * Retrieve the set of values that occur in matches for HostType.
368 * @return the Set of all values or empty set if there are no matches
369 *
370 */
371 protected Stream<HostType> rawStreamAllValuesOfHostType(final Object[] parameters) {
372 return rawStreamAllValues(POSITION_HOSTTYPE, parameters).map(HostType.class::cast);
373 }
374
375 /**
376 * Retrieve the set of values that occur in matches for HostType.
377 * @return the Set of all values or empty set if there are no matches
378 *
379 */
380 public Set<HostType> getAllValuesOfHostType() {
381 return rawStreamAllValuesOfHostType(emptyArray()).collect(Collectors.toSet());
382 }
383
384 /**
385 * Retrieve the set of values that occur in matches for HostType.
386 * @return the Set of all values or empty set if there are no matches
387 *
388 */
389 public Stream<HostType> streamAllValuesOfHostType() {
390 return rawStreamAllValuesOfHostType(emptyArray());
391 }
392
393 @Override
394 protected CreateHostInstance.Match tupleToMatch(final Tuple t) {
395 try {
396 return CreateHostInstance.Match.newMatch((HostType) t.get(POSITION_HOSTTYPE));
397 } catch(ClassCastException e) {
398 LOGGER.error("Element(s) in tuple not properly typed!",e);
399 return null;
400 }
401 }
402
403 @Override
404 protected CreateHostInstance.Match arrayToMatch(final Object[] match) {
405 try {
406 return CreateHostInstance.Match.newMatch((HostType) match[POSITION_HOSTTYPE]);
407 } catch(ClassCastException e) {
408 LOGGER.error("Element(s) in array not properly typed!",e);
409 return null;
410 }
411 }
412
413 @Override
414 protected CreateHostInstance.Match arrayToMatchMutable(final Object[] match) {
415 try {
416 return CreateHostInstance.Match.newMutableMatch((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 /**
424 * @return the singleton instance of the query specification of this pattern
425 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
426 *
427 */
428 public static IQuerySpecification<CreateHostInstance.Matcher> querySpecification() {
429 return CreateHostInstance.instance();
430 }
431 }
432
433 private CreateHostInstance() {
434 super(GeneratedPQuery.INSTANCE);
435 }
436
437 /**
438 * @return the singleton instance of the query specification
439 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
440 *
441 */
442 public static CreateHostInstance instance() {
443 try{
444 return LazyHolder.INSTANCE;
445 } catch (ExceptionInInitializerError err) {
446 throw processInitializerError(err);
447 }
448 }
449
450 @Override
451 protected CreateHostInstance.Matcher instantiate(final ViatraQueryEngine engine) {
452 return CreateHostInstance.Matcher.on(engine);
453 }
454
455 @Override
456 public CreateHostInstance.Matcher instantiate() {
457 return CreateHostInstance.Matcher.create();
458 }
459
460 @Override
461 public CreateHostInstance.Match newEmptyMatch() {
462 return CreateHostInstance.Match.newEmptyMatch();
463 }
464
465 @Override
466 public CreateHostInstance.Match newMatch(final Object... parameters) {
467 return CreateHostInstance.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostType) parameters[0]);
468 }
469
470 /**
471 * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance (visibility: PUBLIC, simpleName: CreateHostInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
472 * <b>not</b> at the class load time of the outer class,
473 * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance (visibility: PUBLIC, simpleName: CreateHostInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
474 *
475 * <p> This workaround is required e.g. to support recursion.
476 *
477 */
478 private static class LazyHolder {
479 private static final CreateHostInstance INSTANCE = new CreateHostInstance();
480
481 /**
482 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
483 * This initialization order is required to support indirect recursion.
484 *
485 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
486 *
487 */
488 private static final Object STATIC_INITIALIZER = ensureInitialized();
489
490 public static Object ensureInitialized() {
491 INSTANCE.ensureInitializedInternal();
492 return null;
493 }
494 }
495
496 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
497 private static final CreateHostInstance.GeneratedPQuery INSTANCE = new GeneratedPQuery();
498
499 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);
500
501 private final List<PParameter> parameters = Arrays.asList(parameter_HostType);
502
503 private GeneratedPQuery() {
504 super(PVisibility.PUBLIC);
505 }
506
507 @Override
508 public String getFullyQualifiedName() {
509 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.createHostInstance";
510 }
511
512 @Override
513 public List<String> getParameterNames() {
514 return Arrays.asList("HostType");
515 }
516
517 @Override
518 public List<PParameter> getParameters() {
519 return parameters;
520 }
521
522 @Override
523 public Set<PBody> doGetContainedBodies() {
524 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
525 Set<PBody> bodies = new LinkedHashSet<>();
526 {
527 PBody body = new PBody(this);
528 PVariable var_HostType = body.getOrCreateVariableByName("HostType");
529 PVariable var_App = body.getOrCreateVariableByName("App");
530 new TypeConstraint(body, Tuples.flatTupleOf(var_HostType), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType")));
531 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
532 new ExportedParameter(body, var_HostType, parameter_HostType)
533 ));
534 // find unallocatedAppInstance(App)
535 new PositivePatternCall(body, Tuples.flatTupleOf(var_App), UnallocatedAppInstance.instance().getInternalQueryRepresentation());
536 // ApplicationInstance.type.requirements.hostType(App, HostType)
537 new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
538 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
539 new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type")));
540 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType")));
541 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
542 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "requirements")));
543 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
544 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
545 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "hostType")));
546 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType")));
547 new Equality(body, var__virtual_2_, var_HostType);
548 bodies.add(body);
549 }
550 return bodies;
551 }
552 }
553}
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..cfed0c4b
--- /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,591 @@
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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.NoHostToAllocateTo;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.RequiredAppInstances;
8import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance;
9import java.util.Arrays;
10import java.util.Collection;
11import java.util.LinkedHashSet;
12import java.util.List;
13import java.util.Objects;
14import java.util.Optional;
15import java.util.Set;
16import java.util.function.Consumer;
17import java.util.stream.Collectors;
18import java.util.stream.Stream;
19import org.apache.log4j.Logger;
20import org.eclipse.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.matchers.aggregators.sum;
28import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
29import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey;
30import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
31import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
32import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
33import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter;
39import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
41import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
42import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
43import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
44import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
45import 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")
65public 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 if ("Value".equals(parameterName)) return this.fValue;
90 return null;
91 }
92
93 public Integer getValue() {
94 return this.fValue;
95 }
96
97 @Override
98 public boolean set(final String parameterName, final Object newValue) {
99 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
100 if ("Value".equals(parameterName) ) {
101 this.fValue = (Integer) newValue;
102 return true;
103 }
104 return false;
105 }
106
107 public void setValue(final Integer pValue) {
108 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
109 this.fValue = pValue;
110 }
111
112 @Override
113 public String patternName() {
114 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.guidanceObjective";
115 }
116
117 @Override
118 public List<String> parameterNames() {
119 return GuidanceObjective.Match.parameterNames;
120 }
121
122 @Override
123 public Object[] toArray() {
124 return new Object[]{fValue};
125 }
126
127 @Override
128 public GuidanceObjective.Match toImmutable() {
129 return isMutable() ? newMatch(fValue) : this;
130 }
131
132 @Override
133 public String prettyPrint() {
134 StringBuilder result = new StringBuilder();
135 result.append("\"Value\"=" + prettyPrintValue(fValue));
136 return result.toString();
137 }
138
139 @Override
140 public int hashCode() {
141 return Objects.hash(fValue);
142 }
143
144 @Override
145 public boolean equals(final Object obj) {
146 if (this == obj)
147 return true;
148 if (obj == null) {
149 return false;
150 }
151 if ((obj instanceof GuidanceObjective.Match)) {
152 GuidanceObjective.Match other = (GuidanceObjective.Match) obj;
153 return Objects.equals(fValue, other.fValue);
154 } else {
155 // this should be infrequent
156 if (!(obj instanceof IPatternMatch)) {
157 return false;
158 }
159 IPatternMatch otherSig = (IPatternMatch) obj;
160 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
161 }
162 }
163
164 @Override
165 public GuidanceObjective specification() {
166 return GuidanceObjective.instance();
167 }
168
169 /**
170 * Returns an empty, mutable match.
171 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
172 *
173 * @return the empty match.
174 *
175 */
176 public static GuidanceObjective.Match newEmptyMatch() {
177 return new Mutable(null);
178 }
179
180 /**
181 * Returns a mutable (partial) match.
182 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
183 *
184 * @param pValue the fixed value of pattern parameter Value, or null if not bound.
185 * @return the new, mutable (partial) match object.
186 *
187 */
188 public static GuidanceObjective.Match newMutableMatch(final Integer pValue) {
189 return new Mutable(pValue);
190 }
191
192 /**
193 * Returns a new (partial) match.
194 * This can be used e.g. to call the matcher with a partial match.
195 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
196 * @param pValue the fixed value of pattern parameter Value, or null if not bound.
197 * @return the (partial) match object.
198 *
199 */
200 public static GuidanceObjective.Match newMatch(final Integer pValue) {
201 return new Immutable(pValue);
202 }
203
204 private static final class Mutable extends GuidanceObjective.Match {
205 Mutable(final Integer pValue) {
206 super(pValue);
207 }
208
209 @Override
210 public boolean isMutable() {
211 return true;
212 }
213 }
214
215 private static final class Immutable extends GuidanceObjective.Match {
216 Immutable(final Integer pValue) {
217 super(pValue);
218 }
219
220 @Override
221 public boolean isMutable() {
222 return false;
223 }
224 }
225 }
226
227 /**
228 * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.guidanceObjective pattern,
229 * providing pattern-specific query methods.
230 *
231 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
232 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
233 *
234 * <p>Matches of the pattern will be represented as {@link Match}.
235 *
236 * <p>Original source:
237 * <code><pre>
238 * pattern guidanceObjective(Value : java Integer) {
239 * UnallocatedInstances == count find unallocatedAppInstance(_);
240 * RequiredInstances == sum find requiredAppInstances(_, #_);
241 * NoHostToAllocate == count find noHostToAllocateTo(_);
242 * Value == eval(2 UnallocatedInstances + 4 RequiredInstances + NoHostToAllocate);
243 * }
244 * </pre></code>
245 *
246 * @see Match
247 * @see GuidanceObjective
248 *
249 */
250 public static class Matcher extends BaseMatcher<GuidanceObjective.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 GuidanceObjective.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 GuidanceObjective.Matcher create() {
275 return new Matcher();
276 }
277
278 private static final int POSITION_VALUE = 0;
279
280 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(GuidanceObjective.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 pValue the fixed value of pattern parameter Value, or null if not bound.
297 * @return matches represented as a Match object.
298 *
299 */
300 public Collection<GuidanceObjective.Match> getAllMatches(final Integer pValue) {
301 return rawStreamAllMatches(new Object[]{pValue}).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 pValue the fixed value of pattern parameter Value, or null if not bound.
311 * @return a stream of matches represented as a Match object.
312 *
313 */
314 public Stream<GuidanceObjective.Match> streamAllMatches(final Integer pValue) {
315 return rawStreamAllMatches(new Object[]{pValue});
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 pValue the fixed value of pattern parameter Value, 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<GuidanceObjective.Match> getOneArbitraryMatch(final Integer pValue) {
326 return rawGetOneArbitraryMatch(new Object[]{pValue});
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 pValue the fixed value of pattern parameter Value, 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 Integer pValue) {
337 return rawHasMatch(new Object[]{pValue});
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 pValue the fixed value of pattern parameter Value, or null if not bound.
343 * @return the number of pattern matches found.
344 *
345 */
346 public int countMatches(final Integer pValue) {
347 return rawCountMatches(new Object[]{pValue});
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 pValue the fixed value of pattern parameter Value, 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 Integer pValue, final Consumer<? super GuidanceObjective.Match> processor) {
359 return rawForOneArbitraryMatch(new Object[]{pValue}, 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 pValue the fixed value of pattern parameter Value, or null if not bound.
367 * @return the (partial) match object.
368 *
369 */
370 public GuidanceObjective.Match newMatch(final Integer pValue) {
371 return GuidanceObjective.Match.newMatch(pValue);
372 }
373
374 /**
375 * Retrieve the set of values that occur in matches for Value.
376 * @return the Set of all values or empty set if there are no matches
377 *
378 */
379 protected Stream<Integer> rawStreamAllValuesOfValue(final Object[] parameters) {
380 return rawStreamAllValues(POSITION_VALUE, parameters).map(Integer.class::cast);
381 }
382
383 /**
384 * Retrieve the set of values that occur in matches for Value.
385 * @return the Set of all values or empty set if there are no matches
386 *
387 */
388 public Set<Integer> getAllValuesOfValue() {
389 return rawStreamAllValuesOfValue(emptyArray()).collect(Collectors.toSet());
390 }
391
392 /**
393 * Retrieve the set of values that occur in matches for Value.
394 * @return the Set of all values or empty set if there are no matches
395 *
396 */
397 public Stream<Integer> streamAllValuesOfValue() {
398 return rawStreamAllValuesOfValue(emptyArray());
399 }
400
401 @Override
402 protected GuidanceObjective.Match tupleToMatch(final Tuple t) {
403 try {
404 return GuidanceObjective.Match.newMatch((Integer) t.get(POSITION_VALUE));
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 GuidanceObjective.Match arrayToMatch(final Object[] match) {
413 try {
414 return GuidanceObjective.Match.newMatch((Integer) match[POSITION_VALUE]);
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 GuidanceObjective.Match arrayToMatchMutable(final Object[] match) {
423 try {
424 return GuidanceObjective.Match.newMutableMatch((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 /**
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<GuidanceObjective.Matcher> querySpecification() {
437 return GuidanceObjective.instance();
438 }
439 }
440
441 private GuidanceObjective() {
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 GuidanceObjective instance() {
451 try{
452 return LazyHolder.INSTANCE;
453 } catch (ExceptionInInitializerError err) {
454 throw processInitializerError(err);
455 }
456 }
457
458 @Override
459 protected GuidanceObjective.Matcher instantiate(final ViatraQueryEngine engine) {
460 return GuidanceObjective.Matcher.on(engine);
461 }
462
463 @Override
464 public GuidanceObjective.Matcher instantiate() {
465 return GuidanceObjective.Matcher.create();
466 }
467
468 @Override
469 public GuidanceObjective.Match newEmptyMatch() {
470 return GuidanceObjective.Match.newEmptyMatch();
471 }
472
473 @Override
474 public GuidanceObjective.Match newMatch(final Object... parameters) {
475 return GuidanceObjective.Match.newMatch((java.lang.Integer) parameters[0]);
476 }
477
478 /**
479 * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective (visibility: PUBLIC, simpleName: GuidanceObjective, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective (visibility: PUBLIC, simpleName: GuidanceObjective, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
482 *
483 * <p> This workaround is required e.g. to support recursion.
484 *
485 */
486 private static class LazyHolder {
487 private static final GuidanceObjective INSTANCE = new GuidanceObjective();
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 GuidanceObjective.GeneratedPQuery INSTANCE = new GeneratedPQuery();
506
507 private final PParameter parameter_Value = new PParameter("Value", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT);
508
509 private final List<PParameter> parameters = Arrays.asList(parameter_Value);
510
511 private GeneratedPQuery() {
512 super(PVisibility.PUBLIC);
513 }
514
515 @Override
516 public String getFullyQualifiedName() {
517 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.guidanceObjective";
518 }
519
520 @Override
521 public List<String> getParameterNames() {
522 return Arrays.asList("Value");
523 }
524
525 @Override
526 public List<PParameter> getParameters() {
527 return parameters;
528 }
529
530 @Override
531 public Set<PBody> doGetContainedBodies() {
532 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
533 Set<PBody> bodies = new LinkedHashSet<>();
534 {
535 PBody body = new PBody(this);
536 PVariable var_Value = body.getOrCreateVariableByName("Value");
537 PVariable var_UnallocatedInstances = body.getOrCreateVariableByName("UnallocatedInstances");
538 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
539 PVariable var_RequiredInstances = body.getOrCreateVariableByName("RequiredInstances");
540 PVariable var___1_ = body.getOrCreateVariableByName("_<1>");
541 PVariable var___2_ = body.getOrCreateVariableByName("_<2>");
542 PVariable var_NoHostToAllocate = body.getOrCreateVariableByName("NoHostToAllocate");
543 PVariable var___3_ = body.getOrCreateVariableByName("_<3>");
544 new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Value), new JavaTransitiveInstancesKey(java.lang.Integer.class));
545 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
546 new ExportedParameter(body, var_Value, parameter_Value)
547 ));
548 // UnallocatedInstances == count find unallocatedAppInstance(_)
549 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
550 new PatternMatchCounter(body, Tuples.flatTupleOf(var___0_), UnallocatedAppInstance.instance().getInternalQueryRepresentation(), var__virtual_0_);
551 new Equality(body, var_UnallocatedInstances, var__virtual_0_);
552 // RequiredInstances == sum find requiredAppInstances(_, #_)
553 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
554 new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var___1_, var___2_), RequiredAppInstances.instance().getInternalQueryRepresentation(), var__virtual_1_, 1);
555 new Equality(body, var_RequiredInstances, var__virtual_1_);
556 // NoHostToAllocate == count find noHostToAllocateTo(_)
557 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
558 new PatternMatchCounter(body, Tuples.flatTupleOf(var___3_), NoHostToAllocateTo.instance().getInternalQueryRepresentation(), var__virtual_2_);
559 new Equality(body, var_NoHostToAllocate, var__virtual_2_);
560 // Value == eval(2 * UnallocatedInstances + 4 * RequiredInstances + NoHostToAllocate)
561 PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}");
562 new ExpressionEvaluation(body, new IExpressionEvaluator() {
563
564 @Override
565 public String getShortDescription() {
566 return "Expression evaluation from pattern guidanceObjective";
567 }
568
569 @Override
570 public Iterable<String> getInputParameterNames() {
571 return Arrays.asList("NoHostToAllocate", "RequiredInstances", "UnallocatedInstances");}
572
573 @Override
574 public Object evaluateExpression(IValueProvider provider) throws Exception {
575 Integer NoHostToAllocate = (Integer) provider.getValue("NoHostToAllocate");
576 Integer RequiredInstances = (Integer) provider.getValue("RequiredInstances");
577 Integer UnallocatedInstances = (Integer) provider.getValue("UnallocatedInstances");
578 return evaluateExpression_1_1(NoHostToAllocate, RequiredInstances, UnallocatedInstances);
579 }
580 }, var__virtual_3_ );
581 new Equality(body, var_Value, var__virtual_3_);
582 bodies.add(body);
583 }
584 return bodies;
585 }
586 }
587
588 private static int evaluateExpression_1_1(final Integer NoHostToAllocate, final Integer RequiredInstances, final Integer UnallocatedInstances) {
589 return (((2 * (UnallocatedInstances).intValue()) + (4 * (RequiredInstances).intValue())) + (NoHostToAllocate).intValue());
590 }
591}
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
index 41615598..0c0d57a6 100644
--- 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
@@ -4,7 +4,7 @@
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries; 4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5 5
6import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; 6import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd; 7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd;
8import java.util.Arrays; 8import java.util.Arrays;
9import java.util.Collection; 9import java.util.Collection;
10import java.util.LinkedHashSet; 10import java.util.LinkedHashSet;
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
index 4803ec3a..9f091a95 100644
--- 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
@@ -4,7 +4,7 @@
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries; 4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5 5
6import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; 6import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory; 7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory;
8import java.util.Arrays; 8import java.util.Arrays;
9import java.util.Collection; 9import java.util.Collection;
10import java.util.LinkedHashSet; 10import java.util.LinkedHashSet;
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RemoveHostInstance.java
index e1abf758..1141e898 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RemoveHostInstance.java
@@ -3,10 +3,10 @@
3 */ 3 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries; 4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5 5
6import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem;
7import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; 6import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance;
8import java.util.Arrays; 7import java.util.Arrays;
9import java.util.Collection; 8import java.util.Collection;
9import java.util.Collections;
10import java.util.LinkedHashSet; 10import java.util.LinkedHashSet;
11import java.util.List; 11import java.util.List;
12import java.util.Objects; 12import java.util.Objects;
@@ -29,9 +29,9 @@ import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey
29import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; 29import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; 30import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
31import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; 31import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
32import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; 32import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; 33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; 35import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
36import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; 36import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; 37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
@@ -45,9 +45,8 @@ import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
45 * 45 *
46 * <p>Original source: 46 * <p>Original source:
47 * <code><pre> 47 * <code><pre>
48 * {@literal @}QueryBasedFeature(feature = "hosts") 48 * pattern removeHostInstance(HostInstance : HostInstance) {
49 * pattern cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) { 49 * neg HostInstance.applications(HostInstance, _);
50 * CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance);
51 * } 50 * }
52 * </pre></code> 51 * </pre></code>
53 * 52 *
@@ -56,9 +55,9 @@ import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
56 * 55 *
57 */ 56 */
58@SuppressWarnings("all") 57@SuppressWarnings("all")
59public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.Matcher> { 58public final class RemoveHostInstance extends BaseGeneratedEMFQuerySpecification<RemoveHostInstance.Matcher> {
60 /** 59 /**
61 * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts pattern, 60 * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.removeHostInstance pattern,
62 * to be used in conjunction with {@link Matcher}. 61 * to be used in conjunction with {@link Matcher}.
63 * 62 *
64 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. 63 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
@@ -70,28 +69,20 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
70 * 69 *
71 */ 70 */
72 public static abstract class Match extends BasePatternMatch { 71 public static abstract class Match extends BasePatternMatch {
73 private CyberPhysicalSystem fCps;
74
75 private HostInstance fHostInstance; 72 private HostInstance fHostInstance;
76 73
77 private static List<String> parameterNames = makeImmutableList("Cps", "HostInstance"); 74 private static List<String> parameterNames = makeImmutableList("HostInstance");
78 75
79 private Match(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { 76 private Match(final HostInstance pHostInstance) {
80 this.fCps = pCps;
81 this.fHostInstance = pHostInstance; 77 this.fHostInstance = pHostInstance;
82 } 78 }
83 79
84 @Override 80 @Override
85 public Object get(final String parameterName) { 81 public Object get(final String parameterName) {
86 if ("Cps".equals(parameterName)) return this.fCps;
87 if ("HostInstance".equals(parameterName)) return this.fHostInstance; 82 if ("HostInstance".equals(parameterName)) return this.fHostInstance;
88 return null; 83 return null;
89 } 84 }
90 85
91 public CyberPhysicalSystem getCps() {
92 return this.fCps;
93 }
94
95 public HostInstance getHostInstance() { 86 public HostInstance getHostInstance() {
96 return this.fHostInstance; 87 return this.fHostInstance;
97 } 88 }
@@ -99,10 +90,6 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
99 @Override 90 @Override
100 public boolean set(final String parameterName, final Object newValue) { 91 public boolean set(final String parameterName, final Object newValue) {
101 if (!isMutable()) throw new java.lang.UnsupportedOperationException(); 92 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
102 if ("Cps".equals(parameterName) ) {
103 this.fCps = (CyberPhysicalSystem) newValue;
104 return true;
105 }
106 if ("HostInstance".equals(parameterName) ) { 93 if ("HostInstance".equals(parameterName) ) {
107 this.fHostInstance = (HostInstance) newValue; 94 this.fHostInstance = (HostInstance) newValue;
108 return true; 95 return true;
@@ -110,11 +97,6 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
110 return false; 97 return false;
111 } 98 }
112 99
113 public void setCps(final CyberPhysicalSystem pCps) {
114 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
115 this.fCps = pCps;
116 }
117
118 public void setHostInstance(final HostInstance pHostInstance) { 100 public void setHostInstance(final HostInstance pHostInstance) {
119 if (!isMutable()) throw new java.lang.UnsupportedOperationException(); 101 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
120 this.fHostInstance = pHostInstance; 102 this.fHostInstance = pHostInstance;
@@ -122,35 +104,34 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
122 104
123 @Override 105 @Override
124 public String patternName() { 106 public String patternName() {
125 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts"; 107 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.removeHostInstance";
126 } 108 }
127 109
128 @Override 110 @Override
129 public List<String> parameterNames() { 111 public List<String> parameterNames() {
130 return CpsHosts.Match.parameterNames; 112 return RemoveHostInstance.Match.parameterNames;
131 } 113 }
132 114
133 @Override 115 @Override
134 public Object[] toArray() { 116 public Object[] toArray() {
135 return new Object[]{fCps, fHostInstance}; 117 return new Object[]{fHostInstance};
136 } 118 }
137 119
138 @Override 120 @Override
139 public CpsHosts.Match toImmutable() { 121 public RemoveHostInstance.Match toImmutable() {
140 return isMutable() ? newMatch(fCps, fHostInstance) : this; 122 return isMutable() ? newMatch(fHostInstance) : this;
141 } 123 }
142 124
143 @Override 125 @Override
144 public String prettyPrint() { 126 public String prettyPrint() {
145 StringBuilder result = new StringBuilder(); 127 StringBuilder result = new StringBuilder();
146 result.append("\"Cps\"=" + prettyPrintValue(fCps) + ", ");
147 result.append("\"HostInstance\"=" + prettyPrintValue(fHostInstance)); 128 result.append("\"HostInstance\"=" + prettyPrintValue(fHostInstance));
148 return result.toString(); 129 return result.toString();
149 } 130 }
150 131
151 @Override 132 @Override
152 public int hashCode() { 133 public int hashCode() {
153 return Objects.hash(fCps, fHostInstance); 134 return Objects.hash(fHostInstance);
154 } 135 }
155 136
156 @Override 137 @Override
@@ -160,9 +141,9 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
160 if (obj == null) { 141 if (obj == null) {
161 return false; 142 return false;
162 } 143 }
163 if ((obj instanceof CpsHosts.Match)) { 144 if ((obj instanceof RemoveHostInstance.Match)) {
164 CpsHosts.Match other = (CpsHosts.Match) obj; 145 RemoveHostInstance.Match other = (RemoveHostInstance.Match) obj;
165 return Objects.equals(fCps, other.fCps) && Objects.equals(fHostInstance, other.fHostInstance); 146 return Objects.equals(fHostInstance, other.fHostInstance);
166 } else { 147 } else {
167 // this should be infrequent 148 // this should be infrequent
168 if (!(obj instanceof IPatternMatch)) { 149 if (!(obj instanceof IPatternMatch)) {
@@ -174,8 +155,8 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
174 } 155 }
175 156
176 @Override 157 @Override
177 public CpsHosts specification() { 158 public RemoveHostInstance specification() {
178 return CpsHosts.instance(); 159 return RemoveHostInstance.instance();
179 } 160 }
180 161
181 /** 162 /**
@@ -185,39 +166,37 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
185 * @return the empty match. 166 * @return the empty match.
186 * 167 *
187 */ 168 */
188 public static CpsHosts.Match newEmptyMatch() { 169 public static RemoveHostInstance.Match newEmptyMatch() {
189 return new Mutable(null, null); 170 return new Mutable(null);
190 } 171 }
191 172
192 /** 173 /**
193 * Returns a mutable (partial) match. 174 * Returns a mutable (partial) match.
194 * Fields of the mutable match can be filled to create a partial match, usable as matcher input. 175 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
195 * 176 *
196 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
197 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. 177 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound.
198 * @return the new, mutable (partial) match object. 178 * @return the new, mutable (partial) match object.
199 * 179 *
200 */ 180 */
201 public static CpsHosts.Match newMutableMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { 181 public static RemoveHostInstance.Match newMutableMatch(final HostInstance pHostInstance) {
202 return new Mutable(pCps, pHostInstance); 182 return new Mutable(pHostInstance);
203 } 183 }
204 184
205 /** 185 /**
206 * Returns a new (partial) match. 186 * Returns a new (partial) match.
207 * This can be used e.g. to call the matcher with a partial match. 187 * This can be used e.g. to call the matcher with a partial match.
208 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. 188 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
209 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
210 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. 189 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound.
211 * @return the (partial) match object. 190 * @return the (partial) match object.
212 * 191 *
213 */ 192 */
214 public static CpsHosts.Match newMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { 193 public static RemoveHostInstance.Match newMatch(final HostInstance pHostInstance) {
215 return new Immutable(pCps, pHostInstance); 194 return new Immutable(pHostInstance);
216 } 195 }
217 196
218 private static final class Mutable extends CpsHosts.Match { 197 private static final class Mutable extends RemoveHostInstance.Match {
219 Mutable(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { 198 Mutable(final HostInstance pHostInstance) {
220 super(pCps, pHostInstance); 199 super(pHostInstance);
221 } 200 }
222 201
223 @Override 202 @Override
@@ -226,9 +205,9 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
226 } 205 }
227 } 206 }
228 207
229 private static final class Immutable extends CpsHosts.Match { 208 private static final class Immutable extends RemoveHostInstance.Match {
230 Immutable(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { 209 Immutable(final HostInstance pHostInstance) {
231 super(pCps, pHostInstance); 210 super(pHostInstance);
232 } 211 }
233 212
234 @Override 213 @Override
@@ -239,7 +218,7 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
239 } 218 }
240 219
241 /** 220 /**
242 * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts pattern, 221 * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.removeHostInstance pattern,
243 * providing pattern-specific query methods. 222 * providing pattern-specific query methods.
244 * 223 *
245 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, 224 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
@@ -249,17 +228,16 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
249 * 228 *
250 * <p>Original source: 229 * <p>Original source:
251 * <code><pre> 230 * <code><pre>
252 * {@literal @}QueryBasedFeature(feature = "hosts") 231 * pattern removeHostInstance(HostInstance : HostInstance) {
253 * pattern cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) { 232 * neg HostInstance.applications(HostInstance, _);
254 * CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance);
255 * } 233 * }
256 * </pre></code> 234 * </pre></code>
257 * 235 *
258 * @see Match 236 * @see Match
259 * @see CpsHosts 237 * @see RemoveHostInstance
260 * 238 *
261 */ 239 */
262 public static class Matcher extends BaseMatcher<CpsHosts.Match> { 240 public static class Matcher extends BaseMatcher<RemoveHostInstance.Match> {
263 /** 241 /**
264 * Initializes the pattern matcher within an existing VIATRA Query engine. 242 * Initializes the pattern matcher within an existing VIATRA Query engine.
265 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. 243 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
@@ -268,7 +246,7 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
268 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation 246 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
269 * 247 *
270 */ 248 */
271 public static CpsHosts.Matcher on(final ViatraQueryEngine engine) { 249 public static RemoveHostInstance.Matcher on(final ViatraQueryEngine engine) {
272 // check if matcher already exists 250 // check if matcher already exists
273 Matcher matcher = engine.getExistingMatcher(querySpecification()); 251 Matcher matcher = engine.getExistingMatcher(querySpecification());
274 if (matcher == null) { 252 if (matcher == null) {
@@ -283,15 +261,13 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
283 * @noreference This method is for internal matcher initialization by the framework, do not call it manually. 261 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
284 * 262 *
285 */ 263 */
286 public static CpsHosts.Matcher create() { 264 public static RemoveHostInstance.Matcher create() {
287 return new Matcher(); 265 return new Matcher();
288 } 266 }
289 267
290 private static final int POSITION_CPS = 0; 268 private static final int POSITION_HOSTINSTANCE = 0;
291
292 private static final int POSITION_HOSTINSTANCE = 1;
293 269
294 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CpsHosts.Matcher.class); 270 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(RemoveHostInstance.Matcher.class);
295 271
296 /** 272 /**
297 * Initializes the pattern matcher within an existing VIATRA Query engine. 273 * Initializes the pattern matcher within an existing VIATRA Query engine.
@@ -307,13 +283,12 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
307 283
308 /** 284 /**
309 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. 285 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
310 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
311 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. 286 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound.
312 * @return matches represented as a Match object. 287 * @return matches represented as a Match object.
313 * 288 *
314 */ 289 */
315 public Collection<CpsHosts.Match> getAllMatches(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { 290 public Collection<RemoveHostInstance.Match> getAllMatches(final HostInstance pHostInstance) {
316 return rawStreamAllMatches(new Object[]{pCps, pHostInstance}).collect(Collectors.toSet()); 291 return rawStreamAllMatches(new Object[]{pHostInstance}).collect(Collectors.toSet());
317 } 292 }
318 293
319 /** 294 /**
@@ -322,147 +297,68 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
322 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. 297 * <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>. 298 * 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. 299 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
325 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
326 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. 300 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound.
327 * @return a stream of matches represented as a Match object. 301 * @return a stream of matches represented as a Match object.
328 * 302 *
329 */ 303 */
330 public Stream<CpsHosts.Match> streamAllMatches(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { 304 public Stream<RemoveHostInstance.Match> streamAllMatches(final HostInstance pHostInstance) {
331 return rawStreamAllMatches(new Object[]{pCps, pHostInstance}); 305 return rawStreamAllMatches(new Object[]{pHostInstance});
332 } 306 }
333 307
334 /** 308 /**
335 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. 309 * 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. 310 * Neither determinism nor randomness of selection is guaranteed.
337 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
338 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. 311 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound.
339 * @return a match represented as a Match object, or null if no match is found. 312 * @return a match represented as a Match object, or null if no match is found.
340 * 313 *
341 */ 314 */
342 public Optional<CpsHosts.Match> getOneArbitraryMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { 315 public Optional<RemoveHostInstance.Match> getOneArbitraryMatch(final HostInstance pHostInstance) {
343 return rawGetOneArbitraryMatch(new Object[]{pCps, pHostInstance}); 316 return rawGetOneArbitraryMatch(new Object[]{pHostInstance});
344 } 317 }
345 318
346 /** 319 /**
347 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, 320 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
348 * under any possible substitution of the unspecified parameters (if any). 321 * under any possible substitution of the unspecified parameters (if any).
349 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
350 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. 322 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound.
351 * @return true if the input is a valid (partial) match of the pattern. 323 * @return true if the input is a valid (partial) match of the pattern.
352 * 324 *
353 */ 325 */
354 public boolean hasMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { 326 public boolean hasMatch(final HostInstance pHostInstance) {
355 return rawHasMatch(new Object[]{pCps, pHostInstance}); 327 return rawHasMatch(new Object[]{pHostInstance});
356 } 328 }
357 329
358 /** 330 /**
359 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. 331 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
360 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
361 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. 332 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound.
362 * @return the number of pattern matches found. 333 * @return the number of pattern matches found.
363 * 334 *
364 */ 335 */
365 public int countMatches(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { 336 public int countMatches(final HostInstance pHostInstance) {
366 return rawCountMatches(new Object[]{pCps, pHostInstance}); 337 return rawCountMatches(new Object[]{pHostInstance});
367 } 338 }
368 339
369 /** 340 /**
370 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. 341 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
371 * Neither determinism nor randomness of selection is guaranteed. 342 * Neither determinism nor randomness of selection is guaranteed.
372 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
373 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. 343 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound.
374 * @param processor the action that will process the selected match. 344 * @param processor the action that will process the selected match.
375 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked 345 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
376 * 346 *
377 */ 347 */
378 public boolean forOneArbitraryMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance, final Consumer<? super CpsHosts.Match> processor) { 348 public boolean forOneArbitraryMatch(final HostInstance pHostInstance, final Consumer<? super RemoveHostInstance.Match> processor) {
379 return rawForOneArbitraryMatch(new Object[]{pCps, pHostInstance}, processor); 349 return rawForOneArbitraryMatch(new Object[]{pHostInstance}, processor);
380 } 350 }
381 351
382 /** 352 /**
383 * Returns a new (partial) match. 353 * Returns a new (partial) match.
384 * This can be used e.g. to call the matcher with a partial match. 354 * This can be used e.g. to call the matcher with a partial match.
385 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. 355 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
386 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
387 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. 356 * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound.
388 * @return the (partial) match object. 357 * @return the (partial) match object.
389 * 358 *
390 */ 359 */
391 public CpsHosts.Match newMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { 360 public RemoveHostInstance.Match newMatch(final HostInstance pHostInstance) {
392 return CpsHosts.Match.newMatch(pCps, pHostInstance); 361 return RemoveHostInstance.Match.newMatch(pHostInstance);
393 }
394
395 /**
396 * Retrieve the set of values that occur in matches for Cps.
397 * @return the Set of all values or empty set if there are no matches
398 *
399 */
400 protected Stream<CyberPhysicalSystem> rawStreamAllValuesOfCps(final Object[] parameters) {
401 return rawStreamAllValues(POSITION_CPS, parameters).map(CyberPhysicalSystem.class::cast);
402 }
403
404 /**
405 * Retrieve the set of values that occur in matches for Cps.
406 * @return the Set of all values or empty set if there are no matches
407 *
408 */
409 public Set<CyberPhysicalSystem> getAllValuesOfCps() {
410 return rawStreamAllValuesOfCps(emptyArray()).collect(Collectors.toSet());
411 }
412
413 /**
414 * Retrieve the set of values that occur in matches for Cps.
415 * @return the Set of all values or empty set if there are no matches
416 *
417 */
418 public Stream<CyberPhysicalSystem> streamAllValuesOfCps() {
419 return rawStreamAllValuesOfCps(emptyArray());
420 }
421
422 /**
423 * Retrieve the set of values that occur in matches for Cps.
424 * </p>
425 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
426 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
427 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
428 *
429 * @return the Stream of all values or empty set if there are no matches
430 *
431 */
432 public Stream<CyberPhysicalSystem> streamAllValuesOfCps(final CpsHosts.Match partialMatch) {
433 return rawStreamAllValuesOfCps(partialMatch.toArray());
434 }
435
436 /**
437 * Retrieve the set of values that occur in matches for Cps.
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<CyberPhysicalSystem> streamAllValuesOfCps(final HostInstance pHostInstance) {
447 return rawStreamAllValuesOfCps(new Object[]{null, pHostInstance});
448 }
449
450 /**
451 * Retrieve the set of values that occur in matches for Cps.
452 * @return the Set of all values or empty set if there are no matches
453 *
454 */
455 public Set<CyberPhysicalSystem> getAllValuesOfCps(final CpsHosts.Match partialMatch) {
456 return rawStreamAllValuesOfCps(partialMatch.toArray()).collect(Collectors.toSet());
457 }
458
459 /**
460 * Retrieve the set of values that occur in matches for Cps.
461 * @return the Set of all values or empty set if there are no matches
462 *
463 */
464 public Set<CyberPhysicalSystem> getAllValuesOfCps(final HostInstance pHostInstance) {
465 return rawStreamAllValuesOfCps(new Object[]{null, pHostInstance}).collect(Collectors.toSet());
466 } 362 }
467 363
468 /** 364 /**
@@ -492,56 +388,10 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
492 return rawStreamAllValuesOfHostInstance(emptyArray()); 388 return rawStreamAllValuesOfHostInstance(emptyArray());
493 } 389 }
494 390
495 /**
496 * Retrieve the set of values that occur in matches for HostInstance.
497 * </p>
498 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
499 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
500 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
501 *
502 * @return the Stream of all values or empty set if there are no matches
503 *
504 */
505 public Stream<HostInstance> streamAllValuesOfHostInstance(final CpsHosts.Match partialMatch) {
506 return rawStreamAllValuesOfHostInstance(partialMatch.toArray());
507 }
508
509 /**
510 * Retrieve the set of values that occur in matches for HostInstance.
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<HostInstance> streamAllValuesOfHostInstance(final CyberPhysicalSystem pCps) {
520 return rawStreamAllValuesOfHostInstance(new Object[]{pCps, null});
521 }
522
523 /**
524 * Retrieve the set of values that occur in matches for HostInstance.
525 * @return the Set of all values or empty set if there are no matches
526 *
527 */
528 public Set<HostInstance> getAllValuesOfHostInstance(final CpsHosts.Match partialMatch) {
529 return rawStreamAllValuesOfHostInstance(partialMatch.toArray()).collect(Collectors.toSet());
530 }
531
532 /**
533 * Retrieve the set of values that occur in matches for HostInstance.
534 * @return the Set of all values or empty set if there are no matches
535 *
536 */
537 public Set<HostInstance> getAllValuesOfHostInstance(final CyberPhysicalSystem pCps) {
538 return rawStreamAllValuesOfHostInstance(new Object[]{pCps, null}).collect(Collectors.toSet());
539 }
540
541 @Override 391 @Override
542 protected CpsHosts.Match tupleToMatch(final Tuple t) { 392 protected RemoveHostInstance.Match tupleToMatch(final Tuple t) {
543 try { 393 try {
544 return CpsHosts.Match.newMatch((CyberPhysicalSystem) t.get(POSITION_CPS), (HostInstance) t.get(POSITION_HOSTINSTANCE)); 394 return RemoveHostInstance.Match.newMatch((HostInstance) t.get(POSITION_HOSTINSTANCE));
545 } catch(ClassCastException e) { 395 } catch(ClassCastException e) {
546 LOGGER.error("Element(s) in tuple not properly typed!",e); 396 LOGGER.error("Element(s) in tuple not properly typed!",e);
547 return null; 397 return null;
@@ -549,9 +399,9 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
549 } 399 }
550 400
551 @Override 401 @Override
552 protected CpsHosts.Match arrayToMatch(final Object[] match) { 402 protected RemoveHostInstance.Match arrayToMatch(final Object[] match) {
553 try { 403 try {
554 return CpsHosts.Match.newMatch((CyberPhysicalSystem) match[POSITION_CPS], (HostInstance) match[POSITION_HOSTINSTANCE]); 404 return RemoveHostInstance.Match.newMatch((HostInstance) match[POSITION_HOSTINSTANCE]);
555 } catch(ClassCastException e) { 405 } catch(ClassCastException e) {
556 LOGGER.error("Element(s) in array not properly typed!",e); 406 LOGGER.error("Element(s) in array not properly typed!",e);
557 return null; 407 return null;
@@ -559,9 +409,9 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
559 } 409 }
560 410
561 @Override 411 @Override
562 protected CpsHosts.Match arrayToMatchMutable(final Object[] match) { 412 protected RemoveHostInstance.Match arrayToMatchMutable(final Object[] match) {
563 try { 413 try {
564 return CpsHosts.Match.newMutableMatch((CyberPhysicalSystem) match[POSITION_CPS], (HostInstance) match[POSITION_HOSTINSTANCE]); 414 return RemoveHostInstance.Match.newMutableMatch((HostInstance) match[POSITION_HOSTINSTANCE]);
565 } catch(ClassCastException e) { 415 } catch(ClassCastException e) {
566 LOGGER.error("Element(s) in array not properly typed!",e); 416 LOGGER.error("Element(s) in array not properly typed!",e);
567 return null; 417 return null;
@@ -573,12 +423,12 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
573 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded 423 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
574 * 424 *
575 */ 425 */
576 public static IQuerySpecification<CpsHosts.Matcher> querySpecification() { 426 public static IQuerySpecification<RemoveHostInstance.Matcher> querySpecification() {
577 return CpsHosts.instance(); 427 return RemoveHostInstance.instance();
578 } 428 }
579 } 429 }
580 430
581 private CpsHosts() { 431 private RemoveHostInstance() {
582 super(GeneratedPQuery.INSTANCE); 432 super(GeneratedPQuery.INSTANCE);
583 } 433 }
584 434
@@ -587,7 +437,7 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
587 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded 437 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
588 * 438 *
589 */ 439 */
590 public static CpsHosts instance() { 440 public static RemoveHostInstance instance() {
591 try{ 441 try{
592 return LazyHolder.INSTANCE; 442 return LazyHolder.INSTANCE;
593 } catch (ExceptionInInitializerError err) { 443 } catch (ExceptionInInitializerError err) {
@@ -596,35 +446,35 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
596 } 446 }
597 447
598 @Override 448 @Override
599 protected CpsHosts.Matcher instantiate(final ViatraQueryEngine engine) { 449 protected RemoveHostInstance.Matcher instantiate(final ViatraQueryEngine engine) {
600 return CpsHosts.Matcher.on(engine); 450 return RemoveHostInstance.Matcher.on(engine);
601 } 451 }
602 452
603 @Override 453 @Override
604 public CpsHosts.Matcher instantiate() { 454 public RemoveHostInstance.Matcher instantiate() {
605 return CpsHosts.Matcher.create(); 455 return RemoveHostInstance.Matcher.create();
606 } 456 }
607 457
608 @Override 458 @Override
609 public CpsHosts.Match newEmptyMatch() { 459 public RemoveHostInstance.Match newEmptyMatch() {
610 return CpsHosts.Match.newEmptyMatch(); 460 return RemoveHostInstance.Match.newEmptyMatch();
611 } 461 }
612 462
613 @Override 463 @Override
614 public CpsHosts.Match newMatch(final Object... parameters) { 464 public RemoveHostInstance.Match newMatch(final Object... parameters) {
615 return CpsHosts.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[1]); 465 return RemoveHostInstance.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0]);
616 } 466 }
617 467
618 /** 468 /**
619 * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts (visibility: PUBLIC, simpleName: CpsHosts, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created 469 * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RemoveHostInstance (visibility: PUBLIC, simpleName: RemoveHostInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RemoveHostInstance, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
620 * <b>not</b> at the class load time of the outer class, 470 * <b>not</b> at the class load time of the outer class,
621 * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts (visibility: PUBLIC, simpleName: CpsHosts, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. 471 * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RemoveHostInstance (visibility: PUBLIC, simpleName: RemoveHostInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RemoveHostInstance, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
622 * 472 *
623 * <p> This workaround is required e.g. to support recursion. 473 * <p> This workaround is required e.g. to support recursion.
624 * 474 *
625 */ 475 */
626 private static class LazyHolder { 476 private static class LazyHolder {
627 private static final CpsHosts INSTANCE = new CpsHosts(); 477 private static final RemoveHostInstance INSTANCE = new RemoveHostInstance();
628 478
629 /** 479 /**
630 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. 480 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
@@ -642,13 +492,51 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
642 } 492 }
643 493
644 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { 494 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
645 private static final CpsHosts.GeneratedPQuery INSTANCE = new GeneratedPQuery(); 495 private static final RemoveHostInstance.GeneratedPQuery INSTANCE = new GeneratedPQuery();
646
647 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);
648 496
649 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); 497 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);
650 498
651 private final List<PParameter> parameters = Arrays.asList(parameter_Cps, parameter_HostInstance); 499 private final List<PParameter> parameters = Arrays.asList(parameter_HostInstance);
500
501 private class Embedded_1_HostInstance_applications extends BaseGeneratedEMFPQuery {
502 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);
503
504 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);
505
506 private final List<PParameter> embeddedParameters = Arrays.asList(parameter_p0, parameter_p1);
507
508 public Embedded_1_HostInstance_applications() {
509 super(PVisibility.EMBEDDED);
510 }
511
512 @Override
513 public String getFullyQualifiedName() {
514 return GeneratedPQuery.this.getFullyQualifiedName() + "$Embedded_1_HostInstance_applications";
515 }
516
517 @Override
518 public List<PParameter> getParameters() {
519 return embeddedParameters;
520 }
521
522 @Override
523 public Set<PBody> doGetContainedBodies() {
524 PBody body = new PBody(this);
525 PVariable var_p0 = body.getOrCreateVariableByName("p0");
526 PVariable var_p1 = body.getOrCreateVariableByName("p1");
527 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
528 new ExportedParameter(body, var_p0, parameter_p0),
529 new ExportedParameter(body, var_p1, parameter_p1)
530 ));
531 // HostInstance.applications(HostInstance, _)
532 new TypeConstraint(body, Tuples.flatTupleOf(var_p0), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
533 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
534 new TypeConstraint(body, Tuples.flatTupleOf(var_p0, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "applications")));
535 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
536 new Equality(body, var__virtual_0_, var_p1);
537 return Collections.singleton(body);
538 }
539 }
652 540
653 private GeneratedPQuery() { 541 private GeneratedPQuery() {
654 super(PVisibility.PUBLIC); 542 super(PVisibility.PUBLIC);
@@ -656,12 +544,12 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
656 544
657 @Override 545 @Override
658 public String getFullyQualifiedName() { 546 public String getFullyQualifiedName() {
659 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts"; 547 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.removeHostInstance";
660 } 548 }
661 549
662 @Override 550 @Override
663 public List<String> getParameterNames() { 551 public List<String> getParameterNames() {
664 return Arrays.asList("Cps","HostInstance"); 552 return Arrays.asList("HostInstance");
665 } 553 }
666 554
667 @Override 555 @Override
@@ -675,30 +563,16 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecification<CpsHosts.
675 Set<PBody> bodies = new LinkedHashSet<>(); 563 Set<PBody> bodies = new LinkedHashSet<>();
676 { 564 {
677 PBody body = new PBody(this); 565 PBody body = new PBody(this);
678 PVariable var_Cps = body.getOrCreateVariableByName("Cps");
679 PVariable var_HostInstance = body.getOrCreateVariableByName("HostInstance"); 566 PVariable var_HostInstance = body.getOrCreateVariableByName("HostInstance");
680 new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); 567 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
681 new TypeConstraint(body, Tuples.flatTupleOf(var_HostInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); 568 new TypeConstraint(body, Tuples.flatTupleOf(var_HostInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
682 body.setSymbolicParameters(Arrays.<ExportedParameter>asList( 569 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
683 new ExportedParameter(body, var_Cps, parameter_Cps),
684 new ExportedParameter(body, var_HostInstance, parameter_HostInstance) 570 new ExportedParameter(body, var_HostInstance, parameter_HostInstance)
685 )); 571 ));
686 // CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance) 572 // neg HostInstance.applications(HostInstance, _)
687 new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); 573 new NegativePatternCall(body, Tuples.flatTupleOf(var_HostInstance, var___0_), new RemoveHostInstance.GeneratedPQuery.Embedded_1_HostInstance_applications());
688 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
689 new TypeConstraint(body, Tuples.flatTupleOf(var_Cps, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "CyberPhysicalSystem", "hostTypes")));
690 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType")));
691 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
692 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "instances")));
693 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
694 new Equality(body, var__virtual_1_, var_HostInstance);
695 bodies.add(body); 574 bodies.add(body);
696 } 575 }
697 {
698 PAnnotation annotation = new PAnnotation("QueryBasedFeature");
699 annotation.addAttribute("feature", "hosts");
700 addAnnotation(annotation);
701 }
702 return bodies; 576 return bodies;
703 } 577 }
704 } 578 }
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..db7710f5
--- /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,829 @@
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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance;
7import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance;
8import java.util.Arrays;
9import java.util.Collection;
10import java.util.LinkedHashSet;
11import java.util.List;
12import java.util.Objects;
13import java.util.Optional;
14import java.util.Set;
15import java.util.function.Consumer;
16import java.util.stream.Collectors;
17import java.util.stream.Stream;
18import org.apache.log4j.Logger;
19import org.eclipse.emf.ecore.EClass;
20import org.eclipse.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
29import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
31import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
32import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
35import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
36import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
38import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
39import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
40import 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")
60public 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 if ("Host".equals(parameterName)) return this.fHost;
91 if ("App".equals(parameterName)) return this.fApp;
92 if ("Req".equals(parameterName)) return this.fReq;
93 return null;
94 }
95
96 public HostInstance getHost() {
97 return this.fHost;
98 }
99
100 public ApplicationInstance getApp() {
101 return this.fApp;
102 }
103
104 public hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement getReq() {
105 return this.fReq;
106 }
107
108 @Override
109 public boolean set(final String parameterName, final Object newValue) {
110 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
111 if ("Host".equals(parameterName) ) {
112 this.fHost = (HostInstance) newValue;
113 return true;
114 }
115 if ("App".equals(parameterName) ) {
116 this.fApp = (ApplicationInstance) newValue;
117 return true;
118 }
119 if ("Req".equals(parameterName) ) {
120 this.fReq = (hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement) newValue;
121 return true;
122 }
123 return false;
124 }
125
126 public void setHost(final HostInstance pHost) {
127 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
128 this.fHost = pHost;
129 }
130
131 public void setApp(final ApplicationInstance pApp) {
132 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
133 this.fApp = pApp;
134 }
135
136 public void setReq(final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
137 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
138 this.fReq = pReq;
139 }
140
141 @Override
142 public String patternName() {
143 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement";
144 }
145
146 @Override
147 public List<String> parameterNames() {
148 return ResourceRequirement.Match.parameterNames;
149 }
150
151 @Override
152 public Object[] toArray() {
153 return new Object[]{fHost, fApp, fReq};
154 }
155
156 @Override
157 public ResourceRequirement.Match toImmutable() {
158 return isMutable() ? newMatch(fHost, fApp, fReq) : this;
159 }
160
161 @Override
162 public String prettyPrint() {
163 StringBuilder result = new StringBuilder();
164 result.append("\"Host\"=" + prettyPrintValue(fHost) + ", ");
165 result.append("\"App\"=" + prettyPrintValue(fApp) + ", ");
166 result.append("\"Req\"=" + prettyPrintValue(fReq));
167 return result.toString();
168 }
169
170 @Override
171 public int hashCode() {
172 return Objects.hash(fHost, fApp, fReq);
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 ResourceRequirement.Match)) {
183 ResourceRequirement.Match other = (ResourceRequirement.Match) obj;
184 return Objects.equals(fHost, other.fHost) && Objects.equals(fApp, other.fApp) && Objects.equals(fReq, other.fReq);
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 ResourceRequirement specification() {
197 return ResourceRequirement.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 ResourceRequirement.Match newEmptyMatch() {
208 return new Mutable(null, 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 pHost the fixed value of pattern parameter Host, or null if not bound.
216 * @param pApp the fixed value of pattern parameter App, or null if not bound.
217 * @param pReq the fixed value of pattern parameter Req, or null if not bound.
218 * @return the new, mutable (partial) match object.
219 *
220 */
221 public static ResourceRequirement.Match newMutableMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
222 return new Mutable(pHost, pApp, pReq);
223 }
224
225 /**
226 * Returns a new (partial) match.
227 * This can be used e.g. to call the matcher with a partial match.
228 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
229 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
230 * @param pApp the fixed value of pattern parameter App, or null if not bound.
231 * @param pReq the fixed value of pattern parameter Req, or null if not bound.
232 * @return the (partial) match object.
233 *
234 */
235 public static ResourceRequirement.Match newMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
236 return new Immutable(pHost, pApp, pReq);
237 }
238
239 private static final class Mutable extends ResourceRequirement.Match {
240 Mutable(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
241 super(pHost, pApp, pReq);
242 }
243
244 @Override
245 public boolean isMutable() {
246 return true;
247 }
248 }
249
250 private static final class Immutable extends ResourceRequirement.Match {
251 Immutable(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
252 super(pHost, pApp, pReq);
253 }
254
255 @Override
256 public boolean isMutable() {
257 return false;
258 }
259 }
260 }
261
262 /**
263 * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement pattern,
264 * providing pattern-specific query methods.
265 *
266 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
267 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
268 *
269 * <p>Matches of the pattern will be represented as {@link Match}.
270 *
271 * <p>Original source:
272 * <code><pre>
273 * pattern resourceRequirement(Host : HostInstance, App : ApplicationInstance, Req : ResourceRequirement) {
274 * ApplicationInstance.allocatedTo(App, Host);
275 * ApplicationInstance.type.requirements(App, Req);
276 * HostInstance.type(Host, HostType);
277 * ResourceRequirement.hostType(Req, HostType);
278 * }
279 * </pre></code>
280 *
281 * @see Match
282 * @see ResourceRequirement
283 *
284 */
285 public static class Matcher extends BaseMatcher<ResourceRequirement.Match> {
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 public static ResourceRequirement.Matcher on(final ViatraQueryEngine engine) {
295 // check if matcher already exists
296 Matcher matcher = engine.getExistingMatcher(querySpecification());
297 if (matcher == null) {
298 matcher = (Matcher)engine.getMatcher(querySpecification());
299 }
300 return matcher;
301 }
302
303 /**
304 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
305 * @return an initialized matcher
306 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
307 *
308 */
309 public static ResourceRequirement.Matcher create() {
310 return new Matcher();
311 }
312
313 private static final int POSITION_HOST = 0;
314
315 private static final int POSITION_APP = 1;
316
317 private static final int POSITION_REQ = 2;
318
319 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ResourceRequirement.Matcher.class);
320
321 /**
322 * Initializes the pattern matcher within an existing VIATRA Query engine.
323 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
324 *
325 * @param engine the existing VIATRA Query engine in which this matcher will be created.
326 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
327 *
328 */
329 private Matcher() {
330 super(querySpecification());
331 }
332
333 /**
334 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
335 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
336 * @param pApp the fixed value of pattern parameter App, or null if not bound.
337 * @param pReq the fixed value of pattern parameter Req, or null if not bound.
338 * @return matches represented as a Match object.
339 *
340 */
341 public Collection<ResourceRequirement.Match> getAllMatches(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
342 return rawStreamAllMatches(new Object[]{pHost, pApp, pReq}).collect(Collectors.toSet());
343 }
344
345 /**
346 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
347 * </p>
348 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
349 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
350 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
351 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
352 * @param pApp the fixed value of pattern parameter App, or null if not bound.
353 * @param pReq the fixed value of pattern parameter Req, or null if not bound.
354 * @return a stream of matches represented as a Match object.
355 *
356 */
357 public Stream<ResourceRequirement.Match> streamAllMatches(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
358 return rawStreamAllMatches(new Object[]{pHost, pApp, pReq});
359 }
360
361 /**
362 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
363 * Neither determinism nor randomness of selection is guaranteed.
364 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
365 * @param pApp the fixed value of pattern parameter App, or null if not bound.
366 * @param pReq the fixed value of pattern parameter Req, or null if not bound.
367 * @return a match represented as a Match object, or null if no match is found.
368 *
369 */
370 public Optional<ResourceRequirement.Match> getOneArbitraryMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
371 return rawGetOneArbitraryMatch(new Object[]{pHost, pApp, pReq});
372 }
373
374 /**
375 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
376 * under any possible substitution of the unspecified parameters (if any).
377 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
378 * @param pApp the fixed value of pattern parameter App, or null if not bound.
379 * @param pReq the fixed value of pattern parameter Req, or null if not bound.
380 * @return true if the input is a valid (partial) match of the pattern.
381 *
382 */
383 public boolean hasMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
384 return rawHasMatch(new Object[]{pHost, pApp, pReq});
385 }
386
387 /**
388 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
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 the number of pattern matches found.
393 *
394 */
395 public int countMatches(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
396 return rawCountMatches(new Object[]{pHost, pApp, pReq});
397 }
398
399 /**
400 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
401 * Neither determinism nor randomness of selection is guaranteed.
402 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
403 * @param pApp the fixed value of pattern parameter App, or null if not bound.
404 * @param pReq the fixed value of pattern parameter Req, or null if not bound.
405 * @param processor the action that will process the selected match.
406 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
407 *
408 */
409 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) {
410 return rawForOneArbitraryMatch(new Object[]{pHost, pApp, pReq}, processor);
411 }
412
413 /**
414 * Returns a new (partial) match.
415 * This can be used e.g. to call the matcher with a partial match.
416 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
417 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
418 * @param pApp the fixed value of pattern parameter App, or null if not bound.
419 * @param pReq the fixed value of pattern parameter Req, or null if not bound.
420 * @return the (partial) match object.
421 *
422 */
423 public ResourceRequirement.Match newMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
424 return ResourceRequirement.Match.newMatch(pHost, pApp, pReq);
425 }
426
427 /**
428 * Retrieve the set of values that occur in matches for Host.
429 * @return the Set of all values or empty set if there are no matches
430 *
431 */
432 protected Stream<HostInstance> rawStreamAllValuesOfHost(final Object[] parameters) {
433 return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast);
434 }
435
436 /**
437 * Retrieve the set of values that occur in matches for Host.
438 * @return the Set of all values or empty set if there are no matches
439 *
440 */
441 public Set<HostInstance> getAllValuesOfHost() {
442 return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet());
443 }
444
445 /**
446 * Retrieve the set of values that occur in matches for Host.
447 * @return the Set of all values or empty set if there are no matches
448 *
449 */
450 public Stream<HostInstance> streamAllValuesOfHost() {
451 return rawStreamAllValuesOfHost(emptyArray());
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 ResourceRequirement.Match partialMatch) {
465 return rawStreamAllValuesOfHost(partialMatch.toArray());
466 }
467
468 /**
469 * Retrieve the set of values that occur in matches for Host.
470 * </p>
471 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
472 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
473 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
474 *
475 * @return the Stream of all values or empty set if there are no matches
476 *
477 */
478 public Stream<HostInstance> streamAllValuesOfHost(final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
479 return rawStreamAllValuesOfHost(new Object[]{null, pApp, pReq});
480 }
481
482 /**
483 * Retrieve the set of values that occur in matches for Host.
484 * @return the Set of all values or empty set if there are no matches
485 *
486 */
487 public Set<HostInstance> getAllValuesOfHost(final ResourceRequirement.Match partialMatch) {
488 return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet());
489 }
490
491 /**
492 * Retrieve the set of values that occur in matches for Host.
493 * @return the Set of all values or empty set if there are no matches
494 *
495 */
496 public Set<HostInstance> getAllValuesOfHost(final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
497 return rawStreamAllValuesOfHost(new Object[]{null, pApp, pReq}).collect(Collectors.toSet());
498 }
499
500 /**
501 * Retrieve the set of values that occur in matches for App.
502 * @return the Set of all values or empty set if there are no matches
503 *
504 */
505 protected Stream<ApplicationInstance> rawStreamAllValuesOfApp(final Object[] parameters) {
506 return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast);
507 }
508
509 /**
510 * Retrieve the set of values that occur in matches for App.
511 * @return the Set of all values or empty set if there are no matches
512 *
513 */
514 public Set<ApplicationInstance> getAllValuesOfApp() {
515 return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet());
516 }
517
518 /**
519 * Retrieve the set of values that occur in matches for App.
520 * @return the Set of all values or empty set if there are no matches
521 *
522 */
523 public Stream<ApplicationInstance> streamAllValuesOfApp() {
524 return rawStreamAllValuesOfApp(emptyArray());
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 ResourceRequirement.Match partialMatch) {
538 return rawStreamAllValuesOfApp(partialMatch.toArray());
539 }
540
541 /**
542 * Retrieve the set of values that occur in matches for App.
543 * </p>
544 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
545 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
546 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
547 *
548 * @return the Stream of all values or empty set if there are no matches
549 *
550 */
551 public Stream<ApplicationInstance> streamAllValuesOfApp(final HostInstance pHost, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
552 return rawStreamAllValuesOfApp(new Object[]{pHost, null, pReq});
553 }
554
555 /**
556 * Retrieve the set of values that occur in matches for App.
557 * @return the Set of all values or empty set if there are no matches
558 *
559 */
560 public Set<ApplicationInstance> getAllValuesOfApp(final ResourceRequirement.Match partialMatch) {
561 return rawStreamAllValuesOfApp(partialMatch.toArray()).collect(Collectors.toSet());
562 }
563
564 /**
565 * Retrieve the set of values that occur in matches for App.
566 * @return the Set of all values or empty set if there are no matches
567 *
568 */
569 public Set<ApplicationInstance> getAllValuesOfApp(final HostInstance pHost, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) {
570 return rawStreamAllValuesOfApp(new Object[]{pHost, null, pReq}).collect(Collectors.toSet());
571 }
572
573 /**
574 * Retrieve the set of values that occur in matches for Req.
575 * @return the Set of all values or empty set if there are no matches
576 *
577 */
578 protected Stream<hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement> rawStreamAllValuesOfReq(final Object[] parameters) {
579 return rawStreamAllValues(POSITION_REQ, parameters).map(hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement.class::cast);
580 }
581
582 /**
583 * Retrieve the set of values that occur in matches for Req.
584 * @return the Set of all values or empty set if there are no matches
585 *
586 */
587 public Set<hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement> getAllValuesOfReq() {
588 return rawStreamAllValuesOfReq(emptyArray()).collect(Collectors.toSet());
589 }
590
591 /**
592 * Retrieve the set of values that occur in matches for Req.
593 * @return the Set of all values or empty set if there are no matches
594 *
595 */
596 public Stream<hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement> streamAllValuesOfReq() {
597 return rawStreamAllValuesOfReq(emptyArray());
598 }
599
600 /**
601 * Retrieve the set of values that occur in matches for Req.
602 * </p>
603 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
604 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
605 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
606 *
607 * @return the Stream of all values or empty set if there are no matches
608 *
609 */
610 public Stream<hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement> streamAllValuesOfReq(final ResourceRequirement.Match partialMatch) {
611 return rawStreamAllValuesOfReq(partialMatch.toArray());
612 }
613
614 /**
615 * Retrieve the set of values that occur in matches for Req.
616 * </p>
617 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
618 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
619 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
620 *
621 * @return the Stream of all values or empty set if there are no matches
622 *
623 */
624 public Stream<hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement> streamAllValuesOfReq(final HostInstance pHost, final ApplicationInstance pApp) {
625 return rawStreamAllValuesOfReq(new Object[]{pHost, pApp, null});
626 }
627
628 /**
629 * Retrieve the set of values that occur in matches for Req.
630 * @return the Set of all values or empty set if there are no matches
631 *
632 */
633 public Set<hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement> getAllValuesOfReq(final ResourceRequirement.Match partialMatch) {
634 return rawStreamAllValuesOfReq(partialMatch.toArray()).collect(Collectors.toSet());
635 }
636
637 /**
638 * Retrieve the set of values that occur in matches for Req.
639 * @return the Set of all values or empty set if there are no matches
640 *
641 */
642 public Set<hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement> getAllValuesOfReq(final HostInstance pHost, final ApplicationInstance pApp) {
643 return rawStreamAllValuesOfReq(new Object[]{pHost, pApp, null}).collect(Collectors.toSet());
644 }
645
646 @Override
647 protected ResourceRequirement.Match tupleToMatch(final Tuple t) {
648 try {
649 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));
650 } catch(ClassCastException e) {
651 LOGGER.error("Element(s) in tuple not properly typed!",e);
652 return null;
653 }
654 }
655
656 @Override
657 protected ResourceRequirement.Match arrayToMatch(final Object[] match) {
658 try {
659 return ResourceRequirement.Match.newMatch((HostInstance) match[POSITION_HOST], (ApplicationInstance) match[POSITION_APP], (hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement) match[POSITION_REQ]);
660 } catch(ClassCastException e) {
661 LOGGER.error("Element(s) in array not properly typed!",e);
662 return null;
663 }
664 }
665
666 @Override
667 protected ResourceRequirement.Match arrayToMatchMutable(final Object[] match) {
668 try {
669 return ResourceRequirement.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (ApplicationInstance) match[POSITION_APP], (hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement) match[POSITION_REQ]);
670 } catch(ClassCastException e) {
671 LOGGER.error("Element(s) in array not properly typed!",e);
672 return null;
673 }
674 }
675
676 /**
677 * @return the singleton instance of the query specification of this pattern
678 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
679 *
680 */
681 public static IQuerySpecification<ResourceRequirement.Matcher> querySpecification() {
682 return ResourceRequirement.instance();
683 }
684 }
685
686 private ResourceRequirement() {
687 super(GeneratedPQuery.INSTANCE);
688 }
689
690 /**
691 * @return the singleton instance of the query specification
692 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
693 *
694 */
695 public static ResourceRequirement instance() {
696 try{
697 return LazyHolder.INSTANCE;
698 } catch (ExceptionInInitializerError err) {
699 throw processInitializerError(err);
700 }
701 }
702
703 @Override
704 protected ResourceRequirement.Matcher instantiate(final ViatraQueryEngine engine) {
705 return ResourceRequirement.Matcher.on(engine);
706 }
707
708 @Override
709 public ResourceRequirement.Matcher instantiate() {
710 return ResourceRequirement.Matcher.create();
711 }
712
713 @Override
714 public ResourceRequirement.Match newEmptyMatch() {
715 return ResourceRequirement.Match.newEmptyMatch();
716 }
717
718 @Override
719 public ResourceRequirement.Match newMatch(final Object... parameters) {
720 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]);
721 }
722
723 /**
724 * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement (visibility: PUBLIC, simpleName: ResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
725 * <b>not</b> at the class load time of the outer class,
726 * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement (visibility: PUBLIC, simpleName: ResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
727 *
728 * <p> This workaround is required e.g. to support recursion.
729 *
730 */
731 private static class LazyHolder {
732 private static final ResourceRequirement INSTANCE = new ResourceRequirement();
733
734 /**
735 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
736 * This initialization order is required to support indirect recursion.
737 *
738 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
739 *
740 */
741 private static final Object STATIC_INITIALIZER = ensureInitialized();
742
743 public static Object ensureInitialized() {
744 INSTANCE.ensureInitializedInternal();
745 return null;
746 }
747 }
748
749 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
750 private static final ResourceRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery();
751
752 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);
753
754 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);
755
756 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);
757
758 private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_App, parameter_Req);
759
760 private GeneratedPQuery() {
761 super(PVisibility.PUBLIC);
762 }
763
764 @Override
765 public String getFullyQualifiedName() {
766 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement";
767 }
768
769 @Override
770 public List<String> getParameterNames() {
771 return Arrays.asList("Host","App","Req");
772 }
773
774 @Override
775 public List<PParameter> getParameters() {
776 return parameters;
777 }
778
779 @Override
780 public Set<PBody> doGetContainedBodies() {
781 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
782 Set<PBody> bodies = new LinkedHashSet<>();
783 {
784 PBody body = new PBody(this);
785 PVariable var_Host = body.getOrCreateVariableByName("Host");
786 PVariable var_App = body.getOrCreateVariableByName("App");
787 PVariable var_Req = body.getOrCreateVariableByName("Req");
788 PVariable var_HostType = body.getOrCreateVariableByName("HostType");
789 new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
790 new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
791 new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
792 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
793 new ExportedParameter(body, var_Host, parameter_Host),
794 new ExportedParameter(body, var_App, parameter_App),
795 new ExportedParameter(body, var_Req, parameter_Req)
796 ));
797 // ApplicationInstance.allocatedTo(App, Host)
798 new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
799 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
800 new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo")));
801 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
802 new Equality(body, var__virtual_0_, var_Host);
803 // ApplicationInstance.type.requirements(App, Req)
804 new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
805 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
806 new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type")));
807 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType")));
808 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
809 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "requirements")));
810 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
811 new Equality(body, var__virtual_2_, var_Req);
812 // HostInstance.type(Host, HostType)
813 new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
814 PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}");
815 new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type")));
816 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType")));
817 new Equality(body, var__virtual_3_, var_HostType);
818 // ResourceRequirement.hostType(Req, HostType)
819 new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
820 PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}");
821 new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "hostType")));
822 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType")));
823 new Equality(body, var__virtual_4_, var_HostType);
824 bodies.add(body);
825 }
826 return bodies;
827 }
828 }
829}
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java
deleted file mode 100644
index f91853de..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java
+++ /dev/null
@@ -1,706 +0,0 @@
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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance;
7import java.util.Arrays;
8import java.util.Collection;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Objects;
12import java.util.Optional;
13import java.util.Set;
14import java.util.function.Consumer;
15import java.util.stream.Collectors;
16import java.util.stream.Stream;
17import org.apache.log4j.Logger;
18import org.eclipse.emf.ecore.EClass;
19import org.eclipse.emf.ecore.EDataType;
20import org.eclipse.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
29import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
30import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
31import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
32import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
33import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
38import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
40import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
41import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
42import 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 @}QueryBasedFeature(feature = "totalHdd")
50 * pattern totalHdd(Host : HostInstance, Hdd : EInt) {
51 * HostInstance.type.defaultHdd(Host, Hdd);
52 * }
53 * </pre></code>
54 *
55 * @see Matcher
56 * @see Match
57 *
58 */
59@SuppressWarnings("all")
60public final class TotalHdd extends BaseGeneratedEMFQuerySpecification<TotalHdd.Matcher> {
61 /**
62 * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd 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 Integer fHdd;
77
78 private static List<String> parameterNames = makeImmutableList("Host", "Hdd");
79
80 private Match(final HostInstance pHost, final Integer pHdd) {
81 this.fHost = pHost;
82 this.fHdd = pHdd;
83 }
84
85 @Override
86 public Object get(final String parameterName) {
87 if ("Host".equals(parameterName)) return this.fHost;
88 if ("Hdd".equals(parameterName)) return this.fHdd;
89 return null;
90 }
91
92 public HostInstance getHost() {
93 return this.fHost;
94 }
95
96 public Integer getHdd() {
97 return this.fHdd;
98 }
99
100 @Override
101 public boolean set(final String parameterName, final Object newValue) {
102 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
103 if ("Host".equals(parameterName) ) {
104 this.fHost = (HostInstance) newValue;
105 return true;
106 }
107 if ("Hdd".equals(parameterName) ) {
108 this.fHdd = (Integer) newValue;
109 return true;
110 }
111 return false;
112 }
113
114 public void setHost(final HostInstance pHost) {
115 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
116 this.fHost = pHost;
117 }
118
119 public void setHdd(final Integer pHdd) {
120 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
121 this.fHdd = pHdd;
122 }
123
124 @Override
125 public String patternName() {
126 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd";
127 }
128
129 @Override
130 public List<String> parameterNames() {
131 return TotalHdd.Match.parameterNames;
132 }
133
134 @Override
135 public Object[] toArray() {
136 return new Object[]{fHost, fHdd};
137 }
138
139 @Override
140 public TotalHdd.Match toImmutable() {
141 return isMutable() ? newMatch(fHost, fHdd) : this;
142 }
143
144 @Override
145 public String prettyPrint() {
146 StringBuilder result = new StringBuilder();
147 result.append("\"Host\"=" + prettyPrintValue(fHost) + ", ");
148 result.append("\"Hdd\"=" + prettyPrintValue(fHdd));
149 return result.toString();
150 }
151
152 @Override
153 public int hashCode() {
154 return Objects.hash(fHost, fHdd);
155 }
156
157 @Override
158 public boolean equals(final Object obj) {
159 if (this == obj)
160 return true;
161 if (obj == null) {
162 return false;
163 }
164 if ((obj instanceof TotalHdd.Match)) {
165 TotalHdd.Match other = (TotalHdd.Match) obj;
166 return Objects.equals(fHost, other.fHost) && Objects.equals(fHdd, other.fHdd);
167 } else {
168 // this should be infrequent
169 if (!(obj instanceof IPatternMatch)) {
170 return false;
171 }
172 IPatternMatch otherSig = (IPatternMatch) obj;
173 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
174 }
175 }
176
177 @Override
178 public TotalHdd specification() {
179 return TotalHdd.instance();
180 }
181
182 /**
183 * Returns an empty, mutable match.
184 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
185 *
186 * @return the empty match.
187 *
188 */
189 public static TotalHdd.Match newEmptyMatch() {
190 return new Mutable(null, null);
191 }
192
193 /**
194 * Returns a mutable (partial) match.
195 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
196 *
197 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
198 * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound.
199 * @return the new, mutable (partial) match object.
200 *
201 */
202 public static TotalHdd.Match newMutableMatch(final HostInstance pHost, final Integer pHdd) {
203 return new Mutable(pHost, pHdd);
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 pHost the fixed value of pattern parameter Host, or null if not bound.
211 * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound.
212 * @return the (partial) match object.
213 *
214 */
215 public static TotalHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) {
216 return new Immutable(pHost, pHdd);
217 }
218
219 private static final class Mutable extends TotalHdd.Match {
220 Mutable(final HostInstance pHost, final Integer pHdd) {
221 super(pHost, pHdd);
222 }
223
224 @Override
225 public boolean isMutable() {
226 return true;
227 }
228 }
229
230 private static final class Immutable extends TotalHdd.Match {
231 Immutable(final HostInstance pHost, final Integer pHdd) {
232 super(pHost, pHdd);
233 }
234
235 @Override
236 public boolean isMutable() {
237 return false;
238 }
239 }
240 }
241
242 /**
243 * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd pattern,
244 * providing pattern-specific query methods.
245 *
246 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
247 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
248 *
249 * <p>Matches of the pattern will be represented as {@link Match}.
250 *
251 * <p>Original source:
252 * <code><pre>
253 * {@literal @}QueryBasedFeature(feature = "totalHdd")
254 * pattern totalHdd(Host : HostInstance, Hdd : EInt) {
255 * HostInstance.type.defaultHdd(Host, Hdd);
256 * }
257 * </pre></code>
258 *
259 * @see Match
260 * @see TotalHdd
261 *
262 */
263 public static class Matcher extends BaseMatcher<TotalHdd.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 TotalHdd.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 TotalHdd.Matcher create() {
288 return new Matcher();
289 }
290
291 private static final int POSITION_HOST = 0;
292
293 private static final int POSITION_HDD = 1;
294
295 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TotalHdd.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 pHost the fixed value of pattern parameter Host, or null if not bound.
312 * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound.
313 * @return matches represented as a Match object.
314 *
315 */
316 public Collection<TotalHdd.Match> getAllMatches(final HostInstance pHost, final Integer pHdd) {
317 return rawStreamAllMatches(new Object[]{pHost, pHdd}).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 pHost the fixed value of pattern parameter Host, or null if not bound.
327 * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound.
328 * @return a stream of matches represented as a Match object.
329 *
330 */
331 public Stream<TotalHdd.Match> streamAllMatches(final HostInstance pHost, final Integer pHdd) {
332 return rawStreamAllMatches(new Object[]{pHost, pHdd});
333 }
334
335 /**
336 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
337 * Neither determinism nor randomness of selection is guaranteed.
338 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
339 * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound.
340 * @return a match represented as a Match object, or null if no match is found.
341 *
342 */
343 public Optional<TotalHdd.Match> getOneArbitraryMatch(final HostInstance pHost, final Integer pHdd) {
344 return rawGetOneArbitraryMatch(new Object[]{pHost, pHdd});
345 }
346
347 /**
348 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
349 * under any possible substitution of the unspecified parameters (if any).
350 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
351 * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound.
352 * @return true if the input is a valid (partial) match of the pattern.
353 *
354 */
355 public boolean hasMatch(final HostInstance pHost, final Integer pHdd) {
356 return rawHasMatch(new Object[]{pHost, pHdd});
357 }
358
359 /**
360 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
361 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
362 * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound.
363 * @return the number of pattern matches found.
364 *
365 */
366 public int countMatches(final HostInstance pHost, final Integer pHdd) {
367 return rawCountMatches(new Object[]{pHost, pHdd});
368 }
369
370 /**
371 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
372 * Neither determinism nor randomness of selection is guaranteed.
373 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
374 * @param pHdd the fixed value of pattern parameter Hdd, 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 HostInstance pHost, final Integer pHdd, final Consumer<? super TotalHdd.Match> processor) {
380 return rawForOneArbitraryMatch(new Object[]{pHost, pHdd}, 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 pHost the fixed value of pattern parameter Host, or null if not bound.
388 * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound.
389 * @return the (partial) match object.
390 *
391 */
392 public TotalHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) {
393 return TotalHdd.Match.newMatch(pHost, pHdd);
394 }
395
396 /**
397 * Retrieve the set of values that occur in matches for Host.
398 * @return the Set of all values or empty set if there are no matches
399 *
400 */
401 protected Stream<HostInstance> rawStreamAllValuesOfHost(final Object[] parameters) {
402 return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast);
403 }
404
405 /**
406 * Retrieve the set of values that occur in matches for Host.
407 * @return the Set of all values or empty set if there are no matches
408 *
409 */
410 public Set<HostInstance> getAllValuesOfHost() {
411 return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet());
412 }
413
414 /**
415 * Retrieve the set of values that occur in matches for Host.
416 * @return the Set of all values or empty set if there are no matches
417 *
418 */
419 public Stream<HostInstance> streamAllValuesOfHost() {
420 return rawStreamAllValuesOfHost(emptyArray());
421 }
422
423 /**
424 * Retrieve the set of values that occur in matches for Host.
425 * </p>
426 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
427 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
428 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
429 *
430 * @return the Stream of all values or empty set if there are no matches
431 *
432 */
433 public Stream<HostInstance> streamAllValuesOfHost(final TotalHdd.Match partialMatch) {
434 return rawStreamAllValuesOfHost(partialMatch.toArray());
435 }
436
437 /**
438 * Retrieve the set of values that occur in matches for Host.
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<HostInstance> streamAllValuesOfHost(final Integer pHdd) {
448 return rawStreamAllValuesOfHost(new Object[]{null, pHdd});
449 }
450
451 /**
452 * Retrieve the set of values that occur in matches for Host.
453 * @return the Set of all values or empty set if there are no matches
454 *
455 */
456 public Set<HostInstance> getAllValuesOfHost(final TotalHdd.Match partialMatch) {
457 return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet());
458 }
459
460 /**
461 * Retrieve the set of values that occur in matches for Host.
462 * @return the Set of all values or empty set if there are no matches
463 *
464 */
465 public Set<HostInstance> getAllValuesOfHost(final Integer pHdd) {
466 return rawStreamAllValuesOfHost(new Object[]{null, pHdd}).collect(Collectors.toSet());
467 }
468
469 /**
470 * Retrieve the set of values that occur in matches for Hdd.
471 * @return the Set of all values or empty set if there are no matches
472 *
473 */
474 protected Stream<Integer> rawStreamAllValuesOfHdd(final Object[] parameters) {
475 return rawStreamAllValues(POSITION_HDD, parameters).map(Integer.class::cast);
476 }
477
478 /**
479 * Retrieve the set of values that occur in matches for Hdd.
480 * @return the Set of all values or empty set if there are no matches
481 *
482 */
483 public Set<Integer> getAllValuesOfHdd() {
484 return rawStreamAllValuesOfHdd(emptyArray()).collect(Collectors.toSet());
485 }
486
487 /**
488 * Retrieve the set of values that occur in matches for Hdd.
489 * @return the Set of all values or empty set if there are no matches
490 *
491 */
492 public Stream<Integer> streamAllValuesOfHdd() {
493 return rawStreamAllValuesOfHdd(emptyArray());
494 }
495
496 /**
497 * Retrieve the set of values that occur in matches for Hdd.
498 * </p>
499 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
500 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
501 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
502 *
503 * @return the Stream of all values or empty set if there are no matches
504 *
505 */
506 public Stream<Integer> streamAllValuesOfHdd(final TotalHdd.Match partialMatch) {
507 return rawStreamAllValuesOfHdd(partialMatch.toArray());
508 }
509
510 /**
511 * Retrieve the set of values that occur in matches for Hdd.
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<Integer> streamAllValuesOfHdd(final HostInstance pHost) {
521 return rawStreamAllValuesOfHdd(new Object[]{pHost, null});
522 }
523
524 /**
525 * Retrieve the set of values that occur in matches for Hdd.
526 * @return the Set of all values or empty set if there are no matches
527 *
528 */
529 public Set<Integer> getAllValuesOfHdd(final TotalHdd.Match partialMatch) {
530 return rawStreamAllValuesOfHdd(partialMatch.toArray()).collect(Collectors.toSet());
531 }
532
533 /**
534 * Retrieve the set of values that occur in matches for Hdd.
535 * @return the Set of all values or empty set if there are no matches
536 *
537 */
538 public Set<Integer> getAllValuesOfHdd(final HostInstance pHost) {
539 return rawStreamAllValuesOfHdd(new Object[]{pHost, null}).collect(Collectors.toSet());
540 }
541
542 @Override
543 protected TotalHdd.Match tupleToMatch(final Tuple t) {
544 try {
545 return TotalHdd.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_HDD));
546 } catch(ClassCastException e) {
547 LOGGER.error("Element(s) in tuple not properly typed!",e);
548 return null;
549 }
550 }
551
552 @Override
553 protected TotalHdd.Match arrayToMatch(final Object[] match) {
554 try {
555 return TotalHdd.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]);
556 } catch(ClassCastException e) {
557 LOGGER.error("Element(s) in array not properly typed!",e);
558 return null;
559 }
560 }
561
562 @Override
563 protected TotalHdd.Match arrayToMatchMutable(final Object[] match) {
564 try {
565 return TotalHdd.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]);
566 } catch(ClassCastException e) {
567 LOGGER.error("Element(s) in array not properly typed!",e);
568 return null;
569 }
570 }
571
572 /**
573 * @return the singleton instance of the query specification of this pattern
574 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
575 *
576 */
577 public static IQuerySpecification<TotalHdd.Matcher> querySpecification() {
578 return TotalHdd.instance();
579 }
580 }
581
582 private TotalHdd() {
583 super(GeneratedPQuery.INSTANCE);
584 }
585
586 /**
587 * @return the singleton instance of the query specification
588 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
589 *
590 */
591 public static TotalHdd instance() {
592 try{
593 return LazyHolder.INSTANCE;
594 } catch (ExceptionInInitializerError err) {
595 throw processInitializerError(err);
596 }
597 }
598
599 @Override
600 protected TotalHdd.Matcher instantiate(final ViatraQueryEngine engine) {
601 return TotalHdd.Matcher.on(engine);
602 }
603
604 @Override
605 public TotalHdd.Matcher instantiate() {
606 return TotalHdd.Matcher.create();
607 }
608
609 @Override
610 public TotalHdd.Match newEmptyMatch() {
611 return TotalHdd.Match.newEmptyMatch();
612 }
613
614 @Override
615 public TotalHdd.Match newMatch(final Object... parameters) {
616 return TotalHdd.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]);
617 }
618
619 /**
620 * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd (visibility: PUBLIC, simpleName: TotalHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
621 * <b>not</b> at the class load time of the outer class,
622 * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd (visibility: PUBLIC, simpleName: TotalHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
623 *
624 * <p> This workaround is required e.g. to support recursion.
625 *
626 */
627 private static class LazyHolder {
628 private static final TotalHdd INSTANCE = new TotalHdd();
629
630 /**
631 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
632 * This initialization order is required to support indirect recursion.
633 *
634 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
635 *
636 */
637 private static final Object STATIC_INITIALIZER = ensureInitialized();
638
639 public static Object ensureInitialized() {
640 INSTANCE.ensureInitializedInternal();
641 return null;
642 }
643 }
644
645 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
646 private static final TotalHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery();
647
648 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);
649
650 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);
651
652 private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_Hdd);
653
654 private GeneratedPQuery() {
655 super(PVisibility.PUBLIC);
656 }
657
658 @Override
659 public String getFullyQualifiedName() {
660 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd";
661 }
662
663 @Override
664 public List<String> getParameterNames() {
665 return Arrays.asList("Host","Hdd");
666 }
667
668 @Override
669 public List<PParameter> getParameters() {
670 return parameters;
671 }
672
673 @Override
674 public Set<PBody> doGetContainedBodies() {
675 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
676 Set<PBody> bodies = new LinkedHashSet<>();
677 {
678 PBody body = new PBody(this);
679 PVariable var_Host = body.getOrCreateVariableByName("Host");
680 PVariable var_Hdd = body.getOrCreateVariableByName("Hdd");
681 new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
682 new TypeConstraint(body, Tuples.flatTupleOf(var_Hdd), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt")));
683 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
684 new ExportedParameter(body, var_Host, parameter_Host),
685 new ExportedParameter(body, var_Hdd, parameter_Hdd)
686 ));
687 // HostInstance.type.defaultHdd(Host, Hdd)
688 new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
689 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
690 new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type")));
691 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType")));
692 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
693 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "defaultHdd")));
694 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt")));
695 new Equality(body, var__virtual_1_, var_Hdd);
696 bodies.add(body);
697 }
698 {
699 PAnnotation annotation = new PAnnotation("QueryBasedFeature");
700 annotation.addAttribute("feature", "totalHdd");
701 addAnnotation(annotation);
702 }
703 return bodies;
704 }
705 }
706}
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java
deleted file mode 100644
index e8a11e36..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java
+++ /dev/null
@@ -1,706 +0,0 @@
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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance;
7import java.util.Arrays;
8import java.util.Collection;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Objects;
12import java.util.Optional;
13import java.util.Set;
14import java.util.function.Consumer;
15import java.util.stream.Collectors;
16import java.util.stream.Stream;
17import org.apache.log4j.Logger;
18import org.eclipse.emf.ecore.EClass;
19import org.eclipse.emf.ecore.EDataType;
20import org.eclipse.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
29import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
30import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
31import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
32import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
33import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
38import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
40import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
41import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
42import 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 @}QueryBasedFeature(feature = "totalMemory")
50 * pattern totalMemory(Host : HostInstance, Memory : EInt) {
51 * HostInstance.type.defaultMemory(Host, Memory);
52 * }
53 * </pre></code>
54 *
55 * @see Matcher
56 * @see Match
57 *
58 */
59@SuppressWarnings("all")
60public final class TotalMemory extends BaseGeneratedEMFQuerySpecification<TotalMemory.Matcher> {
61 /**
62 * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory 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 Integer fMemory;
77
78 private static List<String> parameterNames = makeImmutableList("Host", "Memory");
79
80 private Match(final HostInstance pHost, final Integer pMemory) {
81 this.fHost = pHost;
82 this.fMemory = pMemory;
83 }
84
85 @Override
86 public Object get(final String parameterName) {
87 if ("Host".equals(parameterName)) return this.fHost;
88 if ("Memory".equals(parameterName)) return this.fMemory;
89 return null;
90 }
91
92 public HostInstance getHost() {
93 return this.fHost;
94 }
95
96 public Integer getMemory() {
97 return this.fMemory;
98 }
99
100 @Override
101 public boolean set(final String parameterName, final Object newValue) {
102 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
103 if ("Host".equals(parameterName) ) {
104 this.fHost = (HostInstance) newValue;
105 return true;
106 }
107 if ("Memory".equals(parameterName) ) {
108 this.fMemory = (Integer) newValue;
109 return true;
110 }
111 return false;
112 }
113
114 public void setHost(final HostInstance pHost) {
115 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
116 this.fHost = pHost;
117 }
118
119 public void setMemory(final Integer pMemory) {
120 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
121 this.fMemory = pMemory;
122 }
123
124 @Override
125 public String patternName() {
126 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory";
127 }
128
129 @Override
130 public List<String> parameterNames() {
131 return TotalMemory.Match.parameterNames;
132 }
133
134 @Override
135 public Object[] toArray() {
136 return new Object[]{fHost, fMemory};
137 }
138
139 @Override
140 public TotalMemory.Match toImmutable() {
141 return isMutable() ? newMatch(fHost, fMemory) : this;
142 }
143
144 @Override
145 public String prettyPrint() {
146 StringBuilder result = new StringBuilder();
147 result.append("\"Host\"=" + prettyPrintValue(fHost) + ", ");
148 result.append("\"Memory\"=" + prettyPrintValue(fMemory));
149 return result.toString();
150 }
151
152 @Override
153 public int hashCode() {
154 return Objects.hash(fHost, fMemory);
155 }
156
157 @Override
158 public boolean equals(final Object obj) {
159 if (this == obj)
160 return true;
161 if (obj == null) {
162 return false;
163 }
164 if ((obj instanceof TotalMemory.Match)) {
165 TotalMemory.Match other = (TotalMemory.Match) obj;
166 return Objects.equals(fHost, other.fHost) && Objects.equals(fMemory, other.fMemory);
167 } else {
168 // this should be infrequent
169 if (!(obj instanceof IPatternMatch)) {
170 return false;
171 }
172 IPatternMatch otherSig = (IPatternMatch) obj;
173 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
174 }
175 }
176
177 @Override
178 public TotalMemory specification() {
179 return TotalMemory.instance();
180 }
181
182 /**
183 * Returns an empty, mutable match.
184 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
185 *
186 * @return the empty match.
187 *
188 */
189 public static TotalMemory.Match newEmptyMatch() {
190 return new Mutable(null, null);
191 }
192
193 /**
194 * Returns a mutable (partial) match.
195 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
196 *
197 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
198 * @param pMemory the fixed value of pattern parameter Memory, or null if not bound.
199 * @return the new, mutable (partial) match object.
200 *
201 */
202 public static TotalMemory.Match newMutableMatch(final HostInstance pHost, final Integer pMemory) {
203 return new Mutable(pHost, pMemory);
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 pHost the fixed value of pattern parameter Host, or null if not bound.
211 * @param pMemory the fixed value of pattern parameter Memory, or null if not bound.
212 * @return the (partial) match object.
213 *
214 */
215 public static TotalMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) {
216 return new Immutable(pHost, pMemory);
217 }
218
219 private static final class Mutable extends TotalMemory.Match {
220 Mutable(final HostInstance pHost, final Integer pMemory) {
221 super(pHost, pMemory);
222 }
223
224 @Override
225 public boolean isMutable() {
226 return true;
227 }
228 }
229
230 private static final class Immutable extends TotalMemory.Match {
231 Immutable(final HostInstance pHost, final Integer pMemory) {
232 super(pHost, pMemory);
233 }
234
235 @Override
236 public boolean isMutable() {
237 return false;
238 }
239 }
240 }
241
242 /**
243 * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory pattern,
244 * providing pattern-specific query methods.
245 *
246 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
247 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
248 *
249 * <p>Matches of the pattern will be represented as {@link Match}.
250 *
251 * <p>Original source:
252 * <code><pre>
253 * {@literal @}QueryBasedFeature(feature = "totalMemory")
254 * pattern totalMemory(Host : HostInstance, Memory : EInt) {
255 * HostInstance.type.defaultMemory(Host, Memory);
256 * }
257 * </pre></code>
258 *
259 * @see Match
260 * @see TotalMemory
261 *
262 */
263 public static class Matcher extends BaseMatcher<TotalMemory.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 TotalMemory.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 TotalMemory.Matcher create() {
288 return new Matcher();
289 }
290
291 private static final int POSITION_HOST = 0;
292
293 private static final int POSITION_MEMORY = 1;
294
295 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TotalMemory.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 pHost the fixed value of pattern parameter Host, or null if not bound.
312 * @param pMemory the fixed value of pattern parameter Memory, or null if not bound.
313 * @return matches represented as a Match object.
314 *
315 */
316 public Collection<TotalMemory.Match> getAllMatches(final HostInstance pHost, final Integer pMemory) {
317 return rawStreamAllMatches(new Object[]{pHost, pMemory}).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 pHost the fixed value of pattern parameter Host, or null if not bound.
327 * @param pMemory the fixed value of pattern parameter Memory, or null if not bound.
328 * @return a stream of matches represented as a Match object.
329 *
330 */
331 public Stream<TotalMemory.Match> streamAllMatches(final HostInstance pHost, final Integer pMemory) {
332 return rawStreamAllMatches(new Object[]{pHost, pMemory});
333 }
334
335 /**
336 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
337 * Neither determinism nor randomness of selection is guaranteed.
338 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
339 * @param pMemory the fixed value of pattern parameter Memory, or null if not bound.
340 * @return a match represented as a Match object, or null if no match is found.
341 *
342 */
343 public Optional<TotalMemory.Match> getOneArbitraryMatch(final HostInstance pHost, final Integer pMemory) {
344 return rawGetOneArbitraryMatch(new Object[]{pHost, pMemory});
345 }
346
347 /**
348 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
349 * under any possible substitution of the unspecified parameters (if any).
350 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
351 * @param pMemory the fixed value of pattern parameter Memory, or null if not bound.
352 * @return true if the input is a valid (partial) match of the pattern.
353 *
354 */
355 public boolean hasMatch(final HostInstance pHost, final Integer pMemory) {
356 return rawHasMatch(new Object[]{pHost, pMemory});
357 }
358
359 /**
360 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
361 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
362 * @param pMemory the fixed value of pattern parameter Memory, or null if not bound.
363 * @return the number of pattern matches found.
364 *
365 */
366 public int countMatches(final HostInstance pHost, final Integer pMemory) {
367 return rawCountMatches(new Object[]{pHost, pMemory});
368 }
369
370 /**
371 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
372 * Neither determinism nor randomness of selection is guaranteed.
373 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
374 * @param pMemory the fixed value of pattern parameter Memory, 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 HostInstance pHost, final Integer pMemory, final Consumer<? super TotalMemory.Match> processor) {
380 return rawForOneArbitraryMatch(new Object[]{pHost, pMemory}, 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 pHost the fixed value of pattern parameter Host, or null if not bound.
388 * @param pMemory the fixed value of pattern parameter Memory, or null if not bound.
389 * @return the (partial) match object.
390 *
391 */
392 public TotalMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) {
393 return TotalMemory.Match.newMatch(pHost, pMemory);
394 }
395
396 /**
397 * Retrieve the set of values that occur in matches for Host.
398 * @return the Set of all values or empty set if there are no matches
399 *
400 */
401 protected Stream<HostInstance> rawStreamAllValuesOfHost(final Object[] parameters) {
402 return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast);
403 }
404
405 /**
406 * Retrieve the set of values that occur in matches for Host.
407 * @return the Set of all values or empty set if there are no matches
408 *
409 */
410 public Set<HostInstance> getAllValuesOfHost() {
411 return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet());
412 }
413
414 /**
415 * Retrieve the set of values that occur in matches for Host.
416 * @return the Set of all values or empty set if there are no matches
417 *
418 */
419 public Stream<HostInstance> streamAllValuesOfHost() {
420 return rawStreamAllValuesOfHost(emptyArray());
421 }
422
423 /**
424 * Retrieve the set of values that occur in matches for Host.
425 * </p>
426 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
427 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
428 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
429 *
430 * @return the Stream of all values or empty set if there are no matches
431 *
432 */
433 public Stream<HostInstance> streamAllValuesOfHost(final TotalMemory.Match partialMatch) {
434 return rawStreamAllValuesOfHost(partialMatch.toArray());
435 }
436
437 /**
438 * Retrieve the set of values that occur in matches for Host.
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<HostInstance> streamAllValuesOfHost(final Integer pMemory) {
448 return rawStreamAllValuesOfHost(new Object[]{null, pMemory});
449 }
450
451 /**
452 * Retrieve the set of values that occur in matches for Host.
453 * @return the Set of all values or empty set if there are no matches
454 *
455 */
456 public Set<HostInstance> getAllValuesOfHost(final TotalMemory.Match partialMatch) {
457 return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet());
458 }
459
460 /**
461 * Retrieve the set of values that occur in matches for Host.
462 * @return the Set of all values or empty set if there are no matches
463 *
464 */
465 public Set<HostInstance> getAllValuesOfHost(final Integer pMemory) {
466 return rawStreamAllValuesOfHost(new Object[]{null, pMemory}).collect(Collectors.toSet());
467 }
468
469 /**
470 * Retrieve the set of values that occur in matches for Memory.
471 * @return the Set of all values or empty set if there are no matches
472 *
473 */
474 protected Stream<Integer> rawStreamAllValuesOfMemory(final Object[] parameters) {
475 return rawStreamAllValues(POSITION_MEMORY, parameters).map(Integer.class::cast);
476 }
477
478 /**
479 * Retrieve the set of values that occur in matches for Memory.
480 * @return the Set of all values or empty set if there are no matches
481 *
482 */
483 public Set<Integer> getAllValuesOfMemory() {
484 return rawStreamAllValuesOfMemory(emptyArray()).collect(Collectors.toSet());
485 }
486
487 /**
488 * Retrieve the set of values that occur in matches for Memory.
489 * @return the Set of all values or empty set if there are no matches
490 *
491 */
492 public Stream<Integer> streamAllValuesOfMemory() {
493 return rawStreamAllValuesOfMemory(emptyArray());
494 }
495
496 /**
497 * Retrieve the set of values that occur in matches for Memory.
498 * </p>
499 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
500 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
501 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
502 *
503 * @return the Stream of all values or empty set if there are no matches
504 *
505 */
506 public Stream<Integer> streamAllValuesOfMemory(final TotalMemory.Match partialMatch) {
507 return rawStreamAllValuesOfMemory(partialMatch.toArray());
508 }
509
510 /**
511 * Retrieve the set of values that occur in matches for Memory.
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<Integer> streamAllValuesOfMemory(final HostInstance pHost) {
521 return rawStreamAllValuesOfMemory(new Object[]{pHost, null});
522 }
523
524 /**
525 * Retrieve the set of values that occur in matches for Memory.
526 * @return the Set of all values or empty set if there are no matches
527 *
528 */
529 public Set<Integer> getAllValuesOfMemory(final TotalMemory.Match partialMatch) {
530 return rawStreamAllValuesOfMemory(partialMatch.toArray()).collect(Collectors.toSet());
531 }
532
533 /**
534 * Retrieve the set of values that occur in matches for Memory.
535 * @return the Set of all values or empty set if there are no matches
536 *
537 */
538 public Set<Integer> getAllValuesOfMemory(final HostInstance pHost) {
539 return rawStreamAllValuesOfMemory(new Object[]{pHost, null}).collect(Collectors.toSet());
540 }
541
542 @Override
543 protected TotalMemory.Match tupleToMatch(final Tuple t) {
544 try {
545 return TotalMemory.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_MEMORY));
546 } catch(ClassCastException e) {
547 LOGGER.error("Element(s) in tuple not properly typed!",e);
548 return null;
549 }
550 }
551
552 @Override
553 protected TotalMemory.Match arrayToMatch(final Object[] match) {
554 try {
555 return TotalMemory.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]);
556 } catch(ClassCastException e) {
557 LOGGER.error("Element(s) in array not properly typed!",e);
558 return null;
559 }
560 }
561
562 @Override
563 protected TotalMemory.Match arrayToMatchMutable(final Object[] match) {
564 try {
565 return TotalMemory.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]);
566 } catch(ClassCastException e) {
567 LOGGER.error("Element(s) in array not properly typed!",e);
568 return null;
569 }
570 }
571
572 /**
573 * @return the singleton instance of the query specification of this pattern
574 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
575 *
576 */
577 public static IQuerySpecification<TotalMemory.Matcher> querySpecification() {
578 return TotalMemory.instance();
579 }
580 }
581
582 private TotalMemory() {
583 super(GeneratedPQuery.INSTANCE);
584 }
585
586 /**
587 * @return the singleton instance of the query specification
588 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
589 *
590 */
591 public static TotalMemory instance() {
592 try{
593 return LazyHolder.INSTANCE;
594 } catch (ExceptionInInitializerError err) {
595 throw processInitializerError(err);
596 }
597 }
598
599 @Override
600 protected TotalMemory.Matcher instantiate(final ViatraQueryEngine engine) {
601 return TotalMemory.Matcher.on(engine);
602 }
603
604 @Override
605 public TotalMemory.Matcher instantiate() {
606 return TotalMemory.Matcher.create();
607 }
608
609 @Override
610 public TotalMemory.Match newEmptyMatch() {
611 return TotalMemory.Match.newEmptyMatch();
612 }
613
614 @Override
615 public TotalMemory.Match newMatch(final Object... parameters) {
616 return TotalMemory.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]);
617 }
618
619 /**
620 * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory (visibility: PUBLIC, simpleName: TotalMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
621 * <b>not</b> at the class load time of the outer class,
622 * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory (visibility: PUBLIC, simpleName: TotalMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
623 *
624 * <p> This workaround is required e.g. to support recursion.
625 *
626 */
627 private static class LazyHolder {
628 private static final TotalMemory INSTANCE = new TotalMemory();
629
630 /**
631 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
632 * This initialization order is required to support indirect recursion.
633 *
634 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
635 *
636 */
637 private static final Object STATIC_INITIALIZER = ensureInitialized();
638
639 public static Object ensureInitialized() {
640 INSTANCE.ensureInitializedInternal();
641 return null;
642 }
643 }
644
645 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
646 private static final TotalMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery();
647
648 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);
649
650 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);
651
652 private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_Memory);
653
654 private GeneratedPQuery() {
655 super(PVisibility.PUBLIC);
656 }
657
658 @Override
659 public String getFullyQualifiedName() {
660 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory";
661 }
662
663 @Override
664 public List<String> getParameterNames() {
665 return Arrays.asList("Host","Memory");
666 }
667
668 @Override
669 public List<PParameter> getParameters() {
670 return parameters;
671 }
672
673 @Override
674 public Set<PBody> doGetContainedBodies() {
675 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
676 Set<PBody> bodies = new LinkedHashSet<>();
677 {
678 PBody body = new PBody(this);
679 PVariable var_Host = body.getOrCreateVariableByName("Host");
680 PVariable var_Memory = body.getOrCreateVariableByName("Memory");
681 new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
682 new TypeConstraint(body, Tuples.flatTupleOf(var_Memory), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt")));
683 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
684 new ExportedParameter(body, var_Host, parameter_Host),
685 new ExportedParameter(body, var_Memory, parameter_Memory)
686 ));
687 // HostInstance.type.defaultMemory(Host, Memory)
688 new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
689 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
690 new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type")));
691 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType")));
692 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
693 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "defaultMemory")));
694 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt")));
695 new Equality(body, var__virtual_1_, var_Memory);
696 bodies.add(body);
697 }
698 {
699 PAnnotation annotation = new PAnnotation("QueryBasedFeature");
700 annotation.addAttribute("feature", "totalMemory");
701 addAnnotation(annotation);
702 }
703 return bodies;
704 }
705 }
706}
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..ccc0ba22
--- /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,541 @@
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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance;
7import java.util.Arrays;
8import java.util.Collection;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Objects;
12import java.util.Optional;
13import java.util.Set;
14import java.util.function.Consumer;
15import java.util.stream.Collectors;
16import java.util.stream.Stream;
17import org.apache.log4j.Logger;
18import org.eclipse.emf.ecore.EClass;
19import org.eclipse.viatra.query.runtime.api.IPatternMatch;
20import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
21import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
22import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
24import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
25import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
26import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
27import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
28import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
29import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
31import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
32import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
34import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
35import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
36import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
37import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
38import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
39import 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")
56public 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 if ("App".equals(parameterName)) return this.fApp;
81 return null;
82 }
83
84 public ApplicationInstance getApp() {
85 return this.fApp;
86 }
87
88 @Override
89 public boolean set(final String parameterName, final Object newValue) {
90 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
91 if ("App".equals(parameterName) ) {
92 this.fApp = (ApplicationInstance) newValue;
93 return true;
94 }
95 return false;
96 }
97
98 public void setApp(final ApplicationInstance pApp) {
99 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
100 this.fApp = pApp;
101 }
102
103 @Override
104 public String patternName() {
105 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.unallocateAppInstance";
106 }
107
108 @Override
109 public List<String> parameterNames() {
110 return UnallocateAppInstance.Match.parameterNames;
111 }
112
113 @Override
114 public Object[] toArray() {
115 return new Object[]{fApp};
116 }
117
118 @Override
119 public UnallocateAppInstance.Match toImmutable() {
120 return isMutable() ? newMatch(fApp) : this;
121 }
122
123 @Override
124 public String prettyPrint() {
125 StringBuilder result = new StringBuilder();
126 result.append("\"App\"=" + prettyPrintValue(fApp));
127 return result.toString();
128 }
129
130 @Override
131 public int hashCode() {
132 return Objects.hash(fApp);
133 }
134
135 @Override
136 public boolean equals(final Object obj) {
137 if (this == obj)
138 return true;
139 if (obj == null) {
140 return false;
141 }
142 if ((obj instanceof UnallocateAppInstance.Match)) {
143 UnallocateAppInstance.Match other = (UnallocateAppInstance.Match) obj;
144 return Objects.equals(fApp, other.fApp);
145 } else {
146 // this should be infrequent
147 if (!(obj instanceof IPatternMatch)) {
148 return false;
149 }
150 IPatternMatch otherSig = (IPatternMatch) obj;
151 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
152 }
153 }
154
155 @Override
156 public UnallocateAppInstance specification() {
157 return UnallocateAppInstance.instance();
158 }
159
160 /**
161 * Returns an empty, mutable match.
162 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
163 *
164 * @return the empty match.
165 *
166 */
167 public static UnallocateAppInstance.Match newEmptyMatch() {
168 return new Mutable(null);
169 }
170
171 /**
172 * Returns a mutable (partial) match.
173 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
174 *
175 * @param pApp the fixed value of pattern parameter App, or null if not bound.
176 * @return the new, mutable (partial) match object.
177 *
178 */
179 public static UnallocateAppInstance.Match newMutableMatch(final ApplicationInstance pApp) {
180 return new Mutable(pApp);
181 }
182
183 /**
184 * Returns a new (partial) match.
185 * This can be used e.g. to call the matcher with a partial match.
186 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
187 * @param pApp the fixed value of pattern parameter App, or null if not bound.
188 * @return the (partial) match object.
189 *
190 */
191 public static UnallocateAppInstance.Match newMatch(final ApplicationInstance pApp) {
192 return new Immutable(pApp);
193 }
194
195 private static final class Mutable extends UnallocateAppInstance.Match {
196 Mutable(final ApplicationInstance pApp) {
197 super(pApp);
198 }
199
200 @Override
201 public boolean isMutable() {
202 return true;
203 }
204 }
205
206 private static final class Immutable extends UnallocateAppInstance.Match {
207 Immutable(final ApplicationInstance pApp) {
208 super(pApp);
209 }
210
211 @Override
212 public boolean isMutable() {
213 return false;
214 }
215 }
216 }
217
218 /**
219 * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.unallocateAppInstance pattern,
220 * providing pattern-specific query methods.
221 *
222 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
223 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
224 *
225 * <p>Matches of the pattern will be represented as {@link Match}.
226 *
227 * <p>Original source:
228 * <code><pre>
229 * pattern unallocateAppInstance(App : ApplicationInstance) {
230 * ApplicationInstance.allocatedTo(App, _);
231 * }
232 * </pre></code>
233 *
234 * @see Match
235 * @see UnallocateAppInstance
236 *
237 */
238 public static class Matcher extends BaseMatcher<UnallocateAppInstance.Match> {
239 /**
240 * Initializes the pattern matcher within an existing VIATRA Query engine.
241 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
242 *
243 * @param engine the existing VIATRA Query engine in which this matcher will be created.
244 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
245 *
246 */
247 public static UnallocateAppInstance.Matcher on(final ViatraQueryEngine engine) {
248 // check if matcher already exists
249 Matcher matcher = engine.getExistingMatcher(querySpecification());
250 if (matcher == null) {
251 matcher = (Matcher)engine.getMatcher(querySpecification());
252 }
253 return matcher;
254 }
255
256 /**
257 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
258 * @return an initialized matcher
259 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
260 *
261 */
262 public static UnallocateAppInstance.Matcher create() {
263 return new Matcher();
264 }
265
266 private static final int POSITION_APP = 0;
267
268 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(UnallocateAppInstance.Matcher.class);
269
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 private Matcher() {
279 super(querySpecification());
280 }
281
282 /**
283 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
284 * @param pApp the fixed value of pattern parameter App, or null if not bound.
285 * @return matches represented as a Match object.
286 *
287 */
288 public Collection<UnallocateAppInstance.Match> getAllMatches(final ApplicationInstance pApp) {
289 return rawStreamAllMatches(new Object[]{pApp}).collect(Collectors.toSet());
290 }
291
292 /**
293 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
294 * </p>
295 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
296 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
297 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
298 * @param pApp the fixed value of pattern parameter App, or null if not bound.
299 * @return a stream of matches represented as a Match object.
300 *
301 */
302 public Stream<UnallocateAppInstance.Match> streamAllMatches(final ApplicationInstance pApp) {
303 return rawStreamAllMatches(new Object[]{pApp});
304 }
305
306 /**
307 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
308 * Neither determinism nor randomness of selection is guaranteed.
309 * @param pApp the fixed value of pattern parameter App, or null if not bound.
310 * @return a match represented as a Match object, or null if no match is found.
311 *
312 */
313 public Optional<UnallocateAppInstance.Match> getOneArbitraryMatch(final ApplicationInstance pApp) {
314 return rawGetOneArbitraryMatch(new Object[]{pApp});
315 }
316
317 /**
318 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
319 * under any possible substitution of the unspecified parameters (if any).
320 * @param pApp the fixed value of pattern parameter App, or null if not bound.
321 * @return true if the input is a valid (partial) match of the pattern.
322 *
323 */
324 public boolean hasMatch(final ApplicationInstance pApp) {
325 return rawHasMatch(new Object[]{pApp});
326 }
327
328 /**
329 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
330 * @param pApp the fixed value of pattern parameter App, or null if not bound.
331 * @return the number of pattern matches found.
332 *
333 */
334 public int countMatches(final ApplicationInstance pApp) {
335 return rawCountMatches(new Object[]{pApp});
336 }
337
338 /**
339 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
340 * Neither determinism nor randomness of selection is guaranteed.
341 * @param pApp the fixed value of pattern parameter App, or null if not bound.
342 * @param processor the action that will process the selected match.
343 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
344 *
345 */
346 public boolean forOneArbitraryMatch(final ApplicationInstance pApp, final Consumer<? super UnallocateAppInstance.Match> processor) {
347 return rawForOneArbitraryMatch(new Object[]{pApp}, processor);
348 }
349
350 /**
351 * Returns a new (partial) match.
352 * This can be used e.g. to call the matcher with a partial match.
353 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
354 * @param pApp the fixed value of pattern parameter App, or null if not bound.
355 * @return the (partial) match object.
356 *
357 */
358 public UnallocateAppInstance.Match newMatch(final ApplicationInstance pApp) {
359 return UnallocateAppInstance.Match.newMatch(pApp);
360 }
361
362 /**
363 * Retrieve the set of values that occur in matches for App.
364 * @return the Set of all values or empty set if there are no matches
365 *
366 */
367 protected Stream<ApplicationInstance> rawStreamAllValuesOfApp(final Object[] parameters) {
368 return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast);
369 }
370
371 /**
372 * Retrieve the set of values that occur in matches for App.
373 * @return the Set of all values or empty set if there are no matches
374 *
375 */
376 public Set<ApplicationInstance> getAllValuesOfApp() {
377 return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet());
378 }
379
380 /**
381 * Retrieve the set of values that occur in matches for App.
382 * @return the Set of all values or empty set if there are no matches
383 *
384 */
385 public Stream<ApplicationInstance> streamAllValuesOfApp() {
386 return rawStreamAllValuesOfApp(emptyArray());
387 }
388
389 @Override
390 protected UnallocateAppInstance.Match tupleToMatch(final Tuple t) {
391 try {
392 return UnallocateAppInstance.Match.newMatch((ApplicationInstance) t.get(POSITION_APP));
393 } catch(ClassCastException e) {
394 LOGGER.error("Element(s) in tuple not properly typed!",e);
395 return null;
396 }
397 }
398
399 @Override
400 protected UnallocateAppInstance.Match arrayToMatch(final Object[] match) {
401 try {
402 return UnallocateAppInstance.Match.newMatch((ApplicationInstance) match[POSITION_APP]);
403 } catch(ClassCastException e) {
404 LOGGER.error("Element(s) in array not properly typed!",e);
405 return null;
406 }
407 }
408
409 @Override
410 protected UnallocateAppInstance.Match arrayToMatchMutable(final Object[] match) {
411 try {
412 return UnallocateAppInstance.Match.newMutableMatch((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 /**
420 * @return the singleton instance of the query specification of this pattern
421 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
422 *
423 */
424 public static IQuerySpecification<UnallocateAppInstance.Matcher> querySpecification() {
425 return UnallocateAppInstance.instance();
426 }
427 }
428
429 private UnallocateAppInstance() {
430 super(GeneratedPQuery.INSTANCE);
431 }
432
433 /**
434 * @return the singleton instance of the query specification
435 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
436 *
437 */
438 public static UnallocateAppInstance instance() {
439 try{
440 return LazyHolder.INSTANCE;
441 } catch (ExceptionInInitializerError err) {
442 throw processInitializerError(err);
443 }
444 }
445
446 @Override
447 protected UnallocateAppInstance.Matcher instantiate(final ViatraQueryEngine engine) {
448 return UnallocateAppInstance.Matcher.on(engine);
449 }
450
451 @Override
452 public UnallocateAppInstance.Matcher instantiate() {
453 return UnallocateAppInstance.Matcher.create();
454 }
455
456 @Override
457 public UnallocateAppInstance.Match newEmptyMatch() {
458 return UnallocateAppInstance.Match.newEmptyMatch();
459 }
460
461 @Override
462 public UnallocateAppInstance.Match newMatch(final Object... parameters) {
463 return UnallocateAppInstance.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[0]);
464 }
465
466 /**
467 * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.UnallocateAppInstance (visibility: PUBLIC, simpleName: UnallocateAppInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.UnallocateAppInstance, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
468 * <b>not</b> at the class load time of the outer class,
469 * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.UnallocateAppInstance (visibility: PUBLIC, simpleName: UnallocateAppInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.UnallocateAppInstance, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
470 *
471 * <p> This workaround is required e.g. to support recursion.
472 *
473 */
474 private static class LazyHolder {
475 private static final UnallocateAppInstance INSTANCE = new UnallocateAppInstance();
476
477 /**
478 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
479 * This initialization order is required to support indirect recursion.
480 *
481 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
482 *
483 */
484 private static final Object STATIC_INITIALIZER = ensureInitialized();
485
486 public static Object ensureInitialized() {
487 INSTANCE.ensureInitializedInternal();
488 return null;
489 }
490 }
491
492 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
493 private static final UnallocateAppInstance.GeneratedPQuery INSTANCE = new GeneratedPQuery();
494
495 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);
496
497 private final List<PParameter> parameters = Arrays.asList(parameter_App);
498
499 private GeneratedPQuery() {
500 super(PVisibility.PUBLIC);
501 }
502
503 @Override
504 public String getFullyQualifiedName() {
505 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.unallocateAppInstance";
506 }
507
508 @Override
509 public List<String> getParameterNames() {
510 return Arrays.asList("App");
511 }
512
513 @Override
514 public List<PParameter> getParameters() {
515 return parameters;
516 }
517
518 @Override
519 public Set<PBody> doGetContainedBodies() {
520 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
521 Set<PBody> bodies = new LinkedHashSet<>();
522 {
523 PBody body = new PBody(this);
524 PVariable var_App = body.getOrCreateVariableByName("App");
525 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
526 new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
527 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
528 new ExportedParameter(body, var_App, parameter_App)
529 ));
530 // ApplicationInstance.allocatedTo(App, _)
531 new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
532 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
533 new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo")));
534 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
535 new Equality(body, var__virtual_0_, var___0_);
536 bodies.add(body);
537 }
538 return bodies;
539 }
540 }
541}
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
index 2f593811..c903a5e9 100644
--- 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
@@ -9,3 +9,12 @@
9/.FreeHddPercentage.java._trace 9/.FreeHddPercentage.java._trace
10/.ApplicationInstance.java._trace 10/.ApplicationInstance.java._trace
11/.HostInstanceCost.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
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..7d07b83a
--- /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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd;
8import java.util.Arrays;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Set;
12import org.eclipse.emf.ecore.EClass;
13import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
14import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher;
15import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
16import org.eclipse.viatra.query.runtime.matchers.aggregators.sum;
17import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
18import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey;
19import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
20import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
21import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
22import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
23import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint;
24import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
25import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
26import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
27import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint;
28import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
29import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
30import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
31import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
32import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
33import 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")
52public 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd (visibility: PUBLIC, simpleName: AvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd (visibility: PUBLIC, simpleName: AvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#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..b06544d5
--- /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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory;
8import java.util.Arrays;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Set;
12import org.eclipse.emf.ecore.EClass;
13import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
14import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher;
15import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
16import org.eclipse.viatra.query.runtime.matchers.aggregators.sum;
17import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
18import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey;
19import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
20import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
21import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
22import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
23import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint;
24import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
25import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
26import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
27import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint;
28import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
29import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
30import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
31import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
32import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
33import 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")
52public 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory (visibility: PUBLIC, simpleName: AvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory (visibility: PUBLIC, simpleName: AvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#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..23867558
--- /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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5
6import java.util.Arrays;
7import java.util.LinkedHashSet;
8import java.util.List;
9import java.util.Set;
10import org.eclipse.emf.ecore.EClass;
11import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
12import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher;
13import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
14import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
15import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
16import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
17import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
18import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
19import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
20import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
21import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
22import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
23import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
24import 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")
41public 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsApplications (visibility: PUBLIC, simpleName: CpsApplications, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsApplications, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsApplications (visibility: PUBLIC, simpleName: CpsApplications, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsApplications, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#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..e55bddff
--- /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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5
6import java.util.Arrays;
7import java.util.LinkedHashSet;
8import java.util.List;
9import java.util.Set;
10import org.eclipse.emf.ecore.EClass;
11import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
12import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher;
13import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
14import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
15import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
16import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
17import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
18import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
19import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
20import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
21import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
22import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
23import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
24import 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")
41public 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsHosts (visibility: PUBLIC, simpleName: CpsHosts, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsHosts, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsHosts (visibility: PUBLIC, simpleName: CpsHosts, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsHosts, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#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
index 58b113eb..67f75e1d 100644
--- 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
@@ -3,29 +3,37 @@
3 */ 3 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; 4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5 5
6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate;
6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement; 7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd;
8import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory;
9import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric; 8import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric;
10import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric; 9import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric;
11import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric; 10import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric;
12import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications;
13import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost; 11import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost;
14import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts; 12import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance;
13import hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective;
15import hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement; 14import hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement;
16import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd; 15import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd;
17import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory; 16import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory;
18import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RedundantInstancesOnSameHost; 17import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RedundantInstancesOnSameHost;
18import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RemoveHostInstance;
19import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied; 19import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied;
20import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; 20import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement;
21import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; 21import hu.bme.mit.inf.dslreasoner.domains.cps.queries.UnallocateAppInstance;
22import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd;
23import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory;
24import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsApplications;
25import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsHosts;
22import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage; 26import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage;
23import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage; 27import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage;
24import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement; 28import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement;
25import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost; 29import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost;
26import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement; 30import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement;
27import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; 31import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.NoHostToAllocateTo;
32import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.RequiredAppInstances;
28import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance; 33import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance;
34import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd;
35import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory;
36import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance;
29import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; 37import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
30 38
31/** 39/**
@@ -57,6 +65,14 @@ import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
57 * <li>costMetric</li> 65 * <li>costMetric</li>
58 * <li>cpsCost</li> 66 * <li>cpsCost</li>
59 * <li>hostInstanceCost</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>
60 * </ul> 76 * </ul>
61 * 77 *
62 * @see IQueryGroup 78 * @see IQueryGroup
@@ -104,5 +120,13 @@ public final class CpsQueriesAll extends BaseGeneratedPatternGroup {
104 querySpecifications.add(CostMetric.instance()); 120 querySpecifications.add(CostMetric.instance());
105 querySpecifications.add(CpsCost.instance()); 121 querySpecifications.add(CpsCost.instance());
106 querySpecifications.add(HostInstanceCost.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());
107 } 131 }
108} 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
index 366677b5..c24f46a1 100644
--- 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
@@ -3,8 +3,8 @@
3 */ 3 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; 4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5 5
6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd; 6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; 7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd;
8import java.util.Arrays; 8import java.util.Arrays;
9import java.util.LinkedHashSet; 9import java.util.LinkedHashSet;
10import java.util.List; 10import java.util.List;
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
index bd151ea6..c2bb2bb3 100644
--- 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
@@ -3,8 +3,8 @@
3 */ 3 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; 4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5 5
6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory; 6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; 7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory;
8import java.util.Arrays; 8import java.util.Arrays;
9import java.util.LinkedHashSet; 9import java.util.LinkedHashSet;
10import java.util.List; 10import java.util.List;
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
index fbe7a46b..68448930 100644
--- 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
@@ -3,7 +3,7 @@
3 */ 3 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; 4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5 5
6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; 6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement;
7import java.util.Arrays; 7import java.util.Arrays;
8import java.util.LinkedHashSet; 8import java.util.LinkedHashSet;
9import java.util.List; 9import java.util.List;
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
index 767ca342..db7f7021 100644
--- 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
@@ -3,7 +3,7 @@
3 */ 3 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; 4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5 5
6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts; 6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsHosts;
7import java.util.Arrays; 7import java.util.Arrays;
8import java.util.LinkedHashSet; 8import java.util.LinkedHashSet;
9import java.util.List; 9import java.util.List;
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
index 0a24d105..d15f9bfa 100644
--- 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
@@ -3,7 +3,7 @@
3 */ 3 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; 4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5 5
6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; 6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement;
7import java.util.Arrays; 7import java.util.Arrays;
8import java.util.LinkedHashSet; 8import java.util.LinkedHashSet;
9import java.util.List; 9import java.util.List;
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..50597805
--- /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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance;
8import java.util.Arrays;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Set;
12import org.eclipse.emf.ecore.EClass;
13import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
14import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher;
15import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
16import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
17import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
18import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
19import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
20import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
21import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
22import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
23import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
24import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
25import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
26import 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")
44public 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.NoHostToAllocateTo (visibility: PUBLIC, simpleName: NoHostToAllocateTo, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.NoHostToAllocateTo, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.NoHostToAllocateTo (visibility: PUBLIC, simpleName: NoHostToAllocateTo, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.NoHostToAllocateTo, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#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..dc76cbde
--- /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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance;
7import java.util.Arrays;
8import java.util.LinkedHashSet;
9import java.util.List;
10import java.util.Set;
11import org.eclipse.emf.ecore.EClass;
12import org.eclipse.emf.ecore.EDataType;
13import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
14import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher;
15import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
16import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
17import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
18import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
19import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey;
20import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
21import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
22import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
23import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
24import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
25import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
26import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
27import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter;
28import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint;
29import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
30import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
31import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
32import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
33import 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")
52public 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.RequiredAppInstances (visibility: PUBLIC, simpleName: RequiredAppInstances, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.RequiredAppInstances, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.RequiredAppInstances (visibility: PUBLIC, simpleName: RequiredAppInstances, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.RequiredAppInstances, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#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/ResourceRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java
deleted file mode 100644
index 8c5bdefe..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java
+++ /dev/null
@@ -1,168 +0,0 @@
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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5
6import java.util.Arrays;
7import java.util.LinkedHashSet;
8import java.util.List;
9import java.util.Set;
10import org.eclipse.emf.ecore.EClass;
11import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
12import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher;
13import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
14import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
15import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
16import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
17import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
18import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
19import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
20import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
21import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
22import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
23import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
24import 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 resourceRequirement(Host : HostInstance, App : ApplicationInstance, Req : ResourceRequirement) {
32 * ApplicationInstance.allocatedTo(App, Host);
33 * ApplicationInstance.type.requirements(App, Req);
34 * HostInstance.type(Host, HostType);
35 * ResourceRequirement.hostType(Req, HostType);
36 * }
37 * </pre></code>
38 *
39 * @see GenericPatternMatcher
40 * @see GenericPatternMatch
41 *
42 */
43@SuppressWarnings("all")
44public final class ResourceRequirement extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher {
45 private ResourceRequirement() {
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 ResourceRequirement 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement (visibility: PUBLIC, simpleName: ResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement (visibility: PUBLIC, simpleName: ResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
66 *
67 * <p> This workaround is required e.g. to support recursion.
68 *
69 */
70 private static class LazyHolder {
71 private static final ResourceRequirement INSTANCE = new ResourceRequirement();
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 ResourceRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery();
90
91 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);
92
93 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);
94
95 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);
96
97 private final List<PParameter> parameters = Arrays.asList(parameter_Host, parameter_App, parameter_Req);
98
99 private GeneratedPQuery() {
100 super(PVisibility.PRIVATE);
101 }
102
103 @Override
104 public String getFullyQualifiedName() {
105 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement";
106 }
107
108 @Override
109 public List<String> getParameterNames() {
110 return Arrays.asList("Host","App","Req");
111 }
112
113 @Override
114 public List<PParameter> getParameters() {
115 return parameters;
116 }
117
118 @Override
119 public Set<PBody> doGetContainedBodies() {
120 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
121 Set<PBody> bodies = new LinkedHashSet<>();
122 {
123 PBody body = new PBody(this);
124 PVariable var_Host = body.getOrCreateVariableByName("Host");
125 PVariable var_App = body.getOrCreateVariableByName("App");
126 PVariable var_Req = body.getOrCreateVariableByName("Req");
127 PVariable var_HostType = body.getOrCreateVariableByName("HostType");
128 new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
129 new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
130 new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
131 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
132 new ExportedParameter(body, var_Host, parameter_Host),
133 new ExportedParameter(body, var_App, parameter_App),
134 new ExportedParameter(body, var_Req, parameter_Req)
135 ));
136 // ApplicationInstance.allocatedTo(App, Host)
137 new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
138 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
139 new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo")));
140 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
141 new Equality(body, var__virtual_0_, var_Host);
142 // ApplicationInstance.type.requirements(App, Req)
143 new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
144 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
145 new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type")));
146 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType")));
147 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
148 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "requirements")));
149 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
150 new Equality(body, var__virtual_2_, var_Req);
151 // HostInstance.type(Host, HostType)
152 new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
153 PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}");
154 new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type")));
155 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType")));
156 new Equality(body, var__virtual_3_, var_HostType);
157 // ResourceRequirement.hostType(Req, HostType)
158 new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
159 PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}");
160 new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "hostType")));
161 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType")));
162 new Equality(body, var__virtual_4_, var_HostType);
163 bodies.add(body);
164 }
165 return bodies;
166 }
167 }
168}
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..f250f76d
--- /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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5
6import java.util.Arrays;
7import java.util.LinkedHashSet;
8import java.util.List;
9import java.util.Set;
10import org.eclipse.emf.ecore.EClass;
11import org.eclipse.emf.ecore.EDataType;
12import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
13import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher;
14import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
15import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
16import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
17import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
18import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
19import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
20import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
21import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
22import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
23import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
24import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
25import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
26import 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")
43public 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd (visibility: PUBLIC, simpleName: TotalHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd (visibility: PUBLIC, simpleName: TotalHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#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..aecd97e2
--- /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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5
6import java.util.Arrays;
7import java.util.LinkedHashSet;
8import java.util.List;
9import java.util.Set;
10import org.eclipse.emf.ecore.EClass;
11import org.eclipse.emf.ecore.EDataType;
12import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
13import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher;
14import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
15import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
16import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
17import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
18import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
19import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
20import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
21import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
22import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
23import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
24import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
25import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
26import 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")
43public 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory (visibility: PUBLIC, simpleName: TotalMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory (visibility: PUBLIC, simpleName: TotalMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#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..a20b534c
--- /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 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal;
5
6import java.util.Arrays;
7import java.util.Collections;
8import java.util.LinkedHashSet;
9import java.util.List;
10import java.util.Set;
11import org.eclipse.emf.ecore.EClass;
12import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
13import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher;
14import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
15import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
16import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
17import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
18import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
19import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
20import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
21import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
22import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
23import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
24import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
25import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
26import 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")
43public 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance (visibility: PUBLIC, simpleName: UnallocatedAppInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} 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 JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance (visibility: PUBLIC, simpleName: UnallocatedAppInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#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}