HoverRace  2.0
Nav.h
Go to the documentation of this file.
1 
2 // Nav.h
3 //
4 // Copyright (c) 2015 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
25 # ifdef MR_ENGINE
26 # define MR_DllDeclare __declspec( dllexport )
27 # else
28 # define MR_DllDeclare __declspec( dllimport )
29 # endif
30 #else
31 # define MR_DllDeclare
32 #endif
33 
34 namespace HoverRace {
35 namespace Control {
36 
46 {
47 public:
48  enum dir_t { NEUTRAL, UP, DOWN, LEFT, RIGHT, NEXT, PREV };
49 
50 public:
51  constexpr Nav(dir_t dir = NEUTRAL) noexcept : dir(dir) { }
52  constexpr Nav(const Nav&) noexcept = default;
53  constexpr Nav(Nav&&) noexcept = default;
54 
55  Nav &operator=(const Nav&) noexcept = default;
56  Nav &operator=(Nav&&) noexcept = default;
57 
58 public:
63  constexpr dir_t AsDigital() const noexcept { return dir; }
64 
65 private:
67 };
68 
69 inline std::ostream &operator<<(std::ostream &os, const Nav &nav)
70 {
71  switch (nav.AsDigital()) {
72  case Nav::NEUTRAL: os << "NEUTRAL"; break;
73  case Nav::UP: os << "UP"; break;
74  case Nav::DOWN: os << "DOWN"; break;
75  case Nav::LEFT: os << "LEFT"; break;
76  case Nav::RIGHT: os << "RIGHT"; break;
77  case Nav::NEXT: os << "NEXT"; break;
78  case Nav::PREV: os << "PREV"; break;
79  default: os << "Unknown(" << nav.AsDigital() << ")";
80  }
81  return os;
82 }
83 
84 } // namespace Control
85 } // namespace HoverRace
86 
87 #undef MR_DllDeclare
Definition: Nav.h:48
Definition: Nav.h:48
Definition: Nav.h:48
#define MR_DllDeclare
Definition: Nav.h:31
constexpr dir_t AsDigital() const noexcept
Converts this direction into one of the cardinal directions.
Definition: Nav.h:63
Definition: Nav.h:48
std::ostream & operator<<(std::ostream &os, const ControlAction< T > &action)
Definition: ControlAction.h:70
Definition: Nav.h:48
constexpr Nav(dir_t dir=NEUTRAL) noexcept
Definition: Nav.h:51
A navigation direction.
Definition: Nav.h:45
Definition: Action.h:59
Definition: Nav.h:48
Definition: Announcement.h:24
Definition: Action.h:61
dir_t dir
Definition: Nav.h:66
dir_t
Definition: Nav.h:48