Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:27

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2021, Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0006 
0007 // Licensed under the Boost Software License version 1.0.
0008 // http://www.boost.org/users/license.html
0009 
0010 #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_GEOMETRY_COLLECTION_CONCEPT_HPP
0011 #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_GEOMETRY_COLLECTION_CONCEPT_HPP
0012 
0013 
0014 #include <utility>
0015 
0016 #include <boost/concept_check.hpp>
0017 #include <boost/range/concepts.hpp>
0018 
0019 #include <boost/geometry/core/geometry_types.hpp>
0020 #include <boost/geometry/core/mutable_range.hpp>
0021 #include <boost/geometry/core/tag.hpp>
0022 #include <boost/geometry/core/tags.hpp>
0023 #include <boost/geometry/core/visit.hpp>
0024 
0025 #include <boost/geometry/geometries/concepts/box_concept.hpp>
0026 #include <boost/geometry/geometries/concepts/concept_type.hpp>
0027 #include <boost/geometry/geometries/concepts/linestring_concept.hpp>
0028 #include <boost/geometry/geometries/concepts/multi_point_concept.hpp>
0029 #include <boost/geometry/geometries/concepts/multi_linestring_concept.hpp>
0030 #include <boost/geometry/geometries/concepts/multi_polygon_concept.hpp>
0031 #include <boost/geometry/geometries/concepts/point_concept.hpp>
0032 #include <boost/geometry/geometries/concepts/polygon_concept.hpp>
0033 #include <boost/geometry/geometries/concepts/ring_concept.hpp>
0034 #include <boost/geometry/geometries/concepts/segment_concept.hpp>
0035 
0036 #include <boost/geometry/util/sequence.hpp>
0037 #include <boost/geometry/util/type_traits.hpp>
0038 
0039 
0040 namespace boost { namespace geometry { namespace concepts
0041 {
0042 
0043 namespace detail
0044 {
0045 
0046 template
0047 <
0048     typename Geometry,
0049     typename SubGeometry,
0050     typename Tag = typename tag<Geometry>::type,
0051     bool IsSubDynamicOrCollection = util::is_dynamic_geometry<SubGeometry>::value
0052                                  || util::is_geometry_collection<SubGeometry>::value
0053 >
0054 struct GeometryType;
0055 
0056 // Prevent recursive concept checking
0057 template <typename Geometry, typename SubGeometry, typename Tag>
0058 struct GeometryType<Geometry, SubGeometry, Tag, true> {};
0059 
0060 template <typename Geometry, typename SubGeometry, typename Tag>
0061 struct GeometryType<Geometry const, SubGeometry, Tag, true> {};
0062 
0063 
0064 template <typename Geometry, typename SubGeometry>
0065 struct GeometryType<Geometry, SubGeometry, geometry_collection_tag, false>
0066     : concepts::concept_type<SubGeometry>::type
0067 {
0068 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
0069     BOOST_CONCEPT_USAGE(GeometryType)
0070     {
0071         Geometry* gc = nullptr;
0072         SubGeometry* sg = nullptr;
0073         traits::emplace_back<Geometry>::apply(*gc, std::move(*sg));
0074     }
0075 #endif // DOXYGEN_NO_CONCEPT_MEMBERS
0076 };
0077 
0078 template <typename Geometry, typename SubGeometry>
0079 struct GeometryType<Geometry const, SubGeometry, geometry_collection_tag, false>
0080     : concepts::concept_type<SubGeometry const>::type
0081 {};
0082 
0083 
0084 template <typename Geometry, typename ...SubGeometries>
0085 struct GeometryTypesPack {};
0086 
0087 template <typename Geometry, typename SubGeometry, typename ...SubGeometries>
0088 struct GeometryTypesPack<Geometry, SubGeometry, SubGeometries...>
0089     : GeometryTypesPack<Geometry, SubGeometries...>
0090     , GeometryType<Geometry, SubGeometry>
0091 {};
0092 
0093 
0094 template <typename Geometry, typename SubGeometriesSequence>
0095 struct GeometryTypes;
0096 
0097 template <typename Geometry, typename ...SubGeometries>
0098 struct GeometryTypes<Geometry, util::type_sequence<SubGeometries...>>
0099     : GeometryTypesPack<Geometry, SubGeometries...>
0100 {};
0101 
0102 
0103 } // namespace detail
0104 
0105 
0106 template <typename Geometry>
0107 struct GeometryCollection
0108     : boost::ForwardRangeConcept<Geometry>
0109 {
0110 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
0111     using sequence_t = typename traits::geometry_types<Geometry>::type;
0112     BOOST_CONCEPT_ASSERT( (detail::GeometryTypes<Geometry, sequence_t>) );
0113 
0114     BOOST_CONCEPT_USAGE(GeometryCollection)
0115     {
0116         Geometry* gc = nullptr;
0117         traits::clear<Geometry>::apply(*gc);
0118         traits::iter_visit<Geometry>::apply([](auto &&) {}, boost::begin(*gc));
0119     }
0120 #endif // DOXYGEN_NO_CONCEPT_MEMBERS
0121 };
0122 
0123 
0124 template <typename Geometry>
0125 struct ConstGeometryCollection
0126     : boost::ForwardRangeConcept<Geometry>
0127 {
0128 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
0129     using sequence_t = typename traits::geometry_types<Geometry>::type;
0130     BOOST_CONCEPT_ASSERT( (detail::GeometryTypes<Geometry const, sequence_t>) );
0131 
0132     BOOST_CONCEPT_USAGE(ConstGeometryCollection)
0133     {
0134         Geometry const* gc = nullptr;
0135         traits::iter_visit<Geometry>::apply([](auto &&) {}, boost::begin(*gc));
0136     }
0137 #endif // DOXYGEN_NO_CONCEPT_MEMBERS
0138 };
0139 
0140 
0141 template <typename Geometry>
0142 struct concept_type<Geometry, geometry_collection_tag>
0143 {
0144     using type = GeometryCollection<Geometry>;
0145 };
0146 
0147 template <typename Geometry>
0148 struct concept_type<Geometry const, geometry_collection_tag>
0149 {
0150     using type = ConstGeometryCollection<Geometry>;
0151 };
0152 
0153 
0154 }}} // namespace boost::geometry::concepts
0155 
0156 
0157 #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_GEOMETRY_COLLECTION_CONCEPT_HPP