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

source code of boost/boost/geometry/geometries/concepts/check.hpp