|
19 | 19 | * |
20 | 20 | * Use in the private section of the class. |
21 | 21 | */ |
22 | | -#define RCLCPP_DISABLE_COPY(Class) \ |
23 | | - Class(const Class &) = delete; \ |
24 | | - Class & operator=(const Class &) = delete; |
| 22 | +#define RCLCPP_DISABLE_COPY(...) \ |
| 23 | + __VA_ARGS__(const __VA_ARGS__ &) = delete; \ |
| 24 | + __VA_ARGS__ & operator=(const __VA_ARGS__ &) = delete; |
25 | 25 |
|
26 | 26 | /* Defines aliases and static functions for using the Class with smart pointers. |
27 | 27 | * |
28 | 28 | * Use in the public section of the class. |
29 | 29 | * Make sure to include <memory> in the header when using this. |
30 | 30 | */ |
31 | | -#define RCLCPP_SMART_PTR_DEFINITIONS(Class) \ |
32 | | - RCLCPP_SHARED_PTR_DEFINITIONS(Class) \ |
33 | | - RCLCPP_WEAK_PTR_DEFINITIONS(Class) \ |
34 | | - RCLCPP_UNIQUE_PTR_DEFINITIONS(Class) |
| 31 | +#define RCLCPP_SMART_PTR_DEFINITIONS(...) \ |
| 32 | + RCLCPP_SHARED_PTR_DEFINITIONS(__VA_ARGS__) \ |
| 33 | + RCLCPP_WEAK_PTR_DEFINITIONS(__VA_ARGS__) \ |
| 34 | + RCLCPP_UNIQUE_PTR_DEFINITIONS(__VA_ARGS__) |
35 | 35 |
|
36 | 36 | /* Defines aliases and static functions for using the Class with smart pointers. |
37 | 37 | * |
|
42 | 42 | * Use in the public section of the class. |
43 | 43 | * Make sure to include <memory> in the header when using this. |
44 | 44 | */ |
45 | | -#define RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(Class) \ |
46 | | - RCLCPP_SHARED_PTR_DEFINITIONS(Class) \ |
47 | | - RCLCPP_WEAK_PTR_DEFINITIONS(Class) \ |
48 | | - __RCLCPP_UNIQUE_PTR_ALIAS(Class) |
| 45 | +#define RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(...) \ |
| 46 | + RCLCPP_SHARED_PTR_DEFINITIONS(__VA_ARGS__) \ |
| 47 | + RCLCPP_WEAK_PTR_DEFINITIONS(__VA_ARGS__) \ |
| 48 | + __RCLCPP_UNIQUE_PTR_ALIAS(__VA_ARGS__) |
49 | 49 |
|
50 | | -#define __RCLCPP_SHARED_PTR_ALIAS(Class) using SharedPtr = std::shared_ptr<Class>; |
| 50 | +#define __RCLCPP_SHARED_PTR_ALIAS(...) using SharedPtr = std::shared_ptr<__VA_ARGS__>; |
51 | 51 |
|
52 | | -#define __RCLCPP_MAKE_SHARED_DEFINITION(Class) \ |
| 52 | +#define __RCLCPP_MAKE_SHARED_DEFINITION(...) \ |
53 | 53 | template<typename ... Args> \ |
54 | | - static std::shared_ptr<Class> \ |
| 54 | + static std::shared_ptr<__VA_ARGS__> \ |
55 | 55 | make_shared(Args && ... args) \ |
56 | 56 | { \ |
57 | | - return std::make_shared<Class>(std::forward<Args>(args) ...); \ |
| 57 | + return std::make_shared<__VA_ARGS__>(std::forward<Args>(args) ...); \ |
58 | 58 | } |
59 | 59 |
|
60 | 60 | /// Defines aliases and static functions for using the Class with shared_ptrs. |
61 | | -#define RCLCPP_SHARED_PTR_DEFINITIONS(Class) \ |
62 | | - __RCLCPP_SHARED_PTR_ALIAS(Class) \ |
63 | | - __RCLCPP_MAKE_SHARED_DEFINITION(Class) |
| 61 | +#define RCLCPP_SHARED_PTR_DEFINITIONS(...) \ |
| 62 | + __RCLCPP_SHARED_PTR_ALIAS(__VA_ARGS__) \ |
| 63 | + __RCLCPP_MAKE_SHARED_DEFINITION(__VA_ARGS__) |
64 | 64 |
|
65 | | -#define __RCLCPP_WEAK_PTR_ALIAS(Class) using WeakPtr = std::weak_ptr<Class>; |
| 65 | +#define __RCLCPP_WEAK_PTR_ALIAS(...) using WeakPtr = std::weak_ptr<__VA_ARGS__>; |
66 | 66 |
|
67 | 67 | /// Defines aliases and static functions for using the Class with weak_ptrs. |
68 | | -#define RCLCPP_WEAK_PTR_DEFINITIONS(Class) __RCLCPP_WEAK_PTR_ALIAS(Class) |
| 68 | +#define RCLCPP_WEAK_PTR_DEFINITIONS(...) __RCLCPP_WEAK_PTR_ALIAS(__VA_ARGS__) |
69 | 69 |
|
70 | | -#define __RCLCPP_UNIQUE_PTR_ALIAS(Class) using UniquePtr = std::unique_ptr<Class>; |
| 70 | +#define __RCLCPP_UNIQUE_PTR_ALIAS(...) using UniquePtr = std::unique_ptr<__VA_ARGS__>; |
71 | 71 |
|
72 | | -#define __RCLCPP_MAKE_UNIQUE_DEFINITION(Class) \ |
| 72 | +#define __RCLCPP_MAKE_UNIQUE_DEFINITION(...) \ |
73 | 73 | template<typename ... Args> \ |
74 | | - static std::unique_ptr<Class> \ |
| 74 | + static std::unique_ptr<__VA_ARGS__> \ |
75 | 75 | make_unique(Args && ... args) \ |
76 | 76 | { \ |
77 | | - return std::unique_ptr<Class>(new Class(std::forward<Args>(args) ...)); \ |
| 77 | + return std::unique_ptr<__VA_ARGS__>(new __VA_ARGS__(std::forward<Args>(args) ...)); \ |
78 | 78 | } |
79 | 79 | /// Defines aliases and static functions for using the Class with unique_ptrs. |
80 | | -#define RCLCPP_UNIQUE_PTR_DEFINITIONS(Class) \ |
81 | | - __RCLCPP_UNIQUE_PTR_ALIAS(Class) \ |
82 | | - __RCLCPP_MAKE_UNIQUE_DEFINITION(Class) |
| 80 | +#define RCLCPP_UNIQUE_PTR_DEFINITIONS(...) \ |
| 81 | + __RCLCPP_UNIQUE_PTR_ALIAS(__VA_ARGS__) \ |
| 82 | + __RCLCPP_MAKE_UNIQUE_DEFINITION(__VA_ARGS__) |
83 | 83 |
|
84 | 84 | #define RCLCPP_INFO(Args) std::cout << Args << std::endl; |
85 | 85 |
|
|
0 commit comments