Merge branch 'hamed' into brian
[satune.git] / src / Encoders / elementencoding.h
1 #ifndef ELEMENTENCODING_H
2 #define ELEMENTENCODING_H
3 #include "classlist.h"
4 #include "naiveencoder.h"
5
6 enum ElementEncodingType {
7         ELEM_UNASSIGNED, ONEHOT, UNARY, BINARYINDEX, ONEHOTBINARY, BINARYVAL
8 };
9
10 typedef enum ElementEncodingType ElementEncodingType;
11
12 struct ElementEncoding {
13         ElementEncodingType type;
14         Element * element;
15         Constraint ** variables;/* List Variables Used To Encode Element */
16         uint64_t * encodingArray;       /* List the Variables in the appropriate order */
17         uint64_t * inUseArray;/* Bitmap to track variables in use */
18         uint encArraySize;
19         uint numVars;   /* Number of variables */
20 };
21
22 void initElementEncoding(ElementEncoding *This, Element *element);
23 void setElementEncodingType(ElementEncoding* This, ElementEncodingType type);
24 void deleteElementEncoding(ElementEncoding *This);
25 void allocEncodingArrayElement(ElementEncoding *This, uint size);
26 void allocInUseArrayElement(ElementEncoding *This, uint size);
27 static inline bool isinUseElement(ElementEncoding *This, uint offset) {
28         return (This->inUseArray[(offset>>6)] >> (offset & 63)) &0x1;
29 }
30
31 static inline void setInUseElement(ElementEncoding *This, uint offset) {
32         This->inUseArray[(offset>>6)] |= 1 << (offset & 63);
33 }
34
35 void generateBinaryIndexEncodingVars(SATEncoder* encode, ElementEncoding* This);
36 void generateElementEncodingVariables(SATEncoder* encoder, ElementEncoding* This);
37
38 #endif