00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __DISASSEMBLER_NODE_H__
00022 #define __DISASSEMBLER_NODE_H__
00023
00024 #include "bt_assert.h"
00025
00026 #include <stdlib.h>
00027 #include <stdint.h>
00028
00029 class assembly_c;
00030
00049 class disassemblerNode_c {
00050
00051 private:
00052
00058 static const int16_t maxMove = 32767;
00059
00066 disassemblerNode_c * comefrom;
00067
00071 unsigned int piecenumber;
00072
00087 int16_t * dat;
00088
00095 unsigned int refcount;
00096
00107 unsigned int dir;
00108
00115 int amount;
00116
00124 mutable unsigned int hashValue;
00125
00133 unsigned int waylength;
00134
00135 public:
00136
00145 disassemblerNode_c(unsigned int pn, disassemblerNode_c * comf, int _dir, int _amount, int step = 1);
00146
00148 disassemblerNode_c(const assembly_c * assm);
00149
00151 disassemblerNode_c(unsigned int pn);
00152
00153 ~disassemblerNode_c();
00154
00167 void replaceNode(const disassemblerNode_c *n);
00168
00175 bool decRefCount(void) {
00176 bt_assert(refcount > 0);
00177 refcount--;
00178 return refcount == 0;
00179 }
00180
00184 void incRefCount(void) {
00185 refcount++;
00186 }
00187
00195 unsigned int hash(void) const;
00196
00205 bool operator == (const disassemblerNode_c &b) const;
00206
00208 int getX(unsigned int i) const {
00209 bt_assert(i < piecenumber);
00210 return dat[4*i+0];
00211 }
00212
00214 int getY(unsigned int i) const {
00215 bt_assert(i < piecenumber);
00216 return dat[4*i+1];
00217 }
00218
00220 int getZ(unsigned int i) const {
00221 bt_assert(i < piecenumber);
00222 return dat[4*i+2];
00223 }
00224
00226 unsigned int getTrans(unsigned int i) const {
00227 bt_assert(i < piecenumber);
00228 return (unsigned char)dat[4*i+3];
00229 }
00230
00232 unsigned int getPiecenumber(void) const {
00233 return piecenumber;
00234 }
00235
00242 void setRemove(unsigned int i, int x, int y, int z) {
00243 bt_assert(i < piecenumber);
00244 bt_assert(abs(x) < maxMove && abs(y) < maxMove && abs(z) < maxMove);
00245
00246 dat[4*i+0] = x;
00247 dat[4*i+1] = y;
00248 dat[4*i+2] = z;
00249 dat[4*i+3] = (int16_t)0xFFFF;
00250 hashValue = 0;
00251 }
00252
00256 void set(unsigned int i, int x, int y, int z, unsigned int tr) {
00257 bt_assert(i < piecenumber);
00258 bt_assert(abs(x) < maxMove && abs(y) < maxMove && abs(z) < maxMove);
00259
00260 dat[4*i+0] = x;
00261 dat[4*i+1] = y;
00262 dat[4*i+2] = z;
00263 dat[4*i+3] = (int16_t)tr;
00264 hashValue = 0;
00265 }
00266
00270 void set(unsigned int i, int tx, int ty, int tz)
00271 {
00272 bt_assert(i < piecenumber);
00273 bt_assert(comefrom);
00274 bt_assert(abs(comefrom->dat[4*i+0]+tx) < maxMove &&
00275 abs(comefrom->dat[4*i+1]+ty) < maxMove &&
00276 abs(comefrom->dat[4*i+2]+tz) < maxMove);
00277
00278 dat[4*i+0] = comefrom->dat[4*i+0]+tx;
00279 dat[4*i+1] = comefrom->dat[4*i+1]+ty;
00280 dat[4*i+2] = comefrom->dat[4*i+2]+tz;
00281 dat[4*i+3] = comefrom->dat[4*i+3];
00282 hashValue = 0;
00283 }
00284
00288 bool is_piece_removed(unsigned int nr) const {
00289 bt_assert(nr < piecenumber);
00290 return (dat[4*nr+3] == (int16_t)0xFFFF);
00291 }
00292
00296 bool is_separation() const;
00297
00299 const disassemblerNode_c * getComefrom(void) const {
00300 return comefrom;
00301 }
00302
00304 int getAmount(void) const {
00305 return amount;
00306 }
00307
00309 unsigned int getDirection(void) const {
00310 return dir;
00311 }
00312
00314 unsigned int getWaylength(void) const {
00315 return waylength;
00316 }
00317
00325 disassemblerNode_c * next;
00326
00327 private:
00328
00329
00330 disassemblerNode_c(const disassemblerNode_c&);
00331 void operator=(const disassemblerNode_c&);
00332 };
00333
00334 #endif