00001 /* positionCompressor.h 00002 */ 00003 #ifndef _POSITIONCOMPRESSOR_H 00004 #define _POSITIONCOMPRESSOR_H 00005 00006 #include "osl/position.h" 00007 #include "osl/misc/carray.h" 00008 namespace osl 00009 { 00010 00015 struct PositionCompressor 00016 { 00017 private: 00019 static CArray<signed char, Position::SIZE> positionToIndex; 00020 public: 00021 class Initializer; 00022 friend class Initializer; 00023 00024 static int compress(Position pos) 00025 { 00026 const int result = positionToIndex[pos.index()]; 00027 assert(result >= 0); 00028 return result; 00029 } 00030 static Position 00031 #ifdef __GNUC__ 00032 __attribute__ ((noinline)) 00033 #endif 00034 melt(int index) 00035 { 00036 assert(0 <= index); 00037 assert(index < 82); 00038 if (index == 0) 00039 return Position::STAND(); 00040 --index; 00041 return Position(index/9+1, index%9+1); 00042 } 00043 }; 00044 00045 } // namespace osl 00046 00047 #endif /* _POSITIONCOMPRESSOR_H */ 00048 // ;;; Local Variables: 00049 // ;;; mode:c++ 00050 // ;;; c-basic-offset:2 00051 // ;;; End: