TypeJointVisitor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3  *
4  * This software is provided 'as-is', without any express or implied
5  * warranty. In no event will the authors be held liable for any damages
6  * arising from the use of this software.
7  *
8  * Permission is granted to anyone to use this software for any purpose,
9  * including commercial applications, and to alter it and redistribute it
10  * freely, subject to the following restrictions:
11  *
12  * 1. The origin of this software must not be misrepresented; you must not
13  * claim that you wrote the original software. If you use this software
14  * in a product, an acknowledgment in the product documentation would be
15  * appreciated but is not required.
16  * 2. Altered source versions must be plainly marked as such, and must not be
17  * misrepresented as being the original software.
18  * 3. This notice may not be removed or altered from any source distribution.
19  */
20 
21 #ifndef PLAYRHO_DYNAMICS_JOINTS_TYPEJOINTVISITOR_HPP
22 #define PLAYRHO_DYNAMICS_JOINTS_TYPEJOINTVISITOR_HPP
23 
27 
28 namespace playrho {
29 namespace d2 {
30 
34 {
35 public:
36 
37  void Visit(const RevoluteJoint& /*joint*/) override
38  {
39  m_type = JointType::Revolute;
40  }
41 
42  void Visit(RevoluteJoint& /*joint*/) override
43  {
44  m_type = JointType::Revolute;
45  m_writable = true;
46  }
47 
48  void Visit(const PrismaticJoint& /*joint*/) override
49  {
50  m_type = JointType::Prismatic;
51  }
52 
53  void Visit(PrismaticJoint& /*joint*/) override
54  {
55  m_type = JointType::Prismatic;
56  m_writable = true;
57  }
58 
59  void Visit(const DistanceJoint& /*joint*/) override
60  {
61  m_type = JointType::Distance;
62  }
63 
64  void Visit(DistanceJoint& /*joint*/) override
65  {
66  m_type = JointType::Distance;
67  m_writable = true;
68  }
69 
70  void Visit(const PulleyJoint& /*joint*/) override
71  {
72  m_type = JointType::Pulley;
73  }
74 
75  void Visit(PulleyJoint& /*joint*/) override
76  {
77  m_type = JointType::Pulley;
78  m_writable = true;
79  }
80 
81  void Visit(const TargetJoint& /*joint*/) override
82  {
83  m_type = JointType::Target;
84  }
85 
86  void Visit(TargetJoint& /*joint*/) override
87  {
88  m_type = JointType::Target;
89  m_writable = true;
90  }
91 
92  void Visit(const GearJoint& /*joint*/) override
93  {
94  m_type = JointType::Gear;
95  }
96 
97  void Visit(GearJoint& /*joint*/) override
98  {
99  m_type = JointType::Gear;
100  m_writable = true;
101  }
102 
103  void Visit(const WheelJoint& /*joint*/) override
104  {
105  m_type = JointType::Wheel;
106  }
107 
108  void Visit(WheelJoint& /*joint*/) override
109  {
110  m_type = JointType::Wheel;
111  m_writable = true;
112  }
113 
114  void Visit(const WeldJoint& /*joint*/) override
115  {
116  m_type = JointType::Weld;
117  }
118 
119  void Visit(WeldJoint& /*joint*/) override
120  {
121  m_type = JointType::Weld;
122  m_writable = true;
123  }
124 
125  void Visit(const FrictionJoint& /*joint*/) override
126  {
127  m_type = JointType::Friction;
128  }
129 
130  void Visit(FrictionJoint& /*joint*/) override
131  {
132  m_type = JointType::Friction;
133  m_writable = true;
134  }
135 
136  void Visit(const RopeJoint& /*joint*/) override
137  {
138  m_type = JointType::Rope;
139  }
140 
141  void Visit(RopeJoint& /*joint*/) override
142  {
143  m_type = JointType::Rope;
144  m_writable = true;
145  }
146 
147  void Visit(const MotorJoint& /*joint*/) override
148  {
149  m_type = JointType::Motor;
150  }
151 
152  void Visit(MotorJoint& /*joint*/) override
153  {
154  m_type = JointType::Motor;
155  m_writable = true;
156  }
157 
159  Optional<JointType> GetType() const noexcept
160  {
161  return m_type;
162  }
163 
165  bool GetWritable() const noexcept
166  {
167  return m_writable;
168  }
169 
170 private:
171  Optional<JointType> m_type;
172  bool m_writable = false;
173 };
174 
175 } // namespace d2
176 } // namespace playrho
177 
178 #endif // PLAYRHO_DYNAMICS_JOINTS_TYPEJOINTVISITOR_HPP