1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
4 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
15 #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP
16 #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP
19 #include <boost/concept_check.hpp>
20 #include <boost/concept/requires.hpp>
21 #include <boost/type_traits/is_const.hpp>
22 #include <boost/variant/variant_fwd.hpp>
24 #include <boost/geometry/core/tag.hpp>
25 #include <boost/geometry/core/tags.hpp>
27 #include <boost/geometry/geometries/concepts/box_concept.hpp>
28 #include <boost/geometry/geometries/concepts/linestring_concept.hpp>
29 #include <boost/geometry/geometries/concepts/multi_point_concept.hpp>
30 #include <boost/geometry/geometries/concepts/multi_linestring_concept.hpp>
31 #include <boost/geometry/geometries/concepts/multi_polygon_concept.hpp>
32 #include <boost/geometry/geometries/concepts/point_concept.hpp>
33 #include <boost/geometry/geometries/concepts/polygon_concept.hpp>
34 #include <boost/geometry/geometries/concepts/ring_concept.hpp>
35 #include <boost/geometry/geometries/concepts/segment_concept.hpp>
37 #include <boost/geometry/algorithms/not_implemented.hpp>
39 namespace boost { namespace geometry
43 #ifndef DOXYGEN_NO_DETAIL
44 namespace detail { namespace concept_check
47 template <typename Concept>
50 BOOST_CONCEPT_ASSERT((Concept ));
53 }} // namespace detail::concept_check
54 #endif // DOXYGEN_NO_DETAIL
58 #ifndef DOXYGEN_NO_DISPATCH
65 typename GeometryTag = typename geometry::tag<Geometry>::type,
66 bool IsConst = boost::is_const<Geometry>::type::value
68 struct check : not_implemented<GeometryTag>
72 template <typename Geometry>
73 struct check<Geometry, point_tag, true>
74 : detail::concept_check::check<concepts::ConstPoint<Geometry> >
78 template <typename Geometry>
79 struct check<Geometry, point_tag, false>
80 : detail::concept_check::check<concepts::Point<Geometry> >
84 template <typename Geometry>
85 struct check<Geometry, linestring_tag, true>
86 : detail::concept_check::check<concepts::ConstLinestring<Geometry> >
90 template <typename Geometry>
91 struct check<Geometry, linestring_tag, false>
92 : detail::concept_check::check<concepts::Linestring<Geometry> >
96 template <typename Geometry>
97 struct check<Geometry, ring_tag, true>
98 : detail::concept_check::check<concepts::ConstRing<Geometry> >
102 template <typename Geometry>
103 struct check<Geometry, ring_tag, false>
104 : detail::concept_check::check<concepts::Ring<Geometry> >
107 template <typename Geometry>
108 struct check<Geometry, polygon_tag, true>
109 : detail::concept_check::check<concepts::ConstPolygon<Geometry> >
113 template <typename Geometry>
114 struct check<Geometry, polygon_tag, false>
115 : detail::concept_check::check<concepts::Polygon<Geometry> >
119 template <typename Geometry>
120 struct check<Geometry, box_tag, true>
121 : detail::concept_check::check<concepts::ConstBox<Geometry> >
125 template <typename Geometry>
126 struct check<Geometry, box_tag, false>
127 : detail::concept_check::check<concepts::Box<Geometry> >
131 template <typename Geometry>
132 struct check<Geometry, segment_tag, true>
133 : detail::concept_check::check<concepts::ConstSegment<Geometry> >
137 template <typename Geometry>
138 struct check<Geometry, segment_tag, false>
139 : detail::concept_check::check<concepts::Segment<Geometry> >
143 template <typename Geometry>
144 struct check<Geometry, multi_point_tag, true>
145 : detail::concept_check::check<concepts::ConstMultiPoint<Geometry> >
149 template <typename Geometry>
150 struct check<Geometry, multi_point_tag, false>
151 : detail::concept_check::check<concepts::MultiPoint<Geometry> >
155 template <typename Geometry>
156 struct check<Geometry, multi_linestring_tag, true>
157 : detail::concept_check::check<concepts::ConstMultiLinestring<Geometry> >
161 template <typename Geometry>
162 struct check<Geometry, multi_linestring_tag, false>
163 : detail::concept_check::check<concepts::MultiLinestring<Geometry> >
167 template <typename Geometry>
168 struct check<Geometry, multi_polygon_tag, true>
169 : detail::concept_check::check<concepts::ConstMultiPolygon<Geometry> >
173 template <typename Geometry>
174 struct check<Geometry, multi_polygon_tag, false>
175 : detail::concept_check::check<concepts::MultiPolygon<Geometry> >
179 } // namespace dispatch
189 #ifndef DOXYGEN_NO_DETAIL
194 template <typename Geometry>
195 struct checker : dispatch::check<Geometry>
198 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
199 struct checker<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
202 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
203 struct checker<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const>
208 #endif // DOXYGEN_NO_DETAIL
212 \brief Checks, in compile-time, the concept of any geometry
215 template <typename Geometry>
218 detail::checker<Geometry> c;
219 boost::ignore_unused_variable_warning(c);
224 \brief Checks, in compile-time, the concept of two geometries, and if they
225 have equal dimensions
228 template <typename Geometry1, typename Geometry2>
229 inline void check_concepts_and_equal_dimensions()
233 assert_dimension_equal<Geometry1, Geometry2>();
237 } // namespace concepts
240 }} // namespace boost::geometry
243 #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP