aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/single/TimelyProductionNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/single/TimelyProductionNode.java')
-rw-r--r--subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/single/TimelyProductionNode.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/single/TimelyProductionNode.java b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/single/TimelyProductionNode.java
new file mode 100644
index 00000000..82640948
--- /dev/null
+++ b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/single/TimelyProductionNode.java
@@ -0,0 +1,63 @@
1/*******************************************************************************
2 * Copyright (c) 2010-2019, Tamas Szabo, Istvan Rath and Daniel Varro
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.rete.single;
10
11import java.util.Iterator;
12import java.util.Map;
13
14import tools.refinery.viatra.runtime.matchers.tuple.Tuple;
15import tools.refinery.viatra.runtime.rete.network.ProductionNode;
16import tools.refinery.viatra.runtime.rete.network.ReteContainer;
17import tools.refinery.viatra.runtime.rete.traceability.CompiledQuery;
18import tools.refinery.viatra.runtime.rete.traceability.TraceInfo;
19/**
20 * Differential dataflow implementation of the Production node, based on {@link TimelyUniquenessEnforcerNode}.
21 *
22 * @author Tamas Szabo
23 * @noinstantiate This class is not intended to be instantiated by clients.
24 * @since 2.3
25 */
26public class TimelyProductionNode extends TimelyUniquenessEnforcerNode implements ProductionNode {
27
28 protected final Map<String, Integer> posMapping;
29
30 public TimelyProductionNode(final ReteContainer reteContainer, final Map<String, Integer> posMapping) {
31 super(reteContainer, posMapping.size());
32 this.posMapping = posMapping;
33 }
34
35 @Override
36 public Map<String, Integer> getPosMapping() {
37 return this.posMapping;
38 }
39
40 @Override
41 public Iterator<Tuple> iterator() {
42 return this.memory.keySet().iterator();
43 }
44
45 @Override
46 public void acceptPropagatedTraceInfo(final TraceInfo traceInfo) {
47 if (traceInfo.propagateToProductionNodeParentAlso()) {
48 super.acceptPropagatedTraceInfo(traceInfo);
49 }
50 }
51
52 @Override
53 public String toString() {
54 for (final TraceInfo traceInfo : this.traceInfos) {
55 if (traceInfo instanceof CompiledQuery) {
56 final String patternName = ((CompiledQuery) traceInfo).getPatternName();
57 return String.format(this.getClass().getName() + "<%s>=%s", patternName, super.toString());
58 }
59 }
60 return super.toString();
61 }
62
63}