Gazebo Common

API Reference

4.7.0
gz/common/PluginLoader.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_COMMON_PLUGINLOADER_HH_
20 #define IGNITION_COMMON_PLUGINLOADER_HH_
21 
22 #include <memory>
23 #include <string>
24 #include <typeinfo>
25 #include <unordered_set>
26 
27 #include <gz/common/config.hh>
28 #include <gz/common/Export.hh>
30 #include <gz/common/PluginPtr.hh>
31 
32 namespace ignition
33 {
34  namespace common
35  {
37  class PluginLoaderPrivate;
38  struct PluginInfo;
39 
41  class IGNITION_COMMON_VISIBLE PluginLoader
42  {
44  public: PluginLoader();
45 
47  public: ~PluginLoader();
48 
51  public: std::string PrettyStr() const;
52 
55  public: std::unordered_set<std::string> InterfacesImplemented() const;
56 
60  public: std::unordered_set<std::string> PluginsImplementing(
61  const std::string &_interface) const;
62 
66  public: std::unordered_set<std::string> LoadLibrary(
67  const std::string &_pathToLibrary);
68 
73  public: PluginPtr Instantiate(const std::string &_pluginName) const;
74 
83  public: template <typename PluginPtrType>
84  PluginPtrType Instantiate(
85  const std::string &_pluginName) const;
86 
92  private: const PluginInfo *PrivateGetPluginInfo(
93  const std::string &_pluginName) const;
94 
97  private: std::unique_ptr<PluginLoaderPrivate> dataPtr;
99  };
100  }
101 }
102 
103 #include "gz/common/detail/PluginLoader.hh"
104 
105 #endif
Forward declarations for the common classes.
STL class.
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: gz/common/SuppressWarning.hh:65
Class for loading plugins.
Definition: gz/common/PluginLoader.hh:41
std::unordered_set< std::string > PluginsImplementing(const std::string &_interface) const
Get plugin names that implement the interface.
PluginPtr Instantiate(const std::string &_pluginName) const
Instantiates a plugin for the given plugin name.
std::unordered_set< std::string > LoadLibrary(const std::string &_pathToLibrary)
Load a library at the given path.
std::unordered_set< std::string > InterfacesImplemented() const
Get names of interfaces that the loader has plugins for.
Holds info required to construct a plugin.
Definition: gz/common/PluginInfo.hh:40
std::string PrettyStr() const
Makes a printable string with info about plugins.
This class manages the lifecycle of a plugin instance. It can receive a plugin instance from the igni...
Definition: gz/common/PluginPtr.hh:54
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: gz/common/SuppressWarning.hh:68