Include encoding for values
[satune.git] / src / Encoders / elementencoding.h
index 1af74beb9c92eb635e0a53c1a19b961c1a70ca09..61bdb3e88af8dfb783bcdf5c94f4b0e8ee213ded 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef ELEMENTENCODING_H
 #define ELEMENTENCODING_H
 #include "classlist.h"
+#include "naiveencoder.h"
+#include "constraint.h"
 
 enum ElementEncodingType {
        ELEM_UNASSIGNED, ONEHOT, UNARY, BINARYINDEX, ONEHOTBINARY, BINARYVAL
@@ -11,17 +13,31 @@ typedef enum ElementEncodingType ElementEncodingType;
 struct ElementEncoding {
        ElementEncodingType type;
        Element * element;
-       Constraint ** variables;/* List Variables Used To Encode Element */
-       uint64_t * encodingArray;       /* List the Variables in the appropriate order */
-       uint64_t * inUseArray;/* Bitmap to track variables in use */
+       Edge * variables;/* List Variables Used To Encode Element */
+       union {
+               struct {
+                       uint64_t * encodingArray;       /* List the Variables in the appropriate order */
+                       uint64_t * inUseArray;/* Bitmap to track variables in use */
+                       uint encArraySize;
+               };
+               struct {
+                       uint64_t offset;/* Value = offset + encoded number (interpretted according to isBinaryValSigned) */
+                       uint64_t low;/* Lowest value to encode */
+                       uint64_t high;/* High value to encode.   If low > high, we assume wrap around to include 0. */
+                       uint numBits;
+                       bool isBinaryValSigned;
+               };
+       };
        uint numVars;   /* Number of variables */
 };
 
 void initElementEncoding(ElementEncoding *This, Element *element);
+static inline ElementEncodingType getElementEncodingType(ElementEncoding * This) {return This->type;}
+void setElementEncodingType(ElementEncoding* This, ElementEncodingType type);
 void deleteElementEncoding(ElementEncoding *This);
-void baseBinaryIndexElementAssign(ElementEncoding *This);
 void allocEncodingArrayElement(ElementEncoding *This, uint size);
 void allocInUseArrayElement(ElementEncoding *This, uint size);
+static inline uint numEncodingVars(ElementEncoding *This) {return This->numVars;}
 
 static inline bool isinUseElement(ElementEncoding *This, uint offset) {
        return (This->inUseArray[(offset>>6)] >> (offset & 63)) &0x1;
@@ -30,4 +46,5 @@ static inline bool isinUseElement(ElementEncoding *This, uint offset) {
 static inline void setInUseElement(ElementEncoding *This, uint offset) {
        This->inUseArray[(offset>>6)] |= 1 << (offset & 63);
 }
+
 #endif