Gazebo Plugin

API Reference

1.2.1
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
28namespace ignition
29{
30 namespace plugin
31 {
32 // Forward declarations
33 namespace detail { template<class, class> class ComposePlugin; }
34
51 template <typename PluginType>
53 {
57 public: ~TemplatePluginPtr() = default;
58
63
67 public: TemplatePluginPtr(const TemplatePluginPtr &_other);
68
75
84 public: template <typename OtherPluginType>
87
94
102 public: template <typename OtherPluginType>
105
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 "ignition/plugin/detail/PluginPtr.hh"
222
223#endif
Class for loading plugins.
Definition: Loader.hh:39
This class manages the lifecycle of a plugin instance. It can receive a plugin instance from the igni...
Definition: PluginPtr.hh:53
bool operator>(const TemplatePluginPtr &_other) const
Comparison operator.
TemplatePluginPtr(const TemplatePluginPtr &_other)
Copy constructor. This PluginPtr will now point at the same plugin instance as _other,...
TemplatePluginPtr(const TemplatePluginPtr< OtherPluginType > &_other)
Casting constructor. This PluginPtr will now point at the same plugin instance as _other,...
bool operator!=(const TemplatePluginPtr &_other) const
Comparison operator.
bool operator<(const TemplatePluginPtr &_other) const
Comparison operator.
TemplatePluginPtr(TemplatePluginPtr &&_other)
Move constructor. This PluginPtr will take ownership of the plugin instance held by _other....
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...
TemplatePluginPtr & operator=(std::nullptr_t _null)
nullptr assignment operator. Same as calling Clear()
TemplatePluginPtr & operator=(const TemplatePluginPtr &_other)
Copy assignment operator. This PluginPtr will now point at the same plugin instance as _other,...
bool IsEmpty() const
Check whether this is pointing at a valid plugin.
friend class TemplatePluginPtr
Definition: PluginPtr.hh:197
TemplatePluginPtr & operator=(TemplatePluginPtr &&_other)
Move assignment operator. This PluginPtr will take ownership of the plugin instance held by _other....
void Clear()
Clears the Plugin instance from this PluginPtr. IsEmpty() will return true after this is used,...
PluginType & operator*() const
Get a reference to the wrapper for the plugin instance that is being managed by this PluginPtr.
bool operator==(const TemplatePluginPtr &_other) const
Comparison operator.
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.
TemplatePluginPtr()
Default constructor. Creates a PluginPtr object that does not point to any plugin instance....
bool operator>=(const TemplatePluginPtr &_other) const
Comparison operator.
Definition: EnablePluginFromThis.hh:26