Bug fix: typos
[satune.git] / src / Encoders / elementencoding.h
1 #ifndef ELEMENTENCODING_H
2 #define ELEMENTENCODING_H
3 #include "classlist.h"
4 #include "naiveencoder.h"
5 #include "constraint.h"
6
7 typedef enum ElemEnc {EENC_UNKNOWN, EENC_NONE, EENC_BOTH} ElemEnc;
8
9 class ElementEncoding {
10 public:
11         ElementEncoding(Element *element);
12         ElementEncodingType getElementEncodingType() {return type;}
13         ~ElementEncoding();
14         void setElementEncodingType(ElementEncodingType type);
15         void deleteElementEncoding();
16         void allocEncodingArrayElement(uint size);
17         void allocInUseArrayElement(uint size);
18         uint numEncodingVars() {return numVars;}
19         bool isinUseElement(uint offset) { return (inUseArray[(offset >> 6)] >> (offset & 63)) & 0x1;}
20         void setInUseElement(uint offset) {inUseArray[(offset >> 6)] |= ((uint64_t)1) << (offset & 63);}
21         void encodingArrayInitialization();
22         uint getSizeEncodingArray(uint setSize) {
23                 switch (type) {
24                 case BINARYINDEX:
25                         return NEXTPOW2(setSize);
26                 case ONEHOT:
27                 case UNARY:
28                         return setSize;
29                 default:
30                         ASSERT(0);
31                 }
32                 return -1;
33         }
34         void print();
35
36         ElementEncodingType type;
37         Element *element;
38         Edge *variables;/* List Variables Used To Encode Element */
39         union {
40                 struct {
41                         uint64_t *encodingArray;        /* List the Variables in the appropriate order */
42                         uint64_t *inUseArray;   /* Bitmap to track variables in use */
43                         Edge *edgeArray;
44                         Polarity *polarityArray;
45                         uint encArraySize;
46                         ElemEnc encoding;
47                 };
48                 struct {
49                         uint64_t offset;/* Value = offset + encoded number (interpretted according to isBinaryValSigned) */
50                         uint64_t low;   /* Lowest value to encode */
51                         uint64_t high;/* High value to encode.   If low > high, we assume wrap around to include 0. */
52                         uint numBits;
53                         bool isBinaryValSigned;
54                 };
55         };
56         uint numVars;   /* Number of variables */
57         CMEMALLOC;
58 };
59
60
61
62 #endif