DART  6.10.1
CompositeJoiner.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_DETAIL_COMPOSITEJOINER_HPP_
34 #define DART_COMMON_DETAIL_COMPOSITEJOINER_HPP_
35 
38 
39 namespace dart {
40 namespace common {
41 
42 //==============================================================================
43 template <class Base1, class Base2>
44 template <typename Base1Arg, typename... Base2Args>
46  Base1Arg&& arg1, Base2Args&&... args2)
47  : Base1(std::forward<Base1Arg>(arg1)),
48  Base2(std::forward<Base2Args>(args2)...)
49 {
50  // Do nothing
51 }
52 
53 //==============================================================================
54 template <class Base1, class Base2>
55 template <typename Base1Arg>
57  : Base1(std::forward<Base1Arg>(arg1)), Base2()
58 {
59  // Do nothing
60 }
61 
62 //==============================================================================
63 template <class Base1, class Base2>
64 template <typename... Base2Args>
66  : Base1(), Base2(std::forward<Base2Args>(args2)...)
67 {
68  // Do nothing
69 }
70 
71 //==============================================================================
73  bool, CompositeJoiner, has, () const, ())
76  const T*, CompositeJoiner, get, () const, ())
78  void, CompositeJoiner, set, (const T* aspect), (aspect))
80  void,
82  set,
83  (std::unique_ptr<T> && aspect),
84  (std::move(aspect)))
86  void, CompositeJoiner, removeAspect, (), ())
88  std::unique_ptr<T>, CompositeJoiner, releaseAspect, (), ())
89 
90 //==============================================================================
91 // Because this function requires a comma inside of its template argument list,
92 // it is not easily fit into a macro like the other functions, so we just
93 // implement it explicitly.
94 template <class Base1, class Base2>
95 template <class T, typename... Args>
96 T* CompositeJoiner<Base1, Base2>::createAspect(Args&&... args)
97 {
98  if (Base1::template isSpecializedFor<T>())
99  return Base1::template createAspect<T, Args...>(
100  std::forward<Args>(args)...);
101 
102  return Base2::template createAspect<T, Args...>(std::forward<Args>(args)...);
103 }
104 
105 //==============================================================================
106 template <class Base1, class Base2>
107 template <class T>
109 {
110  return (
111  Base1::template isSpecializedFor<T>()
112  || Base2::template isSpecializedFor<T>());
113 }
114 
115 //==============================================================================
116 template <class Base1, class Base2, class... OtherBases>
117 template <typename... Args>
119  : CompositeJoiner<Base1, CompositeJoiner<Base2, OtherBases...>>(
120  std::forward<Args>(args)...)
121 {
122  // Do nothing
123 }
124 
125 } // namespace common
126 } // namespace dart
127 
128 #endif // DART_COMMON_DETAIL_COMPOSITEJOINER_HPP_
#define DETAIL_DART_COMMON_TEMPLATEJOINERDISPATCH_IMPL( ReturnType, ClassName, Function, Suffix, Args)
Definition: TemplateJoinerDispatchMacro.hpp:54
Terminator for the variadic template.
Definition: CompositeJoiner.hpp:45
NoArgTag
Used to tag arguments as blank for in variadic joiner classes such as common::CompositeJoiner and dyn...
Definition: Empty.hpp:48
Definition: BulletCollisionDetector.cpp:65
Definition: SharedLibraryManager.hpp:46