Ignition Common

API Reference

3.5.0
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 <ignition/common/Export.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 "ignition/common/detail/PluginLoader.hh"
103 
104 #endif
This class manages the lifecycle of a plugin instance. It can receive a plugin instance from the Plug...
Definition: PluginPtr.hh:53
Class for loading plugins.
Definition: PluginLoader.hh:40
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: SuppressWarning.hh:67
STL class.
Holds info required to construct a plugin.
Definition: PluginInfo.hh:38
Forward declarations for the common classes.
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: SuppressWarning.hh:64