DART 6.7.3
Loading...
Searching...
No Matches
CompositeJoiner.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_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 Base1Arg&& arg1, NoArgTag)
58 : Base1(std::forward<Base1Arg>(arg1)),
59 Base2()
60{
61 // Do nothing
62}
63
64//==============================================================================
65template <class Base1, class Base2>
66template <typename... Base2Args>
68 NoArgTag, Base2Args&&... args2)
69 : Base1(),
70 Base2(std::forward<Base2Args>(args2)...)
71{
72 // Do nothing
73}
74
75//==============================================================================
80DETAIL_DART_COMMON_TEMPLATEJOINERDISPATCH_IMPL(void, CompositeJoiner, set, (std::unique_ptr<T>&& aspect), (std::move(aspect)))
83
84//==============================================================================
85// Because this function requires a comma inside of its template argument list,
86// it is not easily fit into a macro like the other functions, so we just
87// implement it explicitly.
88template <class Base1, class Base2>
89template <class T, typename ...Args>
90T* CompositeJoiner<Base1, Base2>::createAspect(Args&&... args)
91{
92 if(Base1::template isSpecializedFor<T>())
93 return Base1::template createAspect<T, Args...>(std::forward<Args>(args)...);
94
95 return Base2::template createAspect<T, Args...>(std::forward<Args>(args)...);
96}
97
98//==============================================================================
99template <class Base1, class Base2>
100template <class T>
102{
103 return (Base1::template isSpecializedFor<T>()
104 || Base2::template isSpecializedFor<T>());
105}
106
107//==============================================================================
108template <class Base1, class Base2, class... OtherBases>
109template <typename... Args>
111 Args&&... args)
112 : CompositeJoiner<Base1, CompositeJoiner<Base2, OtherBases...>>(
113 std::forward<Args>(args)...)
114{
115 // Do nothing
116}
117
118} // namespace common
119} // namespace dart
120
121#endif // DART_COMMON_DETAIL_COMPOSITEJOINER_HPP_
122
#define DETAIL_DART_COMMON_TEMPLATEJOINERDISPATCH_IMPL(ReturnType, ClassName, Function, Suffix, Args)
Definition TemplateJoinerDispatchMacro.hpp:53
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:45
Definition BulletCollisionDetector.cpp:63
Definition SharedLibraryManager.hpp:43