Gazebo Plugin

API Reference

2.0.3
gz/plugin/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 GZ_PLUGIN_LOADER_HH_
20 #define GZ_PLUGIN_LOADER_HH_
21 
22 #include <memory>
23 #include <set>
24 #include <string>
25 #include <typeinfo>
26 #include <unordered_set>
27 
28 #include <gz/utils/SuppressWarning.hh>
29 
30 #include <gz/plugin/loader/Export.hh>
31 #include <gz/plugin/PluginPtr.hh>
32 
33 namespace gz
34 {
35  namespace plugin
36  {
38  class GZ_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 
144  public: std::unordered_set<std::string> LoadLib(
145  const std::string &_pathToLibrary, bool _noDelete);
146 
153  public: PluginPtr Instantiate(
154  const std::string &_pluginNameOrAlias) const;
155 
167  public: template <typename PluginPtrType>
168  PluginPtrType Instantiate(const std::string &_pluginNameOrAlias) const;
169 
193  public: template <typename InterfaceType>
195  const std::string &_pluginNameOrAlias) const;
196 
221  public: bool ForgetLibrary(const std::string &_pathToLibrary);
222 
231  public: bool ForgetLibraryOfPlugin(const std::string &_pluginNameOrAlias);
232 
240  private: std::string PrivateLookupFilePlugin(
241  const std::string &_nameOrAlias) const;
242 
253  private: ConstInfoPtr PrivateGetInfoForFilePlugin(
254  const std::string &_resolvedName) const;
255 
263  private: std::string PrivateLookupStaticPlugin(
264  const std::string &_nameOrAlias) const;
265 
276  private: ConstInfoPtr PrivateGetInfoForStaticPlugin(
277  const std::string &_resolvedName) const;
278 
288  private: std::shared_ptr<void> PrivateGetPluginDlHandlePtr(
289  const std::string &_resolvedName) const;
290 
291  class Implementation;
292  GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
294  private: std::unique_ptr<Implementation> dataPtr;
295  GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
296  };
297  }
298 }
299 
300 #include <gz/plugin/detail/Loader.hh>
301 
302 #endif