From 6770960661c1b389f252109999162f458d0d4c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20G=C3=B6rner?= Date: Sun, 24 Nov 2019 13:16:21 +0100 Subject: [PATCH] Provide UniquePtr macros (#1771) --- .../include/moveit/macros/class_forward.h | 4 +-- .../include/moveit/macros/declare_ptr.h | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/moveit_core/macros/include/moveit/macros/class_forward.h b/moveit_core/macros/include/moveit/macros/class_forward.h index 57bb5ce56b..126537803e 100644 --- a/moveit_core/macros/include/moveit/macros/class_forward.h +++ b/moveit_core/macros/include/moveit/macros/class_forward.h @@ -41,9 +41,7 @@ /** * \def MOVEIT_CLASS_FORWARD - * Macro that forward declares a class and defines two shared ptrs types: - * - ${Class}Ptr = shared_ptr<${Class}> - * - ${Class}ConstPtr = shared_ptr + * Macro that forward declares a class and defines the respective smartpointers through MOVEIT_DECLARE_PTR. */ #define MOVEIT_CLASS_FORWARD(C) \ diff --git a/moveit_core/macros/include/moveit/macros/declare_ptr.h b/moveit_core/macros/include/moveit/macros/declare_ptr.h index 36506e618a..5169e5088d 100644 --- a/moveit_core/macros/include/moveit/macros/declare_ptr.h +++ b/moveit_core/macros/include/moveit/macros/declare_ptr.h @@ -40,8 +40,12 @@ /** * \def MOVEIT_DELCARE_PTR * Macro that given a Name and a Type declares the following types: - * - ${Name}Ptr = shared_ptr<${Type}> - * - ${Name}ConstPtr = shared_ptr + * - ${Name}Ptr = shared_ptr<${Type}> + * - ${Name}ConstPtr = shared_ptr + * - ${Name}WeakPtr = weak_ptr<${Type}> + * - ${Name}ConstWeakPtr = weak_ptr + * - ${Name}UniquePtr = unique_ptr<${Type}> + * - ${Name}ConstUniquePtr = unique_ptr * * For best portability the exact type of shared_ptr declared by the macro * should be considered to be an implementation detail, liable to change in @@ -52,23 +56,24 @@ typedef std::shared_ptr Name##Ptr; \ typedef std::shared_ptr Name##ConstPtr; \ typedef std::weak_ptr Name##WeakPtr; \ - typedef std::weak_ptr Name##ConstWeakPtr; + typedef std::weak_ptr Name##ConstWeakPtr; \ + typedef std::unique_ptr Name##UniquePtr; \ + typedef std::unique_ptr Name##ConstUniquePtr; /** * \def MOVEIT_DELCARE_PTR_MEMBER - * Macro that given a Type declares the following types: - * - Ptr = shared_ptr<${Type}> - * - ConstPtr = shared_ptr + * The macro defines the same typedefs as MOVEIT_DECLARE_PTR, but shortens the new names to their suffix. * - * This macro is intended for declaring the pointer typedefs as members of a - * class template. In other situations, MOVEIT_CLASS_FORWARD and - * MOVEIT_DECLARE_PTR should be preferred. + * This can be used to create `Classname::Ptr` style names, but in most situations in MoveIt's codebase, + * MOVEIT_CLASS_FORWARD and MOVEIT_DECLARE_PTR should be preferred. */ #define MOVEIT_DECLARE_PTR_MEMBER(Type) \ typedef std::shared_ptr Ptr; \ typedef std::shared_ptr ConstPtr; \ typedef std::weak_ptr WeakPtr; \ - typedef std::weak_ptr ConstWeakPtr; + typedef std::weak_ptr ConstWeakPtr; \ + typedef std::unique_ptr UniquePtr; \ + typedef std::unique_ptr ConstUniquePtr; #endif