blob: 24750656fb742e8ae5014d8212fd5a0dcdf75598 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/*******************************************************************************
* Copyright (c) 2004-2008 Gabor Bergmann and Daniel Varro
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-v20.html.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package tools.refinery.viatra.runtime.rete.single;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import tools.refinery.viatra.runtime.matchers.tuple.Tuple;
import tools.refinery.viatra.runtime.matchers.util.Direction;
import tools.refinery.viatra.runtime.matchers.util.timeline.Timeline;
import tools.refinery.viatra.runtime.rete.network.ReteContainer;
import tools.refinery.viatra.runtime.rete.network.communication.Timestamp;
public abstract class TransformerNode extends SingleInputNode {
public TransformerNode(final ReteContainer reteContainer) {
super(reteContainer);
}
protected abstract Tuple transform(final Tuple input);
@Override
public void pullInto(final Collection<Tuple> collector, final boolean flush) {
for (Tuple ps : reteContainer.pullPropagatedContents(this, flush)) {
collector.add(transform(ps));
}
}
@Override
public void pullIntoWithTimeline(final Map<Tuple, Timeline<Timestamp>> collector, final boolean flush) {
for (final Entry<Tuple, Timeline<Timestamp>> entry : reteContainer.pullPropagatedContentsWithTimestamp(this, flush).entrySet()) {
collector.put(transform(entry.getKey()), entry.getValue());
}
}
@Override
public void update(final Direction direction, final Tuple updateElement, final Timestamp timestamp) {
propagateUpdate(direction, transform(updateElement), timestamp);
}
}
|