.. _program_listing_file__tmp_ws_src_rmf_traffic_rmf_traffic_include_rmf_traffic_geometry_Shape.hpp: Program Listing for File Shape.hpp ================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/rmf_traffic/rmf_traffic/include/rmf_traffic/geometry/Shape.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /* * Copyright (C) 2019 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef RMF_TRAFFIC__GEOMETRY__SHAPE_HPP #define RMF_TRAFFIC__GEOMETRY__SHAPE_HPP #include #include #include namespace rmf_traffic { namespace geometry { class FinalShape; //============================================================================== class Shape { public: virtual FinalShape finalize() const = 0; // Abstract shape references must not be moved, because we cannot ensure that // they get moved into the same derived type. Shape(Shape&&) = delete; Shape& operator=(Shape&&) = delete; class Internal; virtual ~Shape(); protected: Internal* _get_internal(); const Internal* _get_internal() const; Shape(std::unique_ptr internal); private: std::unique_ptr _internal; }; using ShapePtr = std::shared_ptr; using ConstShapePtr = std::shared_ptr; //============================================================================== class FinalShape { public: const Shape& source() const; double get_characteristic_length() const; virtual ~FinalShape() = default; bool operator==(const FinalShape& other) const; bool operator!=(const FinalShape& other) const; class Implementation; protected: FinalShape(); rmf_utils::impl_ptr _pimpl; }; using FinalShapePtr = std::shared_ptr; using ConstFinalShapePtr = std::shared_ptr; //============================================================================== template FinalShapePtr make_final(Args&& ... args) { return std::make_shared( T(std::forward(args)...).finalize()); } //============================================================================== template FinalShapePtr make_final(const T& shape) { return std::make_shared(shape.finalize()); } } // namespace geometry } // namespace rmf_traffic #endif // RMF_TRAFFIC__GEOMETRY__SHAPE_HPP