説明を見る。00001
00002
00003 #ifndef _MOBILITY_TABLE_H
00004 #define _MOBILITY_TABLE_H
00005 #include "osl/basic_type.h"
00006 #include "osl/simpleState.h"
00007 #include <cassert>
00008 #include <iosfwd>
00009
00010 namespace osl
00011 {
00012 namespace mobility
00013 {
00014 union V4 {
00015 unsigned int lv;
00016 CArray<unsigned char,4> uc;
00017 }
00018 #ifdef __GNUC__
00019 __attribute__((aligned(4)))
00020 #endif
00021 ;
00029 class MobilityContent
00030 {
00031 V4 v;
00032 public:
00033 MobilityContent() {
00034 clear();
00035 }
00036 void clear(){
00037 v.lv=0u;
00038 }
00039 const Square get(Direction d) const{
00040 return Square::makeDirect(v.uc[((unsigned int)d)>>1]);
00041 }
00042 void set(Direction d,Square pos){
00043 v.uc[((unsigned int)d)>>1]=static_cast<unsigned char>(pos.uintValue());
00044 }
00045 };
00046 std::ostream& operator<<(std::ostream& os,MobilityContent const& mc);
00047
00051 class MobilityTable
00052 {
00053 CArray<MobilityContent,8> table
00054 #ifdef __GNUC__
00055 __attribute__((aligned(16)))
00056 #endif
00057 ;
00058 public:
00059 MobilityTable(){}
00060 MobilityTable(SimpleState const& state);
00061 void set(Direction d,int num,Square pos){
00062 assert(0<=(int)d && (int)d<=7);
00063 return table[num-32].set(d,pos);
00064 }
00065 const Square get(Direction d,int num) const{
00066 assert(0<=(int)d && (int)d<=7);
00067 return table[num-32].get(d);
00068 }
00069 friend bool operator==(const MobilityTable& mt1,const MobilityTable& mt2);
00070 };
00071 std::ostream& operator<<(std::ostream& os,MobilityTable const& mt);
00072 bool operator==(const MobilityTable&,const MobilityTable&);
00073 }
00074 using mobility::MobilityTable;
00075 }
00076 #endif
00077
00078
00079
00080