00001 #ifndef _DIRECTION_H
00002 #define _DIRECTION_H
00003 #include <cassert>
00004 #include <iosfwd>
00005
00006 namespace osl
00007 {
00008 enum Direction{
00009 UL=0,
00010 U=1,
00011 UR=2,
00012 L=3,
00013 R=4,
00014 DL=5,
00015 D=6,
00016 DR=7,
00017 UUL=8,
00018 UUR=9,
00019 LONG_UL=10,
00020 LONG_U=11,
00021 LONG_UR=12,
00022 LONG_L=13,
00023 LONG_R=14,
00024 LONG_DL=15,
00025 LONG_D=16,
00026 LONG_DR=17,
00027 DIRECTION_MIN=0,
00028 SHORT_DIRECTION_MAX=9,
00029 SHORT_DIRECTION_SIZE=10,
00030 DIRECTION_MAX=17,
00031 DIRECTION_SIZE=18
00032 };
00033
00034 inline bool isShort(Direction d){
00035 return d<LONG_UL;
00036 }
00037
00038 inline bool isLong(Direction d){
00039 return d>=LONG_UL;
00040 }
00041
00042 bool isValid(Direction d);
00043
00044 inline Direction longToShort(Direction d){
00045 assert(isLong(d));
00046 return static_cast<Direction>(static_cast<int>(d)-LONG_UL);
00047 }
00048
00052 inline Direction shortToLong(Direction d){
00053 assert(isShort(d));
00054 return static_cast<Direction>(static_cast<int>(d)+LONG_UL);
00055 }
00056
00057 inline int dirToMask(Direction dir){
00058 return (1<<static_cast<int>(dir));
00059 }
00060
00061 std::ostream& operator<<(std::ostream& os,const Direction d);
00062 }
00063 #endif
00064
00065
00066
00067