DART 6.10.1
Loading...
Searching...
No Matches
JointPtr.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2021, The DART development contributors
3 * All rights reserved.
4 *
5 * The list of contributors can be found at:
6 * https://github.com/dartsim/dart/blob/master/LICENSE
7 *
8 * This file is provided under the following "BSD-style" License:
9 * Redistribution and use in source and binary forms, with or
10 * without modification, are permitted provided that the following
11 * conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef DART_DYNAMICS_DETAIL_JOINTPTR_HPP_
34#define DART_DYNAMICS_DETAIL_JOINTPTR_HPP_
35
37
38namespace dart {
39namespace dynamics {
40
47template <class JointT, class BodyNodeT>
49{
50public:
51 template <class, class>
52 friend class TemplateJointPtr;
53
54 typedef JointT element_type;
55
57 TemplateJointPtr() = default;
58
61 TemplateJointPtr(JointT* _ptr)
62 {
63 set(_ptr);
64 }
65
67 template <class OtherJointT, class OtherBodyNodeT>
72
75 {
76 set(_ptr);
77 return *this;
78 }
79
81 template <class OtherJointT, class OtherBodyNodeT>
84 {
85 set(_jptr.get());
86 return *this;
87 }
88
90 operator JointT*() const
91 {
92 return get();
93 }
94
96 JointT& operator*() const
97 {
98 return *get();
99 }
100
102 JointT* operator->() const
103 {
104 return get();
105 }
106
108 JointT* get() const
109 {
110 if (nullptr == mBodyNodePtr)
111 return nullptr;
112
113 return mBodyNodePtr->getParentJoint();
114 }
115
121
123 void set(JointT* _ptr)
124 {
125 if (nullptr == _ptr)
126 {
127 mBodyNodePtr = nullptr;
128 return;
129 }
130
131 mBodyNodePtr = _ptr->getChildBodyNode();
132 }
133
134 //----------------------------------------------------------------------------
136 //----------------------------------------------------------------------------
137
139 template <class OtherJointT, class OtherBodyNodeT>
142 {
143 return mBodyNodePtr == _rhs.mBodyNodePtr;
144 }
145
147 template <class OtherJointT, class OtherBodyNodeT>
150 {
151 return !(*this == _rhs);
152 }
153
155 template <class OtherJointT, class OtherBodyNodeT>
158 {
159 return (mBodyNodePtr < _rhs.mBodyNodePtr);
160 }
161
163 template <class OtherJointT, class OtherBodyNodeT>
166 {
167 return (mBodyNodePtr > _rhs.mBodyNodePtr);
168 }
169
171 template <class OtherJointT, class OtherBodyNodeT>
174 {
175 return (*this < _rhs) || (*this == _rhs);
176 }
177
179 template <class OtherJointT, class OtherBodyNodeT>
182 {
183 return (*this > _rhs) || (*this == _rhs);
184 }
185
187
188private:
191};
192
198template <class JointT, class BodyNodeT>
200{
201public:
202 template <class, class>
204
207
211 {
212 set(_ptr);
213 }
214
216 template <class OtherJointT, class OtherBodyNodeT>
219 {
220 set(_weakPtr);
221 }
222
224 template <class OtherJointT, class OtherBodyNodeT>
227 {
228 set(_strongPtr.get());
229 }
230
233 {
234 set(_ptr);
235 return *this;
236 }
237
239 template <class OtherJointT, class OtherBodyNodeT>
242 {
243 set(_weakPtr);
244 return *this;
245 }
246
248 template <class OtherJointT, class OtherBodyNodeT>
251 {
252 set(_strongPtr.get());
253 return *this;
254 }
255
260 {
262 if (nullptr == bodyNode)
263 return nullptr;
264
265 return TemplateJointPtr<JointT, BodyNodeT>(bodyNode->getParentJoint());
266 }
267
269 void set(JointT* _ptr)
270 {
271 if (nullptr == _ptr)
272 {
273 mWeakBodyNode = nullptr;
274 return;
275 }
276
277 mWeakBodyNode = _ptr->getChildBodyNode();
278 }
279
281 template <class OtherJointT, class OtherBodyNodeT>
283 {
284 mWeakBodyNode = _weakPtr.mWeakBodyNode;
285 }
286
287private:
290};
291
292} // namespace dynamics
293} // namespace dart
294
295#endif // DART_DYNAMICS_DETAIL_JOINTPTR_HPP_
TemplateBodyNodePtr is a templated class that enables users to create a reference-counting BodyNodePt...
Definition BodyNodePtr.hpp:110
TemplateJointPtr is a templated class that enables users to create a strong reference-counting JointP...
Definition JointPtr.hpp:49
bool operator>=(const TemplateJointPtr< OtherJointT, OtherBodyNodeT > &_rhs) const
Greater than or equal to.
Definition JointPtr.hpp:180
TemplateJointPtr(JointT *_ptr)
Typical constructor.
Definition JointPtr.hpp:61
bool operator==(const TemplateJointPtr< OtherJointT, OtherBodyNodeT > &_rhs) const
Equality.
Definition JointPtr.hpp:140
TemplateJointPtr()=default
Default constructor.
bool operator<(const TemplateJointPtr< OtherJointT, OtherBodyNodeT > &_rhs) const
Less than.
Definition JointPtr.hpp:156
TemplateJointPtr & operator=(JointT *_ptr)
Assignment operator.
Definition JointPtr.hpp:74
void set(JointT *_ptr)
Set the Joint for this JointPtr.
Definition JointPtr.hpp:123
bool operator<=(const TemplateJointPtr< OtherJointT, OtherBodyNodeT > &_rhs) const
Less than or equal to.
Definition JointPtr.hpp:172
TemplateBodyNodePtr< BodyNodeT > getBodyNodePtr() const
Get the BodyNode that this JointPtr is tied to.
Definition JointPtr.hpp:117
TemplateJointPtr(const TemplateJointPtr< OtherJointT, OtherBodyNodeT > &_jptr)
Constructor that takes in a strong JointPtr.
Definition JointPtr.hpp:68
JointT * operator->() const
Dereferencing operation.
Definition JointPtr.hpp:102
JointT & operator*() const
Dereferencing operator.
Definition JointPtr.hpp:96
bool operator>(const TemplateJointPtr< OtherJointT, OtherBodyNodeT > &_rhs) const
Greater than.
Definition JointPtr.hpp:164
JointT element_type
Definition JointPtr.hpp:54
TemplateJointPtr & operator=(const TemplateJointPtr< OtherJointT, OtherBodyNodeT > &_jptr)
Assignment operator for JointPtrs.
Definition JointPtr.hpp:82
JointT * get() const
Get the raw Joint pointer.
Definition JointPtr.hpp:108
TemplateBodyNodePtr< BodyNodeT > mBodyNodePtr
Reference-holding pointer to the child BodyNode of this Joint.
Definition JointPtr.hpp:190
bool operator!=(const TemplateJointPtr< OtherJointT, OtherBodyNodeT > &_rhs) const
Inequality.
Definition JointPtr.hpp:148
TemplateWeakBodyNodePtr is a templated class that enables users to create a non-reference-holding Wea...
Definition BodyNodePtr.hpp:224
TemplateWeakJointPtr is a templated class that enables users to create a non-reference-holding WeakJo...
Definition JointPtr.hpp:200
TemplateWeakJointPtr(const TemplateWeakJointPtr< OtherJointT, OtherBodyNodeT > &_weakPtr)
Constructor that takes in a WeakJointPtr.
Definition JointPtr.hpp:217
TemplateWeakJointPtr(JointT *_ptr)
Typical constructor.
Definition JointPtr.hpp:210
void set(JointT *_ptr)
Set the Joint for this WeakJointPtr.
Definition JointPtr.hpp:269
TemplateWeakJointPtr & operator=(JointT *_ptr)
Assignment operator for raw Joint pointers.
Definition JointPtr.hpp:232
TemplateWeakJointPtr & operator=(const TemplateJointPtr< OtherJointT, OtherBodyNodeT > &_strongPtr)
Assignment operator for strong JointPtrs.
Definition JointPtr.hpp:249
TemplateWeakJointPtr()=default
Default constructor.
void set(const TemplateWeakJointPtr< OtherJointT, OtherBodyNodeT > &_weakPtr)
Set the Joint for this WeakJointPtr based on another WeakJointPtr.
Definition JointPtr.hpp:282
TemplateWeakJointPtr(const TemplateJointPtr< OtherJointT, OtherBodyNodeT > &_strongPtr)
Constructor that takes in a strong JointPtr.
Definition JointPtr.hpp:225
TemplateWeakJointPtr & operator=(const TemplateWeakJointPtr< OtherJointT, OtherBodyNodeT > &_weakPtr)
Assignment operator for WeakJointPtrs.
Definition JointPtr.hpp:240
TemplateWeakBodyNodePtr< BodyNodeT > mWeakBodyNode
Weak poiner to the child BodyNode of this Joint.
Definition JointPtr.hpp:289
TemplateJointPtr< JointT, BodyNodeT > lock() const
Locks the Joint reference to ensure that the referenced Joint is currently still available.
Definition JointPtr.hpp:259
Definition BulletCollisionDetector.cpp:65