00001
00002
00168
00169
00170 # include <cstddef>
00171
00172
00173 # include <cuddObj.hh>
00174
00175 #ifndef pbori_defs_h_
00176 #define pbori_defs_h_
00177
00179 #ifdef __GNUC__
00180 #ifndef LIKELY
00181 #define LIKELY(expression) (__builtin_expect(!!(expression), 1))
00182 #endif
00183 #ifndef UNLIKELY
00184 #define UNLIKELY(expression) (__builtin_expect(!!(expression), 0))
00185 #endif
00186 #else
00187 #ifndef LIKELY
00188 #define LIKELY(expression) (expression)
00189 #endif
00190 #ifndef UNLIKELY
00191 #define UNLIKELY(expression) (expression)
00192 #endif
00193 #endif
00194
00196 #define PBORINAME polybori
00197
00199 #ifndef PBORI_NO_DEVELOPER
00200 # define PBORI_DEVELOPER
00201 #endif
00202
00203 #ifndef PBORI_NO_NAMESPACES
00204
00206 # define BEGIN_NAMESPACE_PBORI namespace PBORINAME {
00207
00209 # define END_NAMESPACE_PBORI } // end of namespace
00210
00212 # define USING_NAMESPACE_PBORI using namespace PBORINAME;
00213
00215 # define PBORI PBORINAME
00216
00218 # define USING_PBORI using PBORI
00219
00221 # define PBORI_BEGIN_NAMESPACE( sub_space ) namespace sub_space {
00222
00224 # define PBORI_END_NAMESPACE }
00225
00226 #else
00227
00228 # define BEGIN_NAMESPACE_PBORI
00229 # define END_NAMESPACE_PBORI
00230 # define USING_NAMESPACE_PBORI
00231 # define PBORI
00232 # define USING_PBORI
00233 # define PBORI_BEGIN_NAMESPACE( sub_space )
00234 # define PBORI_END_NAMESPACE
00235
00236 #endif // PBORI_NO_NAMESPACES
00237
00239 #ifdef PBORI_DEBUG_TRACE
00240 # include <iostream>
00241 # define PBORI_TRACE_FUNC(text) std::cerr << text << std::endl;
00242 #else
00243 # define PBORI_TRACE_FUNC(text)
00244 #endif
00245
00247 #ifndef PBORI_NO_STDSTREAMS
00248
00249 # include <iostream>
00250 # define PBORI_OSTREAM std::ostream
00251
00252 #else
00253
00254 BEGIN_NAMESPACE_PBORI
00255
00257 struct PBORI_OSTREAM {};
00258
00259 template <class StreamedType>
00260 PBORI_OSTREAM&
00261 operator<<(PBORI_OSTREAM& dummy, const StreamedType&) {
00262 return dummy;
00263 };
00264 END_NAMESPACE_PBORI
00265
00266 #endif // of #ifndef PBORI_NO_STDSTREAMS
00267
00269 #ifndef PBORI_NO_BOOST_PTR
00270
00271 # include <boost/shared_ptr.hpp>
00272 # define PBORI_SHARED_PTR(Type) boost::shared_ptr<Type>
00273
00274 BEGIN_NAMESPACE_PBORI
00275
00276
00277 template <class ValueType>
00278 void
00279 pbori_shared_ptr_postclean( const PBORI_SHARED_PTR(ValueType)&,
00280 const PBORI_SHARED_PTR(ValueType)& ){
00281
00282 }
00283 END_NAMESPACE_PBORI
00284
00285 #else
00286
00287 BEGIN_NAMESPACE_PBORI
00296 template <class ValueType>
00297 class pbori_shared_ptr {
00298 public:
00299
00301 typedef ValueType value_type;
00302
00304 typedef pbori_shared_ptr<value_type> self;
00305
00308 pbori_shared_ptr(value_type* pRhs = NULL):
00309 pVal(pRhs), is_shared(pRhs == NULL) {}
00310
00312 pbori_shared_ptr(const self& rhs):
00313 pVal(rhs.pVal), is_shared(true) {}
00314
00316 ~pbori_shared_ptr(){ if (!is_shared) delete pVal; }
00317
00319 self& operator=(const self& rhs) {
00320 pVal = rhs.pVal; is_shared = true;
00321 return *this;
00322 }
00323
00325
00326 value_type* operator->(){ return pVal; }
00327 const value_type* operator->() const { return pVal; }
00328 value_type& operator*(){ return *pVal; }
00329 const value_type& operator*() const { return *pVal; }
00330 bool operator==(const self& rhs) const { return (pVal==rhs.pVal); }
00331 operator bool() const { return pVal != NULL; }
00333
00335 bool unique() const { return !is_shared; }
00336
00337 protected:
00339 value_type* pVal;
00340
00342 bool is_shared;
00343 };
00344 END_NAMESPACE_PBORI
00345
00346 # define PBORI_SHARED_PTR(Type) PBORI::pbori_shared_ptr<Type>
00347
00348 BEGIN_NAMESPACE_PBORI
00349
00350 template <class ValueType>
00351 void
00352 pbori_shared_ptr_postclean( const PBORI_SHARED_PTR(ValueType)& lhs,
00353 PBORI_SHARED_PTR(ValueType)& rhs ){
00354 if( lhs.unique() && (lhs == rhs) )
00355 rhs = PBORI_SHARED_PTR(ValueType)();
00356 }
00357 END_NAMESPACE_PBORI
00358
00359
00360 #endif // of #ifndef PBORI_NO_BOOST_PTR
00361
00362
00363 BEGIN_NAMESPACE_PBORI
00364
00366 template <class DDType>
00367 class CDDInterface;
00368
00370 template <class ManType>
00371 class CDDManager;
00372
00378 struct COrderEnums {
00380 enum ordercodes {
00381 lp,
00382 dlex,
00383 dp_asc,
00384 block_dlex,
00385 block_dp_asc
00386 };
00387 };
00388
00394 struct CErrorEnums {
00396 enum errorcodes {
00397 alright = 0,
00398 failed,
00399 no_ring,
00400 invalid,
00401 out_of_bounds,
00402 io_error,
00403 monomial_zero,
00404 illegal_on_zero,
00405 division_by_zero,
00406 invalid_ite,
00407 not_implemented,
00408 matrix_size_exceeded,
00409
00410 last_error
00411 };
00412 };
00413
00419 struct CCompareEnums {
00421 enum comparecodes {
00422 less_than = -1,
00423 equality = 0,
00424 greater_than = +1,
00425 less_or_equal_max = 0,
00426 greater_or_equal_min = 0
00427 };
00428
00429 enum { max_idx = CUDD_MAXINDEX };
00430 };
00431
00436 struct CAuxTypes {
00437
00438
00439
00440
00442 typedef bool bool_type;
00443
00445 typedef unsigned int size_type;
00447 typedef int deg_type;
00448
00450 typedef int integer_type;
00451
00453 typedef int idx_type;
00454
00456 typedef std::size_t hash_type;
00457
00459 typedef unsigned int errornum_type;
00460
00462 typedef int comp_type;
00463
00465 typedef int ordercode_type;
00466
00468 typedef const char* errortext_type;
00469
00471 typedef PBORI_OSTREAM ostream_type;
00472
00474 typedef const char* vartext_type;
00475 };
00476
00477 class CCuddZDD;
00478 class CCuddInterface;
00479
00480
00489 struct CTypes:
00490 public COrderEnums, public CErrorEnums, public CCompareEnums,
00491 public CAuxTypes {
00492
00493
00494
00495
00497
00498 typedef COrderEnums orderenums_type;
00499 typedef CErrorEnums errorenums_type;
00500 typedef CCompareEnums compenums_type;
00501 typedef CAuxTypes auxtypes_type;
00503
00505 typedef CCuddZDD dd_base;
00506
00507
00509 typedef CDDInterface<dd_base> dd_type;
00510
00512 typedef ZDDvector ddvector_type;
00513
00515 typedef CCuddInterface manager_base;
00516
00518 typedef CDDManager<manager_base> manager_type;
00519
00521 typedef CDDManager<manager_base&> manager_reference;
00522
00524 typedef PBORI_SHARED_PTR(manager_type) manager_ptr;
00525
00527 static idx_type max_index() { return max_idx; }
00528 };
00529
00530 END_NAMESPACE_PBORI
00531
00532 #ifdef PBORI_DEVELOPER
00533 # define PBORI_NOT_IMPLEMENTED \
00534 throw PBORI::PBoRiError(PBORI::CTypes::not_implemented);
00535 #else
00536 # define PBORI_NOT_IMPLEMENTED
00537 #endif
00538
00539
00540 #if defined(PBORI_ADD_BY_ITE) || defined(PBORI_ADD_BY_OR) \
00541 || defined(PBORI_ADD_BY_UNION) || defined(PBORI_ADD_BY_EXTRA_XOR) \
00542 || defined(PBORI_ADD_BY_XOR)
00543 #else
00544 # define PBORI_ADD_BY_XOR
00545 #endif
00546
00547
00548
00549 #ifdef PBORI_ADD_BY_XOR
00550 # define PBORI_LOWLEVEL_XOR
00551 #endif
00552
00553
00554 #if defined(PBORI_USEDVARS_BY_IDX) || defined(PBORI_USEDVARS_BY_TRANSFORM) \
00555 || defined(PBORI_USEDVARS_HIGHLEVEL)|| defined(PBORI_USEDVARS_BY_SUPPORT)\
00556 || defined(PBORI_USEDVARS_EXTRA)
00557 #else
00558 # define PBORI_USEDVARS_BY_IDX
00559
00560 #endif
00561
00562 #endif // of #ifndef pbori_defs_h_