DART  6.10.1
SpecializedNodeManager.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_SPECIALIZEDNODEMANAGER_HPP_
34 #define DART_DYNAMICS_SPECIALIZEDNODEMANAGER_HPP_
35 
36 #include "dart/common/Virtual.hpp"
39 
40 namespace dart {
41 namespace dynamics {
42 
43 class BodyNode;
44 class Skeleton;
45 
46 //==============================================================================
48 template <class... OtherSpecNodes>
50 {
51 };
52 
53 //==============================================================================
57 template <class SpecNode>
58 class BodyNodeSpecializedFor<SpecNode>
60 {
61 public:
64 
66  template <class NodeType>
67  std::size_t getNumNodes() const;
68 
70  template <class NodeType>
71  NodeType* getNode(std::size_t index);
72 
74  template <class NodeType>
75  const NodeType* getNode(std::size_t index) const;
76 
78  template <class NodeType>
79  static constexpr bool isSpecializedForNode();
80 
81 protected:
83  template <class NodeType>
84  std::size_t _getNumNodes(type<NodeType>) const;
85 
87  std::size_t _getNumNodes(type<SpecNode>) const;
88 
90  template <class NodeType>
91  NodeType* _getNode(type<NodeType>, std::size_t index);
92 
94  SpecNode* _getNode(type<SpecNode>, std::size_t index);
95 
97  template <class NodeType>
98  static constexpr bool _isSpecializedForNode(type<NodeType>);
99 
101  static constexpr bool _isSpecializedForNode(type<SpecNode>);
102 
105 };
107 
108 //==============================================================================
112 template <class SpecNode1, class... OtherSpecNodes>
113 class BodyNodeSpecializedFor<SpecNode1, OtherSpecNodes...>
115  common::Virtual<BodyNodeSpecializedFor<SpecNode1> >,
116  common::Virtual<BodyNodeSpecializedFor<OtherSpecNodes...> > >
117 {
118 };
119 
120 //==============================================================================
122 template <class... OtherSpecNodes>
124 {
125 };
126 
127 //==============================================================================
131 template <class SpecNode>
132 class SkeletonSpecializedFor<SpecNode>
133  : public virtual detail::BasicNodeManagerForSkeleton,
134  public virtual BodyNodeSpecializedFor<SpecNode>
135 {
136 public:
140 
142 
145  template <class NodeType>
146  std::size_t getNumNodes(std::size_t treeIndex) const;
147 
150  template <class NodeType>
151  NodeType* getNode(std::size_t treeIndex, std::size_t nodeIndex);
152 
155  template <class NodeType>
156  const NodeType* getNode(std::size_t treeIndex, std::size_t nodeIndex) const;
157 
159  template <class NodeType>
160  NodeType* getNode(const std::string& name);
161 
163  template <class NodeType>
164  const NodeType* getNode(const std::string& name) const;
165 
167  template <class T>
168  static constexpr bool isSpecializedForNode();
169 
170 protected:
172  template <class NodeType>
173  std::size_t _getNumNodes(type<NodeType>, std::size_t treeIndex) const;
174 
176  std::size_t _getNumNodes(type<SpecNode>, std::size_t treeIndex) const;
177 
179  template <class NodeType>
180  NodeType* _getNode(
181  type<NodeType>, std::size_t treeIndex, std::size_t nodeIndex);
182 
184  SpecNode* _getNode(
185  type<SpecNode>, std::size_t treeIndex, std::size_t nodeIndex);
186 
188  template <class NodeType>
189  NodeType* _getNode(type<NodeType>, const std::string& name);
190 
192  SpecNode* _getNode(type<SpecNode>, const std::string& name);
193 
195  template <class T>
196  static constexpr bool _isSpecializedForNode(type<T>);
197 
199  static constexpr bool _isSpecializedForNode(type<SpecNode>);
200 
203  std::vector<BasicNodeManagerForBodyNode::NodeMap::iterator>
205 
209 };
211 
212 //==============================================================================
216 template <class SpecNode1, class... OtherSpecNodes>
217 class SkeletonSpecializedFor<SpecNode1, OtherSpecNodes...>
219  common::Virtual<SkeletonSpecializedFor<SpecNode1> >,
220  common::Virtual<SkeletonSpecializedFor<OtherSpecNodes...> > >
221 {
222 };
223 
224 } // namespace dynamics
225 } // namespace dart
226 
228 
229 #endif // DART_DYNAMICS_SPECIALIZEDNODEMANAGER_HPP_
#define DART_DECLARE_CLASS_WITH_VIRTUAL_BASE_END
Definition: ClassWithVirtualBase.hpp:44
#define DART_DECLARE_CLASS_WITH_VIRTUAL_BASE_BEGIN
Definition: ClassWithVirtualBase.hpp:43
std::string * name
Definition: SkelParser.cpp:1697
std::size_t index
Definition: SkelParser.cpp:1672
BasicNodeManagerForBodyNode::NodeMap::iterator mSpecNodeIterator
Iterator that allows direct access to the specialized Nodes.
Definition: SpecializedNodeManager.hpp:104
Declaration of the variadic template.
Definition: SpecializedNodeManager.hpp:50
Declaration of the variadic template.
Definition: NodeManagerJoiner.hpp:47
Declaration of variadic template.
Definition: NodeManagerJoiner.hpp:117
std::vector< BasicNodeManagerForBodyNode::NodeMap::iterator > mTreeSpecNodeIterators
std::vector of iterators that allow direct access to the specialized Nodes of each tree
Definition: SpecializedNodeManager.hpp:204
static constexpr bool _isSpecializedForNode(type< T >)
Return false.
NodeNameMgrMap::iterator mSpecNodeNameMgrIterator
Iterator that gives direct access to the name manager of the specialized Nodes.
Definition: SpecializedNodeManager.hpp:208
Declaration of the variadic template.
Definition: SpecializedNodeManager.hpp:124
Definition: BasicNodeManager.hpp:50
Definition: BasicNodeManager.hpp:97
std::multimap< dart::dynamics::Shape *, SimpleFrameShapeDnD * >::iterator iterator
Definition: Viewer.cpp:620
Definition: BulletCollisionDetector.cpp:65