aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/index/Indexer.java
blob: fc9d778153a62c666f267a5f3f8e5d1589781286 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*******************************************************************************
 * 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.index;

import java.util.Collection;
import java.util.Map;

import tools.refinery.viatra.runtime.matchers.tuple.Tuple;
import tools.refinery.viatra.runtime.matchers.tuple.TupleMask;
import tools.refinery.viatra.runtime.matchers.util.timeline.Timeline;
import tools.refinery.viatra.runtime.rete.network.Node;
import tools.refinery.viatra.runtime.rete.network.Supplier;
import tools.refinery.viatra.runtime.rete.network.communication.Timestamp;

/**
 * A node that indexes incoming Tuples by their signatures as specified by a TupleMask. Notifies listeners about such
 * update events through the IndexerListener.
 * 
 * Signature tuples are created by transforming the update tuples using the mask. Tuples stored with the same signature
 * are grouped together. The group or a reduction thereof is retrievable.
 * 
 * @author Gabor Bergmann
 */
public interface Indexer extends Node {
    /**
     * @return the mask by which the contents are indexed.
     */
    public TupleMask getMask();

    /**
     * @return the node whose contents are indexed.
     */
    public Supplier getParent();

    /**
     * @return all stored tuples that conform to the specified signature, null if there are none such. CONTRACT: do not
     *         modify!
     */
    public Collection<Tuple> get(Tuple signature);
    
    /**
     * @since 2.4
     */
    default public Map<Tuple, Timeline<Timestamp>> getTimeline(Tuple signature) {
        throw new UnsupportedOperationException();
    }

    /**
     * This indexer will be updated whenever a Rete update is sent to the active node (or an equivalent time slot
     * allotted to it). The active node is typically the indexer itself, but it can be a different node such as its
     * parent.
     * 
     * @return the active node that operates this indexer
     */
    public Node getActiveNode();

    
    public Collection<IndexerListener> getListeners();
    
    public void attachListener(IndexerListener listener);

    public void detachListener(IndexerListener listener);

}