• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

pbori_defs.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //*****************************************************************************
00159 //*****************************************************************************
00160 
00161 # include <cstddef>
00162 
00163 // load cudd's c++ interface
00164 # include <cuddObj.hh>
00165 
00166 #ifndef pbori_defs_h_
00167 #define pbori_defs_h_
00168 
00170 #ifdef __GNUC__
00171 #define LIKELY(expression) (__builtin_expect(!!(expression), 1))
00172 #define UNLIKELY(expression) (__builtin_expect(!!(expression), 0))
00173 #else
00174 #define LIKELY(expression) (expression)
00175 #define UNLIKELY(expression) (expression)
00176 #endif 
00177 
00179 #define PBORINAME polybori
00180 
00182 #ifndef PBORI_NO_DEVELOPER
00183 #  define PBORI_DEVELOPER
00184 #endif
00185 
00186 #ifndef PBORI_NO_NAMESPACES
00187 
00189 #  define BEGIN_NAMESPACE_PBORI namespace PBORINAME {
00190 
00192 #  define END_NAMESPACE_PBORI } // end of namespace 
00193 
00195 #  define USING_NAMESPACE_PBORI using namespace PBORINAME;
00196 
00198 #  define PBORI PBORINAME
00199 
00201 #  define USING_PBORI using PBORI
00202 
00204 #  define PBORI_BEGIN_NAMESPACE( sub_space ) namespace sub_space {
00205 
00207 #  define PBORI_END_NAMESPACE }
00208 
00209 #else 
00210 
00211 #  define BEGIN_NAMESPACE_PBORI 
00212 #  define END_NAMESPACE_PBORI 
00213 #  define USING_NAMESPACE_PBORI 
00214 #  define PBORI 
00215 #  define USING_PBORI 
00216 #  define PBORI_BEGIN_NAMESPACE( sub_space ) 
00217 #  define PBORI_END_NAMESPACE 
00218 
00219 #endif // PBORI_NO_NAMESPACES
00220 
00222 #ifdef PBORI_DEBUG_TRACE
00223 # include <iostream>
00224 # define PBORI_TRACE_FUNC(text) std::cerr << text << std::endl;
00225 #else
00226 # define PBORI_TRACE_FUNC(text) 
00227 #endif
00228 
00230 #ifndef PBORI_NO_STDSTREAMS
00231 
00232 # include <iostream>
00233 # define PBORI_OSTREAM std::ostream
00234 
00235 #else
00236 
00237 BEGIN_NAMESPACE_PBORI
00238 
00240 struct PBORI_OSTREAM {};
00241 
00242 template <class StreamedType>
00243 PBORI_OSTREAM& 
00244 operator<<(PBORI_OSTREAM& dummy, const StreamedType&) {
00245   return dummy;
00246 };
00247 END_NAMESPACE_PBORI
00248 
00249 #endif // of #ifndef PBORI_NO_STDSTREAMS
00250 
00252 #ifndef PBORI_NO_BOOST_PTR
00253 
00254 # include <boost/shared_ptr.hpp>
00255 # define PBORI_SHARED_PTR(Type) boost::shared_ptr<Type>
00256 
00257 BEGIN_NAMESPACE_PBORI
00258 
00259 // Clean second pointer
00260 template <class ValueType>
00261 void
00262 pbori_shared_ptr_postclean( const PBORI_SHARED_PTR(ValueType)&, 
00263                             const PBORI_SHARED_PTR(ValueType)& ){
00264   // nothing needed for boost::shared_ptr
00265 }
00266 END_NAMESPACE_PBORI
00267 
00268 #else
00269 
00270 BEGIN_NAMESPACE_PBORI
00279 template <class ValueType>
00280 class pbori_shared_ptr {
00281 public:
00282 
00284   typedef ValueType value_type;
00285 
00287   typedef pbori_shared_ptr<value_type> self;
00288 
00291   pbori_shared_ptr(value_type* pRhs = NULL): 
00292     pVal(pRhs), is_shared(pRhs == NULL) {}
00293 
00295   pbori_shared_ptr(const self& rhs):
00296     pVal(rhs.pVal), is_shared(true) {}
00297 
00299   ~pbori_shared_ptr(){ if (!is_shared) delete pVal; }
00300 
00302   self& operator=(const self& rhs) {
00303     pVal = rhs.pVal; is_shared = true; 
00304     return *this;
00305   } 
00306 
00308 
00309   value_type* operator->(){ return pVal; }
00310   const value_type* operator->() const { return pVal; }
00311   value_type& operator*(){ return *pVal; }
00312   const value_type& operator*() const { return *pVal; }
00313   bool operator==(const self& rhs) const { return (pVal==rhs.pVal); }
00314   operator bool() const { return pVal != NULL; }
00316 
00318   bool unique() const { return !is_shared; }
00319 
00320 protected:
00322   value_type* pVal;
00323 
00325   bool is_shared;
00326 };
00327 END_NAMESPACE_PBORI
00328 
00329 # define PBORI_SHARED_PTR(Type) PBORI::pbori_shared_ptr<Type>
00330 
00331 BEGIN_NAMESPACE_PBORI
00332 // Clean second pointer
00333 template <class ValueType>
00334 void
00335 pbori_shared_ptr_postclean( const PBORI_SHARED_PTR(ValueType)& lhs, 
00336                             PBORI_SHARED_PTR(ValueType)& rhs ){
00337   if( lhs.unique() && (lhs == rhs) )
00338     rhs = PBORI_SHARED_PTR(ValueType)();
00339 }
00340 END_NAMESPACE_PBORI
00341 
00342 
00343 #endif // of #ifndef PBORI_NO_BOOST_PTR
00344 
00345 
00346 BEGIN_NAMESPACE_PBORI
00347 
00349 template <class DDType>
00350 class CDDInterface;
00351 
00353 template <class ManType>
00354 class CDDManager;
00355 
00361 struct COrderEnums {
00363   enum ordercodes {
00364     lp,
00365     dlex,
00366     dp_asc,
00367     block_dlex,
00368     block_dp_asc
00369   };
00370 };
00371 
00377 struct CErrorEnums {
00379   enum errorcodes {
00380     alright = 0,
00381     failed,
00382     no_ring,
00383     invalid,
00384     out_of_bounds,
00385     io_error,
00386     monomial_zero,
00387     illegal_on_zero,
00388     division_by_zero,
00389     invalid_ite,
00390     not_implemented,
00391 
00392     last_error
00393   };
00394 };
00395 
00401 struct CCompareEnums {
00403   enum comparecodes {
00404     less_than = -1,
00405     equality = 0,
00406     greater_than = +1,
00407     less_or_equal_max = 0,
00408     greater_or_equal_min = 0
00409   };
00410 
00411   enum { max_idx = CUDD_MAXINDEX };
00412 };
00413 
00418 struct CAuxTypes {
00419   //-------------------------------------------------------------------------
00420   // types for several purposes
00421   //-------------------------------------------------------------------------
00422 
00424   typedef bool bool_type;
00425 
00427   typedef unsigned int size_type;
00428 
00430   typedef int integer_type;
00431 
00433   typedef int idx_type;
00434 
00436   typedef std::size_t hash_type;
00437 
00439   typedef unsigned int errornum_type;
00440 
00442   typedef int comp_type;
00443 
00445   typedef int ordercode_type;
00446 
00448   typedef const char* errortext_type;
00449 
00451   typedef PBORI_OSTREAM ostream_type;
00452 
00454   typedef const char* vartext_type;
00455 };
00456 
00457 class CCuddZDD;
00458 class CCuddInterface;
00459 
00460 
00469 struct CTypes: 
00470   public COrderEnums, public CErrorEnums, public CCompareEnums,
00471   public CAuxTypes {
00472   //-------------------------------------------------------------------------
00473   // types for treatment of decision diagrams
00474   //-------------------------------------------------------------------------
00475 
00477 
00478   typedef COrderEnums orderenums_type;
00479   typedef CErrorEnums errorenums_type;
00480   typedef CCompareEnums compenums_type;
00481   typedef CAuxTypes auxtypes_type;
00483 
00485   typedef CCuddZDD dd_base;
00486   //  typedef ZDD dd_base;
00487 
00489   typedef CDDInterface<dd_base> dd_type;
00490 
00492   typedef ZDDvector ddvector_type;
00493 
00495   typedef CCuddInterface manager_base;
00496 
00498   typedef CDDManager<manager_base> manager_type;
00499 
00501   typedef CDDManager<manager_base&>  manager_reference;
00502   
00504   typedef PBORI_SHARED_PTR(manager_type) manager_ptr;
00505 
00507   static idx_type max_index() { return CCompareEnums::max_idx; }
00508 };
00509 
00510 END_NAMESPACE_PBORI
00511 
00512 #ifdef PBORI_DEVELOPER
00513 # define PBORI_NOT_IMPLEMENTED \
00514   throw PBORI::PBoRiError(PBORI::CTypes::not_implemented);
00515 #else
00516 # define PBORI_NOT_IMPLEMENTED 
00517 #endif
00518 
00519 // Set default addition method
00520 #if defined(PBORI_ADD_BY_ITE) || defined(PBORI_ADD_BY_OR) \
00521     || defined(PBORI_ADD_BY_UNION) || defined(PBORI_ADD_BY_EXTRA_XOR) \
00522     || defined(PBORI_ADD_BY_XOR)
00523 #else
00524 # define PBORI_ADD_BY_XOR
00525 #endif 
00526 
00527 
00528 // Set default union-xor method
00529 #ifdef PBORI_ADD_BY_XOR
00530 # define PBORI_LOWLEVEL_XOR 
00531 #endif 
00532 
00533 // Set default method for getting all used variables
00534 #if defined(PBORI_USEDVARS_BY_IDX) || defined(PBORI_USEDVARS_BY_TRANSFORM) \
00535   || defined(PBORI_USEDVARS_HIGHLEVEL)|| defined(PBORI_USEDVARS_BY_SUPPORT)\
00536   || defined(PBORI_USEDVARS_EXTRA)
00537 #else
00538 # define PBORI_USEDVARS_BY_IDX
00539 //PBORI_USEDVARS_EXTRA
00540 #endif 
00541 
00542 #endif // of #ifndef pbori_defs_h_

Generated on Thu Oct 21 2010 02:56:33 for PolyBoRi by  doxygen 1.7.1