PolyBoRi
|
00001 // -*- c++ -*- 00002 //***************************************************************************** 00014 //***************************************************************************** 00015 00016 #include <set> 00017 #include <vector> 00018 00019 // include basic definitions 00020 #include "pbori_defs.h" 00021 #include "pbori_tags.h" 00022 // #include "CCuddInterface.h" 00023 00024 #include <boost/preprocessor/cat.hpp> 00025 #include <boost/preprocessor/seq/for_each.hpp> 00026 #include <boost/preprocessor/facilities/expand.hpp> 00027 #include <boost/preprocessor/stringize.hpp> 00028 00029 #ifndef pbori_traits_h_ 00030 #define pbori_traits_h_ 00031 00032 BEGIN_NAMESPACE_PBORI 00033 00039 template <class ValueType> 00040 class pbori_traits { 00041 00042 public: 00043 //------------------------------------------------------------------------- 00044 // types for treatment of decision diagrams 00045 //------------------------------------------------------------------------- 00046 typedef ValueType value_type; 00047 00048 //------------------------------------------------------------------------- 00049 // types for several purposes 00050 //------------------------------------------------------------------------- 00051 00053 typedef typename value_type::bool_type bool_type; 00054 00056 typedef typename value_type::size_type size_type; 00057 00059 typedef typename value_type::integer_type integer_type; 00060 00062 typedef typename value_type::idx_type idx_type; 00063 00065 typedef typename value_type::comp_type comp_type; 00066 00068 typedef typename value_type::hash_type hash_type; 00069 00071 typedef typename value_type::ostream_type ostream_type; 00072 00074 typedef typename value_type::easy_equality_property easy_equality_property; 00075 }; 00076 00077 // Built-in types inherit global definitions 00078 template <> 00079 class pbori_traits<void>: 00080 public CTypes, public equality_property<valid_tag> { 00081 }; 00082 00083 template <> 00084 class pbori_traits<int>: 00085 public CTypes, public equality_property<valid_tag> { 00086 }; 00087 00088 template <> 00089 class pbori_traits<unsigned int>: 00090 public CTypes, public equality_property<valid_tag> { 00091 }; 00092 00093 template <> 00094 class pbori_traits<long int>: 00095 public CTypes, public equality_property<valid_tag> { 00096 }; 00097 00098 00099 template <class ValueType> 00100 class pbori_traits< std::set<ValueType> >: 00101 public CTypes, public equality_property<invalid_tag> { 00102 }; 00103 00104 template <class ValueType> 00105 class pbori_traits< std::vector<ValueType> >: 00106 public CTypes, public equality_property<invalid_tag> { 00107 }; 00108 00109 00115 template <class FirstType, class SecondType> 00116 class pbori_binary_traits; 00117 00118 template <class OnlyType> 00119 class pbori_binary_traits<OnlyType, OnlyType> { 00120 public: 00121 typedef typename OnlyType::easy_equality_property easy_equality_property; 00122 }; 00123 00124 template <class FirstType, class SecondType> 00125 class pbori_binary_traits: 00126 public equality_property<invalid_tag>{ 00127 }; 00128 00129 00130 00131 00132 template <class MgrType> 00133 struct manager_traits; 00134 00135 template <class CuddLike> 00136 struct manager_traits { 00137 00138 typedef unsigned long large_size_type; 00139 typedef long int refcount_type; 00140 00141 typedef CTypes::idx_type idx_type; 00142 typedef CTypes::size_type size_type; 00143 00144 typedef DdNode* node_type; 00145 typedef DdManager* mgrcore_type; 00146 00147 typedef node_type (*unary_int_function)(mgrcore_type, int); 00148 typedef node_type (*void_function)(mgrcore_type); 00149 00150 typedef DD_CTFP binary_function; 00151 typedef node_type (*binary_int_function)(mgrcore_type, node_type, int); 00152 typedef 00153 node_type (*ternary_function)(mgrcore_type, node_type, node_type, node_type); 00154 00155 typedef int (*int_unary_function)(mgrcore_type, node_type); 00156 }; 00157 00158 00159 #define PB_DECLARE_CUDD_TYPES(fromspace) \ 00160 typedef fromspace::errorfunc_type errorfunc_type; \ 00161 typedef fromspace::large_size_type large_size_type; \ 00162 typedef fromspace::refcount_type refcount_type; \ 00163 typedef fromspace::node_type node_type; \ 00164 typedef fromspace::mgrcore_type mgrcore_type; \ 00165 typedef fromspace::unary_int_function unary_int_function; \ 00166 typedef fromspace::void_function void_function; \ 00167 typedef fromspace::binary_function binary_function; \ 00168 typedef fromspace::binary_int_function binary_int_function; \ 00169 typedef fromspace::ternary_function ternary_function; \ 00170 typedef fromspace::int_unary_function int_unary_function; \ 00171 typedef fromspace::size_type size_type;\ 00172 typedef fromspace::idx_type idx_type; 00173 00174 00175 #define PB_BINARY_FUNC_CALL(count, funcname, arg_pair) \ 00176 BOOST_PP_EXPAND(funcname(BOOST_PP_SEQ_HEAD(arg_pair), \ 00177 BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_TAIL(arg_pair)))) 00178 00179 template<unsigned ErrorNumber> 00180 struct cudd_error_traits { 00181 typedef const char* result_type; 00182 00183 result_type operator()() const; 00184 }; 00185 00186 00187 00188 00189 #define PB_CUDD_ERROR_TRAITS(errcode, errstr) \ 00190 template<> inline cudd_error_traits<errcode>::result_type \ 00191 cudd_error_traits<errcode>::operator()() const { \ 00192 return BOOST_PP_STRINGIZE(errstr); } 00193 00194 BOOST_PP_SEQ_FOR_EACH( PB_BINARY_FUNC_CALL, PB_CUDD_ERROR_TRAITS, 00195 ((CUDD_MEMORY_OUT)(Out of memory.)) 00196 ((CUDD_TOO_MANY_NODES)(Too many nodes.)) 00197 ((CUDD_MAX_MEM_EXCEEDED)(Maximum memory exceeded.)) 00198 ((CUDD_INVALID_ARG)(Invalid argument.)) 00199 ((CUDD_INTERNAL_ERROR)(Internal error.)) 00200 ((CUDD_NO_ERROR)(Unexpected error.)) 00201 ) 00202 00203 #undef PB_CUDD_ERROR_TRAITS 00204 00205 END_NAMESPACE_PBORI 00206 00207 #endif