DART  6.7.3
SpecializedNodeManager.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_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 //==============================================================================
54 template <class SpecNode>
55 class BodyNodeSpecializedFor<SpecNode> :
57 {
58 public:
59 
62 
64  template <class NodeType>
65  std::size_t getNumNodes() const;
66 
68  template <class NodeType>
69  NodeType* getNode(std::size_t index);
70 
72  template <class NodeType>
73  const NodeType* getNode(std::size_t index) const;
74 
76  template <class NodeType>
77  static constexpr bool isSpecializedForNode();
78 
79 protected:
80 
82  template <class NodeType>
83  std::size_t _getNumNodes(type<NodeType>) const;
84 
86  std::size_t _getNumNodes(type<SpecNode>) const;
87 
89  template <class NodeType>
90  NodeType* _getNode(type<NodeType>, std::size_t index);
91 
93  SpecNode* _getNode(type<SpecNode>, std::size_t index);
94 
96  template <class NodeType>
97  static constexpr bool _isSpecializedForNode(type<NodeType>);
98 
100  static constexpr bool _isSpecializedForNode(type<SpecNode>);
101 
104 
105 };
106 
107 //==============================================================================
111 template <class SpecNode1, class... OtherSpecNodes>
112 class BodyNodeSpecializedFor<SpecNode1, OtherSpecNodes...> :
114  common::Virtual< BodyNodeSpecializedFor<SpecNode1> >,
115  common::Virtual< BodyNodeSpecializedFor<OtherSpecNodes...> > > { };
116 
117 //==============================================================================
119 template <class... OtherSpecNodes>
121 
122 //==============================================================================
125 template <class SpecNode>
126 class SkeletonSpecializedFor<SpecNode> :
128  public virtual BodyNodeSpecializedFor<SpecNode>
129 {
130 public:
131 
135 
137 
140  template <class NodeType>
141  std::size_t getNumNodes(std::size_t treeIndex) const;
142 
145  template <class NodeType>
146  NodeType* getNode(std::size_t treeIndex, std::size_t nodeIndex);
147 
150  template <class NodeType>
151  const NodeType* getNode(std::size_t treeIndex, std::size_t nodeIndex) const;
152 
154  template <class NodeType>
155  NodeType* getNode(const std::string& name);
156 
158  template <class NodeType>
159  const NodeType* getNode(const std::string& name) const;
160 
162  template <class T>
163  static constexpr bool isSpecializedForNode();
164 
165 protected:
166 
168  template <class NodeType>
169  std::size_t _getNumNodes(type<NodeType>, std::size_t treeIndex) const;
170 
172  std::size_t _getNumNodes(type<SpecNode>, std::size_t treeIndex) const;
173 
175  template <class NodeType>
176  NodeType* _getNode(type<NodeType>, std::size_t treeIndex, std::size_t nodeIndex);
177 
179  SpecNode* _getNode(type<SpecNode>, std::size_t treeIndex, std::size_t nodeIndex);
180 
182  template <class NodeType>
183  NodeType* _getNode(type<NodeType>, const std::string& name);
184 
186  SpecNode* _getNode(type<SpecNode>, const std::string& name);
187 
189  template <class T>
190  static constexpr bool _isSpecializedForNode(type<T>);
191 
193  static constexpr bool _isSpecializedForNode(type<SpecNode>);
194 
197  std::vector<BasicNodeManagerForBodyNode::NodeMap::iterator> mTreeSpecNodeIterators;
198 
202 
203 };
204 
205 //==============================================================================
209 template <class SpecNode1, class... OtherSpecNodes>
210 class SkeletonSpecializedFor<SpecNode1, OtherSpecNodes...> :
212  common::Virtual< SkeletonSpecializedFor<SpecNode1> >,
213  common::Virtual< SkeletonSpecializedFor<OtherSpecNodes...> > > { };
214 
215 } // namespace dynamics
216 } // namespace dart
217 
219 
220 #endif // DART_DYNAMICS_SPECIALIZEDNODEMANAGER_HPP_
std::string * name
Definition: SkelParser.cpp:1642
std::size_t index
Definition: SkelParser.cpp:1617
BasicNodeManagerForBodyNode::NodeMap::iterator mSpecNodeIterator
Iterator that allows direct access to the specialized Nodes.
Definition: SpecializedNodeManager.hpp:103
Declaration of the variadic template.
Definition: SpecializedNodeManager.hpp:49
Declaration of the variadic template.
Definition: NodeManagerJoiner.hpp:46
Declaration of variadic template.
Definition: NodeManagerJoiner.hpp:114
std::vector< BasicNodeManagerForBodyNode::NodeMap::iterator > mTreeSpecNodeIterators
std::vector of iterators that allow direct access to the specialized Nodes of each tree
Definition: SpecializedNodeManager.hpp:197
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:201
Declaration of the variadic template.
Definition: SpecializedNodeManager.hpp:120
Definition: BasicNodeManager.hpp:49
Definition: BasicNodeManager.hpp:93
std::multimap< dart::dynamics::Shape *, SimpleFrameShapeDnD * >::iterator iterator
Definition: Viewer.cpp:622
Definition: BulletCollisionDetector.cpp:63