DART  6.7.3
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_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:
66 
68  CompositeJoiner() = default;
69 
70  virtual ~CompositeJoiner() = default;
71 
74  //
75  // TODO(MXG): When we migrate to using C++14, we can use std::tuple and
76  // std::index_sequence (which is only available in C++14) to dispatch
77  // arbitrarily many arguments to the constructors of each base class. Until
78  // then, this is the best we can offer due to fundamental limitations of
79  // variadic templates in C++11.
80  template <typename Base1Arg, typename... Base2Args>
81  CompositeJoiner(Base1Arg&& arg1, Base2Args&&... args2);
82 
85  template <typename Base1Arg>
86  CompositeJoiner(Base1Arg&& arg1, NoArgTag);
87 
90  template <typename... Base2Args>
91  CompositeJoiner(NoArgTag, Base2Args&&... args2);
92 
93  // Documentation inherited
94  template <class T>
95  bool has() const;
96 
97  // Documentation inherited
98  template <class T>
99  T* get();
100 
101  // Documentation inherited
102  template <class T>
103  const T* get() const;
104 
105  // Documentation inherited
106  template <class T>
107  void set(const T* aspect);
108 
109  // Documentation inherited
110  template <class T>
111  void set(std::unique_ptr<T>&& aspect);
112 
113  // Documentation inherited
114  template <class T, typename ...Args>
115  T* createAspect(Args&&... args);
116 
117  // Documentation inherited
118  template <class T>
119  void removeAspect();
120 
121  // Documentation inherited
122  template <class T>
123  std::unique_ptr<T> releaseAspect();
124 
125  // Documentation inherited
126  template <class T>
127  static constexpr bool isSpecializedFor();
128 
129 };
130 
133 template <class Base1, class Base2, class... OtherBases>
134 class CompositeJoiner<Base1, Base2, OtherBases...> :
135  public CompositeJoiner< Base1, CompositeJoiner<Base2, OtherBases...> >
136 {
137 public:
138 
140  CompositeJoiner() = default;
141 
146  //
147  // TODO(MXG): When we migrate to using C++14, we can use std::tuple and
148  // std::index_sequence (which is only available in C++14) to dispatch
149  // arbitrarily many arguments to the constructors of each base class. Until
150  // then, this is the best we can offer due to fundamental limitations of
151  // variadic templates in C++11.
152  template <typename... Args>
153  CompositeJoiner(Args&&... args);
154 
155  virtual ~CompositeJoiner() = default;
156 };
157 
158 } // namespace common
159 } // namespace dart
160 
162 
163 #endif // DART_COMMON_COMPOSITEJOINER_HPP_
164 
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:45
Definition: BulletCollisionDetector.cpp:63