From 562ac9dd6d1b862da581f9d239ec362b69ee7ed6 Mon Sep 17 00:00:00 2001 From: tin1254 Date: Mon, 24 May 2021 02:55:22 +0200 Subject: [PATCH 1/2] Improve code style in documentation Update include guard to #pragma once, fix link to style guide --- doc/tutorials/content/writing_new_classes.rst | 42 ++++--------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/doc/tutorials/content/writing_new_classes.rst b/doc/tutorials/content/writing_new_classes.rst index b9eccd49689..bca60f66fdd 100644 --- a/doc/tutorials/content/writing_new_classes.rst +++ b/doc/tutorials/content/writing_new_classes.rst @@ -160,7 +160,7 @@ Setting up the structure If you're not familiar with the PCL file structure already, please go ahead and read the `PCL C++ Programming Style Guide - `_ to + `_ to familiarize yourself with the concepts. There're two different ways we could set up the structure: i) set up the code @@ -193,8 +193,7 @@ skeleton: .. code-block:: cpp :linenos: - #ifndef PCL_FILTERS_BILATERAL_H_ - #define PCL_FILTERS_BILATERAL_H_ + #pragma once #include @@ -206,8 +205,6 @@ skeleton: }; } - #endif // PCL_FILTERS_BILATERAL_H_ - bilateral.hpp ============= @@ -217,12 +214,9 @@ While we're at it, let's set up two skeleton *bilateral.hpp* and .. code-block:: cpp :linenos: - #ifndef PCL_FILTERS_BILATERAL_IMPL_H_ - #define PCL_FILTERS_BILATERAL_IMPL_H_ + #pragma once #include - - #endif // PCL_FILTERS_BILATERAL_IMPL_H_ This should be straightforward. We haven't declared any methods for `BilateralFilter` yet, therefore there is no implementation. @@ -511,8 +505,7 @@ header file becomes: .. code-block:: cpp :linenos: - #ifndef PCL_FILTERS_BILATERAL_H_ - #define PCL_FILTERS_BILATERAL_H_ + #pragma once #include #include @@ -584,8 +577,6 @@ header file becomes: }; } - #endif // PCL_FILTERS_BILATERAL_H_ - bilateral.hpp ============= @@ -651,8 +642,7 @@ entry for the class: .. code-block:: cpp :linenos: - #ifndef PCL_FILTERS_BILATERAL_IMPL_H_ - #define PCL_FILTERS_BILATERAL_IMPL_H_ + #pragma once #include @@ -660,8 +650,6 @@ entry for the class: #define PCL_INSTANTIATE_BilateralFilter(T) template class PCL_EXPORTS pcl::BilateralFilter; - #endif // PCL_FILTERS_BILATERAL_IMPL_H_ - One additional thing that we can do is error checking on: * whether the two `sigma_s_` and `sigma_r_` parameters have been given; @@ -709,8 +697,7 @@ The implementation file header thus becomes: .. code-block:: cpp :linenos: - #ifndef PCL_FILTERS_BILATERAL_IMPL_H_ - #define PCL_FILTERS_BILATERAL_IMPL_H_ + #pragma once #include #include @@ -770,8 +757,6 @@ The implementation file header thus becomes: #define PCL_INSTANTIATE_BilateralFilter(T) template class PCL_EXPORTS pcl::BilateralFilter; - #endif // PCL_FILTERS_BILATERAL_IMPL_H_ - Taking advantage of other PCL concepts -------------------------------------- @@ -824,8 +809,7 @@ The implementation file header thus becomes: .. code-block:: cpp :linenos: - #ifndef PCL_FILTERS_BILATERAL_IMPL_H_ - #define PCL_FILTERS_BILATERAL_IMPL_H_ + #pragma once #include #include @@ -885,8 +869,6 @@ The implementation file header thus becomes: #define PCL_INSTANTIATE_BilateralFilter(T) template class PCL_EXPORTS pcl::BilateralFilter; - #endif // PCL_FILTERS_BILATERAL_IMPL_H_ - To make :pcl:`indices_` work without typing the full construct, we need to add a new line to *bilateral.h* that specifies the class where `indices_` is declared: @@ -1020,8 +1002,7 @@ class look like: * */ - #ifndef PCL_FILTERS_BILATERAL_H_ - #define PCL_FILTERS_BILATERAL_H_ + #pragma once #include #include @@ -1131,8 +1112,6 @@ class look like: }; } - #endif // PCL_FILTERS_BILATERAL_H_ - And the *bilateral.hpp* likes: .. code-block:: cpp @@ -1175,8 +1154,7 @@ And the *bilateral.hpp* likes: * */ - #ifndef PCL_FILTERS_BILATERAL_IMPL_H_ - #define PCL_FILTERS_BILATERAL_IMPL_H_ + #pragma once #include #include @@ -1249,8 +1227,6 @@ And the *bilateral.hpp* likes: #define PCL_INSTANTIATE_BilateralFilter(T) template class PCL_EXPORTS pcl::BilateralFilter; - #endif // PCL_FILTERS_BILATERAL_IMPL_H_ - Testing the new class --------------------- From d0ebd87d3650b2205222f4a254051d5f92124549 Mon Sep 17 00:00:00 2001 From: tin1254 Date: Mon, 24 May 2021 15:18:57 +0200 Subject: [PATCH 2/2] Update license in documentation --- doc/tutorials/content/writing_new_classes.rst | 132 ++++-------------- 1 file changed, 24 insertions(+), 108 deletions(-) diff --git a/doc/tutorials/content/writing_new_classes.rst b/doc/tutorials/content/writing_new_classes.rst index bca60f66fdd..4c53f0e72bb 100644 --- a/doc/tutorials/content/writing_new_classes.rst +++ b/doc/tutorials/content/writing_new_classes.rst @@ -900,42 +900,14 @@ file, as follows: .. code-block:: cpp :linenos: - /* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2010-2011, Willow Garage, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ + /* + * SPDX-License-Identifier: BSD-3-Clause + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2014-, Open Perception Inc. + * + * All rights reserved + */ An additional like can be inserted if additional copyright is needed (or the original copyright can be changed): @@ -965,42 +937,14 @@ class look like: .. code-block:: cpp :linenos: - /* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2010-2011, Willow Garage, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ + /* + * SPDX-License-Identifier: BSD-3-Clause + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2014-, Open Perception Inc. + * + * All rights reserved + */ #pragma once @@ -1117,42 +1061,14 @@ And the *bilateral.hpp* likes: .. code-block:: cpp :linenos: - /* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2010-2011, Willow Garage, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ + /* + * SPDX-License-Identifier: BSD-3-Clause + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2014-, Open Perception Inc. + * + * All rights reserved + */ #pragma once