All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
direction.h
Go to the documentation of this file.
1 #ifndef OSL_DIRECTION_H
2 #define OSL_DIRECTION_H
3 #include <cassert>
4 #include <iosfwd>
5 
6 namespace osl
7 {
8  enum Direction{
11  UL=0,
12  U=1,
13  UR=2,
14  L=3,
15  R=4,
16  DL=5,
17  D=6,
18  DR=7,
20  UUL=8,
21  UUR=9,
23  LONG_UL=10,
24  LONG_U=11,
25  LONG_UR=12,
26  LONG_L=13,
27  LONG_R=14,
28  LONG_DL=15,
29  LONG_D=16,
30  LONG_DR=17,
38  };
39 
40  inline bool isShort(Direction d){
41  return d<=SHORT_DIRECTION_MAX;
42  }
43 
44  inline bool isShort8(Direction d){
45  return d<=SHORT8_DIRECTION_MAX;
46  }
47 
48  inline bool isLong(Direction d){
49  return d>=LONG_DIRECTION_MIN;
50  }
51 
53  return static_cast<Direction>(7 - d);
54  }
55 
57  assert(isShort8(d) );
58  return inverseUnsafe(d);
59  }
60 
65  assert(isShort8(d) );
66  if(d<4) return d;
67  else return inverse(d);
68  }
74  if(d<4) return d;
75  else return inverseUnsafe(d);
76  }
77 
78  bool isValid(Direction d);
79 
81  assert(isLong(d));
82  return static_cast<Direction>(static_cast<int>(d)-LONG_UL);
83  }
84 
89  assert(isShort(d));
90  return static_cast<Direction>(static_cast<int>(d)+LONG_UL);
91  }
92 
93  inline int dirToMask(Direction dir){
94  return (1<<static_cast<int>(dir));
95  }
96 
97  std::ostream& operator<<(std::ostream& os,const Direction d);
98 }
99 #endif /* OSL_DIRECTION_H */
100 // ;;; Local Variables:
101 // ;;; mode:c++
102 // ;;; c-basic-offset:2
103 // ;;; End: