DART 6.6.2
Loading...
Searching...
No Matches
AspectWithVersion.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2018, 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
38namespace dart {
39namespace common {
40
41//==============================================================================
42template <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//==============================================================================
50template <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//==============================================================================
58template <class DerivedT,
59 typename StateDataT,
60 typename PropertiesDataT,
61 class CompositeT = Composite,
62 void (*updateState)(DerivedT*) = &detail::NoOp<DerivedT*>,
63 void (*updateProperties)(DerivedT*) = updateState>
65 public detail::AspectWithVersionedProperties<
66 AspectWithState<DerivedT, StateDataT, CompositeT, updateState>,
67 DerivedT, PropertiesDataT, CompositeT, updateProperties>
68{
69public:
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
94
97 const StateData& state = StateData(),
100 {
101 // Do nothing
102 }
103
107 const StateData& state = StateData())
109 {
110 // Do nothing
111 }
112
113 // Documentation inherited
114 std::unique_ptr<Aspect> cloneAspect() const override
115 {
116 return make_unique<Derived>(this->getState(), this->getProperties());
117 }
118
119};
120
121//==============================================================================
122//
123// These namespace-level definitions are required to enable ODR-use of static
124// constexpr member variables.
125//
126// See this StackOverflow answer: http://stackoverflow.com/a/14396189/111426
127//
128template <class DerivedT,
129 typename StateDataT,
130 typename PropertiesDataT,
131 class CompositeT,
132 void (*updateState)(DerivedT*),
133 void (*updateProperties)(DerivedT*)>
134constexpr void (*AspectWithStateAndVersionedProperties<DerivedT, StateDataT,
135 PropertiesDataT, CompositeT, updateState, updateProperties>::UpdateState)
136 (DerivedT*);
137
138//==============================================================================
139template <class DerivedT,
140 typename StateDataT,
141 typename PropertiesDataT,
142 class CompositeT,
143 void (*updateState)(DerivedT*),
144 void (*updateProperties)(DerivedT*)>
145constexpr void (*AspectWithStateAndVersionedProperties<DerivedT, StateDataT,
146 PropertiesDataT, CompositeT, updateState, updateProperties>::UpdateProperties)
147 (DerivedT*);
148
149} // namespace common
150} // namespace dart
151
152#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:96
StateDataT StateData
Definition AspectWithVersion.hpp:72
AspectWithStateAndVersionedProperties(const AspectWithStateAndVersionedProperties &)=delete
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:105
CompositeT CompositeType
Definition AspectWithVersion.hpp:74
std::unique_ptr< Aspect > cloneAspect() const override
Definition AspectWithVersion.hpp:114
Definition Aspect.hpp:129
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