Ignition Plugin

API Reference

1.2.1
Loader.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_LOADER_HH_
20 #define IGNITION_PLUGIN_LOADER_HH_
21 
22 #include <memory>
23 #include <set>
24 #include <string>
25 #include <typeinfo>
26 #include <unordered_set>
27 
28 #include <ignition/utilities/SuppressWarning.hh>
29 
30 #include <ignition/plugin/loader/Export.hh>
32 
33 namespace ignition
34 {
35  namespace plugin
36  {
38  class IGNITION_PLUGIN_LOADER_VISIBLE Loader
39  {
41  public: Loader();
42 
44  public: ~Loader();
45 
49  public: std::string PrettyStr() const;
50 
55  public: std::unordered_set<std::string> InterfacesImplemented() const;
56 
60  public: template <typename Interface>
61  std::unordered_set<std::string> PluginsImplementing() const;
62 
82  public: std::unordered_set<std::string> PluginsImplementing(
83  const std::string &_interface,
84  const bool _demangled = true) const;
85 
89  public: std::set<std::string> AllPlugins() const;
90 
104  public: std::set<std::string> PluginsWithAlias(
105  const std::string &_alias) const;
106 
113  public: std::set<std::string> AliasesOfPlugin(
114  const std::string &_pluginName) const;
115 
125  public: std::string LookupPlugin(const std::string &_nameOrAlias) const;
126 
133  public: std::unordered_set<std::string> LoadLib(
134  const std::string &_pathToLibrary);
135 
142  public: PluginPtr Instantiate(
143  const std::string &_pluginNameOrAlias) const;
144 
156  public: template <typename PluginPtrType>
157  PluginPtrType Instantiate(const std::string &_pluginNameOrAlias) const;
158 
182  public: template <typename InterfaceType>
184  const std::string &_pluginNameOrAlias) const;
185 
210  public: bool ForgetLibrary(const std::string &_pathToLibrary);
211 
220  public: bool ForgetLibraryOfPlugin(const std::string &_pluginNameOrAlias);
221 
230  private: ConstInfoPtr PrivateGetInfo(
231  const std::string &_resolvedName) const;
232 
242  private: std::shared_ptr<void> PrivateGetPluginDlHandlePtr(
243  const std::string &_resolvedName) const;
244 
245  class Implementation;
246  IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
248  private: std::unique_ptr<Implementation> dataPtr;
249  IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
250  };
251  }
252 }
253 
254 #include <ignition/plugin/detail/Loader.hh>
255 
256 #endif
STL class.
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
Class for loading plugins.
Definition: Loader.hh:38
The Factory class defines a plugin factory that can be used by the Loader class to produce products t...
Definition: Factory.hh:75