DART  6.10.1
AspectWithVersion.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_COMMON_ASPECTWITHVERSION_HPP_
34 #define DART_COMMON_ASPECTWITHVERSION_HPP_
35 
37 
38 namespace dart {
39 namespace common {
40 
41 //==============================================================================
42 template <
43  class DerivedT,
44  typename StateDataT,
45  class CompositeT = Composite,
46  void (*updateState)(DerivedT*) = &detail::NoOp<DerivedT*> >
49  DerivedT,
50  StateDataT,
51  CompositeT,
52  updateState>;
53 
54 //==============================================================================
55 template <
56  class DerivedT,
57  typename PropertiesDataT,
58  class CompositeT = Composite,
59  void (*updateProperties)(DerivedT*) = &detail::NoOp<DerivedT*> >
62  DerivedT,
63  PropertiesDataT,
64  CompositeT,
65  updateProperties>;
66 
67 //==============================================================================
68 template <
69  class DerivedT,
70  typename StateDataT,
71  typename PropertiesDataT,
72  class CompositeT = Composite,
73  void (*updateState)(DerivedT*) = &detail::NoOp<DerivedT*>,
74  void (*updateProperties)(DerivedT*) = updateState>
78  DerivedT,
79  PropertiesDataT,
80  CompositeT,
81  updateProperties>
82 {
83 public:
84  using Derived = DerivedT;
85  using StateData = StateDataT;
86  using PropertiesData = PropertiesDataT;
87  using CompositeType = CompositeT;
90  constexpr static void (*UpdateState)(Derived*) = updateState;
91  constexpr static void (*UpdateProperties)(Derived*) = updateProperties;
92 
95 
98  Derived,
101  updateProperties>;
102 
104  DerivedT,
105  StateDataT,
106  PropertiesDataT,
107  CompositeT,
108  updateState,
109  updateProperties>;
110 
113  = delete;
114 
117  const StateData& state = StateData(),
120  {
121  // Do nothing
122  }
123 
126  const PropertiesData& properties, const StateData& state = StateData())
128  {
129  // Do nothing
130  }
131 
132  // Documentation inherited
133  std::unique_ptr<Aspect> cloneAspect() const override
134  {
135  return std::make_unique<Derived>(this->getState(), this->getProperties());
136  }
137 };
138 
139 //==============================================================================
140 //
141 // These namespace-level definitions are required to enable ODR-use of static
142 // constexpr member variables.
143 //
144 // See this StackOverflow answer: http://stackoverflow.com/a/14396189/111426
145 //
146 template <
147  class DerivedT,
148  typename StateDataT,
149  typename PropertiesDataT,
150  class CompositeT,
151  void (*updateState)(DerivedT*),
152  void (*updateProperties)(DerivedT*)>
154  DerivedT,
155  StateDataT,
156  PropertiesDataT,
157  CompositeT,
158  updateState,
159  updateProperties>::UpdateState)(DerivedT*);
160 
161 //==============================================================================
162 template <
163  class DerivedT,
164  typename StateDataT,
165  typename PropertiesDataT,
166  class CompositeT,
167  void (*updateState)(DerivedT*),
168  void (*updateProperties)(DerivedT*)>
170  DerivedT,
171  StateDataT,
172  PropertiesDataT,
173  CompositeT,
174  updateState,
175  updateProperties>::UpdateProperties)(DerivedT*);
176 
177 } // namespace common
178 } // namespace dart
179 
180 #endif // DART_COMMON_ASPECTWITHVERSION_HPP_
BodyPropPtr properties
Definition: SdfParser.cpp:80
Definition: AspectWithVersion.hpp:82
AspectWithStateAndVersionedProperties(const StateData &state=StateData(), const PropertiesData &properties=PropertiesData())
Construct using a StateData and a PropertiesData instance.
Definition: AspectWithVersion.hpp:116
StateDataT StateData
Definition: AspectWithVersion.hpp:85
AspectWithStateAndVersionedProperties(const AspectWithStateAndVersionedProperties &)=delete
std::unique_ptr< Aspect > cloneAspect() const override
Definition: AspectWithVersion.hpp:133
DerivedT Derived
Definition: AspectWithVersion.hpp:84
PropertiesDataT PropertiesData
Definition: AspectWithVersion.hpp:86
AspectWithStateAndVersionedProperties(const PropertiesData &properties, const StateData &state=StateData())
Construct using a PropertiesData and a StateData instance.
Definition: AspectWithVersion.hpp:125
CompositeT CompositeType
Definition: AspectWithVersion.hpp:87
Composite is a base class that should be virtually inherited by any class that wants to be able to ma...
Definition: Composite.hpp:53
The MakeCloneable class is used to easily create an Cloneable (such as Node::State) which simply take...
Definition: Cloneable.hpp:84
AspectWithProtectedState generates implementations of the State managing functions for an Aspect clas...
Definition: AspectWithVersion.hpp:54
AspectWithProtectedProperties generates implementations of the Property managing functions for an Asp...
Definition: AspectWithVersion.hpp:109
Definition: BulletCollisionDetector.cpp:65