Gazebo Plugin

API Reference

3.0.0
Plugin.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 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
18
19#ifndef GZ_PLUGIN_PLUGIN_HH_
20#define GZ_PLUGIN_PLUGIN_HH_
21
22#include <memory>
23#include <map>
24#include <string>
25
26#include <gz/utils/SuppressWarning.hh>
27
28#include <gz/plugin/Export.hh>
29#include <gz/plugin/Info.hh>
30
31namespace gz
32{
33 namespace plugin
34 {
35 // Forward declaration
36 namespace detail {
37 template <class, class> class ComposePlugin;
38 template <class> class SelectSpecializers;
39 }
40 class EnablePluginFromThis;
41 class WeakPluginPtr;
42
43 class GZ_PLUGIN_VISIBLE Plugin
44 {
45 // -------------------- Public API ---------------------
46
62 public: template <class Interface>
63 Interface *QueryInterface();
64
66 public: template <class Interface>
67 const Interface *QueryInterface() const;
68
86 public: template <class Interface>
88
91 public: template <class Interface>
93
97 public: template <class Interface>
98 bool HasInterface() const;
99
113 public: bool HasInterface(const std::string &_interfaceName,
114 const bool _demangled = true) const;
115
119 public: const std::string *Name() const;
120
121 // -------------------- Private API -----------------------
122
123 template <class> friend class TemplatePluginPtr;
124 template <class...> friend class SpecializedPlugin;
125 template <class, class> friend class detail::ComposePlugin;
126 template <class> friend class detail::SelectSpecializers;
128 friend class WeakPluginPtr;
129
133 protected: Plugin();
134
136 private: void *PrivateQueryInterface(
137 const std::string &_interfaceName) const;
138
140 private: void PrivateCopyPluginInstance(const Plugin &_other) const;
141
147 private: void PrivateCopyPluginInstance(
148 const ConstInfoPtr &_info,
149 const std::shared_ptr<void> &_instancePtr) const;
150
156 private: void PrivateCreatePluginInstance(
157 const ConstInfoPtr &_info,
158 const std::shared_ptr<void> &_dlHandlePtr) const;
159
164 private: void PrivateCreateStaticPluginInstance(
165 const ConstInfoPtr &_info) const;
166
167
170 private: const std::shared_ptr<void> &PrivateGetInstancePtr() const;
171
173 private: const ConstInfoPtr &PrivateGetInfoPtr() const;
174
181
184 private: InterfaceMap::iterator PrivateGetOrCreateIterator(
185 const std::string &_interfaceName);
186
187 class Implementation;
188 GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
190 private: const std::unique_ptr<Implementation> dataPtr;
191 GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
192
194 public: virtual ~Plugin();
195 };
196 }
197}
198
199#include "gz/plugin/detail/Plugin.hh"
200
201#endif