annotate DEPENDENCIES/generic/include/boost/geometry/core/access.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // Boost.Geometry (aka GGL, Generic Geometry Library)
Chris@16 2
Chris@16 3 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
Chris@16 4 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
Chris@16 5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
Chris@16 6
Chris@16 7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
Chris@16 8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
Chris@16 9
Chris@16 10 // Use, modification and distribution is subject to the Boost Software License,
Chris@16 11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 12 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 13
Chris@16 14 #ifndef BOOST_GEOMETRY_CORE_ACCESS_HPP
Chris@16 15 #define BOOST_GEOMETRY_CORE_ACCESS_HPP
Chris@16 16
Chris@16 17
Chris@16 18 #include <cstddef>
Chris@16 19
Chris@16 20 #include <boost/mpl/assert.hpp>
Chris@16 21 #include <boost/concept_check.hpp>
Chris@16 22 #include <boost/type_traits/is_pointer.hpp>
Chris@16 23
Chris@16 24 #include <boost/geometry/core/coordinate_type.hpp>
Chris@16 25 #include <boost/geometry/core/point_type.hpp>
Chris@16 26 #include <boost/geometry/core/tag.hpp>
Chris@16 27 #include <boost/geometry/util/bare_type.hpp>
Chris@16 28
Chris@16 29
Chris@16 30 namespace boost { namespace geometry
Chris@16 31 {
Chris@16 32
Chris@16 33 /// Index of minimum corner of the box.
Chris@16 34 int const min_corner = 0;
Chris@16 35
Chris@16 36 /// Index of maximum corner of the box.
Chris@16 37 int const max_corner = 1;
Chris@16 38
Chris@16 39 namespace traits
Chris@16 40 {
Chris@16 41
Chris@16 42 /*!
Chris@16 43 \brief Traits class which gives access (get,set) to points.
Chris@16 44 \ingroup traits
Chris@16 45 \par Geometries:
Chris@16 46 /// @li point
Chris@16 47 \par Specializations should provide, per Dimension
Chris@16 48 /// @li static inline T get(G const&)
Chris@16 49 /// @li static inline void set(G&, T const&)
Chris@16 50 \tparam Geometry geometry-type
Chris@16 51 \tparam Dimension dimension to access
Chris@16 52 */
Chris@16 53 template <typename Geometry, std::size_t Dimension, typename Enable = void>
Chris@16 54 struct access
Chris@16 55 {
Chris@16 56 BOOST_MPL_ASSERT_MSG
Chris@16 57 (
Chris@16 58 false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types<Geometry>)
Chris@16 59 );
Chris@16 60 };
Chris@16 61
Chris@16 62
Chris@16 63 /*!
Chris@16 64 \brief Traits class defining "get" and "set" to get
Chris@16 65 and set point coordinate values
Chris@16 66 \tparam Geometry geometry (box, segment)
Chris@16 67 \tparam Index index (min_corner/max_corner for box, 0/1 for segment)
Chris@16 68 \tparam Dimension dimension
Chris@16 69 \par Geometries:
Chris@16 70 - box
Chris@16 71 - segment
Chris@16 72 \par Specializations should provide:
Chris@16 73 - static inline T get(G const&)
Chris@16 74 - static inline void set(G&, T const&)
Chris@16 75 \ingroup traits
Chris@16 76 */
Chris@16 77 template <typename Geometry, std::size_t Index, std::size_t Dimension>
Chris@16 78 struct indexed_access {};
Chris@16 79
Chris@16 80
Chris@16 81 } // namespace traits
Chris@16 82
Chris@16 83 #ifndef DOXYGEN_NO_DETAIL
Chris@16 84 namespace detail
Chris@16 85 {
Chris@16 86
Chris@16 87 template
Chris@16 88 <
Chris@16 89 typename Geometry,
Chris@16 90 typename CoordinateType,
Chris@16 91 std::size_t Index,
Chris@16 92 std::size_t Dimension
Chris@16 93 >
Chris@16 94 struct indexed_access_non_pointer
Chris@16 95 {
Chris@16 96 static inline CoordinateType get(Geometry const& geometry)
Chris@16 97 {
Chris@16 98 return traits::indexed_access<Geometry, Index, Dimension>::get(geometry);
Chris@16 99 }
Chris@16 100 static inline void set(Geometry& b, CoordinateType const& value)
Chris@16 101 {
Chris@16 102 traits::indexed_access<Geometry, Index, Dimension>::set(b, value);
Chris@16 103 }
Chris@16 104 };
Chris@16 105
Chris@16 106 template
Chris@16 107 <
Chris@16 108 typename Geometry,
Chris@16 109 typename CoordinateType,
Chris@16 110 std::size_t Index,
Chris@16 111 std::size_t Dimension
Chris@16 112 >
Chris@16 113 struct indexed_access_pointer
Chris@16 114 {
Chris@16 115 static inline CoordinateType get(Geometry const* geometry)
Chris@16 116 {
Chris@16 117 return traits::indexed_access<typename boost::remove_pointer<Geometry>::type, Index, Dimension>::get(*geometry);
Chris@16 118 }
Chris@16 119 static inline void set(Geometry* geometry, CoordinateType const& value)
Chris@16 120 {
Chris@16 121 traits::indexed_access<typename boost::remove_pointer<Geometry>::type, Index, Dimension>::set(*geometry, value);
Chris@16 122 }
Chris@16 123 };
Chris@16 124
Chris@16 125
Chris@16 126 } // namespace detail
Chris@16 127 #endif // DOXYGEN_NO_DETAIL
Chris@16 128
Chris@16 129
Chris@16 130 #ifndef DOXYGEN_NO_DISPATCH
Chris@16 131 namespace core_dispatch
Chris@16 132 {
Chris@16 133
Chris@16 134 template
Chris@16 135 <
Chris@16 136 typename Tag,
Chris@16 137 typename Geometry,
Chris@16 138 typename
Chris@16 139 CoordinateType,
Chris@16 140 std::size_t Dimension,
Chris@16 141 typename IsPointer
Chris@16 142 >
Chris@16 143 struct access
Chris@16 144 {
Chris@16 145 //static inline T get(G const&) {}
Chris@16 146 //static inline void set(G& g, T const& value) {}
Chris@16 147 };
Chris@16 148
Chris@16 149 template
Chris@16 150 <
Chris@16 151 typename Tag,
Chris@16 152 typename Geometry,
Chris@16 153 typename CoordinateType,
Chris@16 154 std::size_t Index,
Chris@16 155 std::size_t Dimension,
Chris@16 156 typename IsPointer
Chris@16 157 >
Chris@16 158 struct indexed_access
Chris@16 159 {
Chris@16 160 //static inline T get(G const&) {}
Chris@16 161 //static inline void set(G& g, T const& value) {}
Chris@16 162 };
Chris@16 163
Chris@16 164 template <typename Point, typename CoordinateType, std::size_t Dimension>
Chris@16 165 struct access<point_tag, Point, CoordinateType, Dimension, boost::false_type>
Chris@16 166 {
Chris@16 167 static inline CoordinateType get(Point const& point)
Chris@16 168 {
Chris@16 169 return traits::access<Point, Dimension>::get(point);
Chris@16 170 }
Chris@16 171 static inline void set(Point& p, CoordinateType const& value)
Chris@16 172 {
Chris@16 173 traits::access<Point, Dimension>::set(p, value);
Chris@16 174 }
Chris@16 175 };
Chris@16 176
Chris@16 177 template <typename Point, typename CoordinateType, std::size_t Dimension>
Chris@16 178 struct access<point_tag, Point, CoordinateType, Dimension, boost::true_type>
Chris@16 179 {
Chris@16 180 static inline CoordinateType get(Point const* point)
Chris@16 181 {
Chris@16 182 return traits::access<typename boost::remove_pointer<Point>::type, Dimension>::get(*point);
Chris@16 183 }
Chris@16 184 static inline void set(Point* p, CoordinateType const& value)
Chris@16 185 {
Chris@16 186 traits::access<typename boost::remove_pointer<Point>::type, Dimension>::set(*p, value);
Chris@16 187 }
Chris@16 188 };
Chris@16 189
Chris@16 190
Chris@16 191 template
Chris@16 192 <
Chris@16 193 typename Box,
Chris@16 194 typename CoordinateType,
Chris@16 195 std::size_t Index,
Chris@16 196 std::size_t Dimension
Chris@16 197 >
Chris@16 198 struct indexed_access<box_tag, Box, CoordinateType, Index, Dimension, boost::false_type>
Chris@16 199 : detail::indexed_access_non_pointer<Box, CoordinateType, Index, Dimension>
Chris@16 200 {};
Chris@16 201
Chris@16 202 template
Chris@16 203 <
Chris@16 204 typename Box,
Chris@16 205 typename CoordinateType,
Chris@16 206 std::size_t Index,
Chris@16 207 std::size_t Dimension
Chris@16 208 >
Chris@16 209 struct indexed_access<box_tag, Box, CoordinateType, Index, Dimension, boost::true_type>
Chris@16 210 : detail::indexed_access_pointer<Box, CoordinateType, Index, Dimension>
Chris@16 211 {};
Chris@16 212
Chris@16 213
Chris@16 214 template
Chris@16 215 <
Chris@16 216 typename Segment,
Chris@16 217 typename CoordinateType,
Chris@16 218 std::size_t Index,
Chris@16 219 std::size_t Dimension
Chris@16 220 >
Chris@16 221 struct indexed_access<segment_tag, Segment, CoordinateType, Index, Dimension, boost::false_type>
Chris@16 222 : detail::indexed_access_non_pointer<Segment, CoordinateType, Index, Dimension>
Chris@16 223 {};
Chris@16 224
Chris@16 225
Chris@16 226 template
Chris@16 227 <
Chris@16 228 typename Segment,
Chris@16 229 typename CoordinateType,
Chris@16 230 std::size_t Index,
Chris@16 231 std::size_t Dimension
Chris@16 232 >
Chris@16 233 struct indexed_access<segment_tag, Segment, CoordinateType, Index, Dimension, boost::true_type>
Chris@16 234 : detail::indexed_access_pointer<Segment, CoordinateType, Index, Dimension>
Chris@16 235 {};
Chris@16 236
Chris@16 237 } // namespace core_dispatch
Chris@16 238 #endif // DOXYGEN_NO_DISPATCH
Chris@16 239
Chris@16 240
Chris@16 241 #ifndef DOXYGEN_NO_DETAIL
Chris@16 242 namespace detail
Chris@16 243 {
Chris@16 244
Chris@16 245 // Two dummy tags to distinguish get/set variants below.
Chris@16 246 // They don't have to be specified by the user. The functions are distinguished
Chris@16 247 // by template signature also, but for e.g. GCC this is not enough. So give them
Chris@16 248 // a different signature.
Chris@16 249 struct signature_getset_dimension {};
Chris@16 250 struct signature_getset_index_dimension {};
Chris@16 251
Chris@16 252 } // namespace detail
Chris@16 253 #endif // DOXYGEN_NO_DETAIL
Chris@16 254
Chris@16 255
Chris@16 256 /*!
Chris@16 257 \brief Get coordinate value of a geometry (usually a point)
Chris@16 258 \details \details_get_set
Chris@16 259 \ingroup get
Chris@16 260 \tparam Dimension \tparam_dimension_required
Chris@16 261 \tparam Geometry \tparam_geometry (usually a Point Concept)
Chris@16 262 \param geometry \param_geometry (usually a point)
Chris@16 263 \return The coordinate value of specified dimension of specified geometry
Chris@16 264
Chris@16 265 \qbk{[include reference/core/get_point.qbk]}
Chris@16 266 */
Chris@16 267 template <std::size_t Dimension, typename Geometry>
Chris@16 268 inline typename coordinate_type<Geometry>::type get(Geometry const& geometry
Chris@16 269 #ifndef DOXYGEN_SHOULD_SKIP_THIS
Chris@16 270 , detail::signature_getset_dimension* dummy = 0
Chris@16 271 #endif
Chris@16 272 )
Chris@16 273 {
Chris@16 274 boost::ignore_unused_variable_warning(dummy);
Chris@16 275
Chris@16 276 typedef core_dispatch::access
Chris@16 277 <
Chris@16 278 typename tag<Geometry>::type,
Chris@16 279 typename geometry::util::bare_type<Geometry>::type,
Chris@16 280 typename coordinate_type<Geometry>::type,
Chris@16 281 Dimension,
Chris@16 282 typename boost::is_pointer<Geometry>::type
Chris@16 283 > coord_access_type;
Chris@16 284
Chris@16 285 return coord_access_type::get(geometry);
Chris@16 286 }
Chris@16 287
Chris@16 288
Chris@16 289 /*!
Chris@16 290 \brief Set coordinate value of a geometry (usually a point)
Chris@16 291 \details \details_get_set
Chris@16 292 \tparam Dimension \tparam_dimension_required
Chris@16 293 \tparam Geometry \tparam_geometry (usually a Point Concept)
Chris@16 294 \param geometry geometry to assign coordinate to
Chris@16 295 \param geometry \param_geometry (usually a point)
Chris@16 296 \param value The coordinate value to set
Chris@16 297 \ingroup set
Chris@16 298
Chris@16 299 \qbk{[include reference/core/set_point.qbk]}
Chris@16 300 */
Chris@16 301 template <std::size_t Dimension, typename Geometry>
Chris@16 302 inline void set(Geometry& geometry
Chris@16 303 , typename coordinate_type<Geometry>::type const& value
Chris@16 304 #ifndef DOXYGEN_SHOULD_SKIP_THIS
Chris@16 305 , detail::signature_getset_dimension* dummy = 0
Chris@101 306 #endif
Chris@16 307 )
Chris@16 308 {
Chris@16 309 boost::ignore_unused_variable_warning(dummy);
Chris@16 310
Chris@16 311 typedef core_dispatch::access
Chris@16 312 <
Chris@16 313 typename tag<Geometry>::type,
Chris@16 314 typename geometry::util::bare_type<Geometry>::type,
Chris@16 315 typename coordinate_type<Geometry>::type,
Chris@16 316 Dimension,
Chris@16 317 typename boost::is_pointer<Geometry>::type
Chris@16 318 > coord_access_type;
Chris@16 319
Chris@16 320 coord_access_type::set(geometry, value);
Chris@16 321 }
Chris@16 322
Chris@16 323
Chris@16 324 /*!
Chris@16 325 \brief get coordinate value of a Box or Segment
Chris@16 326 \details \details_get_set
Chris@16 327 \tparam Index \tparam_index_required
Chris@16 328 \tparam Dimension \tparam_dimension_required
Chris@16 329 \tparam Geometry \tparam_box_or_segment
Chris@16 330 \param geometry \param_geometry
Chris@16 331 \return coordinate value
Chris@16 332 \ingroup get
Chris@16 333
Chris@16 334 \qbk{distinguish,with index}
Chris@16 335 \qbk{[include reference/core/get_box.qbk]}
Chris@16 336 */
Chris@16 337 template <std::size_t Index, std::size_t Dimension, typename Geometry>
Chris@16 338 inline typename coordinate_type<Geometry>::type get(Geometry const& geometry
Chris@16 339 #ifndef DOXYGEN_SHOULD_SKIP_THIS
Chris@16 340 , detail::signature_getset_index_dimension* dummy = 0
Chris@101 341 #endif
Chris@16 342 )
Chris@16 343 {
Chris@16 344 boost::ignore_unused_variable_warning(dummy);
Chris@16 345
Chris@16 346 typedef core_dispatch::indexed_access
Chris@16 347 <
Chris@16 348 typename tag<Geometry>::type,
Chris@16 349 typename geometry::util::bare_type<Geometry>::type,
Chris@16 350 typename coordinate_type<Geometry>::type,
Chris@16 351 Index,
Chris@16 352 Dimension,
Chris@16 353 typename boost::is_pointer<Geometry>::type
Chris@16 354 > coord_access_type;
Chris@16 355
Chris@16 356 return coord_access_type::get(geometry);
Chris@16 357 }
Chris@16 358
Chris@16 359 /*!
Chris@16 360 \brief set coordinate value of a Box / Segment
Chris@16 361 \details \details_get_set
Chris@16 362 \tparam Index \tparam_index_required
Chris@16 363 \tparam Dimension \tparam_dimension_required
Chris@16 364 \tparam Geometry \tparam_box_or_segment
Chris@16 365 \param geometry geometry to assign coordinate to
Chris@16 366 \param geometry \param_geometry
Chris@16 367 \param value The coordinate value to set
Chris@16 368 \ingroup set
Chris@16 369
Chris@16 370 \qbk{distinguish,with index}
Chris@16 371 \qbk{[include reference/core/set_box.qbk]}
Chris@16 372 */
Chris@16 373 template <std::size_t Index, std::size_t Dimension, typename Geometry>
Chris@16 374 inline void set(Geometry& geometry
Chris@16 375 , typename coordinate_type<Geometry>::type const& value
Chris@16 376 #ifndef DOXYGEN_SHOULD_SKIP_THIS
Chris@16 377 , detail::signature_getset_index_dimension* dummy = 0
Chris@16 378 #endif
Chris@16 379 )
Chris@16 380 {
Chris@16 381 boost::ignore_unused_variable_warning(dummy);
Chris@16 382
Chris@16 383 typedef core_dispatch::indexed_access
Chris@16 384 <
Chris@101 385 typename tag<Geometry>::type,
Chris@16 386 typename geometry::util::bare_type<Geometry>::type,
Chris@16 387 typename coordinate_type<Geometry>::type,
Chris@16 388 Index,
Chris@16 389 Dimension,
Chris@16 390 typename boost::is_pointer<Geometry>::type
Chris@16 391 > coord_access_type;
Chris@16 392
Chris@16 393 coord_access_type::set(geometry, value);
Chris@16 394 }
Chris@16 395
Chris@16 396 }} // namespace boost::geometry
Chris@16 397
Chris@16 398 #endif // BOOST_GEOMETRY_CORE_ACCESS_HPP