rclcpp
master
C++ ROS Client Library API
include
rclcpp
macros.hpp
Go to the documentation of this file.
1
// Copyright 2014 Open Source Robotics Foundation, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include <memory>
16
#include <utility>
17
18
#ifndef RCLCPP__MACROS_HPP_
19
#define RCLCPP__MACROS_HPP_
20
26
#define RCLCPP_DISABLE_COPY(...) \
27
__VA_ARGS__(const __VA_ARGS__ &) = delete; \
28
__VA_ARGS__ & operator=(const __VA_ARGS__ &) = delete;
29
36
#define RCLCPP_SMART_PTR_DEFINITIONS(...) \
37
RCLCPP_SHARED_PTR_DEFINITIONS(__VA_ARGS__) \
38
RCLCPP_WEAK_PTR_DEFINITIONS(__VA_ARGS__) \
39
RCLCPP_UNIQUE_PTR_DEFINITIONS(__VA_ARGS__)
40
51
#define RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(...) \
52
RCLCPP_SHARED_PTR_DEFINITIONS(__VA_ARGS__) \
53
RCLCPP_WEAK_PTR_DEFINITIONS(__VA_ARGS__) \
54
__RCLCPP_UNIQUE_PTR_ALIAS(__VA_ARGS__)
55
66
#define RCLCPP_SMART_PTR_ALIASES_ONLY(...) \
67
__RCLCPP_SHARED_PTR_ALIAS(__VA_ARGS__) \
68
__RCLCPP_WEAK_PTR_ALIAS(__VA_ARGS__) \
69
__RCLCPP_UNIQUE_PTR_ALIAS(__VA_ARGS__) \
70
__RCLCPP_MAKE_SHARED_DEFINITION(__VA_ARGS__)
71
72
#define __RCLCPP_SHARED_PTR_ALIAS(...) \
73
using SharedPtr = std::shared_ptr<__VA_ARGS__>; \
74
using ConstSharedPtr = std::shared_ptr<const __VA_ARGS__>;
75
76
#define __RCLCPP_MAKE_SHARED_DEFINITION(...) \
77
template<typename ... Args> \
78
static std::shared_ptr<__VA_ARGS__> \
79
make_shared(Args && ... args) \
80
{ \
81
return std::make_shared<__VA_ARGS__>(std::forward<Args>(args) ...); \
82
}
83
85
#define RCLCPP_SHARED_PTR_DEFINITIONS(...) \
86
__RCLCPP_SHARED_PTR_ALIAS(__VA_ARGS__) \
87
__RCLCPP_MAKE_SHARED_DEFINITION(__VA_ARGS__)
88
89
#define __RCLCPP_WEAK_PTR_ALIAS(...) \
90
using WeakPtr = std::weak_ptr<__VA_ARGS__>; \
91
using ConstWeakPtr = std::weak_ptr<const __VA_ARGS__>;
92
94
#define RCLCPP_WEAK_PTR_DEFINITIONS(...) __RCLCPP_WEAK_PTR_ALIAS(__VA_ARGS__)
95
96
#define __RCLCPP_UNIQUE_PTR_ALIAS(...) using UniquePtr = std::unique_ptr<__VA_ARGS__>;
97
98
#define __RCLCPP_MAKE_UNIQUE_DEFINITION(...) \
99
template<typename ... Args> \
100
static std::unique_ptr<__VA_ARGS__> \
101
make_unique(Args && ... args) \
102
{ \
103
return std::unique_ptr<__VA_ARGS__>(new __VA_ARGS__(std::forward<Args>(args) ...)); \
104
}
105
107
#define RCLCPP_UNIQUE_PTR_DEFINITIONS(...) \
108
__RCLCPP_UNIQUE_PTR_ALIAS(__VA_ARGS__) \
109
__RCLCPP_MAKE_UNIQUE_DEFINITION(__VA_ARGS__)
110
111
#define RCLCPP_STRING_JOIN(arg1, arg2) RCLCPP_DO_STRING_JOIN(arg1, arg2)
112
#define RCLCPP_DO_STRING_JOIN(arg1, arg2) arg1 ## arg2
113
114
#endif // RCLCPP__MACROS_HPP_
Generated by
1.8.13