diff options
author | 2020-11-02 02:02:40 +0100 | |
---|---|---|
committer | 2020-11-02 02:02:40 +0100 | |
commit | f06427cd7375551582461f91b3458339a8227f9b (patch) | |
tree | 97bc6ec85f4c384e5080a6611b492caf460b6ce9 /Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_4.java | |
parent | Must unit propagation (diff) | |
download | VIATRA-Generator-f06427cd7375551582461f91b3458339a8227f9b.tar.gz VIATRA-Generator-f06427cd7375551582461f91b3458339a8227f9b.tar.zst VIATRA-Generator-f06427cd7375551582461f91b3458339a8227f9b.zip |
Optimizing generator with linear objective functions
Diffstat (limited to 'Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_4.java')
-rw-r--r-- | Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_4.java | 847 |
1 files changed, 847 insertions, 0 deletions
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_4.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_4.java new file mode 100644 index 00000000..73df8514 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_4.java | |||
@@ -0,0 +1,847 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.Train; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern endOfSiding_step_4(in train : Train, in location : Segment, in end : Segment) { | ||
48 | * // frame-{@literal >}end = frame-{@literal >}location-{@literal >}connected_to[i1]; | ||
49 | * // if (frame-{@literal >}end != NULL && | ||
50 | * // frame-{@literal >}end-{@literal >}connected_to[1] == frame-{@literal >}location && | ||
51 | * // frame-{@literal >}end-{@literal >}connected_to[0] == NULL) { | ||
52 | * // ... | ||
53 | * // } | ||
54 | * // if (frame-{@literal >}end != NULL && | ||
55 | * // frame-{@literal >}end-{@literal >}connected_to[0] == frame-{@literal >}location && | ||
56 | * // frame-{@literal >}end-{@literal >}connected_to[1] == NULL) { | ||
57 | * // ... | ||
58 | * // } | ||
59 | * Train(train); | ||
60 | * Train.location(train, location); | ||
61 | * Segment.connectedTo(location, end); | ||
62 | * } | ||
63 | * </pre></code> | ||
64 | * | ||
65 | * @see Matcher | ||
66 | * @see Match | ||
67 | * | ||
68 | */ | ||
69 | @SuppressWarnings("all") | ||
70 | public final class EndOfSiding_step_4 extends BaseGeneratedEMFQuerySpecification<EndOfSiding_step_4.Matcher> { | ||
71 | /** | ||
72 | * Pattern-specific match representation of the modes3.queries.endOfSiding_step_4 pattern, | ||
73 | * to be used in conjunction with {@link Matcher}. | ||
74 | * | ||
75 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
76 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
77 | * usable to represent a match of the pattern in the result of a query, | ||
78 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
79 | * | ||
80 | * @see Matcher | ||
81 | * | ||
82 | */ | ||
83 | public static abstract class Match extends BasePatternMatch { | ||
84 | private Train fTrain; | ||
85 | |||
86 | private Segment fLocation; | ||
87 | |||
88 | private Segment fEnd; | ||
89 | |||
90 | private static List<String> parameterNames = makeImmutableList("train", "location", "end"); | ||
91 | |||
92 | private Match(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
93 | this.fTrain = pTrain; | ||
94 | this.fLocation = pLocation; | ||
95 | this.fEnd = pEnd; | ||
96 | } | ||
97 | |||
98 | @Override | ||
99 | public Object get(final String parameterName) { | ||
100 | switch(parameterName) { | ||
101 | case "train": return this.fTrain; | ||
102 | case "location": return this.fLocation; | ||
103 | case "end": return this.fEnd; | ||
104 | default: return null; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | @Override | ||
109 | public Object get(final int index) { | ||
110 | switch(index) { | ||
111 | case 0: return this.fTrain; | ||
112 | case 1: return this.fLocation; | ||
113 | case 2: return this.fEnd; | ||
114 | default: return null; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | public Train getTrain() { | ||
119 | return this.fTrain; | ||
120 | } | ||
121 | |||
122 | public Segment getLocation() { | ||
123 | return this.fLocation; | ||
124 | } | ||
125 | |||
126 | public Segment getEnd() { | ||
127 | return this.fEnd; | ||
128 | } | ||
129 | |||
130 | @Override | ||
131 | public boolean set(final String parameterName, final Object newValue) { | ||
132 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
133 | if ("train".equals(parameterName) ) { | ||
134 | this.fTrain = (Train) newValue; | ||
135 | return true; | ||
136 | } | ||
137 | if ("location".equals(parameterName) ) { | ||
138 | this.fLocation = (Segment) newValue; | ||
139 | return true; | ||
140 | } | ||
141 | if ("end".equals(parameterName) ) { | ||
142 | this.fEnd = (Segment) newValue; | ||
143 | return true; | ||
144 | } | ||
145 | return false; | ||
146 | } | ||
147 | |||
148 | public void setTrain(final Train pTrain) { | ||
149 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
150 | this.fTrain = pTrain; | ||
151 | } | ||
152 | |||
153 | public void setLocation(final Segment pLocation) { | ||
154 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
155 | this.fLocation = pLocation; | ||
156 | } | ||
157 | |||
158 | public void setEnd(final Segment pEnd) { | ||
159 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
160 | this.fEnd = pEnd; | ||
161 | } | ||
162 | |||
163 | @Override | ||
164 | public String patternName() { | ||
165 | return "modes3.queries.endOfSiding_step_4"; | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public List<String> parameterNames() { | ||
170 | return EndOfSiding_step_4.Match.parameterNames; | ||
171 | } | ||
172 | |||
173 | @Override | ||
174 | public Object[] toArray() { | ||
175 | return new Object[]{fTrain, fLocation, fEnd}; | ||
176 | } | ||
177 | |||
178 | @Override | ||
179 | public EndOfSiding_step_4.Match toImmutable() { | ||
180 | return isMutable() ? newMatch(fTrain, fLocation, fEnd) : this; | ||
181 | } | ||
182 | |||
183 | @Override | ||
184 | public String prettyPrint() { | ||
185 | StringBuilder result = new StringBuilder(); | ||
186 | result.append("\"train\"=" + prettyPrintValue(fTrain) + ", "); | ||
187 | result.append("\"location\"=" + prettyPrintValue(fLocation) + ", "); | ||
188 | result.append("\"end\"=" + prettyPrintValue(fEnd)); | ||
189 | return result.toString(); | ||
190 | } | ||
191 | |||
192 | @Override | ||
193 | public int hashCode() { | ||
194 | return Objects.hash(fTrain, fLocation, fEnd); | ||
195 | } | ||
196 | |||
197 | @Override | ||
198 | public boolean equals(final Object obj) { | ||
199 | if (this == obj) | ||
200 | return true; | ||
201 | if (obj == null) { | ||
202 | return false; | ||
203 | } | ||
204 | if ((obj instanceof EndOfSiding_step_4.Match)) { | ||
205 | EndOfSiding_step_4.Match other = (EndOfSiding_step_4.Match) obj; | ||
206 | return Objects.equals(fTrain, other.fTrain) && Objects.equals(fLocation, other.fLocation) && Objects.equals(fEnd, other.fEnd); | ||
207 | } else { | ||
208 | // this should be infrequent | ||
209 | if (!(obj instanceof IPatternMatch)) { | ||
210 | return false; | ||
211 | } | ||
212 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
213 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | @Override | ||
218 | public EndOfSiding_step_4 specification() { | ||
219 | return EndOfSiding_step_4.instance(); | ||
220 | } | ||
221 | |||
222 | /** | ||
223 | * Returns an empty, mutable match. | ||
224 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
225 | * | ||
226 | * @return the empty match. | ||
227 | * | ||
228 | */ | ||
229 | public static EndOfSiding_step_4.Match newEmptyMatch() { | ||
230 | return new Mutable(null, null, null); | ||
231 | } | ||
232 | |||
233 | /** | ||
234 | * Returns a mutable (partial) match. | ||
235 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
236 | * | ||
237 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
238 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
239 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
240 | * @return the new, mutable (partial) match object. | ||
241 | * | ||
242 | */ | ||
243 | public static EndOfSiding_step_4.Match newMutableMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
244 | return new Mutable(pTrain, pLocation, pEnd); | ||
245 | } | ||
246 | |||
247 | /** | ||
248 | * Returns a new (partial) match. | ||
249 | * This can be used e.g. to call the matcher with a partial match. | ||
250 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
251 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
252 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
253 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
254 | * @return the (partial) match object. | ||
255 | * | ||
256 | */ | ||
257 | public static EndOfSiding_step_4.Match newMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
258 | return new Immutable(pTrain, pLocation, pEnd); | ||
259 | } | ||
260 | |||
261 | private static final class Mutable extends EndOfSiding_step_4.Match { | ||
262 | Mutable(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
263 | super(pTrain, pLocation, pEnd); | ||
264 | } | ||
265 | |||
266 | @Override | ||
267 | public boolean isMutable() { | ||
268 | return true; | ||
269 | } | ||
270 | } | ||
271 | |||
272 | private static final class Immutable extends EndOfSiding_step_4.Match { | ||
273 | Immutable(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
274 | super(pTrain, pLocation, pEnd); | ||
275 | } | ||
276 | |||
277 | @Override | ||
278 | public boolean isMutable() { | ||
279 | return false; | ||
280 | } | ||
281 | } | ||
282 | } | ||
283 | |||
284 | /** | ||
285 | * Generated pattern matcher API of the modes3.queries.endOfSiding_step_4 pattern, | ||
286 | * providing pattern-specific query methods. | ||
287 | * | ||
288 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
289 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
290 | * | ||
291 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
292 | * | ||
293 | * <p>Original source: | ||
294 | * <code><pre> | ||
295 | * pattern endOfSiding_step_4(in train : Train, in location : Segment, in end : Segment) { | ||
296 | * // frame-{@literal >}end = frame-{@literal >}location-{@literal >}connected_to[i1]; | ||
297 | * // if (frame-{@literal >}end != NULL && | ||
298 | * // frame-{@literal >}end-{@literal >}connected_to[1] == frame-{@literal >}location && | ||
299 | * // frame-{@literal >}end-{@literal >}connected_to[0] == NULL) { | ||
300 | * // ... | ||
301 | * // } | ||
302 | * // if (frame-{@literal >}end != NULL && | ||
303 | * // frame-{@literal >}end-{@literal >}connected_to[0] == frame-{@literal >}location && | ||
304 | * // frame-{@literal >}end-{@literal >}connected_to[1] == NULL) { | ||
305 | * // ... | ||
306 | * // } | ||
307 | * Train(train); | ||
308 | * Train.location(train, location); | ||
309 | * Segment.connectedTo(location, end); | ||
310 | * } | ||
311 | * </pre></code> | ||
312 | * | ||
313 | * @see Match | ||
314 | * @see EndOfSiding_step_4 | ||
315 | * | ||
316 | */ | ||
317 | public static class Matcher extends BaseMatcher<EndOfSiding_step_4.Match> { | ||
318 | /** | ||
319 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
320 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
321 | * | ||
322 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
323 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
324 | * | ||
325 | */ | ||
326 | public static EndOfSiding_step_4.Matcher on(final ViatraQueryEngine engine) { | ||
327 | // check if matcher already exists | ||
328 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
329 | if (matcher == null) { | ||
330 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
331 | } | ||
332 | return matcher; | ||
333 | } | ||
334 | |||
335 | /** | ||
336 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
337 | * @return an initialized matcher | ||
338 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
339 | * | ||
340 | */ | ||
341 | public static EndOfSiding_step_4.Matcher create() { | ||
342 | return new Matcher(); | ||
343 | } | ||
344 | |||
345 | private static final int POSITION_TRAIN = 0; | ||
346 | |||
347 | private static final int POSITION_LOCATION = 1; | ||
348 | |||
349 | private static final int POSITION_END = 2; | ||
350 | |||
351 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EndOfSiding_step_4.Matcher.class); | ||
352 | |||
353 | /** | ||
354 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
355 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
356 | * | ||
357 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
358 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
359 | * | ||
360 | */ | ||
361 | private Matcher() { | ||
362 | super(querySpecification()); | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
367 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
368 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
369 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
370 | * @return matches represented as a Match object. | ||
371 | * | ||
372 | */ | ||
373 | public Collection<EndOfSiding_step_4.Match> getAllMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
374 | return rawStreamAllMatches(new Object[]{pTrain, pLocation, pEnd}).collect(Collectors.toSet()); | ||
375 | } | ||
376 | |||
377 | /** | ||
378 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
379 | * </p> | ||
380 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
381 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
382 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
383 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
384 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
385 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
386 | * @return a stream of matches represented as a Match object. | ||
387 | * | ||
388 | */ | ||
389 | public Stream<EndOfSiding_step_4.Match> streamAllMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
390 | return rawStreamAllMatches(new Object[]{pTrain, pLocation, pEnd}); | ||
391 | } | ||
392 | |||
393 | /** | ||
394 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
395 | * Neither determinism nor randomness of selection is guaranteed. | ||
396 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
397 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
398 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
399 | * @return a match represented as a Match object, or null if no match is found. | ||
400 | * | ||
401 | */ | ||
402 | public Optional<EndOfSiding_step_4.Match> getOneArbitraryMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
403 | return rawGetOneArbitraryMatch(new Object[]{pTrain, pLocation, pEnd}); | ||
404 | } | ||
405 | |||
406 | /** | ||
407 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
408 | * under any possible substitution of the unspecified parameters (if any). | ||
409 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
410 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
411 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
412 | * @return true if the input is a valid (partial) match of the pattern. | ||
413 | * | ||
414 | */ | ||
415 | public boolean hasMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
416 | return rawHasMatch(new Object[]{pTrain, pLocation, pEnd}); | ||
417 | } | ||
418 | |||
419 | /** | ||
420 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
421 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
422 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
423 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
424 | * @return the number of pattern matches found. | ||
425 | * | ||
426 | */ | ||
427 | public int countMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
428 | return rawCountMatches(new Object[]{pTrain, pLocation, pEnd}); | ||
429 | } | ||
430 | |||
431 | /** | ||
432 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
433 | * Neither determinism nor randomness of selection is guaranteed. | ||
434 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
435 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
436 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
437 | * @param processor the action that will process the selected match. | ||
438 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
439 | * | ||
440 | */ | ||
441 | public boolean forOneArbitraryMatch(final Train pTrain, final Segment pLocation, final Segment pEnd, final Consumer<? super EndOfSiding_step_4.Match> processor) { | ||
442 | return rawForOneArbitraryMatch(new Object[]{pTrain, pLocation, pEnd}, processor); | ||
443 | } | ||
444 | |||
445 | /** | ||
446 | * Returns a new (partial) match. | ||
447 | * This can be used e.g. to call the matcher with a partial match. | ||
448 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
449 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
450 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
451 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
452 | * @return the (partial) match object. | ||
453 | * | ||
454 | */ | ||
455 | public EndOfSiding_step_4.Match newMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
456 | return EndOfSiding_step_4.Match.newMatch(pTrain, pLocation, pEnd); | ||
457 | } | ||
458 | |||
459 | /** | ||
460 | * Retrieve the set of values that occur in matches for train. | ||
461 | * @return the Set of all values or empty set if there are no matches | ||
462 | * | ||
463 | */ | ||
464 | protected Stream<Train> rawStreamAllValuesOftrain(final Object[] parameters) { | ||
465 | return rawStreamAllValues(POSITION_TRAIN, parameters).map(Train.class::cast); | ||
466 | } | ||
467 | |||
468 | /** | ||
469 | * Retrieve the set of values that occur in matches for train. | ||
470 | * @return the Set of all values or empty set if there are no matches | ||
471 | * | ||
472 | */ | ||
473 | public Set<Train> getAllValuesOftrain() { | ||
474 | return rawStreamAllValuesOftrain(emptyArray()).collect(Collectors.toSet()); | ||
475 | } | ||
476 | |||
477 | /** | ||
478 | * Retrieve the set of values that occur in matches for train. | ||
479 | * @return the Set of all values or empty set if there are no matches | ||
480 | * | ||
481 | */ | ||
482 | public Stream<Train> streamAllValuesOftrain() { | ||
483 | return rawStreamAllValuesOftrain(emptyArray()); | ||
484 | } | ||
485 | |||
486 | /** | ||
487 | * Retrieve the set of values that occur in matches for train. | ||
488 | * </p> | ||
489 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
490 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
491 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
492 | * | ||
493 | * @return the Stream of all values or empty set if there are no matches | ||
494 | * | ||
495 | */ | ||
496 | public Stream<Train> streamAllValuesOftrain(final EndOfSiding_step_4.Match partialMatch) { | ||
497 | return rawStreamAllValuesOftrain(partialMatch.toArray()); | ||
498 | } | ||
499 | |||
500 | /** | ||
501 | * Retrieve the set of values that occur in matches for train. | ||
502 | * </p> | ||
503 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
504 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
505 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
506 | * | ||
507 | * @return the Stream of all values or empty set if there are no matches | ||
508 | * | ||
509 | */ | ||
510 | public Stream<Train> streamAllValuesOftrain(final Segment pLocation, final Segment pEnd) { | ||
511 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation, pEnd}); | ||
512 | } | ||
513 | |||
514 | /** | ||
515 | * Retrieve the set of values that occur in matches for train. | ||
516 | * @return the Set of all values or empty set if there are no matches | ||
517 | * | ||
518 | */ | ||
519 | public Set<Train> getAllValuesOftrain(final EndOfSiding_step_4.Match partialMatch) { | ||
520 | return rawStreamAllValuesOftrain(partialMatch.toArray()).collect(Collectors.toSet()); | ||
521 | } | ||
522 | |||
523 | /** | ||
524 | * Retrieve the set of values that occur in matches for train. | ||
525 | * @return the Set of all values or empty set if there are no matches | ||
526 | * | ||
527 | */ | ||
528 | public Set<Train> getAllValuesOftrain(final Segment pLocation, final Segment pEnd) { | ||
529 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation, pEnd}).collect(Collectors.toSet()); | ||
530 | } | ||
531 | |||
532 | /** | ||
533 | * Retrieve the set of values that occur in matches for location. | ||
534 | * @return the Set of all values or empty set if there are no matches | ||
535 | * | ||
536 | */ | ||
537 | protected Stream<Segment> rawStreamAllValuesOflocation(final Object[] parameters) { | ||
538 | return rawStreamAllValues(POSITION_LOCATION, parameters).map(Segment.class::cast); | ||
539 | } | ||
540 | |||
541 | /** | ||
542 | * Retrieve the set of values that occur in matches for location. | ||
543 | * @return the Set of all values or empty set if there are no matches | ||
544 | * | ||
545 | */ | ||
546 | public Set<Segment> getAllValuesOflocation() { | ||
547 | return rawStreamAllValuesOflocation(emptyArray()).collect(Collectors.toSet()); | ||
548 | } | ||
549 | |||
550 | /** | ||
551 | * Retrieve the set of values that occur in matches for location. | ||
552 | * @return the Set of all values or empty set if there are no matches | ||
553 | * | ||
554 | */ | ||
555 | public Stream<Segment> streamAllValuesOflocation() { | ||
556 | return rawStreamAllValuesOflocation(emptyArray()); | ||
557 | } | ||
558 | |||
559 | /** | ||
560 | * Retrieve the set of values that occur in matches for location. | ||
561 | * </p> | ||
562 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
563 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
564 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
565 | * | ||
566 | * @return the Stream of all values or empty set if there are no matches | ||
567 | * | ||
568 | */ | ||
569 | public Stream<Segment> streamAllValuesOflocation(final EndOfSiding_step_4.Match partialMatch) { | ||
570 | return rawStreamAllValuesOflocation(partialMatch.toArray()); | ||
571 | } | ||
572 | |||
573 | /** | ||
574 | * Retrieve the set of values that occur in matches for location. | ||
575 | * </p> | ||
576 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
577 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
578 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
579 | * | ||
580 | * @return the Stream of all values or empty set if there are no matches | ||
581 | * | ||
582 | */ | ||
583 | public Stream<Segment> streamAllValuesOflocation(final Train pTrain, final Segment pEnd) { | ||
584 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null, pEnd}); | ||
585 | } | ||
586 | |||
587 | /** | ||
588 | * Retrieve the set of values that occur in matches for location. | ||
589 | * @return the Set of all values or empty set if there are no matches | ||
590 | * | ||
591 | */ | ||
592 | public Set<Segment> getAllValuesOflocation(final EndOfSiding_step_4.Match partialMatch) { | ||
593 | return rawStreamAllValuesOflocation(partialMatch.toArray()).collect(Collectors.toSet()); | ||
594 | } | ||
595 | |||
596 | /** | ||
597 | * Retrieve the set of values that occur in matches for location. | ||
598 | * @return the Set of all values or empty set if there are no matches | ||
599 | * | ||
600 | */ | ||
601 | public Set<Segment> getAllValuesOflocation(final Train pTrain, final Segment pEnd) { | ||
602 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null, pEnd}).collect(Collectors.toSet()); | ||
603 | } | ||
604 | |||
605 | /** | ||
606 | * Retrieve the set of values that occur in matches for end. | ||
607 | * @return the Set of all values or empty set if there are no matches | ||
608 | * | ||
609 | */ | ||
610 | protected Stream<Segment> rawStreamAllValuesOfend(final Object[] parameters) { | ||
611 | return rawStreamAllValues(POSITION_END, parameters).map(Segment.class::cast); | ||
612 | } | ||
613 | |||
614 | /** | ||
615 | * Retrieve the set of values that occur in matches for end. | ||
616 | * @return the Set of all values or empty set if there are no matches | ||
617 | * | ||
618 | */ | ||
619 | public Set<Segment> getAllValuesOfend() { | ||
620 | return rawStreamAllValuesOfend(emptyArray()).collect(Collectors.toSet()); | ||
621 | } | ||
622 | |||
623 | /** | ||
624 | * Retrieve the set of values that occur in matches for end. | ||
625 | * @return the Set of all values or empty set if there are no matches | ||
626 | * | ||
627 | */ | ||
628 | public Stream<Segment> streamAllValuesOfend() { | ||
629 | return rawStreamAllValuesOfend(emptyArray()); | ||
630 | } | ||
631 | |||
632 | /** | ||
633 | * Retrieve the set of values that occur in matches for end. | ||
634 | * </p> | ||
635 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
636 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
637 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
638 | * | ||
639 | * @return the Stream of all values or empty set if there are no matches | ||
640 | * | ||
641 | */ | ||
642 | public Stream<Segment> streamAllValuesOfend(final EndOfSiding_step_4.Match partialMatch) { | ||
643 | return rawStreamAllValuesOfend(partialMatch.toArray()); | ||
644 | } | ||
645 | |||
646 | /** | ||
647 | * Retrieve the set of values that occur in matches for end. | ||
648 | * </p> | ||
649 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
650 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
651 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
652 | * | ||
653 | * @return the Stream of all values or empty set if there are no matches | ||
654 | * | ||
655 | */ | ||
656 | public Stream<Segment> streamAllValuesOfend(final Train pTrain, final Segment pLocation) { | ||
657 | return rawStreamAllValuesOfend(new Object[]{pTrain, pLocation, null}); | ||
658 | } | ||
659 | |||
660 | /** | ||
661 | * Retrieve the set of values that occur in matches for end. | ||
662 | * @return the Set of all values or empty set if there are no matches | ||
663 | * | ||
664 | */ | ||
665 | public Set<Segment> getAllValuesOfend(final EndOfSiding_step_4.Match partialMatch) { | ||
666 | return rawStreamAllValuesOfend(partialMatch.toArray()).collect(Collectors.toSet()); | ||
667 | } | ||
668 | |||
669 | /** | ||
670 | * Retrieve the set of values that occur in matches for end. | ||
671 | * @return the Set of all values or empty set if there are no matches | ||
672 | * | ||
673 | */ | ||
674 | public Set<Segment> getAllValuesOfend(final Train pTrain, final Segment pLocation) { | ||
675 | return rawStreamAllValuesOfend(new Object[]{pTrain, pLocation, null}).collect(Collectors.toSet()); | ||
676 | } | ||
677 | |||
678 | @Override | ||
679 | protected EndOfSiding_step_4.Match tupleToMatch(final Tuple t) { | ||
680 | try { | ||
681 | return EndOfSiding_step_4.Match.newMatch((Train) t.get(POSITION_TRAIN), (Segment) t.get(POSITION_LOCATION), (Segment) t.get(POSITION_END)); | ||
682 | } catch(ClassCastException e) { | ||
683 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
684 | return null; | ||
685 | } | ||
686 | } | ||
687 | |||
688 | @Override | ||
689 | protected EndOfSiding_step_4.Match arrayToMatch(final Object[] match) { | ||
690 | try { | ||
691 | return EndOfSiding_step_4.Match.newMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION], (Segment) match[POSITION_END]); | ||
692 | } catch(ClassCastException e) { | ||
693 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
694 | return null; | ||
695 | } | ||
696 | } | ||
697 | |||
698 | @Override | ||
699 | protected EndOfSiding_step_4.Match arrayToMatchMutable(final Object[] match) { | ||
700 | try { | ||
701 | return EndOfSiding_step_4.Match.newMutableMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION], (Segment) match[POSITION_END]); | ||
702 | } catch(ClassCastException e) { | ||
703 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
704 | return null; | ||
705 | } | ||
706 | } | ||
707 | |||
708 | /** | ||
709 | * @return the singleton instance of the query specification of this pattern | ||
710 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
711 | * | ||
712 | */ | ||
713 | public static IQuerySpecification<EndOfSiding_step_4.Matcher> querySpecification() { | ||
714 | return EndOfSiding_step_4.instance(); | ||
715 | } | ||
716 | } | ||
717 | |||
718 | private EndOfSiding_step_4() { | ||
719 | super(GeneratedPQuery.INSTANCE); | ||
720 | } | ||
721 | |||
722 | /** | ||
723 | * @return the singleton instance of the query specification | ||
724 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
725 | * | ||
726 | */ | ||
727 | public static EndOfSiding_step_4 instance() { | ||
728 | try{ | ||
729 | return LazyHolder.INSTANCE; | ||
730 | } catch (ExceptionInInitializerError err) { | ||
731 | throw processInitializerError(err); | ||
732 | } | ||
733 | } | ||
734 | |||
735 | @Override | ||
736 | protected EndOfSiding_step_4.Matcher instantiate(final ViatraQueryEngine engine) { | ||
737 | return EndOfSiding_step_4.Matcher.on(engine); | ||
738 | } | ||
739 | |||
740 | @Override | ||
741 | public EndOfSiding_step_4.Matcher instantiate() { | ||
742 | return EndOfSiding_step_4.Matcher.create(); | ||
743 | } | ||
744 | |||
745 | @Override | ||
746 | public EndOfSiding_step_4.Match newEmptyMatch() { | ||
747 | return EndOfSiding_step_4.Match.newEmptyMatch(); | ||
748 | } | ||
749 | |||
750 | @Override | ||
751 | public EndOfSiding_step_4.Match newMatch(final Object... parameters) { | ||
752 | return EndOfSiding_step_4.Match.newMatch((modes3.Train) parameters[0], (modes3.Segment) parameters[1], (modes3.Segment) parameters[2]); | ||
753 | } | ||
754 | |||
755 | /** | ||
756 | * Inner class allowing the singleton instance of {@link EndOfSiding_step_4} to be created | ||
757 | * <b>not</b> at the class load time of the outer class, | ||
758 | * but rather at the first call to {@link EndOfSiding_step_4#instance()}. | ||
759 | * | ||
760 | * <p> This workaround is required e.g. to support recursion. | ||
761 | * | ||
762 | */ | ||
763 | private static class LazyHolder { | ||
764 | private static final EndOfSiding_step_4 INSTANCE = new EndOfSiding_step_4(); | ||
765 | |||
766 | /** | ||
767 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
768 | * This initialization order is required to support indirect recursion. | ||
769 | * | ||
770 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
771 | * | ||
772 | */ | ||
773 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
774 | |||
775 | public static Object ensureInitialized() { | ||
776 | INSTANCE.ensureInitializedInternal(); | ||
777 | return null; | ||
778 | } | ||
779 | } | ||
780 | |||
781 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
782 | private static final EndOfSiding_step_4.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
783 | |||
784 | private final PParameter parameter_train = new PParameter("train", "modes3.Train", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Train")), PParameterDirection.INOUT); | ||
785 | |||
786 | private final PParameter parameter_location = new PParameter("location", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
787 | |||
788 | private final PParameter parameter_end = new PParameter("end", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
789 | |||
790 | private final List<PParameter> parameters = Arrays.asList(parameter_train, parameter_location, parameter_end); | ||
791 | |||
792 | private GeneratedPQuery() { | ||
793 | super(PVisibility.PUBLIC); | ||
794 | } | ||
795 | |||
796 | @Override | ||
797 | public String getFullyQualifiedName() { | ||
798 | return "modes3.queries.endOfSiding_step_4"; | ||
799 | } | ||
800 | |||
801 | @Override | ||
802 | public List<String> getParameterNames() { | ||
803 | return Arrays.asList("train","location","end"); | ||
804 | } | ||
805 | |||
806 | @Override | ||
807 | public List<PParameter> getParameters() { | ||
808 | return parameters; | ||
809 | } | ||
810 | |||
811 | @Override | ||
812 | public Set<PBody> doGetContainedBodies() { | ||
813 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
814 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
815 | { | ||
816 | PBody body = new PBody(this); | ||
817 | PVariable var_train = body.getOrCreateVariableByName("train"); | ||
818 | PVariable var_location = body.getOrCreateVariableByName("location"); | ||
819 | PVariable var_end = body.getOrCreateVariableByName("end"); | ||
820 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
821 | new TypeConstraint(body, Tuples.flatTupleOf(var_location), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
822 | new TypeConstraint(body, Tuples.flatTupleOf(var_end), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
823 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
824 | new ExportedParameter(body, var_train, parameter_train), | ||
825 | new ExportedParameter(body, var_location, parameter_location), | ||
826 | new ExportedParameter(body, var_end, parameter_end) | ||
827 | )); | ||
828 | // // frame->end = frame->location->connected_to[i1];// if (frame->end != NULL &&// frame->end->connected_to[1] == frame->location &&// frame->end->connected_to[0] == NULL) {// ...// } // if (frame->end != NULL &&// frame->end->connected_to[0] == frame->location &&// frame->end->connected_to[1] == NULL) {// ...// } Train(train) | ||
829 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
830 | // Train.location(train, location) | ||
831 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
832 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
833 | new TypeConstraint(body, Tuples.flatTupleOf(var_train, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train", "location"))); | ||
834 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
835 | new Equality(body, var__virtual_0_, var_location); | ||
836 | // Segment.connectedTo(location, end) | ||
837 | new TypeConstraint(body, Tuples.flatTupleOf(var_location), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
838 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
839 | new TypeConstraint(body, Tuples.flatTupleOf(var_location, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
840 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
841 | new Equality(body, var__virtual_1_, var_end); | ||
842 | bodies.add(body); | ||
843 | } | ||
844 | return bodies; | ||
845 | } | ||
846 | } | ||
847 | } | ||