DART 6.10.1
Loading...
Searching...
No Matches
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
39namespace dart {
40namespace common {
41
42//==============================================================================
43template <class Base1, class Base2>
44template <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//==============================================================================
54template <class Base1, class Base2>
55template <typename Base1Arg>
57 : Base1(std::forward<Base1Arg>(arg1)), Base2()
58{
59 // Do nothing
60}
61
62//==============================================================================
63template <class Base1, class Base2>
64template <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.
94template <class Base1, class Base2>
95template <class T, typename... Args>
96T* 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//==============================================================================
106template <class Base1, class Base2>
107template <class T>
109{
110 return (
111 Base1::template isSpecializedFor<T>()
112 || Base2::template isSpecializedFor<T>());
113}
114
115//==============================================================================
116template <class Base1, class Base2, class... OtherBases>
117template <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