dynamic_geometry_concept.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // Boost.Geometry
  2. // Copyright (c) 2021, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  4. // Licensed under the Boost Software License version 1.0.
  5. // http://www.boost.org/users/license.html
  6. #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_DYNAMIC_GEOMETRY_CONCEPT_HPP
  7. #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_DYNAMIC_GEOMETRY_CONCEPT_HPP
  8. #include <utility>
  9. #include <boost/concept_check.hpp>
  10. #include <boost/geometry/core/geometry_types.hpp>
  11. #include <boost/geometry/core/tags.hpp>
  12. #include <boost/geometry/core/visit.hpp>
  13. #include <boost/geometry/geometries/concepts/box_concept.hpp>
  14. #include <boost/geometry/geometries/concepts/concept_type.hpp>
  15. #include <boost/geometry/geometries/concepts/geometry_collection_concept.hpp>
  16. #include <boost/geometry/geometries/concepts/linestring_concept.hpp>
  17. #include <boost/geometry/geometries/concepts/multi_point_concept.hpp>
  18. #include <boost/geometry/geometries/concepts/multi_linestring_concept.hpp>
  19. #include <boost/geometry/geometries/concepts/multi_polygon_concept.hpp>
  20. #include <boost/geometry/geometries/concepts/point_concept.hpp>
  21. #include <boost/geometry/geometries/concepts/polygon_concept.hpp>
  22. #include <boost/geometry/geometries/concepts/ring_concept.hpp>
  23. #include <boost/geometry/geometries/concepts/segment_concept.hpp>
  24. namespace boost { namespace geometry { namespace concepts
  25. {
  26. namespace detail
  27. {
  28. template <typename Geometry, typename SubGeometry>
  29. struct GeometryType<Geometry, SubGeometry, dynamic_geometry_tag, false>
  30. : concepts::concept_type<SubGeometry>::type
  31. {
  32. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  33. BOOST_CONCEPT_USAGE(GeometryType)
  34. {
  35. Geometry* dg = nullptr;
  36. SubGeometry* sg = nullptr;
  37. *dg = std::move(*sg);
  38. }
  39. #endif // DOXYGEN_NO_CONCEPT_MEMBERS
  40. };
  41. template <typename Geometry, typename SubGeometry>
  42. struct GeometryType<Geometry const, SubGeometry, dynamic_geometry_tag, false>
  43. : concepts::concept_type<SubGeometry const>::type
  44. {};
  45. } // namespace detail
  46. template <typename Geometry>
  47. struct DynamicGeometry
  48. {
  49. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  50. using sequence_t = typename traits::geometry_types<Geometry>::type;
  51. BOOST_CONCEPT_ASSERT((detail::GeometryTypes<Geometry, sequence_t>));
  52. BOOST_CONCEPT_USAGE(DynamicGeometry)
  53. {
  54. Geometry* dg = nullptr;
  55. traits::visit<Geometry>::apply([](auto &&) {}, *dg);
  56. }
  57. #endif // DOXYGEN_NO_CONCEPT_MEMBERS
  58. };
  59. template <typename Geometry>
  60. struct ConstDynamicGeometry
  61. {
  62. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  63. using sequence_t = typename traits::geometry_types<Geometry>::type;
  64. BOOST_CONCEPT_ASSERT((detail::GeometryTypes<Geometry const, sequence_t>));
  65. BOOST_CONCEPT_USAGE(ConstDynamicGeometry)
  66. {
  67. Geometry const* dg = nullptr;
  68. traits::visit<Geometry>::apply([](auto &&) {}, *dg);
  69. }
  70. #endif // DOXYGEN_NO_CONCEPT_MEMBERS
  71. };
  72. template <typename Geometry>
  73. struct concept_type<Geometry, dynamic_geometry_tag>
  74. {
  75. using type = DynamicGeometry<Geometry>;
  76. };
  77. template <typename Geometry>
  78. struct concept_type<Geometry const, dynamic_geometry_tag>
  79. {
  80. using type = ConstDynamicGeometry<Geometry>;
  81. };
  82. }}} // namespace boost::geometry::concepts
  83. #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_DYNAMIC_GEOMETRY_CONCEPT_HPP