-
Notifications
You must be signed in to change notification settings - Fork 1
/
directions.h
113 lines (106 loc) · 3.51 KB
/
directions.h
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
104
105
106
107
108
109
110
111
112
113
//
// Created by ntrrgc on 25/01/16.
//
#ifndef RIGHT_WINDOW_CPP_DIRECTIONS_H
#define RIGHT_WINDOW_CPP_DIRECTIONS_H
#include "wm_abstract.h"
namespace rw {
class Direction {
public:
virtual int opposite_border(const Window * window) = 0;
virtual int agreeing_border(const Window * window) = 0;
virtual bool next_to(int a, int b) = 0;
virtual bool next_or_equal_to(int a, int b) = 0;
virtual bool prev_or_equal_to(int a, int b) = 0;
virtual tuple<int, int> perpendicular_range(const Window * window) = 0;
};
class Right : public Direction {
virtual int opposite_border(const Window * window) {
return window->left;
}
virtual int agreeing_border(const Window * window) {
return window->right;
}
virtual bool next_to(int a, int b) {
// a and b must be x coordinates
// a next (right) to b
return a > b;
}
virtual bool next_or_equal_to(int a, int b) {
return a >= b;
};
virtual bool prev_or_equal_to(int a, int b) {
return a <= b;
}
virtual tuple<int, int> perpendicular_range(const Window * window) {
return make_tuple(window->top, window->bottom);
};
};
class Left : public Direction {
virtual int opposite_border(const Window * window) {
return window->right;
}
virtual int agreeing_border(const Window * window) {
return window->left;
}
virtual bool next_to(int a, int b) {
// a and b must be x coordinates
// a next (left) to b
return a < b;
}
virtual bool next_or_equal_to(int a, int b) {
return a <= b;
};
virtual bool prev_or_equal_to(int a, int b) {
return a >= b;
}
virtual tuple<int, int> perpendicular_range(const Window * window) {
return make_tuple(window->top, window->bottom);
};
};
class Down : public Direction {
virtual int opposite_border(const Window * window) {
return window->top;
}
virtual int agreeing_border(const Window * window) {
return window->bottom;
}
virtual bool next_to(int a, int b) {
// a and b must be y coordinates
// a next (under) b
return a > b;
}
virtual bool next_or_equal_to(int a, int b) {
return a >= b;
};
virtual bool prev_or_equal_to(int a, int b) {
return a <= b;
}
virtual tuple<int, int> perpendicular_range(const Window * window) {
return make_tuple(window->left, window->right);
};
};
class Up : public Direction {
virtual int opposite_border(const Window * window) {
return window->bottom;
}
virtual int agreeing_border(const Window * window) {
return window->top;
}
virtual bool next_to(int a, int b) {
// a and b must be y coordinates
// a next (on top of) to b
return a < b;
}
virtual bool next_or_equal_to(int a, int b) {
return a <= b;
};
virtual bool prev_or_equal_to(int a, int b) {
return a >= b;
}
virtual tuple<int, int> perpendicular_range(const Window * window) {
return make_tuple(window->left, window->right);
};
};
}
#endif //RIGHT_WINDOW_CPP_DIRECTIONS_H