DART  6.7.3
SmartPointer.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2019, 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_SMARTPOINTER_HPP_
34 #define DART_DYNAMICS_SMARTPOINTER_HPP_
35 
42 
43 // This file is a lightweight means of providing the smart pointers which are
44 // commonly used within the dart::dynamics namespace. It is 'lightweight' in the
45 // sense that it does not depend on any types being fully defined, making this
46 // header suitable for inclusion in other headers which might only want access
47 // to the smart pointers without needing fully defined classes.
48 
49 namespace dart {
50 namespace dynamics {
51 
54 
56 
57 //-----------------------------------------------------------------------------
58 // Skeleton Smart Pointers
59 //-----------------------------------------------------------------------------
61 // These pointers will take the form of:
62 // std::shared_ptr<Skeleton> --> SkeletonPtr
63 // std::shared_ptr<const Skeleton> --> ConstSkeletonPtr
64 // std::weak_ptr<Skeleton> --> WeakSkeletonPtr
65 // std::weak_ptr<const Skeleton> --> WeakConstSkeletonPtr
66 
67 // MetaSkeleton smart pointers
69 
70 // ReferentialSkeleton smart pointers
72 
77 
78 //-----------------------------------------------------------------------------
79 // Shape Smart Pointers
80 //-----------------------------------------------------------------------------
90 
91 //-----------------------------------------------------------------------------
92 // BodyNode Smart Pointers
93 //-----------------------------------------------------------------------------
94 #define DART_DYNAMICS_MAKE_BODYNODEPTR(X) \
95  class X; \
96  using X##Ptr = TemplateBodyNodePtr<X>; \
97  using Const##X##Ptr = TemplateBodyNodePtr<const X>; \
98  using Weak##X##Ptr = TemplateWeakBodyNodePtr<X>; \
99  using WeakConst##X##Ptr = TemplateWeakBodyNodePtr<const X>;
100 
101 // BodyNode smart pointers
103 // These pointers will take the form of:
104 // TemplateBodyNodePtr<BodyNode> --> BodyNodePtr
105 // TemplateBodyNodePtr<const BodyNode> --> ConstBodyNodePtr
106 // TemplateWeakBodyNodePtr<BodyNode> --> WeakBodyNodePtr
107 // TemplateWeakBodyNodePtr<const BodyNode> --> WeakConstBodyNodePtr
108 
109 // SoftBodyNode smart pointers
111 
112 //-----------------------------------------------------------------------------
113 // BodyNode-dependent Smart Pointers
114 //-----------------------------------------------------------------------------
115 #define DART_DYNAMICS_MAKE_BN_DEPENDENT_PTR(X) \
116  class X; \
117  using X##Ptr = Template##X##Ptr<X, BodyNode>; \
118  using Const##X##Ptr = Template##X##Ptr<const X, const BodyNode>; \
119  using Weak##X##Ptr = TemplateWeak##X##Ptr<X, BodyNode>; \
120  using WeakConst##X##Ptr = TemplateWeak##X##Ptr<const X, const BodyNode>;
121 
122 // Joint smart pointers
124 // These pointers will take the form of:
125 // TemplateJointPtr<Joint> --> JointPtr
126 // TemplateJointPtr<const Joint> --> ConstJointPtr
127 // TemplateWeakJointPtr<Joint> --> WeakJointPtr
128 // TemplateWeakJointPtr<const Joint> --> WeakConstJointPtr
129 
130 // DegreeOfFreedom smart pointers
132 // These pointers will take the form of:
133 // TemplateDegreeOfFreedomPtr<DegreeOfFreedom> --> DegreeOfFreedomPtr
134 // TemplateDegreeOfFreedomPtr<const DegreeOfFreedom> --> ConstDegreeOfFreedomPtr
135 // TemplateWeakDegreeOfFreedomPtr<DegreeOfFreedom> --> WeakDegreeOfFreedomPtr
136 // TemplateWeakDegreeOfFreedomPtr<const DegreeOfFreedom>
137 // --> WeakConstDegreeOfFreedomPtr
138 
139 //-----------------------------------------------------------------------------
140 // Node Smart Pointers
141 //-----------------------------------------------------------------------------
142 #define DART_DYNAMICS_MAKE_NODEPTR(X) \
143  class X; \
144  using X##Ptr = TemplateNodePtr<X, BodyNode>; \
145  using Const##X##Ptr = TemplateNodePtr<const X, const BodyNode>; \
146  using Weak##X##Ptr = TemplateWeakNodePtr<X, BodyNode>; \
147  using WeakConst##X##Ptr = TemplateWeakNodePtr<const X, const BodyNode>;
148 
150 // These pointers will take the form of:
151 // TemplateNodePtr<Node> --> NodePtr
152 // TemplateNodePtr<const Node> --> ConstNodePtr
153 // TemplateWeakNodePtr<Node> --> WeakNodePtr
154 // TemplateWeakNodePtr<const Node> --> WeakConstNodePtr
155 
157 
159 // These pointers will take the form of:
160 // TemplateNodePtr<EndEffector> --> EndEffectorPtr
161 // TemplateNodePtr<const EndEffector> --> ConstEndEffectorPtr
162 // TemplateWeakNodePtr<EndEffector> --> WeakEndEffectorPtr
163 // TemplateWeakNodePtr<const EndEffector> --> WeakConstEndEffectorPtr
164 
166 
167 //-----------------------------------------------------------------------------
168 // InverseKinematics Smart Pointers
169 //-----------------------------------------------------------------------------
170 #define DART_DYNAMICS_MAKE_IK_PTR(X) \
171  class X; \
172  using X##Ptr = TemplateInverseKinematicsPtr<X, JacobianNodePtr>; \
173  using Const##X##Ptr \
174  = TemplateInverseKinematicsPtr<const X, ConstJacobianNodePtr>; \
175  using Weak##X##Ptr = TemplateWeakInverseKinematicsPtr<X, JacobianNodePtr>; \
176  using WeakConst##X##Ptr \
177  = TemplateWeakInverseKinematicsPtr<const X, ConstJacobianNodePtr>;
178 
180 
181 } // namespace dynamics
182 } // namespace dart
183 
184 #endif // DART_DYNAMICS_SMARTPOINTER_HPP_
Definition: ArrowShape.hpp:42
BodyNode class represents a single node of the skeleton.
Definition: BodyNode.hpp:78
Definition: BoxShape.hpp:42
Branch is a specialized type of Linkage that represents a complete subtree of a Skeleton.
Definition: Branch.hpp:45
Chain is a specialized type of Linkage that represents a single unbranching and fully connected seque...
Definition: Chain.hpp:47
Definition: CylinderShape.hpp:41
DegreeOfFreedom class is a proxy class for accessing single degrees of freedom (aka generalized coord...
Definition: DegreeOfFreedom.hpp:53
Definition: EllipsoidShape.hpp:42
Definition: EndEffector.hpp:84
Definition: Group.hpp:42
The InverseKinematics class provides a convenient way of setting up an IK optimization problem.
Definition: InverseKinematics.hpp:76
The JacobianNode class serves as a common interface for BodyNodes and EndEffectors to both be used as...
Definition: JacobianNode.hpp:54
class Joint
Definition: Joint.hpp:59
The LineSegmentShape facilitates creating graphs of line segments.
Definition: LineSegmentShape.hpp:46
A Linkage is a ReferentialSkeleton with the special property that all the BodyNodes included in it fo...
Definition: Linkage.hpp:54
Definition: MeshShape.hpp:53
MetaSkeleton is a pure abstract base class that provides a common interface for obtaining data (such ...
Definition: MetaSkeleton.hpp:62
Definition: Node.hpp:53
The Node class is a base class for BodyNode and any object that attaches to a BodyNode.
Definition: Node.hpp:84
PlaneShape represents infinite plane has normal and offset as properties.
Definition: PlaneShape.hpp:43
ReferentialSkeleton is a base class used to implement Linkage, Group, and other classes that are used...
Definition: ReferentialSkeleton.hpp:48
Definition: ShapeFrame.hpp:164
Definition: ShapeNode.hpp:49
Definition: Shape.hpp:53
The SimpleFrame class offers a user-friendly way of creating arbitrary Frames within the kinematic tr...
Definition: SimpleFrame.hpp:52
class Skeleton
Definition: Skeleton.hpp:59
SoftBodyNode represent a soft body that has one deformable skin.
Definition: SoftBodyNode.hpp:46
Definition: SoftMeshShape.hpp:47
#define DART_COMMON_DECLARE_SHARED_WEAK(X)
Definition: SmartPointer.hpp:41
#define DART_DYNAMICS_MAKE_NODEPTR(X)
Definition: SmartPointer.hpp:142
#define DART_DYNAMICS_MAKE_BN_DEPENDENT_PTR(X)
Definition: SmartPointer.hpp:115
#define DART_DYNAMICS_MAKE_IK_PTR(X)
Definition: SmartPointer.hpp:170
#define DART_DYNAMICS_MAKE_BODYNODEPTR(X)
Definition: SmartPointer.hpp:94
Definition: BulletCollisionDetector.cpp:63