DART 6.7.3
Loading...
Searching...
No Matches
EmbeddedAspect.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_EMBEDDEDASPECT_HPP_
34#define DART_COMMON_EMBEDDEDASPECT_HPP_
35
39
40namespace dart {
41namespace common {
42
43//==============================================================================
50template <class CompositeT, typename StateDataT>
52 CompositeTrackingAspect<CompositeT>,
53 EmbeddedStateAspect<CompositeT, StateDataT>, StateDataT>
54{
55public:
56
60 using State = typename Impl::State;
61 using StateData = typename Impl::StateData;
62
63 template <typename... Args>
64 EmbeddedStateAspect(Args&&... args)
65 : Impl(std::forward<Args>(args)...)
66 {
67 // Do nothing
68 }
69
70 virtual ~EmbeddedStateAspect() = default;
71
72};
73
74//==============================================================================
90template <class DerivedT, typename StateDataT>
91class EmbedState : public virtual common::RequiresAspect<
92 common::EmbeddedStateAspect<DerivedT, StateDataT> >
93{
94public:
95
96 using Derived = DerivedT;
98 using AspectState = typename Aspect::State;
101
102 // Forwarding constructor
103 template <typename... Args>
104 EmbedState(Args&&... args)
105 : Base(std::forward<Args>(args)...)
106 {
107 // Do nothing
108 }
109
110 virtual ~EmbedState() = default;
111
113 {
114 return mAspectState;
115 }
116
117protected:
118
121
122};
123
124//==============================================================================
128template <class DerivedT, typename StateDataT, typename... BaseComposites>
130 EmbedState<DerivedT, StateDataT>, BaseComposites...>
131{
132public:
133
135 using Derived = typename Impl::Derived;
138 using Aspect = typename Impl::Aspect;
139 using Base = CompositeJoiner<Impl, BaseComposites...>;
141
142 // Forwarding constructor
143 template <typename... Args>
144 EmbedStateOnTopOf(Args&&... args)
145 : Base(NoArg, std::forward<Args>(args)...)
146 {
147 // Do nothing
148 }
149
150 virtual ~EmbedStateOnTopOf() = default;
151
152protected:
153
154 using Impl::mAspectState;
155
156};
157
158//==============================================================================
165template <class CompositeT, typename PropertiesDataT>
167 CompositeTrackingAspect<CompositeT>,
168 EmbeddedPropertiesAspect<CompositeT, PropertiesDataT>, PropertiesDataT>
169{
170public:
171
175 using Properties = typename Impl::Properties;
177
178 // Forwarding constructor
179 template <typename... Args>
181 : Impl(std::forward<Args>(args)...)
182 {
183 // Do nothing
184 }
185
186 virtual ~EmbeddedPropertiesAspect() = default;
187
188};
189
190//==============================================================================
207template <class DerivedT, typename PropertiesDataT>
209 common::EmbeddedPropertiesAspect<DerivedT, PropertiesDataT> >
210{
211public:
212
213 using Derived = DerivedT;
218
219 // Forwarding constructor
220 template <typename... Args>
221 EmbedProperties(Args&&... args)
222 : Base(std::forward<Args>(args)...)
223 {
224 // Do nothing
225 }
226
227 virtual ~EmbedProperties() = default;
228
230 {
231 return mAspectProperties;
232 }
233
234protected:
235
238
239};
240
241//==============================================================================
245template <class DerivedT, typename PropertiesDataT, typename... CompositeBases>
247 EmbedProperties<DerivedT, PropertiesDataT>, CompositeBases...>
248{
249public:
250
252 using Derived = typename Impl::Derived;
255 using Aspect = typename Impl::Aspect;
256 using Base = CompositeJoiner<Impl, CompositeBases...>;
258
259 // Forwarding constructor
260 template <typename... Args>
262 : Base(NoArg, std::forward<Args>(args)...)
263 {
264 // Do nothing
265 }
266
267 virtual ~EmbedPropertiesOnTopOf() = default;
268
269protected:
270
272
273};
274
275//==============================================================================
279//
280// Dev Note: We achieve "multiple inheritance" without the diamond of death
281// issue by specifying detail::EmbeddedStateAspect as the base class of
282// detail::EmbeddedPropertiesAspect. This allows their implementations to stack
283// on top of each other without the conflict that would arise from both of them
284// inheriting from common::Aspect.
285template <class CompositeT, typename StateDataT, typename PropertiesDataT>
288 detail::EmbeddedStateAspect<
289 CompositeTrackingAspect<CompositeT>,
290 EmbeddedStateAndPropertiesAspect<CompositeT, StateDataT, PropertiesDataT>,
291 StateDataT>,
292 EmbeddedStateAndPropertiesAspect<CompositeT, StateDataT, PropertiesDataT>,
293 PropertiesDataT>
294{
295public:
296
298
301
303 AspectStateImpl, Derived, PropertiesDataT>;
304
306
309
312
313 using CompositeType = CompositeT;
314
316 const EmbeddedStateAndPropertiesAspect&) = delete;
317
319
323 {
324 // Do nothing
325 }
326
329 const StateData& state)
330 : AspectPropertiesImpl(state)
331 {
332 // Do nothing
333 }
334
342
345 const StateData& state,
348 {
349 // Do nothing
350 }
351
355 const StateData& state)
357 {
358 // Do nothing
359 }
360
361 // Documentation inherited
362 std::unique_ptr<Aspect> cloneAspect() const override
363 {
364 return make_unique<Derived>(this->getState(), this->getProperties());
365 }
366
367};
368
369//==============================================================================
381template <class DerivedT, typename StateDataT, typename PropertiesDataT>
383 common::EmbeddedStateAndPropertiesAspect<
384 DerivedT, StateDataT, PropertiesDataT> >
385{
386public:
387
388 using Derived = DerivedT;
390 DerivedT, StateDataT, PropertiesDataT>;
391
392 using AspectState = typename Aspect::State;
394
398
399 // Forwarding constructor
400 template <typename... Args>
402 : Base(std::forward<Args>(args)...)
403 {
404 // Do nothing
405 }
406
407 virtual ~EmbedStateAndProperties() = default;
408
410 {
411 return mAspectState;
412 }
413
415 {
416 return mAspectProperties;
417 }
418
419protected:
420
423
426
427};
428
429//==============================================================================
433template <class DerivedT, typename StateDataT, typename PropertiesDataT,
434 typename... CompositeBases>
436 EmbedStateAndProperties<DerivedT, StateDataT, PropertiesDataT>,
437 CompositeBases...>
438{
439public:
440
442 using Derived = typename Impl::Derived;
447 using Aspect = typename Impl::Aspect;
450 using Base = CompositeJoiner<Impl, CompositeBases...>;
451
452 // Forwarding constructor
453 template <typename... Args>
455 : Base(NoArg, std::forward<Args>(args)...)
456 {
457 // Do nothing
458 }
459
461
462protected:
463
464 using Impl::mAspectState;
466
467};
468
469} // namespace common
470} // namespace dart
471
472#endif // DART_COMMON_EMBEDDEDASPECT_HPP_
BodyPropPtr properties
Definition SdfParser.cpp:80
Terminator for the variadic template.
Definition CompositeJoiner.hpp:45
This is an alternative to EmbedProperties which allows your class to also inherit other Composite obj...
Definition EmbeddedAspect.hpp:248
EmbedPropertiesOnTopOf(Args &&... args)
Definition EmbeddedAspect.hpp:261
EmbedProperties< DerivedT, PropertiesDataT > Impl
Definition EmbeddedAspect.hpp:251
typename Impl::Derived Derived
Definition EmbeddedAspect.hpp:252
typename Impl::AspectPropertiesData AspectPropertiesData
Definition EmbeddedAspect.hpp:253
typename Impl::Aspect Aspect
Definition EmbeddedAspect.hpp:255
virtual ~EmbedPropertiesOnTopOf()=default
typename Impl::AspectProperties AspectProperties
Definition EmbeddedAspect.hpp:254
Inherit this class to embed Properties into your Composite object.
Definition EmbeddedAspect.hpp:210
AspectProperties mAspectProperties
Aspect::Properties data, directly accessible to your derived class.
Definition EmbeddedAspect.hpp:237
typename Aspect::PropertiesData AspectPropertiesData
Definition EmbeddedAspect.hpp:216
const AspectProperties & getAspectProperties() const
Definition EmbeddedAspect.hpp:229
DerivedT Derived
Definition EmbeddedAspect.hpp:213
typename Aspect::Properties AspectProperties
Definition EmbeddedAspect.hpp:215
EmbedProperties(Args &&... args)
Definition EmbeddedAspect.hpp:221
common::EmbeddedPropertiesAspect< Derived, PropertiesDataT > Aspect
Definition EmbeddedAspect.hpp:214
virtual ~EmbedProperties()=default
This is an alternative to EmbedStateAndProperties which allows your class to also inherit other Compo...
Definition EmbeddedAspect.hpp:438
typename Impl::AspectState AspectState
Definition EmbeddedAspect.hpp:444
typename Impl::Derived Derived
Definition EmbeddedAspect.hpp:442
EmbedStateAndPropertiesOnTopOf(Args &&... args)
Definition EmbeddedAspect.hpp:454
typename Impl::Aspect Aspect
Definition EmbeddedAspect.hpp:447
typename Impl::AspectStateData AspectStateData
Definition EmbeddedAspect.hpp:443
EmbedStateAndProperties< DerivedT, StateDataT, PropertiesDataT > Impl
Definition EmbeddedAspect.hpp:441
typename Impl::AspectPropertiesData AspectPropertiesData
Definition EmbeddedAspect.hpp:445
typename Impl::AspectProperties AspectProperties
Definition EmbeddedAspect.hpp:446
Inherit this class to embed both State and Properties into your Composite object.
Definition EmbeddedAspect.hpp:385
typename Aspect::Properties AspectProperties
Definition EmbeddedAspect.hpp:395
AspectState mAspectState
Aspect::State data, directly accessible to your derived class.
Definition EmbeddedAspect.hpp:422
virtual ~EmbedStateAndProperties()=default
DerivedT Derived
Definition EmbeddedAspect.hpp:388
common::EmbeddedStateAndPropertiesAspect< DerivedT, StateDataT, PropertiesDataT > Aspect
Definition EmbeddedAspect.hpp:390
const AspectState & getAspectState() const
Definition EmbeddedAspect.hpp:409
const AspectProperties & getAspectProperties() const
Definition EmbeddedAspect.hpp:414
typename Aspect::StateData AspectStateData
Definition EmbeddedAspect.hpp:393
AspectProperties mAspectProperties
Aspect::Properties data, directly accessible to your derived class.
Definition EmbeddedAspect.hpp:425
typename Aspect::State AspectState
Definition EmbeddedAspect.hpp:392
EmbedStateAndProperties(Args &&... args)
Definition EmbeddedAspect.hpp:401
typename Aspect::PropertiesData AspectPropertiesData
Definition EmbeddedAspect.hpp:396
This is an alternative to EmbedState which allows your class to also inherit other Composite objects ...
Definition EmbeddedAspect.hpp:131
typename Impl::Aspect Aspect
Definition EmbeddedAspect.hpp:138
EmbedStateOnTopOf(Args &&... args)
Definition EmbeddedAspect.hpp:144
typename Impl::AspectStateData AspectStateData
Definition EmbeddedAspect.hpp:136
virtual ~EmbedStateOnTopOf()=default
typename Impl::AspectState AspectState
Definition EmbeddedAspect.hpp:137
typename Impl::Derived Derived
Definition EmbeddedAspect.hpp:135
EmbedState< DerivedT, StateDataT > Impl
Definition EmbeddedAspect.hpp:134
Inherit this class to embed a State into your Composite object.
Definition EmbeddedAspect.hpp:93
DerivedT Derived
Definition EmbeddedAspect.hpp:96
typename Aspect::StateData AspectStateData
Definition EmbeddedAspect.hpp:99
AspectState mAspectState
Aspect::State data, directly accessible to your derived class.
Definition EmbeddedAspect.hpp:120
const AspectState & getAspectState() const
Definition EmbeddedAspect.hpp:112
EmbedState(Args &&... args)
Definition EmbeddedAspect.hpp:104
virtual ~EmbedState()=default
common::EmbeddedStateAspect< Derived, StateDataT > Aspect
Definition EmbeddedAspect.hpp:97
typename Aspect::State AspectState
Definition EmbeddedAspect.hpp:98
This is the implementation of a standard embedded-properties Aspect.
Definition EmbeddedAspect.hpp:169
EmbeddedPropertiesAspect(Args &&... args)
Definition EmbeddedAspect.hpp:180
typename Impl::Properties Properties
Definition EmbeddedAspect.hpp:175
typename Impl::PropertiesData PropertiesData
Definition EmbeddedAspect.hpp:176
This is the implementation of a standard combination of embedded-state and embedded-properties Aspect...
Definition EmbeddedAspect.hpp:294
typename AspectStateImpl::StateData StateData
Definition EmbeddedAspect.hpp:308
EmbeddedStateAndPropertiesAspect()
Construct using nothing. The object will remain unaffected.
Definition EmbeddedAspect.hpp:321
EmbeddedStateAndPropertiesAspect(const StateData &state)
Construct using a State. The object's Properties will remain unaffected.
Definition EmbeddedAspect.hpp:328
typename AspectStateImpl::State State
Definition EmbeddedAspect.hpp:307
EmbeddedStateAndPropertiesAspect(const PropertiesData &properties, const StateData &state)
Construct using a Properties and State instance.
Definition EmbeddedAspect.hpp:353
EmbeddedStateAndPropertiesAspect(const StateData &state, const PropertiesData &properties)
Construct using a State and Properties instance.
Definition EmbeddedAspect.hpp:344
CompositeT CompositeType
Definition EmbeddedAspect.hpp:313
detail::EmbeddedStateAspect< CompositeTrackingAspect< CompositeT >, Derived, StateDataT > AspectStateImpl
Definition EmbeddedAspect.hpp:300
typename AspectPropertiesImpl::PropertiesData PropertiesData
Definition EmbeddedAspect.hpp:311
EmbeddedStateAndPropertiesAspect< CompositeT, StateDataT, PropertiesDataT > Derived
Definition EmbeddedAspect.hpp:297
typename AspectPropertiesImpl::Properties Properties
Definition EmbeddedAspect.hpp:310
std::unique_ptr< Aspect > cloneAspect() const override
Clone this Aspect into a new composite.
Definition EmbeddedAspect.hpp:362
EmbeddedStateAndPropertiesAspect(const EmbeddedStateAndPropertiesAspect &)=delete
EmbeddedStateAndPropertiesAspect(const PropertiesData &properties)
Construct using Properties. The object's State will remain unaffected.
Definition EmbeddedAspect.hpp:336
This is the implementation of a standard embedded-state Aspect.
Definition EmbeddedAspect.hpp:54
typename Impl::State State
Definition EmbeddedAspect.hpp:60
EmbeddedStateAspect(Args &&... args)
Definition EmbeddedAspect.hpp:64
virtual ~EmbeddedStateAspect()=default
typename Impl::StateData StateData
Definition EmbeddedAspect.hpp:61
RequiresAspect allows classes that inherit Composite to know which Aspects are required for their ope...
Definition RequiresAspect.hpp:48
Definition EmbeddedAspect.hpp:250
PropertiesDataT PropertiesData
Definition EmbeddedAspect.hpp:260
PropertiesT Properties
Definition EmbeddedAspect.hpp:259
Definition EmbeddedAspect.hpp:79
StateDataT StateData
Definition EmbeddedAspect.hpp:85
StateT State
Definition EmbeddedAspect.hpp:84
@ NoArg
Definition Empty.hpp:45
Definition BulletCollisionDetector.cpp:63
Definition SharedLibraryManager.hpp:43