Ignition Plugin

API Reference

1.1.0
PluginPtr.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_PLUGINPTR_HH_
20 #define IGNITION_PLUGIN_PLUGINPTR_HH_
21 
22 #include <map>
23 #include <string>
24 #include <memory>
25 
27 
28 namespace ignition
29 {
30  namespace plugin
31  {
32  // Forward declarations
33  namespace detail { template<class, class> class ComposePlugin; }
34 
51  template <typename PluginType>
52  class TemplatePluginPtr final
53  {
57  public: ~TemplatePluginPtr() = default;
58 
62  public: TemplatePluginPtr();
63 
67  public: TemplatePluginPtr(const TemplatePluginPtr &_other);
68 
74  public: TemplatePluginPtr(TemplatePluginPtr &&_other);
75 
84  public: template <typename OtherPluginType>
87 
93  public: TemplatePluginPtr &operator =(const TemplatePluginPtr &_other);
94 
102  public: template <typename OtherPluginType>
103  TemplatePluginPtr &operator =(
104  const TemplatePluginPtr<OtherPluginType> &_other);
105 
112  public: TemplatePluginPtr &operator=(TemplatePluginPtr &&_other);
113 
117  public: TemplatePluginPtr &operator=(std::nullptr_t);
118 
123  public: PluginType *operator->() const;
124 
128  public: PluginType &operator*() const;
129 
134  public: bool operator ==(const TemplatePluginPtr &_other) const;
135 
141  public: bool operator <(const TemplatePluginPtr &_other) const;
142 
148  public: bool operator >(const TemplatePluginPtr &_other) const;
149 
154  public: bool operator !=(const TemplatePluginPtr &_other) const;
155 
161  public: bool operator <=(const TemplatePluginPtr &_other) const;
162 
168  public: bool operator >=(const TemplatePluginPtr &_other) const;
169 
176  public: std::size_t Hash() const;
177 
181  public: bool IsEmpty() const;
182 
185  public: operator bool() const;
186 
190  public: void Clear();
191 
193  private: std::unique_ptr<PluginType> dataPtr;
194 
195  // Declare friendship
196  friend class Loader;
197  template <class> friend class TemplatePluginPtr;
198 
206  private: explicit TemplatePluginPtr(
207  const ConstInfoPtr &_info,
208  const std::shared_ptr<void> &_dlHandlePtr);
209  };
210 
214 
218  }
219 }
220 
221 #include "ignition/plugin/detail/PluginPtr.hh"
222 
223 #endif
This class manages the lifecycle of a plugin instance. It can receive a plugin instance from the Load...
Definition: PluginPtr.hh:52
Definition: EnablePluginFromThis.hh:25
Class for loading plugins.
Definition: Loader.hh:38