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_COMPOSITEJOINER_HPP_
34 #define DART_COMMON_COMPOSITEJOINER_HPP_
35 
37 #include "dart/common/Empty.hpp"
38 
39 namespace dart {
40 namespace common {
41 
43 template <class... OtherBases>
45 {
46 public:
47  virtual ~CompositeJoiner() = default;
48 };
49 
51 template <class Base1>
52 class CompositeJoiner<Base1> : public Base1
53 {
54 public:
55  virtual ~CompositeJoiner() = default;
56 };
57 
62 template <class Base1, class Base2>
63 class CompositeJoiner<Base1, Base2> : public Base1, public Base2
64 {
65 public:
67  CompositeJoiner() = default;
68 
69  virtual ~CompositeJoiner() = default;
70 
73  //
74  // TODO(MXG): When we migrate to using C++14, we can use std::tuple and
75  // std::index_sequence (which is only available in C++14) to dispatch
76  // arbitrarily many arguments to the constructors of each base class. Until
77  // then, this is the best we can offer due to fundamental limitations of
78  // variadic templates in C++11.
79  template <typename Base1Arg, typename... Base2Args>
80  CompositeJoiner(Base1Arg&& arg1, Base2Args&&... args2);
81 
84  template <typename Base1Arg>
85  CompositeJoiner(Base1Arg&& arg1, NoArgTag);
86 
89  template <typename... Base2Args>
90  CompositeJoiner(NoArgTag, Base2Args&&... args2);
91 
92  // Documentation inherited
93  template <class T>
94  bool has() const;
95 
96  // Documentation inherited
97  template <class T>
98  T* get();
99 
100  // Documentation inherited
101  template <class T>
102  const T* get() const;
103 
104  // Documentation inherited
105  template <class T>
106  void set(const T* aspect);
107 
108  // Documentation inherited
109  template <class T>
110  void set(std::unique_ptr<T>&& aspect);
111 
112  // Documentation inherited
113  template <class T, typename... Args>
114  T* createAspect(Args&&... args);
115 
116  // Documentation inherited
117  template <class T>
118  void removeAspect();
119 
120  // Documentation inherited
121  template <class T>
122  std::unique_ptr<T> releaseAspect();
123 
124  // Documentation inherited
125  template <class T>
126  static constexpr bool isSpecializedFor();
127 };
128 
131 template <class Base1, class Base2, class... OtherBases>
132 class CompositeJoiner<Base1, Base2, OtherBases...>
133  : public CompositeJoiner<Base1, CompositeJoiner<Base2, OtherBases...> >
134 {
135 public:
137  CompositeJoiner() = default;
138 
143  //
144  // TODO(MXG): When we migrate to using C++14, we can use std::tuple and
145  // std::index_sequence (which is only available in C++14) to dispatch
146  // arbitrarily many arguments to the constructors of each base class. Until
147  // then, this is the best we can offer due to fundamental limitations of
148  // variadic templates in C++11.
149  template <typename... Args>
150  CompositeJoiner(Args&&... args);
151 
152  virtual ~CompositeJoiner() = default;
153 };
154 
155 } // namespace common
156 } // namespace dart
157 
159 
160 #endif // DART_COMMON_COMPOSITEJOINER_HPP_
CompositeJoiner()=default
Default constructor.
Terminator for the variadic template.
Definition: CompositeJoiner.hpp:45
virtual ~CompositeJoiner()=default
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