All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mobility/mobilityTable.h
Go to the documentation of this file.
1 /* mobilityTable.h
2  */
3 #ifndef _MOBILITY_TABLE_H
4 #define _MOBILITY_TABLE_H
5 #include "osl/direction.h"
6 #include "osl/misc/carray.h"
8 #include <cassert>
9 #include <iosfwd>
10 
11 namespace osl
12 {
13  namespace mobility
14  {
15  union V4 {
16  unsigned int lv;
17  CArray<unsigned char,4> uc;
18  }
19 #ifdef __GNUC__
20  __attribute__((aligned(4)))
21 #endif
22  ;
31  {
32  V4 v;
33  public:
35  clear();
36  }
37  void clear(){
38  v.lv=0u;
39  }
40  const Square get(Direction d) const{
41  return Square::makeDirect(v.uc[((unsigned int)d)>>1]);
42  }
43  void set(Direction d,Square pos){
44  v.uc[((unsigned int)d)>>1]=static_cast<unsigned char>(pos.uintValue());
45  }
46  };
47  std::ostream& operator<<(std::ostream& os,MobilityContent const& mc);
48 
53  {
54  CArray<MobilityContent,8> table
55 #ifdef __GNUC__
56  __attribute__((aligned(16)))
57 #endif
58  ;
59  public:
61  MobilityTable(SimpleState const& state);
62  void set(Direction d,int num,Square pos){
63  assert(0<=(int)d && (int)d<=7);
64  return table[num-32].set(d,pos);
65  }
66  const Square get(Direction d,int num) const{
67  assert(0<=(int)d && (int)d<=7);
68  return table[num-32].get(d);
69  }
70  friend bool operator==(const MobilityTable& mt1,const MobilityTable& mt2);
71  };
72  std::ostream& operator<<(std::ostream& os,MobilityTable const& mt);
73  bool operator==(const MobilityTable&,const MobilityTable&);
74  }
75  using mobility::MobilityTable;
76 }
77 #endif /* _MOBILITY_TABLE_H */
78 // ;;; Local Variables:
79 // ;;; mode:c++
80 // ;;; c-basic-offset:2
81 // ;;; End: