aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/check/CheckPositivePatternCall.java
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/check/CheckPositivePatternCall.java')
-rw-r--r--subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/check/CheckPositivePatternCall.java96
1 files changed, 96 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/check/CheckPositivePatternCall.java b/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/check/CheckPositivePatternCall.java
new file mode 100644
index 00000000..5f9b688a
--- /dev/null
+++ b/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/check/CheckPositivePatternCall.java
@@ -0,0 +1,96 @@
1/*******************************************************************************
2 * Copyright (c) 2010-2016, Grill Balázs, IncQueryLabs
3 * This program and the accompanying materials are made available under the
4 * terms of the Eclipse Public License v. 2.0 which is available at
5 * http://www.eclipse.org/legal/epl-v20.html.
6 *
7 * SPDX-License-Identifier: EPL-2.0
8 *******************************************************************************/
9package tools.refinery.viatra.runtime.localsearch.operations.check;
10
11import java.util.List;
12import java.util.function.Function;
13
14import tools.refinery.viatra.runtime.localsearch.MatchingFrame;
15import tools.refinery.viatra.runtime.localsearch.matcher.ISearchContext;
16import tools.refinery.viatra.runtime.localsearch.operations.CheckOperationExecutor;
17import tools.refinery.viatra.runtime.localsearch.operations.IPatternMatcherOperation;
18import tools.refinery.viatra.runtime.localsearch.operations.ISearchOperation;
19import tools.refinery.viatra.runtime.localsearch.operations.util.CallInformation;
20import tools.refinery.viatra.runtime.matchers.backend.IQueryResultProvider;
21import tools.refinery.viatra.runtime.matchers.tuple.VolatileModifiableMaskedTuple;
22
23/**
24 * @author Grill Balázs
25 * @since 1.4
26 * @noextend This class is not intended to be subclassed by clients.
27 */
28public class CheckPositivePatternCall implements ISearchOperation, IPatternMatcherOperation {
29
30 private class Executor extends CheckOperationExecutor {
31
32 private final VolatileModifiableMaskedTuple maskedTuple;
33 private IQueryResultProvider matcher;
34
35 public Executor() {
36 super();
37 this.maskedTuple = new VolatileModifiableMaskedTuple(information.getThinFrameMask());
38 }
39
40 @Override
41 public void onInitialize(MatchingFrame frame, ISearchContext context) {
42 super.onInitialize(frame, context);
43 maskedTuple.updateTuple(frame);
44 matcher = context.getMatcher(information.getCallWithAdornment());
45 }
46
47 /**
48 * @since 1.5
49 */
50 protected boolean check(MatchingFrame frame, ISearchContext context) {
51 return matcher.hasMatch(information.getParameterMask(), maskedTuple);
52 }
53
54 @Override
55 public ISearchOperation getOperation() {
56 return CheckPositivePatternCall.this;
57 }
58 }
59
60 private final CallInformation information;
61
62
63 /**
64 * @since 1.7
65 */
66 public CheckPositivePatternCall(CallInformation information) {
67 super();
68 this.information = information;
69
70 }
71
72 @Override
73 public ISearchOperationExecutor createExecutor() {
74 return new Executor();
75 }
76
77 @Override
78 public List<Integer> getVariablePositions() {
79 return information.getVariablePositions();
80 }
81
82 @Override
83 public String toString() {
84 return toString(Object::toString);
85 }
86
87 @Override
88 public String toString(Function<Integer, String> variableMapping) {
89 return "check find "+information.toString(variableMapping);
90 }
91
92 @Override
93 public CallInformation getCallInformation() {
94 return information;
95 }
96}