aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/misc/ConstantNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/misc/ConstantNode.java')
-rw-r--r--subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/misc/ConstantNode.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/misc/ConstantNode.java b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/misc/ConstantNode.java
new file mode 100644
index 00000000..980d3eee
--- /dev/null
+++ b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/misc/ConstantNode.java
@@ -0,0 +1,50 @@
1/*******************************************************************************
2 * Copyright (c) 2004-2008 Gabor Bergmann 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 *******************************************************************************/
9
10package tools.refinery.viatra.runtime.rete.misc;
11
12import java.util.Collection;
13import java.util.Map;
14
15import tools.refinery.viatra.runtime.matchers.context.IQueryRuntimeContext;
16import tools.refinery.viatra.runtime.matchers.tuple.Tuple;
17import tools.refinery.viatra.runtime.matchers.util.timeline.Timeline;
18import tools.refinery.viatra.runtime.rete.network.ReteContainer;
19import tools.refinery.viatra.runtime.rete.network.StandardNode;
20import tools.refinery.viatra.runtime.rete.network.communication.Timestamp;
21
22/**
23 * Node that always contains a single constant Tuple
24 *
25 * @author Gabor Bergmann
26 */
27public class ConstantNode extends StandardNode {
28
29 protected Tuple constant;
30
31 /**
32 * @param constant
33 * will be wrapped using {@link IQueryRuntimeContext#wrapTuple(Tuple)}
34 */
35 public ConstantNode(ReteContainer reteContainer, Tuple constant) {
36 super(reteContainer);
37 this.constant = reteContainer.getNetwork().getEngine().getRuntimeContext().wrapTuple(constant);
38 }
39
40 @Override
41 public void pullInto(Collection<Tuple> collector, boolean flush) {
42 collector.add(constant);
43 }
44
45 @Override
46 public void pullIntoWithTimeline(final Map<Tuple, Timeline<Timestamp>> collector, final boolean flush) {
47 collector.put(constant, Timestamp.INSERT_AT_ZERO_TIMELINE);
48 }
49
50}