00001
00002
00054
00055
00056 #include <set>
00057 #include <vector>
00058
00059
00060 #include "pbori_defs.h"
00061 #include "pbori_tags.h"
00062
00063
00064 #include <boost/preprocessor/cat.hpp>
00065 #include <boost/preprocessor/seq/for_each.hpp>
00066 #include <boost/preprocessor/facilities/expand.hpp>
00067 #include <boost/preprocessor/stringize.hpp>
00068
00069 #ifndef pbori_traits_h_
00070 #define pbori_traits_h_
00071
00072 BEGIN_NAMESPACE_PBORI
00073
00079 template <class ValueType>
00080 class pbori_traits {
00081
00082 public:
00083
00084
00085
00086 typedef ValueType value_type;
00087
00089 typedef typename value_type::dd_type dd_type;
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00105 typedef typename value_type::bool_type bool_type;
00106
00108 typedef typename value_type::size_type size_type;
00109
00111 typedef typename value_type::integer_type integer_type;
00112
00114 typedef typename value_type::idx_type idx_type;
00115
00117 typedef typename value_type::comp_type comp_type;
00118
00120 typedef typename value_type::hash_type hash_type;
00121
00123 typedef typename value_type::ostream_type ostream_type;
00124
00126 typedef typename value_type::easy_equality_property easy_equality_property;
00127 };
00128
00129
00130 template <>
00131 class pbori_traits<void>:
00132 public CTypes, public equality_property<valid_tag> {
00133 };
00134
00135 template <>
00136 class pbori_traits<int>:
00137 public CTypes, public equality_property<valid_tag> {
00138 };
00139
00140 template <>
00141 class pbori_traits<unsigned int>:
00142 public CTypes, public equality_property<valid_tag> {
00143 };
00144
00145 template <>
00146 class pbori_traits<long int>:
00147 public CTypes, public equality_property<valid_tag> {
00148 };
00149
00150
00151 template <class ValueType>
00152 class pbori_traits< std::set<ValueType> >:
00153 public CTypes, public equality_property<invalid_tag> {
00154 };
00155
00156 template <class ValueType>
00157 class pbori_traits< std::vector<ValueType> >:
00158 public CTypes, public equality_property<invalid_tag> {
00159 };
00160
00161
00167 template <class FirstType, class SecondType>
00168 class pbori_binary_traits;
00169
00170 template <class OnlyType>
00171 class pbori_binary_traits<OnlyType, OnlyType> {
00172 public:
00173 typedef typename OnlyType::easy_equality_property easy_equality_property;
00174 };
00175
00176 template <class FirstType, class SecondType>
00177 class pbori_binary_traits:
00178 public equality_property<invalid_tag>{
00179 };
00180
00181
00182
00183
00184 template <class MgrType>
00185 struct manager_traits;
00186
00187 template <>
00188 struct manager_traits<Cudd> {
00189 typedef ZDD dd_base;
00190 typedef Cudd* core_type;
00191 typedef Cudd& tmp_ref;
00192 };
00193
00194 template <>
00195 struct manager_traits<Cudd*> :
00196 public manager_traits<Cudd> {
00197 };
00198
00199 template <>
00200 struct manager_traits<DdManager*> :
00201 public manager_traits<Cudd> {
00202 };
00203
00204 template <class CuddLike>
00205 struct manager_traits {
00206 typedef typename CuddLike::dd_type dd_base;
00207 typedef typename CuddLike::mgrcore_ptr core_type;
00208 typedef typename CuddLike::tmp_ref tmp_ref;
00209
00210 typedef unsigned long large_size_type;
00211 typedef long int refcount_type;
00212
00213 typedef CTypes::idx_type idx_type;
00214 typedef CTypes::size_type size_type;
00215
00216 typedef DdNode* node_type;
00217 typedef DdManager* mgrcore_type;
00218
00219 typedef PFC errorfunc_type;
00220 typedef node_type (*unary_int_function)(mgrcore_type, int);
00221 typedef node_type (*void_function)(mgrcore_type);
00222
00223 typedef DD_CTFP binary_function;
00224 typedef node_type (*binary_int_function)(mgrcore_type, node_type, int);
00225 typedef
00226 node_type (*ternary_function)(mgrcore_type, node_type, node_type, node_type);
00227
00228 typedef int (*int_unary_function)(mgrcore_type, node_type);
00229 };
00230
00231 template <class CuddLike>
00232 struct mgrcore_traits;
00233
00234 template<>
00235 struct mgrcore_traits<Cudd> {
00236
00237 typedef unsigned long large_size_type;
00238 typedef long int refcount_type;
00239
00240 typedef CTypes::idx_type idx_type;
00241 typedef CTypes::size_type size_type;
00242
00243 typedef DdNode* node_type;
00244 typedef DdManager* mgrcore_type;
00245
00246 typedef PFC errorfunc_type;
00247 typedef node_type (*unary_int_function)(mgrcore_type, int);
00248 typedef node_type (*void_function)(mgrcore_type);
00249
00250 typedef DD_CTFP binary_function;
00251 typedef node_type (*binary_int_function)(mgrcore_type, node_type, int);
00252 typedef
00253 node_type (*ternary_function)(mgrcore_type, node_type, node_type, node_type);
00254
00255 typedef int (*int_unary_function)(mgrcore_type, node_type);
00256 };
00257
00258 #define PB_DECLARE_CUDD_TYPES(fromspace) \
00259 typedef fromspace::errorfunc_type errorfunc_type; \
00260 typedef fromspace::large_size_type large_size_type; \
00261 typedef fromspace::refcount_type refcount_type; \
00262 typedef fromspace::node_type node_type; \
00263 typedef fromspace::mgrcore_type mgrcore_type; \
00264 typedef fromspace::unary_int_function unary_int_function; \
00265 typedef fromspace::void_function void_function; \
00266 typedef fromspace::binary_function binary_function; \
00267 typedef fromspace::binary_int_function binary_int_function; \
00268 typedef fromspace::ternary_function ternary_function; \
00269 typedef fromspace::int_unary_function int_unary_function; \
00270 typedef fromspace::size_type size_type;\
00271 typedef fromspace::idx_type idx_type;
00272
00273
00274
00275
00276
00277
00278
00279 template <class ZDDType>
00280 struct zdd_traits;
00281
00282 template <>
00283 struct zdd_traits<ZDD> {
00284 typedef Cudd manager_base;
00285 };
00286
00287 template <>
00288 struct zdd_traits<CCuddZDD> {
00289 typedef CCuddInterface manager_base;
00290 };
00291
00292
00293 #define PB_BINARY_FUNC_CALL(count, funcname, arg_pair) \
00294 BOOST_PP_EXPAND(funcname(BOOST_PP_SEQ_HEAD(arg_pair), \
00295 BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_TAIL(arg_pair))))
00296
00297 template<unsigned ErrorNumber>
00298 struct cudd_error_traits {
00299 typedef const char* result_type;
00300
00301 result_type operator()() const;
00302 };
00303
00304
00305
00306
00307 #define PB_CUDD_ERROR_TRAITS(errcode, errstr) \
00308 template<> inline cudd_error_traits<errcode>::result_type \
00309 cudd_error_traits<errcode>::operator()() const { \
00310 return BOOST_PP_STRINGIZE(errstr); }
00311
00312 BOOST_PP_SEQ_FOR_EACH( PB_BINARY_FUNC_CALL, PB_CUDD_ERROR_TRAITS,
00313 ((CUDD_MEMORY_OUT)(Out of memory.))
00314 ((CUDD_TOO_MANY_NODES)(Too many nodes.))
00315 ((CUDD_MAX_MEM_EXCEEDED)(Maximum memory exceeded.))
00316 ((CUDD_INVALID_ARG)(Invalid argument.))
00317 ((CUDD_INTERNAL_ERROR)(Internal error.))
00318 ((CUDD_NO_ERROR)(Unexpected error.))
00319 )
00320
00321 #undef PB_CUDD_ERROR_TRAITS
00322
00323 END_NAMESPACE_PBORI
00324
00325 #endif