1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andres Noetzli, Andrew Reynolds, Morgan Deters |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* [[ Add one-line brief description here ]] |
14 |
|
* |
15 |
|
* [[ Add lengthier description here ]] |
16 |
|
* \todo document this file |
17 |
|
*/ |
18 |
|
|
19 |
|
#include "smt/solver_engine_scope.h" |
20 |
|
|
21 |
|
#include "base/check.h" |
22 |
|
#include "base/configuration_private.h" |
23 |
|
#include "base/output.h" |
24 |
|
#include "smt/solver_engine.h" |
25 |
|
|
26 |
|
namespace cvc5 { |
27 |
|
namespace smt { |
28 |
|
|
29 |
|
thread_local SolverEngine* s_slvEngine_current = nullptr; |
30 |
|
|
31 |
47233906 |
SolverEngine* currentSolverEngine() |
32 |
|
{ |
33 |
47233906 |
Assert(s_slvEngine_current != nullptr); |
34 |
47233906 |
return s_slvEngine_current; |
35 |
|
} |
36 |
|
|
37 |
4816355 |
bool solverEngineInScope() { return s_slvEngine_current != nullptr; } |
38 |
|
|
39 |
|
ResourceManager* currentResourceManager() |
40 |
|
{ |
41 |
|
return s_slvEngine_current->getResourceManager(); |
42 |
|
} |
43 |
|
|
44 |
211378 |
SolverEngineScope::SolverEngineScope(const SolverEngine* smt) |
45 |
|
: d_oldSlvEngine(s_slvEngine_current), |
46 |
|
d_optionsScope(smt ? &const_cast<SolverEngine*>(smt)->getOptions() |
47 |
211378 |
: nullptr) |
48 |
|
{ |
49 |
211378 |
Assert(smt != nullptr); |
50 |
211378 |
s_slvEngine_current = const_cast<SolverEngine*>(smt); |
51 |
211378 |
Debug("current") << "smt scope: " << s_slvEngine_current << std::endl; |
52 |
211378 |
} |
53 |
|
|
54 |
417258 |
SolverEngineScope::~SolverEngineScope() |
55 |
|
{ |
56 |
208629 |
s_slvEngine_current = d_oldSlvEngine; |
57 |
417258 |
Debug("current") << "smt scope: returning to " << s_slvEngine_current |
58 |
208629 |
<< std::endl; |
59 |
208629 |
} |
60 |
|
|
61 |
4310253 |
StatisticsRegistry& SolverEngineScope::currentStatisticsRegistry() |
62 |
|
{ |
63 |
4310253 |
Assert(solverEngineInScope()); |
64 |
4310253 |
return s_slvEngine_current->getStatisticsRegistry(); |
65 |
|
} |
66 |
|
|
67 |
|
} // namespace smt |
68 |
31137 |
} // namespace cvc5 |