369c5cfa1ad73d05b1f461d82ffbe3e0350b7e48
[platform/upstream/boost.git] / boost / geometry / core / geometry_id.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
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_CORE_GEOMETRY_ID_HPP
16 #define BOOST_GEOMETRY_CORE_GEOMETRY_ID_HPP
17
18
19 #include <boost/mpl/assert.hpp>
20 #include <boost/mpl/int.hpp>
21 #include <boost/type_traits.hpp>
22
23
24 #include <boost/geometry/core/tag.hpp>
25 #include <boost/geometry/core/tags.hpp>
26
27
28 namespace boost { namespace geometry
29 {
30
31
32 #ifndef DOXYGEN_NO_DISPATCH
33 namespace core_dispatch
34 {
35
36 template <typename GeometryTag>
37 struct geometry_id
38 {
39     BOOST_MPL_ASSERT_MSG
40         (
41             false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
42             , (types<GeometryTag>)
43         );
44 };
45
46
47 template <>
48 struct geometry_id<point_tag>      : boost::mpl::int_<1> {};
49
50
51 template <>
52 struct geometry_id<linestring_tag> : boost::mpl::int_<2> {};
53
54
55 template <>
56 struct geometry_id<polygon_tag>    : boost::mpl::int_<3> {};
57
58
59 template <>
60 struct geometry_id<segment_tag>    : boost::mpl::int_<92> {};
61
62
63 template <>
64 struct geometry_id<ring_tag>       : boost::mpl::int_<93> {};
65
66
67 template <>
68 struct geometry_id<box_tag>        : boost::mpl::int_<94> {};
69
70
71
72 } // namespace core_dispatch
73 #endif
74
75
76
77 /*!
78 \brief Meta-function returning the id of a geometry type
79 \details The meta-function geometry_id defines a numerical ID (based on 
80     boost::mpl::int_<...> ) for each geometry concept. A numerical ID is 
81     sometimes useful, and within Boost.Geometry it is used for the 
82     reverse_dispatch metafuntion.
83 \note Used for e.g. reverse meta-function
84 \ingroup core
85 */
86 template <typename Geometry>
87 struct geometry_id : core_dispatch::geometry_id<typename tag<Geometry>::type>
88 {};
89
90
91 }} // namespace boost::geometry
92
93
94 #endif // BOOST_GEOMETRY_CORE_GEOMETRY_ID_HPP