-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathLoggingSolverContext.java
102 lines (85 loc) · 3.31 KB
/
LoggingSolverContext.java
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// This file is part of JavaSMT,
// an API wrapper for a collection of SMT solvers:
// https://github.com/sosy-lab/java-smt
//
// SPDX-FileCopyrightText: 2020 Dirk Beyer <https://www.sosy-lab.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.sosy_lab.java_smt.delegate.logging;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableMap;
import org.sosy_lab.common.log.LogManager;
import org.sosy_lab.java_smt.SolverContextFactory.Solvers;
import org.sosy_lab.java_smt.api.FormulaManager;
import org.sosy_lab.java_smt.api.InterpolatingProverEnvironment;
import org.sosy_lab.java_smt.api.OptimizationProverEnvironment;
import org.sosy_lab.java_smt.api.ProverEnvironment;
import org.sosy_lab.java_smt.api.SolverContext;
/** {@link SolverContext} that wraps all prover environments in their logging versions. */
public final class LoggingSolverContext implements SolverContext {
private final LogManager logger;
private final SolverContext delegate;
public LoggingSolverContext(LogManager pLogger, SolverContext pDelegate) {
logger = checkNotNull(pLogger);
delegate = checkNotNull(pDelegate);
}
@Override
public FormulaManager getFormulaManager() {
return delegate.getFormulaManager();
}
@SuppressWarnings("resource")
@Override
public ProverEnvironment newProverEnvironment(ProverOptions... pOptions) {
return new LoggingProverEnvironment(logger, delegate.newProverEnvironment(pOptions));
}
@SuppressWarnings("resource")
@Override
public ProverEnvironment copyProverEnvironment(ProverEnvironment proverToCopy) {
// TODO: log this? Because this is not a normal new prover?
return new LoggingProverEnvironment(logger, delegate.copyProverEnvironment(proverToCopy));
}
@SuppressWarnings("resource")
@Override
public InterpolatingProverEnvironment<?> newProverEnvironmentWithInterpolation(
ProverOptions... options) {
return new LoggingInterpolatingProverEnvironment<>(
logger, delegate.newProverEnvironmentWithInterpolation(options));
}
@SuppressWarnings("resource")
@Override
public InterpolatingProverEnvironment<?> copyProverEnvironmentWithInterpolation(
InterpolatingProverEnvironment<?> proverToCopy) {
// TODO: log this? Because this is not a normal new prover?
return new LoggingInterpolatingProverEnvironment<>(
logger, delegate.copyProverEnvironmentWithInterpolation(proverToCopy));
}
@SuppressWarnings("resource")
@Override
public OptimizationProverEnvironment newOptimizationProverEnvironment(ProverOptions... options) {
return new LoggingOptimizationProverEnvironment(
logger, delegate.newOptimizationProverEnvironment(options));
}
@SuppressWarnings("resource")
@Override
public OptimizationProverEnvironment copyOptimizationProverEnvironment(
OptimizationProverEnvironment proverToCopy) {
return new LoggingOptimizationProverEnvironment(
logger, delegate.copyOptimizationProverEnvironment(proverToCopy));
}
@Override
public String getVersion() {
return delegate.getVersion();
}
@Override
public Solvers getSolverName() {
return delegate.getSolverName();
}
@Override
public ImmutableMap<String, String> getStatistics() {
return delegate.getStatistics();
}
@Override
public void close() {
delegate.close();
}
}