Gazebo Utils
API Reference
3.1.0
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
src
gz-utils
include
gz
utils
ImplPtr.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2018 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
#ifndef GZ_UTILS__IMPLPTR_HH_
19
#define GZ_UTILS__IMPLPTR_HH_
20
21
#include <memory>
22
#include <utility>
23
24
#include <gz/utils/detail/DefaultOps.hh>
25
#include <
gz/utils/SuppressWarning.hh
>
26
#include <gz/utils/Export.hh>
27
28
namespace
gz
29
{
30
namespace
utils
31
{
71
template
<
class
T,
72
class
Deleter = void (*)(T*),
73
class
Operations = detail::CopyMoveDeleteOperations<T> >
74
class
ImplPtr
75
{
84
public
:
template
<
class
U,
class
D,
class
Ops>
85
ImplPtr
(U *_ptr, D &&_deleter, Ops &&_ops);
86
89
public
:
ImplPtr
(
const
ImplPtr
&_other);
90
94
public
:
ImplPtr
&
operator=
(
const
ImplPtr
&_other);
95
96
// We explicitly declare the move constructor to make it clear that it is
97
// available.
98
public
:
ImplPtr
(
ImplPtr
&&) =
default
;
99
100
// We explicitly declare the move assignment operator to make it clear
101
// that it is available.
102
public
:
ImplPtr
&
operator=
(
ImplPtr
&&) =
default
;
103
105
public
:
~ImplPtr
() =
default
;
106
111
public
: T &
operator*
();
112
117
public
:
const
T &
operator*
()
const
;
118
123
public
: T *
operator->
();
124
129
public
:
const
T *
operator->
()
const
;
130
135
public
: T *
Get
();
136
141
public
:
const
T *
Get
()
const
;
142
151
private
:
ImplPtr
Clone()
const
;
152
154
private
:
std::unique_ptr<T, Deleter>
ptr;
155
157
private
: Operations ops;
158
};
159
183
template
<
class
T,
typename
... Args>
184
ImplPtr<T>
MakeImpl
(Args &&..._args);
185
200
template
<
class
T,
class
Deleter =
void
(*)(T*)>
201
using
UniqueImplPtr
=
std::unique_ptr<T, Deleter>
;
202
226
template
<
class
T,
typename
... Args>
227
UniqueImplPtr<T>
MakeUniqueImpl
(Args &&..._args);
228
}
// namespace utils
229
}
// namespace gz
230
233
#define GZ_UTILS_IMPL_PTR_FWD(ImplementationClass, memberName) \
234
GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING \
235
private: ::gz::utils::ImplPtr<ImplementationClass> memberName; \
236
GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
237
240
#define GZ_UTILS_UNIQUE_IMPL_PTR_FWD(ImplementationClass, memberName) \
241
GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING \
242
private: ::gz::utils::UniqueImplPtr<ImplementationClass> memberName; \
243
GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
244
247
#define GZ_UTILS_IMPL_PTR(memberName) \
248
public: class Implementation; \
249
GZ_UTILS_IMPL_PTR_FWD(Implementation, memberName)
250
253
#define GZ_UTILS_UNIQUE_IMPL_PTR(memberName) \
254
public: class Implementation; \
255
GZ_UTILS_UNIQUE_IMPL_PTR_FWD(Implementation, memberName)
256
257
258
#include <gz/utils/detail/ImplPtr.hh>
259
260
#endif
// GZ_UTILS__IMPLPTR_HH_