aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/traceability/RecipeTraceInfo.java
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/traceability/RecipeTraceInfo.java')
-rw-r--r--subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/traceability/RecipeTraceInfo.java81
1 files changed, 81 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/traceability/RecipeTraceInfo.java b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/traceability/RecipeTraceInfo.java
new file mode 100644
index 00000000..8f610550
--- /dev/null
+++ b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/traceability/RecipeTraceInfo.java
@@ -0,0 +1,81 @@
1/*******************************************************************************
2 * Copyright (c) 2010-2014, Bergmann Gabor, 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.traceability;
10
11import java.util.ArrayList;
12import java.util.Arrays;
13import java.util.Collection;
14import java.util.Collections;
15import java.util.List;
16
17import tools.refinery.viatra.runtime.rete.network.Node;
18import tools.refinery.viatra.runtime.rete.recipes.ReteNodeRecipe;
19
20/**
21 * A trace marker that indicates the recipe for which the node was built.
22 * @author Bergmann Gabor
23 */
24public class RecipeTraceInfo implements TraceInfo {
25 public ReteNodeRecipe getRecipe() {return recipe;}
26 /**
27 * For cloning in case of recursion cut-off points, use {@link #getParentRecipeTracesForCloning()} instead.
28 * @return an unmodifiable view on parent traces, to be constructed before this node (or alongside, in case of recursion)
29 */
30 public List<RecipeTraceInfo> getParentRecipeTraces() {return Collections.unmodifiableList(new ArrayList<>(parentRecipeTraces));}
31 /**
32 * Directly return the underlying collection so that changes to it will be transparent. Use only for recursion-tolerant cloning.
33 * @noreference This method is not intended to be referenced by clients.
34 */
35 public Collection<? extends RecipeTraceInfo> getParentRecipeTracesForCloning() {return parentRecipeTraces;}
36 @Override
37 public Node getNode() {return node;}
38
39 private Node node;
40 ReteNodeRecipe recipe;
41 ReteNodeRecipe shadowedRecipe;
42 Collection<? extends RecipeTraceInfo> parentRecipeTraces;
43
44
45 public RecipeTraceInfo(ReteNodeRecipe recipe, Collection<? extends RecipeTraceInfo> parentRecipeTraces) {
46 super();
47 this.recipe = recipe;
48 this.parentRecipeTraces = parentRecipeTraces; //ParentTraceList.from(parentRecipeTraces);
49 }
50 public RecipeTraceInfo(ReteNodeRecipe recipe, RecipeTraceInfo... parentRecipeTraces) {
51 this(recipe, Arrays.asList(parentRecipeTraces));
52 }
53
54 @Override
55 public boolean propagateToIndexerParent() {return false;}
56 @Override
57 public boolean propagateFromIndexerToSupplierParent() {return false;}
58 @Override
59 public boolean propagateFromStandardNodeToSupplierParent() {return false;}
60 @Override
61 public boolean propagateToProductionNodeParentAlso() {return false;}
62 @Override
63 public void assignNode(Node node) {this.node = node;}
64
65 /**
66 * @param knownRecipe a known recipe that is equivalent to the current recipe
67 */
68 public void shadowWithEquivalentRecipe(ReteNodeRecipe knownRecipe) {
69 this.shadowedRecipe = this.recipe;
70 this.recipe = knownRecipe;
71 }
72
73 /**
74 * Get original recipe shadowed by an equivalent
75 */
76 public ReteNodeRecipe getShadowedRecipe() {
77 return shadowedRecipe;
78 }
79
80
81} \ No newline at end of file