diff options
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.java | 50 |
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 | |||
10 | package tools.refinery.viatra.runtime.rete.misc; | ||
11 | |||
12 | import java.util.Collection; | ||
13 | import java.util.Map; | ||
14 | |||
15 | import tools.refinery.viatra.runtime.matchers.context.IQueryRuntimeContext; | ||
16 | import tools.refinery.viatra.runtime.matchers.tuple.Tuple; | ||
17 | import tools.refinery.viatra.runtime.matchers.util.timeline.Timeline; | ||
18 | import tools.refinery.viatra.runtime.rete.network.ReteContainer; | ||
19 | import tools.refinery.viatra.runtime.rete.network.StandardNode; | ||
20 | import 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 | */ | ||
27 | public 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 | } | ||