DART  6.7.3
AspectWithVersion.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_COMMON_ASPECTWITHVERSION_HPP_
34 #define DART_COMMON_ASPECTWITHVERSION_HPP_
35 
37 
38 namespace dart {
39 namespace common {
40 
41 //==============================================================================
42 template <class DerivedT,
43  typename StateDataT,
44  class CompositeT = Composite,
45  void (*updateState)(DerivedT*) = &detail::NoOp<DerivedT*> >
47  detail::AspectWithState<CompositeTrackingAspect<CompositeT>, DerivedT, StateDataT, CompositeT, updateState>;
48 
49 //==============================================================================
50 template <class DerivedT,
51  typename PropertiesDataT,
52  class CompositeT = Composite,
53  void (*updateProperties)(DerivedT*) = &detail::NoOp<DerivedT*> >
55  detail::AspectWithVersionedProperties<CompositeTrackingAspect<CompositeT>, DerivedT, PropertiesDataT, CompositeT, updateProperties>;
56 
57 //==============================================================================
58 template <class DerivedT,
59  typename StateDataT,
60  typename PropertiesDataT,
61  class CompositeT = Composite,
62  void (*updateState)(DerivedT*) = &detail::NoOp<DerivedT*>,
63  void (*updateProperties)(DerivedT*) = updateState>
67  DerivedT, PropertiesDataT, CompositeT, updateProperties>
68 {
69 public:
70 
71  using Derived = DerivedT;
72  using StateData = StateDataT;
73  using PropertiesData = PropertiesDataT;
74  using CompositeType = CompositeT;
77  constexpr static void (*UpdateState)(Derived*) = updateState;
78  constexpr static void (*UpdateProperties)(Derived*) = updateProperties;
79 
81  Derived, StateData, CompositeType, updateState>;
82 
85  Derived, PropertiesData, CompositeType, updateProperties>;
86 
88  DerivedT, StateDataT, PropertiesDataT, CompositeT,
89  updateState, updateProperties>;
90 
93 
96  const StateData& state = StateData(),
99  {
100  // Do nothing
101  }
102 
105  const PropertiesData& properties,
106  const StateData& state = StateData())
108  {
109  // Do nothing
110  }
111 
112  // Documentation inherited
113  std::unique_ptr<Aspect> cloneAspect() const override
114  {
115  return make_unique<Derived>(this->getState(), this->getProperties());
116  }
117 
118 };
119 
120 //==============================================================================
121 //
122 // These namespace-level definitions are required to enable ODR-use of static
123 // constexpr member variables.
124 //
125 // See this StackOverflow answer: http://stackoverflow.com/a/14396189/111426
126 //
127 template <class DerivedT,
128  typename StateDataT,
129  typename PropertiesDataT,
130  class CompositeT,
131  void (*updateState)(DerivedT*),
132  void (*updateProperties)(DerivedT*)>
133 constexpr void (*AspectWithStateAndVersionedProperties<DerivedT, StateDataT,
134  PropertiesDataT, CompositeT, updateState, updateProperties>::UpdateState)
135  (DerivedT*);
136 
137 //==============================================================================
138 template <class DerivedT,
139  typename StateDataT,
140  typename PropertiesDataT,
141  class CompositeT,
142  void (*updateState)(DerivedT*),
143  void (*updateProperties)(DerivedT*)>
144 constexpr void (*AspectWithStateAndVersionedProperties<DerivedT, StateDataT,
145  PropertiesDataT, CompositeT, updateState, updateProperties>::UpdateProperties)
146  (DerivedT*);
147 
148 } // namespace common
149 } // namespace dart
150 
151 #endif // DART_COMMON_ASPECTWITHVERSION_HPP_
BodyPropPtr properties
Definition: SdfParser.cpp:80
Definition: AspectWithVersion.hpp:68
AspectWithStateAndVersionedProperties(const StateData &state=StateData(), const PropertiesData &properties=PropertiesData())
Construct using a StateData and a PropertiesData instance.
Definition: AspectWithVersion.hpp:95
StateDataT StateData
Definition: AspectWithVersion.hpp:72
AspectWithStateAndVersionedProperties(const AspectWithStateAndVersionedProperties &)=delete
std::unique_ptr< Aspect > cloneAspect() const override
Definition: AspectWithVersion.hpp:113
DerivedT Derived
Definition: AspectWithVersion.hpp:71
PropertiesDataT PropertiesData
Definition: AspectWithVersion.hpp:73
AspectWithStateAndVersionedProperties(const PropertiesData &properties, const StateData &state=StateData())
Construct using a PropertiesData and a StateData instance.
Definition: AspectWithVersion.hpp:104
CompositeT CompositeType
Definition: AspectWithVersion.hpp:74
Composite is a base class that should be virtually inherited by any class that wants to be able to ma...
Definition: Composite.hpp:52
The MakeCloneable class is used to easily create an Cloneable (such as Node::State) which simply take...
Definition: Cloneable.hpp:85
AspectWithProtectedState generates implementations of the State managing functions for an Aspect clas...
Definition: AspectWithVersion.hpp:51
AspectWithProtectedProperties generates implementations of the Property managing functions for an Asp...
Definition: AspectWithVersion.hpp:107
Definition: BulletCollisionDetector.cpp:63