geometry_id.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  6. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_CORE_GEOMETRY_ID_HPP
  11. #define BOOST_GEOMETRY_CORE_GEOMETRY_ID_HPP
  12. #include <boost/mpl/assert.hpp>
  13. #include <boost/mpl/int.hpp>
  14. #include <boost/geometry/core/tag.hpp>
  15. #include <boost/geometry/core/tags.hpp>
  16. namespace boost { namespace geometry
  17. {
  18. #ifndef DOXYGEN_NO_DISPATCH
  19. namespace core_dispatch
  20. {
  21. template <typename GeometryTag>
  22. struct geometry_id
  23. {
  24. BOOST_MPL_ASSERT_MSG
  25. (
  26. false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
  27. , (types<GeometryTag>)
  28. );
  29. };
  30. template <>
  31. struct geometry_id<point_tag> : boost::mpl::int_<1> {};
  32. template <>
  33. struct geometry_id<linestring_tag> : boost::mpl::int_<2> {};
  34. template <>
  35. struct geometry_id<polygon_tag> : boost::mpl::int_<3> {};
  36. template <>
  37. struct geometry_id<multi_point_tag> : boost::mpl::int_<4> {};
  38. template <>
  39. struct geometry_id<multi_linestring_tag> : boost::mpl::int_<5> {};
  40. template <>
  41. struct geometry_id<multi_polygon_tag> : boost::mpl::int_<6> {};
  42. template <>
  43. struct geometry_id<segment_tag> : boost::mpl::int_<92> {};
  44. template <>
  45. struct geometry_id<ring_tag> : boost::mpl::int_<93> {};
  46. template <>
  47. struct geometry_id<box_tag> : boost::mpl::int_<94> {};
  48. } // namespace core_dispatch
  49. #endif
  50. /*!
  51. \brief Meta-function returning the id of a geometry type
  52. \details The meta-function geometry_id defines a numerical ID (based on
  53. boost::mpl::int_<...> ) for each geometry concept. A numerical ID is
  54. sometimes useful, and within Boost.Geometry it is used for the
  55. reverse_dispatch metafuntion.
  56. \note Used for e.g. reverse meta-function
  57. \ingroup core
  58. */
  59. template <typename Geometry>
  60. struct geometry_id : core_dispatch::geometry_id<typename tag<Geometry>::type>
  61. {};
  62. }} // namespace boost::geometry
  63. #endif // BOOST_GEOMETRY_CORE_GEOMETRY_ID_HPP