Gazebo Plugin

API Reference

1.4.0
gz/plugin/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 GZ_PLUGIN_PLUGINPTR_HH_
20 #define GZ_PLUGIN_PLUGINPTR_HH_
21 
22 #include <map>
23 #include <string>
24 #include <memory>
25 
26 #include <gz/plugin/Plugin.hh>
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>
104  const TemplatePluginPtr<OtherPluginType> &_other);
105 
112  public: TemplatePluginPtr &operator=(TemplatePluginPtr &&_other);
113 
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 "gz/plugin/detail/PluginPtr.hh"
222 
223 #endif
bool operator<=(const TemplatePluginPtr &_other) const
Comparison operator.
Definition: gz/plugin/EnablePluginFromThis.hh:25
STL class.
std::size_t Hash() const
Produces a hash for the plugin instance that this PluginPtr is holding. This function allows PluginPt...
~TemplatePluginPtr()=default
Destructor. Deletes this PluginPtr's reference to the plugin instance. Once all PluginPtrs that refer...
bool operator>(const TemplatePluginPtr &_other) const
Comparison operator.
bool operator!=(const TemplatePluginPtr &_other) const
Comparison operator.
bool operator>=(const TemplatePluginPtr &_other) const
Comparison operator.
friend class TemplatePluginPtr
Definition: gz/plugin/PluginPtr.hh:197
PluginType & operator*() const
Get a reference to the wrapper for the plugin instance that is being managed by this PluginPtr.
void Clear()
Clears the Plugin instance from this PluginPtr. IsEmpty() will return true after this is used,...
TemplatePluginPtr & operator=(const TemplatePluginPtr &_other)
Copy assignment operator. This PluginPtr will now point at the same plugin instance as _other,...
PluginType * operator->() const
Access the wrapper for the plugin instance and call one of its member functions.
bool operator<(const TemplatePluginPtr &_other) const
Comparison operator.
Class for loading plugins.
Definition: gz/plugin/Loader.hh:38
This class manages the lifecycle of a plugin instance. It can receive a plugin instance from the igni...
Definition: gz/plugin/PluginPtr.hh:52
bool operator==(const TemplatePluginPtr &_other) const
Comparison operator.
bool IsEmpty() const
Check whether this is pointing at a valid plugin.