Ignition Plugin

API Reference

1.1.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 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 
101  public: template <class Interface>
102  std::shared_ptr<Interface> QueryInterfaceSharedPtr();
103 
106  public: template <class Interface>
107  std::shared_ptr<const Interface> QueryInterfaceSharedPtr() const;
108 
111  public: template <class Interface>
112  IGN_DEPRECATED(0.0)
113  std::shared_ptr<Interface> QueryInterfaceSharedPtr(
114  const std::string &/*_interfaceName*/);
115 
118  public: template <class Interface>
119  IGN_DEPRECATED(0.0)
120  std::shared_ptr<const Interface> QueryInterfaceSharedPtr(
121  const std::string &/*_interfaceName*/) const;
122 
126  public: template <class Interface>
127  bool HasInterface() const;
128 
142  public: bool HasInterface(const std::string &_interfaceName,
143  const bool _demangled = true) const;
144 
148  public: const std::string *Name() const;
149 
150  // -------------------- Private API -----------------------
151 
152  template <class> friend class TemplatePluginPtr;
153  template <class...> friend class SpecializedPlugin;
154  template <class, class> friend class detail::ComposePlugin;
155  template <class> friend class detail::SelectSpecializers;
156  friend class EnablePluginFromThis;
157  friend class WeakPluginPtr;
158 
162  protected: Plugin();
163 
165  private: void *PrivateQueryInterface(
166  const std::string &_interfaceName) const;
167 
169  private: void PrivateCopyPluginInstance(const Plugin &_other) const;
170 
176  private: void PrivateCopyPluginInstance(
177  const ConstInfoPtr &_info,
178  const std::shared_ptr<void> &_instancePtr) const;
179 
185  private: void PrivateCreatePluginInstance(
186  const ConstInfoPtr &_info,
187  const std::shared_ptr<void> &_dlHandlePtr) const;
188 
191  private: const std::shared_ptr<void> &PrivateGetInstancePtr() const;
192 
194  private: const ConstInfoPtr &PrivateGetInfoPtr() const;
195 
202 
205  private: InterfaceMap::iterator PrivateGetOrCreateIterator(
206  const std::string &_interfaceName);
207 
208  class Implementation;
209  IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
211  private: const std::unique_ptr<Implementation> dataPtr;
212  IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
213 
215  public: virtual ~Plugin();
216  };
217  }
218 }
219 
220 #include "ignition/plugin/detail/Plugin.hh"
221 
222 #endif
STL class.
friend class WeakPluginPtr
Definition: Plugin.hh:157
STL class.
friend class SpecializedPlugin
Definition: Plugin.hh:153
friend class EnablePluginFromThis
Definition: Plugin.hh:156
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