aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/viatra-runtime-matchers/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/rewriters/AbstractRewriterTraceSource.java
blob: 276b2b421084c29ad73448675e1a13dbd60d713c (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
/*******************************************************************************
 * Copyright (c) 2010-2017, Grill Balázs, IncQueryLabs
 * 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.matchers.psystem.rewriters;

import java.util.Objects;

import tools.refinery.viatra.runtime.matchers.psystem.PConstraint;
import tools.refinery.viatra.runtime.matchers.psystem.PTraceable;

/**
 * @since 1.6
 *
 */
public class AbstractRewriterTraceSource {

    private IRewriterTraceCollector traceCollector = NopTraceCollector.INSTANCE;
    
    public void setTraceCollector(IRewriterTraceCollector traceCollector) {
        this.traceCollector = Objects.requireNonNull(traceCollector);
    }
    
    public IPTraceableTraceProvider getTraces() {
        return traceCollector;
    }
    
    protected IRewriterTraceCollector getTraceCollector() {
        return traceCollector;
    }
    
    /**
     * Mark the given derivative to be originated from the given original constraint.
     * @since 1.6
     */
    protected void addTrace(PTraceable original, PTraceable derivative){
        traceCollector.addTrace(original, derivative);
    }
    
    /**
     * Indicate that the given derivative is removed from the resulting query, thus its trace
     * information should be removed also.
     * @since 1.6
     */
    protected void derivativeRemoved(PConstraint derivative, IDerivativeModificationReason reason){
        traceCollector.derivativeRemoved(derivative, reason);
    }

}