Merge branch '1.3.x'
[cvc5.git] / src / smt / smt_engine_scope.h
1 /********************* */
2 /*! \file smt_engine_scope.h
3 ** \verbatim
4 ** Original author: Morgan Deters
5 ** Major contributors: none
6 ** Minor contributors (to current version): none
7 ** This file is part of the CVC4 project.
8 ** Copyright (c) 2009-2013 New York University and The University of Iowa
9 ** See the file COPYING in the top-level source directory for licensing
10 ** information.\endverbatim
11 **
12 ** \brief [[ Add one-line brief description here ]]
13 **
14 ** [[ Add lengthier description here ]]
15 ** \todo document this file
16 **/
17
18 #include "cvc4_private.h"
19
20 #include "smt/smt_engine.h"
21 #include "util/tls.h"
22 #include "util/cvc4_assert.h"
23 #include "expr/node_manager.h"
24 #include "util/output.h"
25 #include "proof/proof.h"
26
27 #pragma once
28
29 namespace CVC4 {
30
31 class ProofManager;
32
33 namespace smt {
34
35 extern CVC4_THREADLOCAL(SmtEngine*) s_smtEngine_current;
36
37 inline SmtEngine* currentSmtEngine() {
38 Assert(s_smtEngine_current != NULL);
39 return s_smtEngine_current;
40 }
41
42 inline ProofManager* currentProofManager() {
43 Assert(PROOF_ON());
44 Assert(s_smtEngine_current != NULL);
45 return s_smtEngine_current->d_proofManager;
46 }
47
48 class SmtScope : public NodeManagerScope {
49 /** The old NodeManager, to be restored on destruction. */
50 SmtEngine* d_oldSmtEngine;
51
52 public:
53
54 SmtScope(const SmtEngine* smt) :
55 NodeManagerScope(smt->d_nodeManager),
56 d_oldSmtEngine(s_smtEngine_current) {
57 Assert(smt != NULL);
58 s_smtEngine_current = const_cast<SmtEngine*>(smt);
59 Debug("current") << "smt scope: " << s_smtEngine_current << std::endl;
60 }
61
62 ~SmtScope() {
63 s_smtEngine_current = d_oldSmtEngine;
64 Debug("current") << "smt scope: returning to " << s_smtEngine_current << std::endl;
65 }
66 };/* class SmtScope */
67
68 }/* CVC4::smt namespace */
69 }/* CVC4 namespace */