1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
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.
6
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
9
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)
13
14
15 #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP
16 #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP
17
18
19 #include <boost/concept_check.hpp>
20 #include <boost/concept/requires.hpp>
21 #include <boost/core/ignore_unused.hpp>
22 #include <boost/type_traits/is_const.hpp>
23 #include <boost/variant/variant_fwd.hpp>
24
25 #include <boost/geometry/core/tag.hpp>
26 #include <boost/geometry/core/tags.hpp>
27
28 #include <boost/geometry/geometries/concepts/box_concept.hpp>
29 #include <boost/geometry/geometries/concepts/linestring_concept.hpp>
30 #include <boost/geometry/geometries/concepts/multi_point_concept.hpp>
31 #include <boost/geometry/geometries/concepts/multi_linestring_concept.hpp>
32 #include <boost/geometry/geometries/concepts/multi_polygon_concept.hpp>
33 #include <boost/geometry/geometries/concepts/point_concept.hpp>
34 #include <boost/geometry/geometries/concepts/polygon_concept.hpp>
35 #include <boost/geometry/geometries/concepts/ring_concept.hpp>
36 #include <boost/geometry/geometries/concepts/segment_concept.hpp>
37
38 #include <boost/geometry/algorithms/not_implemented.hpp>
39
40 namespace boost { namespace geometry
41 {
42
43
44 #ifndef DOXYGEN_NO_DETAIL
45 namespace detail { namespace concept_check
46 {
47
48 template <typename Concept>
49 class check
50 {
51 BOOST_CONCEPT_ASSERT((Concept ));
52 };
53
54 }} // namespace detail::concept_check
55 #endif // DOXYGEN_NO_DETAIL
56
57
58
59 #ifndef DOXYGEN_NO_DISPATCH
60 namespace dispatch
61 {
62
63 template
64 <
65 typename Geometry,
66 typename GeometryTag = typename geometry::tag<Geometry>::type,
67 bool IsConst = boost::is_const<Geometry>::type::value
68 >
69 struct check : not_implemented<GeometryTag>
70 {};
71
72
73 template <typename Geometry>
74 struct check<Geometry, point_tag, true>
75 : detail::concept_check::check<concepts::ConstPoint<Geometry> >
76 {};
77
78
79 template <typename Geometry>
80 struct check<Geometry, point_tag, false>
81 : detail::concept_check::check<concepts::Point<Geometry> >
82 {};
83
84
85 template <typename Geometry>
86 struct check<Geometry, linestring_tag, true>
87 : detail::concept_check::check<concepts::ConstLinestring<Geometry> >
88 {};
89
90
91 template <typename Geometry>
92 struct check<Geometry, linestring_tag, false>
93 : detail::concept_check::check<concepts::Linestring<Geometry> >
94 {};
95
96
97 template <typename Geometry>
98 struct check<Geometry, ring_tag, true>
99 : detail::concept_check::check<concepts::ConstRing<Geometry> >
100 {};
101
102
103 template <typename Geometry>
104 struct check<Geometry, ring_tag, false>
105 : detail::concept_check::check<concepts::Ring<Geometry> >
106 {};
107
108 template <typename Geometry>
109 struct check<Geometry, polygon_tag, true>
110 : detail::concept_check::check<concepts::ConstPolygon<Geometry> >
111 {};
112
113
114 template <typename Geometry>
115 struct check<Geometry, polygon_tag, false>
116 : detail::concept_check::check<concepts::Polygon<Geometry> >
117 {};
118
119
120 template <typename Geometry>
121 struct check<Geometry, box_tag, true>
122 : detail::concept_check::check<concepts::ConstBox<Geometry> >
123 {};
124
125
126 template <typename Geometry>
127 struct check<Geometry, box_tag, false>
128 : detail::concept_check::check<concepts::Box<Geometry> >
129 {};
130
131
132 template <typename Geometry>
133 struct check<Geometry, segment_tag, true>
134 : detail::concept_check::check<concepts::ConstSegment<Geometry> >
135 {};
136
137
138 template <typename Geometry>
139 struct check<Geometry, segment_tag, false>
140 : detail::concept_check::check<concepts::Segment<Geometry> >
141 {};
142
143
144 template <typename Geometry>
145 struct check<Geometry, multi_point_tag, true>
146 : detail::concept_check::check<concepts::ConstMultiPoint<Geometry> >
147 {};
148
149
150 template <typename Geometry>
151 struct check<Geometry, multi_point_tag, false>
152 : detail::concept_check::check<concepts::MultiPoint<Geometry> >
153 {};
154
155
156 template <typename Geometry>
157 struct check<Geometry, multi_linestring_tag, true>
158 : detail::concept_check::check<concepts::ConstMultiLinestring<Geometry> >
159 {};
160
161
162 template <typename Geometry>
163 struct check<Geometry, multi_linestring_tag, false>
164 : detail::concept_check::check<concepts::MultiLinestring<Geometry> >
165 {};
166
167
168 template <typename Geometry>
169 struct check<Geometry, multi_polygon_tag, true>
170 : detail::concept_check::check<concepts::ConstMultiPolygon<Geometry> >
171 {};
172
173
174 template <typename Geometry>
175 struct check<Geometry, multi_polygon_tag, false>
176 : detail::concept_check::check<concepts::MultiPolygon<Geometry> >
177 {};
178
179
180 } // namespace dispatch
181 #endif
182
183
184
185
186 namespace concepts
187 {
188
189
190 #ifndef DOXYGEN_NO_DETAIL
191 namespace detail
192 {
193
194
195 template <typename Geometry>
196 struct checker : dispatch::check<Geometry>
197 {};
198
199 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
200 struct checker<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
201 {};
202
203 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
204 struct checker<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const>
205 {};
206
207
208 }
209 #endif // DOXYGEN_NO_DETAIL
210
211
212 /*!
213 \brief Checks, in compile-time, the concept of any geometry
214 \ingroup concepts
215 */
216 template <typename Geometry>
check()217 inline void check()
218 {
219 detail::checker<Geometry> c;
220 boost::ignore_unused(c);
221 }
222
223
224 /*!
225 \brief Checks, in compile-time, the concept of two geometries, and if they
226 have equal dimensions
227 \ingroup concepts
228 */
229 template <typename Geometry1, typename Geometry2>
check_concepts_and_equal_dimensions()230 inline void check_concepts_and_equal_dimensions()
231 {
232 check<Geometry1>();
233 check<Geometry2>();
234 assert_dimension_equal<Geometry1, Geometry2>();
235 }
236
237
238 } // namespace concepts
239
240
241 }} // namespace boost::geometry
242
243
244 #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP
245