Gazebo Common

API Reference

5.6.0
SpecializedPlugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #ifndef IGNITION_COMMON_SPECIALIZEDPLUGIN_HH_
18 #define IGNITION_COMMON_SPECIALIZEDPLUGIN_HH_
19 
22 
23 #include <memory>
24 
25 namespace gz
26 {
27  namespace common
28  {
29  // Forward declarations
30  namespace detail { template <class, class> class ComposePlugin; }
31  struct PluginInfo;
32 
33  // Forward declaration of the variadic template SpecializedPlugin class.
34  template <class... OtherSpecInterfaces>
36 
68  template <class SpecInterface>
69  class SpecializedPlugin<SpecInterface> : public virtual Plugin
70  {
71  // -------------------- Public API ---------------------
72 
73  // Inherit function overloads
74  public: using Plugin::QueryInterface;
75  public: using Plugin::QueryInterfaceSharedPtr;
76  public: using Plugin::HasInterface;
77 
78  // Documentation inherited
79  public: template <class Interface>
80  Interface *QueryInterface();
81 
82  // Documentation inherited
83  public: template <class Interface>
84  const Interface *QueryInterface() const;
85 
86  // Documentation inherited
87  public: template <class Interface>
89 
90  // Documentation inherited
91  public: template <class Interface>
93 
94  // Documentation inherited
95  public: template <class Interface>
96  bool HasInterface() const;
97 
98 
99  // -------------------- Private API ---------------------
100 
101  // Declare friendship
102  template <class...> friend class SpecializedPlugin;
103  template <class, class> friend class detail::ComposePlugin;
104  template <class> friend class TemplatePluginPtr;
105 
107  private: GZ_DEPRECATED(5) SpecializedPlugin();
108 
113  private: template <class T> struct type { };
114 
119  private: template <class Interface>
120  Interface *PrivateQueryInterface(type<Interface> _type);
121 
126  private: SpecInterface *PrivateQueryInterface(
127  type<SpecInterface> _type);
128 
133  private: template <class Interface>
134  const Interface *PrivateQueryInterface(type<Interface> _type)
135  const;
136 
141  private: const SpecInterface *PrivateQueryInterface(
142  type<SpecInterface> _type) const;
143 
148  private: template <class Interface>
149  bool PrivateHasInterface(type<Interface> _type) const;
150 
155  private: bool PrivateHasInterface(type<SpecInterface> _type) const;
156 
158  private: const Plugin::InterfaceMap::iterator
159  privateSpecializedInterfaceIterator;
160 
161  // Dev note (MXG): The privateSpecializedInterfaceIterator object must be
162  // available to the user during their compile time, so it cannot be hidden
163  // using PIMPL. The iterator is const because it must always point to the
164  // same entry throughout its entire lifecycle.
165  };
166  }
167 }
168 
169 #include "ignition/common/detail/SpecializedPlugin.hh"
170 #endif // IGNITION_COMMON_SPECIALIZEDPLUGIN_HH_