Program Listing for File Shape.hpp
↰ Return to documentation for file (include/rmf_traffic/geometry/Shape.hpp
)
/*
* 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 <rmf_utils/impl_ptr.hpp>
#include <functional>
#include <memory>
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> internal);
private:
std::unique_ptr<Internal> _internal;
};
using ShapePtr = std::shared_ptr<Shape>;
using ConstShapePtr = std::shared_ptr<const Shape>;
//==============================================================================
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<Implementation> _pimpl;
};
using FinalShapePtr = std::shared_ptr<FinalShape>;
using ConstFinalShapePtr = std::shared_ptr<const FinalShape>;
//==============================================================================
template<typename T, typename... Args>
FinalShapePtr make_final(Args&& ... args)
{
return std::make_shared<FinalShape>(
T(std::forward<Args>(args)...).finalize());
}
//==============================================================================
template<typename T>
FinalShapePtr make_final(const T& shape)
{
return std::make_shared<FinalShape>(shape.finalize());
}
} // namespace geometry
} // namespace rmf_traffic
#endif // RMF_TRAFFIC__GEOMETRY__SHAPE_HPP