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