SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
PolyTreePool.h
Go to the documentation of this file.
1 /**
2  * @file PolyTreePool.h
3  * @author Andreas Krueger <andreas.krueger@rwth-aachen.de>
4  */
5 
6 #pragma once
7 
8 #include "carl-formula/bitvector/Pool.h"
9 #include "PolyTree.h"
10 
11 namespace smtrat
12 {
13  class PolyTreePool : public carl::Singleton<PolyTreePool>
14  {
15  private:
16  friend carl::Singleton<PolyTreePool>;
17 
18  // The PolyTree pool. Each Poly is mapped to a corresponding PolyTreeContent.
19  std::map<Poly, PolyTreeContent*> mPool;
20  // Mutex to avoid multiple access to the pool
21  mutable std::mutex mMutexPool;
22 
23  #define POOL_LOCK_GUARD std::lock_guard<std::mutex> lock( mMutexPool );
24  #define POOL_LOCK mMutexPool.lock();
25  #define POOL_UNLOCK mMutexPool.unlock();
26 
27  protected:
28 
29  /**
30  * Constructor of the pool.
31  */
33  mPool()
34  { }
35 
37  {
38  std::map<Poly, PolyTreeContent*>::iterator it = mPool.begin();
39  while(it != mPool.end()) {
40  delete it->second;
41  it = mPool.erase(it);
42  }
43  }
44 
45  public:
46 
47  const PolyTreeContent* get(const Poly& _pol);
48 
49  private:
50 
51  const PolyTreeContent* create(const Poly& _pol);
52  const PolyTreeContent* create(carl::Variable::Arg _variable);
53  const PolyTreeContent* create(Integer _constant);
54  const PolyTreeContent* create(const Poly& _poly, PolyTree::Type _type, const Poly& _left, const Poly& _right);
55 
56  const PolyTreeContent* add(PolyTreeContent* _element);
57  };
58 }
std::mutex mMutexPool
Definition: PolyTreePool.h:21
PolyTreePool()
Constructor of the pool.
Definition: PolyTreePool.h:32
std::map< Poly, PolyTreeContent * > mPool
Definition: PolyTreePool.h:19
const PolyTreeContent * create(const Poly &_pol)
const PolyTreeContent * get(const Poly &_pol)
const PolyTreeContent * add(PolyTreeContent *_element)
Class to create the formulas for axioms.
carl::MultivariatePolynomial< Rational > Poly
Definition: types.h:25
carl::IntegralType< Rational >::type Integer
Definition: types.h:21