Gazebo Plugin

API Reference

1.3.0
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 
56 
60  public: template <typename Interface>
62 
83  const std::string &_interface,
84  const bool _demangled = true) const;
85 
90 
105  const std::string &_alias) const;
106 
114  const std::string &_pluginName) const;
115 
125  public: std::string LookupPlugin(const std::string &_nameOrAlias) const;
126 
134  const std::string &_pathToLibrary);
135 
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
Class for loading plugins.
Definition: Loader.hh:39
std::shared_ptr< InterfaceType > Factory(const std::string &_pluginNameOrAlias) const
Instantiates a plugin for the given plugin name, and then returns a reference-counting interface corr...
PluginPtr Instantiate(const std::string &_pluginNameOrAlias) const
Instantiates a plugin for the given plugin name.
bool ForgetLibraryOfPlugin(const std::string &_pluginNameOrAlias)
Forget the library that provides the plugin with the given name. Note that this will also forget all ...
std::unordered_set< std::string > PluginsImplementing(const std::string &_interface, const bool _demangled=true) const
Get plugin names that implement the specified interface string. Note that the templated version of th...
std::set< std::string > AliasesOfPlugin(const std::string &_pluginName) const
Get the aliases of the plugin with the given name.
std::set< std::string > PluginsWithAlias(const std::string &_alias) const
Get plugin names that correspond to the specified alias string.
std::set< std::string > AllPlugins() const
Get a set of the names of all plugins that are currently known to this Loader.
std::unordered_set< std::string > LoadLib(const std::string &_pathToLibrary)
Load a library at the given path.
PluginPtrType Instantiate(const std::string &_pluginNameOrAlias) const
Instantiates a plugin of PluginType for the given plugin name. This can be used to create a specializ...
std::unordered_set< std::string > InterfacesImplemented() const
Get demangled names of interfaces that the loader has plugins for.
std::string PrettyStr() const
Makes a printable string with info about plugins.
std::string LookupPlugin(const std::string &_nameOrAlias) const
Resolve the plugin name or alias into the name of the plugin that it maps to. If this is a name or al...
bool ForgetLibrary(const std::string &_pathToLibrary)
This loader will forget about the library at the given path location. If you want to instantiate a pl...
std::unordered_set< std::string > PluginsImplementing() const
Get plugin names that implement the specified interface.
This class manages the lifecycle of a plugin instance. It can receive a plugin instance from the Load...
Definition: PluginPtr.hh:53
Definition: EnablePluginFromThis.hh:26