Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
include
osl
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
{
9
SHORT_DIRECTION_MIN
=0,
10
SHORT8_DIRECTION_MIN
=0,
11
UL
=0,
12
U
=1,
13
UR
=2,
14
L
=3,
15
R
=4,
16
DL
=5,
17
D
=6,
18
DR
=7,
19
SHORT8_DIRECTION_MAX
=7,
20
UUL
=8,
21
UUR
=9,
22
LONG_DIRECTION_MIN
=10,
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,
31
LONG_DIRECTION_MAX
=17,
32
DIRECTION_MIN
=0,
33
SHORT_DIRECTION_MAX
=9,
34
SHORT_DIRECTION_SIZE
=10,
35
DIRECTION_MAX
=17,
36
DIRECTION_INVALID_VALUE
=18,
37
DIRECTION_SIZE
=18
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
52
inline
Direction
inverseUnsafe
(
Direction
d){
53
return
static_cast<
Direction
>
(7 - d);
54
}
55
56
inline
Direction
inverse
(
Direction
d){
57
assert(
isShort8
(d) );
58
return
inverseUnsafe
(d);
59
}
60
64
inline
Direction
primDir
(
Direction
d){
65
assert(
isShort8
(d) );
66
if
(d<4)
return
d;
67
else
return
inverse
(d);
68
}
73
inline
Direction
primDirUnsafe
(
Direction
d){
74
if
(d<4)
return
d;
75
else
return
inverseUnsafe
(d);
76
}
77
78
bool
isValid
(
Direction
d);
79
80
inline
Direction
longToShort
(
Direction
d){
81
assert(
isLong
(d));
82
return
static_cast<
Direction
>
(
static_cast<
int
>
(d)-
LONG_UL
);
83
}
84
88
inline
Direction
shortToLong
(
Direction
d){
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:
Generated on Sun Jul 21 2013 13:37:24 by
1.8.4