Ignition Plugin

API Reference

1.2.1
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 IGNITION_PLUGIN_PLUGIN_HH_
20 #define IGNITION_PLUGIN_PLUGIN_HH_
21 
22 #include <memory>
23 #include <map>
24 #include <string>
25 
26 #include <ignition/utilities/SuppressWarning.hh>
27 
28 #include <ignition/plugin/Export.hh>
29 #include <ignition/plugin/Info.hh>
30 
31 namespace ignition
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 IGNITION_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 
71  public: template <class Interface>
72  IGN_DEPRECATED(0.0)
73  Interface *QueryInterface(const std::string &/*_interfaceName*/);
74 
77  public: template <class Interface>
78  IGN_DEPRECATED(0.0)
79  const Interface *QueryInterface(
80  const std::string &/*_interfaceName*/) const;
81 
99  public: template <class Interface>
100  std::shared_ptr<Interface> QueryInterfaceSharedPtr();
101 
104  public: template <class Interface>
105  std::shared_ptr<const Interface> QueryInterfaceSharedPtr() const;
106 
109  public: template <class Interface>
110  IGN_DEPRECATED(0.0)
111  std::shared_ptr<Interface> QueryInterfaceSharedPtr(
112  const std::string &/*_interfaceName*/);
113 
116  public: template <class Interface>
117  IGN_DEPRECATED(0.0)
118  std::shared_ptr<const Interface> QueryInterfaceSharedPtr(
119  const std::string &/*_interfaceName*/) const;
120 
124  public: template <class Interface>
125  bool HasInterface() const;
126 
140  public: bool HasInterface(const std::string &_interfaceName,
141  const bool _demangled = true) const;
142 
146  public: const std::string *Name() const;
147 
148  // -------------------- Private API -----------------------
149 
150  template <class> friend class TemplatePluginPtr;
151  template <class...> friend class SpecializedPlugin;
152  template <class, class> friend class detail::ComposePlugin;
153  template <class> friend class detail::SelectSpecializers;
154  friend class EnablePluginFromThis;
155  friend class WeakPluginPtr;
156 
160  protected: Plugin();
161 
163  private: void *PrivateQueryInterface(
164  const std::string &_interfaceName) const;
165 
167  private: void PrivateCopyPluginInstance(const Plugin &_other) const;
168 
174  private: void PrivateCopyPluginInstance(
175  const ConstInfoPtr &_info,
176  const std::shared_ptr<void> &_instancePtr) const;
177 
183  private: void PrivateCreatePluginInstance(
184  const ConstInfoPtr &_info,
185  const std::shared_ptr<void> &_dlHandlePtr) const;
186 
189  private: const std::shared_ptr<void> &PrivateGetInstancePtr() const;
190 
192  private: const ConstInfoPtr &PrivateGetInfoPtr() const;
193 
200 
203  private: InterfaceMap::iterator PrivateGetOrCreateIterator(
204  const std::string &_interfaceName);
205 
206  class Implementation;
207  IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
209  private: const std::unique_ptr<Implementation> dataPtr;
210  IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
211 
213  public: virtual ~Plugin();
214  };
215  }
216 }
217 
218 #include "ignition/plugin/detail/Plugin.hh"
219 
220 #endif
STL class.
friend class WeakPluginPtr
Definition: Plugin.hh:155
STL class.
friend class SpecializedPlugin
Definition: Plugin.hh:151
friend class EnablePluginFromThis
Definition: Plugin.hh:154
This class manages the lifecycle of a plugin instance. It can receive a plugin instance from the Load...
Definition: PluginPtr.hh:52
Definition: EnablePluginFromThis.hh:25
Definition: Plugin.hh:43