traits.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_common_common_traits_h_
#define polybori_common_common_traits_h_
#include <set>
#include <vector>
// include basic definitions
#include <polybori/pbori_defs.h>
#include <polybori/common/tags.h>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/facilities/expand.hpp>
#include <boost/preprocessor/stringize.hpp>
BEGIN_NAMESPACE_PBORI
typedef PBORI_PREFIX(DdManager) DdManager;
template <class ValueType>
class pbori_traits {
public:
//-------------------------------------------------------------------------
// types for treatment of decision diagrams
//-------------------------------------------------------------------------
typedef ValueType value_type;
//-------------------------------------------------------------------------
// types for several purposes
//-------------------------------------------------------------------------
typedef typename value_type::bool_type bool_type;
typedef typename value_type::size_type size_type;
typedef typename value_type::integer_type integer_type;
typedef typename value_type::idx_type idx_type;
typedef typename value_type::comp_type comp_type;
typedef typename value_type::hash_type hash_type;
typedef typename value_type::ostream_type ostream_type;
typedef typename value_type::easy_equality_property easy_equality_property;
};
// Built-in types inherit global definitions
template <>
class pbori_traits<void>:
public CTypes, public equality_property<valid_tag> {
};
template <>
class pbori_traits<int>:
public CTypes, public equality_property<valid_tag> {
};
template <>
class pbori_traits<unsigned int>:
public CTypes, public equality_property<valid_tag> {
};
template <>
class pbori_traits<long int>:
public CTypes, public equality_property<valid_tag> {
};
template <class ValueType>
class pbori_traits< std::set<ValueType> >:
public CTypes, public equality_property<invalid_tag> {
};
template <class ValueType>
class pbori_traits< std::vector<ValueType> >:
public CTypes, public equality_property<invalid_tag> {
};
template <class FirstType, class SecondType>
class pbori_binary_traits;
template <class OnlyType>
class pbori_binary_traits<OnlyType, OnlyType> {
public:
typedef typename OnlyType::easy_equality_property easy_equality_property;
};
template <class FirstType, class SecondType>
class pbori_binary_traits:
public equality_property<invalid_tag>{
};
template <class MgrType>
struct manager_traits;
template <class CuddLike>
struct manager_traits {
typedef unsigned long large_size_type;
typedef long int refcount_type;
typedef CTypes::idx_type idx_type;
typedef CTypes::size_type size_type;
typedef DdNode* node_type;
typedef DdManager* mgrcore_type;
typedef node_type (*unary_int_function)(mgrcore_type, int);
typedef node_type (*void_function)(mgrcore_type);
typedef DD_CTFP binary_function;
typedef node_type (*binary_int_function)(mgrcore_type, node_type, int);
typedef
node_type (*ternary_function)(mgrcore_type, node_type, node_type, node_type);
typedef int (*int_unary_function)(mgrcore_type, node_type);
};
#define PB_DECLARE_CUDD_TYPES(fromspace) \
typedef fromspace::errorfunc_type errorfunc_type; \
typedef fromspace::large_size_type large_size_type; \
typedef fromspace::refcount_type refcount_type; \
typedef fromspace::node_type node_type; \
typedef fromspace::mgrcore_type mgrcore_type; \
typedef fromspace::unary_int_function unary_int_function; \
typedef fromspace::void_function void_function; \
typedef fromspace::binary_function binary_function; \
typedef fromspace::binary_int_function binary_int_function; \
typedef fromspace::ternary_function ternary_function; \
typedef fromspace::int_unary_function int_unary_function; \
typedef fromspace::size_type size_type;\
typedef fromspace::idx_type idx_type;
#define PB_BINARY_FUNC_CALL(count, funcname, arg_pair) \
BOOST_PP_EXPAND(funcname(BOOST_PP_SEQ_HEAD(arg_pair), \
BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_TAIL(arg_pair))))
template<unsigned ErrorNumber>
struct cudd_error_traits {
typedef const char* result_type;
result_type operator()() const;
};
#define PB_CUDD_ERROR_TRAITS(errcode, errstr) \
template<> inline cudd_error_traits<errcode>::result_type \
cudd_error_traits<errcode>::operator()() const { \
return BOOST_PP_STRINGIZE(errstr); }
BOOST_PP_SEQ_FOR_EACH( PB_BINARY_FUNC_CALL, PB_CUDD_ERROR_TRAITS,
((CUDD_MEMORY_OUT)(Out of memory.))
((CUDD_TOO_MANY_NODES)(Too many nodes.))
((CUDD_MAX_MEM_EXCEEDED)(Maximum memory exceeded.))
((CUDD_INVALID_ARG)(Invalid argument.))
((CUDD_INTERNAL_ERROR)(Internal error.))
((CUDD_NO_ERROR)(Unexpected error.))
)
#undef PB_CUDD_ERROR_TRAITS
END_NAMESPACE_PBORI
#endif
PBORI_PREFIX
#define PBORI_PREFIX(name)
Definition: prefix.h:27
END_NAMESPACE_PBORI
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
polybori::manager_traits
Definition: traits.h:134
polybori::manager_traits::mgrcore_type
DdManager * mgrcore_type
Definition: traits.h:146
BEGIN_NAMESPACE_PBORI
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
polybori::pbori_traits
This class contains property definitions to be used in polybori classes.
Definition: traits.h:41
polybori::manager_traits::idx_type
CTypes::idx_type idx_type
Definition: traits.h:142
polybori::pbori_traits::bool_type
value_type::bool_type bool_type
Type for standard true/false statements.
Definition: traits.h:54
std
polybori::equality_property
Definition: tags.h:66
polybori::pbori_traits::comp_type
value_type::comp_type comp_type
Type for comparisons.
Definition: traits.h:66
polybori::pbori_binary_traits< OnlyType, OnlyType >::easy_equality_property
OnlyType::easy_equality_property easy_equality_property
Definition: traits.h:122
polybori::manager_traits::binary_function
DD_CTFP binary_function
Definition: traits.h:151
polybori::pbori_traits::ostream_type
value_type::ostream_type ostream_type
Type for out-stream.
Definition: traits.h:72
polybori::pbori_traits::hash_type
value_type::hash_type hash_type
Type for hashing.
Definition: traits.h:69
polybori::manager_traits::node_type
DdNode * node_type
Definition: traits.h:145
polybori::pbori_traits::easy_equality_property
value_type::easy_equality_property easy_equality_property
The property whether the equality check is easy.
Definition: traits.h:75
pbori_defs.h
polybori::pbori_traits::value_type
ValueType value_type
Definition: traits.h:47
PB_BINARY_FUNC_CALL
#define PB_BINARY_FUNC_CALL(count, funcname, arg_pair)
Definition: traits.h:176
polybori::manager_traits::large_size_type
unsigned long large_size_type
Definition: traits.h:139
polybori::DdManager
pbori_DdManager DdManager
Definition: traits.h:33
polybori::manager_traits::refcount_type
long int refcount_type
Definition: traits.h:140
polybori::pbori_traits::idx_type
value_type::idx_type idx_type
Type for indices.
Definition: traits.h:63
polybori::CAuxTypes::idx_type
int idx_type
Type for indices.
Definition: pbori_defs.h:228
polybori::manager_traits::size_type
CTypes::size_type size_type
Definition: traits.h:143
polybori::groebner::idx_type
polybori::CTypes::idx_type idx_type
Definition: groebner_defs.h:44
tags.h
polybori::CAuxTypes::size_type
std::size_t size_type
Type for lengths, dimensions, etc.
Definition: pbori_defs.h:219
polybori::pbori_traits::size_type
value_type::size_type size_type
Type for lengths, dimensions, etc.
Definition: traits.h:57
PB_CUDD_ERROR_TRAITS
#define PB_CUDD_ERROR_TRAITS(errcode, errstr)
Definition: traits.h:190
polybori::cudd_error_traits
Definition: traits.h:181
polybori::CTypes
This struct contains type definitions to be used in library classes.
Definition: pbori_defs.h:269
polybori::pbori_traits::integer_type
value_type::integer_type integer_type
Type for integer numbers.
Definition: traits.h:60
polybori::pbori_binary_traits
This class contains property definitions related to two types to be used in polybori classes...
Definition: traits.h:117
polybori::cudd_error_traits::result_type
const char * result_type
Definition: traits.h:182