Gazebo Common

API Reference

3.17.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 GZ_COMMON_PLUGINLOADER_HH_
20 #define GZ_COMMON_PLUGINLOADER_HH_
21 
22 #include <memory>
23 #include <string>
24 #include <typeinfo>
25 #include <unordered_set>
26 
27 #include <gz/common/Export.hh>
29 #include <gz/common/PluginPtr.hh>
30 
31 namespace ignition
32 {
33  namespace common
34  {
36  class PluginLoaderPrivate;
37  struct PluginInfo;
38 
40  class IGNITION_COMMON_VISIBLE PluginLoader
41  {
43  public: PluginLoader();
44 
46  public: ~PluginLoader();
47 
50  public: std::string PrettyStr() const;
51 
54  public: std::unordered_set<std::string> InterfacesImplemented() const;
55 
59  public: std::unordered_set<std::string> PluginsImplementing(
60  const std::string &_interface) const;
61 
65  public: std::unordered_set<std::string> LoadLibrary(
66  const std::string &_pathToLibrary);
67 
72  public: PluginPtr Instantiate(const std::string &_pluginName) const;
73 
82  public: template <typename PluginPtrType>
83  PluginPtrType Instantiate(
84  const std::string &_pluginName) const;
85 
91  private: const PluginInfo *PrivateGetPluginInfo(
92  const std::string &_pluginName) const;
93 
96  private: std::unique_ptr<PluginLoaderPrivate> dataPtr;
98  };
99  }
100 }
101 
102 #include "gz/common/detail/PluginLoader.hh"
103 
104 #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:40
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:38
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:53
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: gz/common/SuppressWarning.hh:68