PolyBoRi
CCuddCore.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
51 //*****************************************************************************
52 
53 #ifndef CCuddCore_h
54 #define CCuddCore_h
55 
56 // include basic definitions
57 #include "pbori_defs.h"
58 
59 // intrisive (shared) pointer functionality
60 #include <boost/intrusive_ptr.hpp>
61 
62 // get PolyBoRi routines and functionals
63 #include "pbori_func.h"
64 #include "pbori_traits.h"
65 
66 #include "CVariableNames.h"
67 
68 #include <vector>
69 #include "cuddInt.h"
70 
72 
84 class CCuddCore {
85 
86 public:
89 
90 
91  typedef CCuddCore self;
92 
94  typedef boost::intrusive_ptr<self> mgrcore_ptr;
95 
98 
100  typedef variable_names_type::const_reference const_varname_reference;
101 
103  mgrcore_type manager;
104 
106  static errorfunc_type errorHandler;
107 
109  static bool verbose;
110 
113 
115  variable_names_type m_names;
116 
117  std::vector<node_type> m_vars;
118 
119 
121  CCuddCore(size_type numVars = 0,
122  size_type numVarsZ = 0,
123  size_type numSlots = CUDD_UNIQUE_SLOTS,
124  size_type cacheSize = CUDD_CACHE_SLOTS,
125  large_size_type maxMemory = 0):
126  ref(0), m_names(numVarsZ), m_vars(numVarsZ) {
127  manager = Cudd_Init(numVars,numVarsZ,numSlots,cacheSize,maxMemory);
128 
129 
130  for (unsigned idx = 0 ; idx < numVarsZ; ++idx) {
131  m_vars[idx] = cuddUniqueInterZdd(manager, idx, DD_ONE(manager),
132  DD_ZERO(manager));
133  Cudd_Ref(m_vars[idx]);
134  }
135 
136  }
137 
140 
141  for (std::vector<node_type>::iterator iter = m_vars.begin(); iter !=
142  m_vars.end(); ++iter) {
143 
144  Cudd_RecursiveDerefZdd(manager, *iter);
145  }
146 
147  int retval = Cudd_CheckZeroRef(manager);
148  // Check for unexpected non-zero reference counts
149  assert(retval == 0);
150 
151  Cudd_Quit(manager);
152  }
153 
155  void addRef(){ ++ref; }
156 
159  return (--ref);
160  }
161 };
162 
164 
165 
166 inline void
168  pCore->addRef();
169 }
170 
172 inline void
174  if (!(pCore->release())) {
175  delete pCore;
176  }
177 }
179 
181 
182 #endif
183 
184