PolyBoRi
pbori_defs.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
17 //*****************************************************************************
18 
19 #ifndef polybori_pbori_defs_h_
20 #define polybori_pbori_defs_h_
21 
22 #include <cstddef>
23 
24 #include <iostream>
25 
27 #include <polybori/cudd/cudd.h>
28 
29 #include "config.h"
30 
31 #ifndef PBORI_UNIQUE_SLOTS
32 # define PBORI_UNIQUE_SLOTS CUDD_UNIQUE_SLOTS // initial size of subtables
33 #endif
34 
35 #ifndef PBORI_CACHE_SLOTS
36 # define PBORI_CACHE_SLOTS CUDD_CACHE_SLOTS // default size of the cache
37 #endif
38 
39 #ifndef PBORI_MAX_MEMORY
40 # define PBORI_MAX_MEMORY 0 // target maximum memory occupation
41  // if PBORI_MAX_MEMORY == 0 then
42  // guess based on the available memory
43 #endif
44 
45 
47 #ifdef __GNUC__
48 #ifndef PBORI_LIKELY
49 #define PBORI_LIKELY(expression) (__builtin_expect(!!(expression), 1))
50 #endif
51 #ifndef PBORI_UNLIKELY
52 #define PBORI_UNLIKELY(expression) (__builtin_expect(!!(expression), 0))
53 #endif
54 #else
55 #ifndef PBORI_LIKELY
56 #define PBORI_LIKELY(expression) (expression)
57 #endif
58 #ifndef PBORI_UNLIKELY
59 #define PBORI_UNLIKELY(expression) (expression)
60 #endif
61 #endif
62 
64 #define PBORINAME polybori
65 
67 #ifndef PBORI_NO_DEVELOPER
68 # define PBORI_DEVELOPER
69 #endif
70 
71 #ifndef PBORI_NO_NAMESPACES
72 
74 # define BEGIN_NAMESPACE_PBORI namespace PBORINAME {
75 
77 # define END_NAMESPACE_PBORI } // end of namespace
78 
80 # define USING_NAMESPACE_PBORI using namespace PBORINAME;
81 
83 # define PBORI PBORINAME
84 
86 # define USING_PBORI using PBORI
87 
89 # define PBORI_BEGIN_NAMESPACE( sub_space ) namespace sub_space {
90 
92 # define PBORI_END_NAMESPACE }
93 
94 #else
95 
96 # define BEGIN_NAMESPACE_PBORI
97 # define END_NAMESPACE_PBORI
98 # define USING_NAMESPACE_PBORI
99 # define PBORI
100 # define USING_PBORI
101 # define PBORI_BEGIN_NAMESPACE( sub_space )
102 # define PBORI_END_NAMESPACE
103 
104 #endif // PBORI_NO_NAMESPACES
105 
107 #ifdef PBORI_DEBUG_TRACE
108 # include <iostream>
109 # define PBORI_TRACE_FUNC(text) std::cerr << text << std::endl;
110 #else
111 # define PBORI_TRACE_FUNC(text)
112 #endif
113 
114 // @todo force assertIon of PBORI_DEBUG
115 #if defined(PBORI_NDEBUG)
116 #define PBORI_ASSERT(arg) (static_cast<void>(0))
117 #else
118 #define PBORI_ASSERT(arg) assert(arg)
119 #endif
120 
122 #ifndef PBORI_NO_STDSTREAMS
123 
124 # include <iostream>
125 # define PBORI_OSTREAM std::ostream
126 
127 #else
128 
130 
132 struct PBORI_OSTREAM {};
133 
134 template <class StreamedType>
136 operator<<(PBORI_OSTREAM& dummy, const StreamedType&) {
137  return dummy;
138 };
140 
141 #endif // of #ifndef PBORI_NO_STDSTREAMS
142 
143 
145 
146 
152 struct COrderEnums {
154  enum ordercodes {
155  lp,
160  };
161 };
162 
168 struct CErrorEnums {
170  enum errorcodes {
171  alright = 0,
183 
184  last_error
185  };
186 };
187 
196  less_than = -1,
197  equality = 0,
198  greater_than = +1,
199  less_or_equal_max = 0,
200  greater_or_equal_min = 0
201  };
202 
203  enum { max_idx = CUDD_MAXINDEX };
204 };
205 
210 struct CAuxTypes {
211  //-------------------------------------------------------------------------
212  // types for several purposes
213  //-------------------------------------------------------------------------
214 
216  typedef bool bool_type;
217 
219  typedef std::size_t size_type;
220 
222  typedef int deg_type;
223 
225  typedef int integer_type;
226 
228  typedef int idx_type;
229 
231  typedef std::size_t hash_type;
232 
234  typedef unsigned int errornum_type;
235 
237  typedef short int comp_type;
238 
240  typedef int ordercode_type;
241 
243  typedef const char* errortext_type;
244 
247 
249  typedef const char* vartext_type;
250 
252  typedef unsigned long large_size_type;
253 
255  typedef std::size_t refcount_type;
256 };
257 
258 class BooleSet;
259 class BoolePolyRing;
260 
269 struct CTypes:
270  public COrderEnums, public CErrorEnums, public CCompareEnums,
271  public CAuxTypes {
272  //-------------------------------------------------------------------------
273  // types for treatment of decision diagrams
274  //-------------------------------------------------------------------------
275 
277 
283 
284 
286  // typedef BooleSet dd_type;
287 
288 
290  static idx_type max_index() { return max_idx; }
291 };
292 
294 
295 #ifdef PBORI_DEVELOPER
296 # define PBORI_NOT_IMPLEMENTED \
297  throw PBORI::PBoRiError(PBORI::CTypes::not_implemented);
298 #else
299 # define PBORI_NOT_IMPLEMENTED
300 #endif
301 
302 // Set default addition method
303 #if defined(PBORI_ADD_BY_ITE) || defined(PBORI_ADD_BY_OR) \
304  || defined(PBORI_ADD_BY_UNION) || defined(PBORI_ADD_BY_EXTRA_XOR) \
305  || defined(PBORI_ADD_BY_XOR)
306 #else
307 # define PBORI_ADD_BY_XOR
308 #endif
309 
310 
311 // Set default union-xor method
312 #ifdef PBORI_ADD_BY_XOR
313 # define PBORI_LOWLEVEL_XOR
314 #endif
315 
316 // Set default method for getting all used variables
317 #if defined(PBORI_USEDVARS_BY_IDX) || defined(PBORI_USEDVARS_BY_TRANSFORM) \
318  || defined(PBORI_USEDVARS_HIGHLEVEL)|| defined(PBORI_USEDVARS_BY_SUPPORT)\
319  || defined(PBORI_USEDVARS_EXTRA)
320 #else
321 # define PBORI_USEDVARS_BY_IDX
322 //PBORI_USEDVARS_EXTRA
323 #endif
324 
325 
326 #endif // of #ifndef polybori_pbori_defs_h_
const char * errortext_type
Type used to verbose error information.
Definition: pbori_defs.h:243
Definition: pbori_defs.h:180
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
ordercodes
Codes For orderings.
Definition: pbori_defs.h:154
Definition: pbori_defs.h:158
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
static idx_type max_index()
Type of interface to binary decicion diagrams.
Definition: pbori_defs.h:290
int deg_type
Type for polynomial degrees (ranges from -1 to maxint)
Definition: pbori_defs.h:222
This struct contains type definitions and enumerations to be used for order codes.
Definition: pbori_defs.h:152
short int comp_type
Type for comparisons.
Definition: pbori_defs.h:237
Definition: pbori_defs.h:172
#define PBORI_OSTREAM
Get output stream type.
Definition: pbori_defs.h:125
This class reinterprets decicion diagram managers as Boolean polynomial rings, adds an ordering and v...
Definition: BoolePolyRing.h:40
This struct contains auxiliary type definitions.
Definition: pbori_defs.h:210
std::ostream ostream_type
Type for out-stream.
Definition: pbori_defs.h:246
Definition: pbori_defs.h:175
Definition: pbori_defs.h:156
Definition: pbori_defs.h:181
int integer_type
Type for integer numbers.
Definition: pbori_defs.h:225
std::size_t hash_type
Type for hashing.
Definition: pbori_defs.h:231
Definition: pbori_defs.h:173
unsigned int errornum_type
Type used to store error codes.
Definition: pbori_defs.h:234
int idx_type
Type for indices.
Definition: pbori_defs.h:228
CErrorEnums errorenums_type
Definition: pbori_defs.h:279
This struct contains type definitions and enumerations to be used for error codes.
Definition: pbori_defs.h:168
errorcodes
Error codes enumeration.
Definition: pbori_defs.h:170
Definition: pbori_defs.h:157
COrderEnums orderenums_type
Definition: pbori_defs.h:278
CCompareEnums compenums_type
Definition: pbori_defs.h:280
comparecodes
Comparision codes enumeration.
Definition: pbori_defs.h:195
Definition: embed.h:61
Definition: pbori_defs.h:174
Definition: pbori_defs.h:176
const char * vartext_type
Type for setting/getting names of variables.
Definition: pbori_defs.h:249
CTypes::ostream_type & operator<<(CTypes::ostream_type &os, const BooleConstant &rhs)
Stream output operator.
Definition: BooleConstant.h:109
std::size_t size_type
Type for lengths, dimensions, etc.
Definition: pbori_defs.h:219
unsigned long large_size_type
large size_type (necessary?)
Definition: pbori_defs.h:252
Definition: pbori_defs.h:178
std::size_t refcount_type
Type for counting references.
Definition: pbori_defs.h:255
Definition: BooleSet.h:57
Definition: pbori_defs.h:179
Definition: pbori_defs.h:155
bool bool_type
Type for standard true/false statements.
Definition: pbori_defs.h:216
This struct contains type definitions to be used in library classes.
Definition: pbori_defs.h:269
Definition: pbori_defs.h:177
This struct contains type definitions and enumerations to be used for comparisons.
Definition: pbori_defs.h:193
int ordercode_type
Type for ordering codes.
Definition: pbori_defs.h:240
CAuxTypes auxtypes_type
Definition: pbori_defs.h:281