diff options
Diffstat (limited to 'subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/remote/RemoteReceiver.java')
-rw-r--r-- | subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/remote/RemoteReceiver.java | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/remote/RemoteReceiver.java b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/remote/RemoteReceiver.java new file mode 100644 index 00000000..f7d267af --- /dev/null +++ b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/remote/RemoteReceiver.java | |||
@@ -0,0 +1,63 @@ | |||
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.remote; | ||
11 | |||
12 | import java.util.ArrayList; | ||
13 | import java.util.Collection; | ||
14 | import java.util.List; | ||
15 | import java.util.Map; | ||
16 | |||
17 | import tools.refinery.viatra.runtime.matchers.tuple.Tuple; | ||
18 | import tools.refinery.viatra.runtime.matchers.util.Direction; | ||
19 | import tools.refinery.viatra.runtime.matchers.util.timeline.Timeline; | ||
20 | import tools.refinery.viatra.runtime.rete.network.Receiver; | ||
21 | import tools.refinery.viatra.runtime.rete.network.ReteContainer; | ||
22 | import tools.refinery.viatra.runtime.rete.network.communication.Timestamp; | ||
23 | import tools.refinery.viatra.runtime.rete.single.SingleInputNode; | ||
24 | |||
25 | /** | ||
26 | * This node delivers updates to a remote recipient; no updates are propagated further in this network. | ||
27 | * | ||
28 | * @author Gabor Bergmann | ||
29 | * | ||
30 | */ | ||
31 | public class RemoteReceiver extends SingleInputNode { | ||
32 | |||
33 | List<Address<? extends Receiver>> targets; | ||
34 | |||
35 | public RemoteReceiver(ReteContainer reteContainer) { | ||
36 | super(reteContainer); | ||
37 | targets = new ArrayList<Address<? extends Receiver>>(); | ||
38 | } | ||
39 | |||
40 | public void addTarget(Address<? extends Receiver> target) { | ||
41 | targets.add(target); | ||
42 | } | ||
43 | |||
44 | @Override | ||
45 | public void pullInto(Collection<Tuple> collector, boolean flush) { | ||
46 | propagatePullInto(collector, flush); | ||
47 | } | ||
48 | |||
49 | @Override | ||
50 | public void pullIntoWithTimeline(Map<Tuple, Timeline<Timestamp>> collector, boolean flush) { | ||
51 | throw new UnsupportedOperationException(); | ||
52 | } | ||
53 | |||
54 | public Collection<Tuple> remotePull(boolean flush) { | ||
55 | return reteContainer.pullContents(this, flush); | ||
56 | } | ||
57 | |||
58 | public void update(Direction direction, Tuple updateElement, Timestamp timestamp) { | ||
59 | for (Address<? extends Receiver> ad : targets) | ||
60 | reteContainer.sendUpdateToRemoteAddress(ad, direction, updateElement); | ||
61 | } | ||
62 | |||
63 | } | ||