Void Sentry
An AI-driven, real-time Sentry Turret platform leveraging asynchronous I/O and computer vision to deliver high-precision autonomous motion tracking on resource-constrained embedded hardware.
Loading...
Searching...
No Matches
move_types.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <stdint.h>
11
16enum class MoveXValue : uint8_t {
17 None = 0,
18 Right = 1,
19 Left = 2
20};
21
26enum class MoveYValue : uint8_t {
27 None = 0,
28 Up = 1,
29 Down = 2
30};
31
37template <typename EnumType> class MoveDirection
38{
39public:
44 constexpr MoveDirection(EnumType v) : _value(v) {}
45
47 bool is_none() const { return static_cast<uint8_t>(_value) == 0; }
48
50 operator uint8_t() const { return static_cast<uint8_t>(_value); }
51
53 bool operator==(EnumType v) const { return _value == v; }
54
56 bool operator!=(EnumType v) const { return _value != v; }
57
58protected:
59 EnumType _value;
60};
61
66class MoveX : public MoveDirection<MoveXValue>
67{
68public:
70 static constexpr MoveXValue None = MoveXValue::None;
74 static constexpr MoveXValue Left = MoveXValue::Left;
75
78
81
86 const char* to_string() const
87 {
88 switch (this->_value)
89 {
91 return "Right";
93 return "Left";
94 default:
95 return "None";
96 }
97 }
98};
99
104class MoveY : public MoveDirection<MoveYValue>
105{
106public:
108 static constexpr MoveYValue None = MoveYValue::None;
110 static constexpr MoveYValue Up = MoveYValue::Up;
112 static constexpr MoveYValue Down = MoveYValue::Down;
113
116
119
124 const char* to_string() const
125 {
126 switch (this->_value)
127 {
128 case MoveYValue::Up:
129 return "Up";
130 case MoveYValue::Down:
131 return "Down";
132 default:
133 return "None";
134 }
135 }
136};
Base template providing common logic for movement directions.
Definition move_types.h:38
EnumType _value
Definition move_types.h:59
bool operator==(EnumType v) const
Equality comparison with underlying enum.
Definition move_types.h:53
constexpr MoveDirection(EnumType v)
Construct a new Move Direction object.
Definition move_types.h:44
bool operator!=(EnumType v) const
Inequality comparison with underlying enum.
Definition move_types.h:56
bool is_none() const
Checks if the movement state is None (0).
Definition move_types.h:47
Encapsulates horizontal movement states and utility methods.
Definition move_types.h:67
static constexpr MoveXValue None
Local alias for None state.
Definition move_types.h:70
static constexpr MoveXValue Right
Local alias for Right state.
Definition move_types.h:72
constexpr MoveX()
Default constructor initializing to None.
Definition move_types.h:80
static constexpr MoveXValue Left
Local alias for Left state.
Definition move_types.h:74
const char * to_string() const
Converts the state to a human-readable string.
Definition move_types.h:86
Encapsulates vertical movement states and utility methods.
Definition move_types.h:105
static constexpr MoveYValue Up
Local alias for Up state.
Definition move_types.h:110
constexpr MoveY()
Default constructor initializing to None.
Definition move_types.h:118
const char * to_string() const
Converts the state to a human-readable string.
Definition move_types.h:124
static constexpr MoveYValue None
Local alias for None state.
Definition move_types.h:108
static constexpr MoveYValue Down
Local alias for Down state.
Definition move_types.h:112
MoveYValue
Raw underlying values for vertical movement.
Definition move_types.h:26
MoveXValue
Raw underlying values for horizontal movement.
Definition move_types.h:16