/usr/include/osl/direction.h is in libosl-dev 0.6.0-3.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | #ifndef OSL_DIRECTION_H
#define OSL_DIRECTION_H
#include <cassert>
#include <iosfwd>
namespace osl
{
enum Direction{
SHORT_DIRECTION_MIN=0,
SHORT8_DIRECTION_MIN=0,
UL=0,
U=1,
UR=2,
L=3,
R=4,
DL=5,
D=6,
DR=7,
SHORT8_DIRECTION_MAX=7,
UUL=8,
UUR=9,
LONG_DIRECTION_MIN=10,
LONG_UL=10,
LONG_U=11,
LONG_UR=12,
LONG_L=13,
LONG_R=14,
LONG_DL=15,
LONG_D=16,
LONG_DR=17,
LONG_DIRECTION_MAX=17,
DIRECTION_MIN=0,
SHORT_DIRECTION_MAX=9,
SHORT_DIRECTION_SIZE=10,
DIRECTION_MAX=17,
DIRECTION_INVALID_VALUE=18,
DIRECTION_SIZE=18
};
inline bool isShort(Direction d){
return d<=SHORT_DIRECTION_MAX;
}
inline bool isShort8(Direction d){
return d<=SHORT8_DIRECTION_MAX;
}
inline bool isLong(Direction d){
return d>=LONG_DIRECTION_MIN;
}
inline Direction inverseUnsafe(Direction d){
return static_cast<Direction>(7 - d);
}
inline Direction inverse(Direction d){
assert(isShort8(d) );
return inverseUnsafe(d);
}
/**
* 8方向について,primitiveな4方向を求める
*/
inline Direction primDir(Direction d){
assert(isShort8(d) );
if(d<4) return d;
else return inverse(d);
}
/**
* 8方向について,primitiveな4方向を求める
* dとしてknight, INVALIDなども来る
*/
inline Direction primDirUnsafe(Direction d){
if(d<4) return d;
else return inverseUnsafe(d);
}
bool isValid(Direction d);
inline Direction longToShort(Direction d){
assert(isLong(d));
return static_cast<Direction>(static_cast<int>(d)-LONG_UL);
}
/**
* 引数に longDirを与えてはいけない
*/
inline Direction shortToLong(Direction d){
assert(isShort(d));
return static_cast<Direction>(static_cast<int>(d)+LONG_UL);
}
inline int dirToMask(Direction dir){
return (1<<static_cast<int>(dir));
}
std::ostream& operator<<(std::ostream& os,const Direction d);
}
#endif /* OSL_DIRECTION_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|