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 | #ifndef BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP |
15 | #define BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP |
16 | |
17 | |
18 | #include <cstddef> |
19 | |
20 | #include <boost/type_traits/remove_reference.hpp> |
21 | #include <boost/range.hpp> |
22 | |
23 | |
24 | namespace boost { namespace geometry |
25 | { |
26 | |
27 | |
28 | namespace traits |
29 | { |
30 | |
31 | /*! |
32 | \brief Metafunction to define the argument passed to the three |
33 | traits classes clear, push_back and resize |
34 | \ingroup mutable_range |
35 | */ |
36 | template <typename Range> |
37 | struct rvalue_type |
38 | { |
39 | typedef typename boost::remove_reference<Range>::type& type; |
40 | }; |
41 | |
42 | |
43 | /*! |
44 | \brief Traits class to clear a geometry |
45 | \ingroup mutable_range |
46 | */ |
47 | template <typename Range> |
48 | struct clear |
49 | { |
50 | static inline void apply(typename rvalue_type<Range>::type range) |
51 | { |
52 | range.clear(); |
53 | } |
54 | }; |
55 | |
56 | |
57 | /*! |
58 | \brief Traits class to append a point to a range (ring, linestring, multi*) |
59 | \ingroup mutable_range |
60 | */ |
61 | template <typename Range> |
62 | struct push_back |
63 | { |
64 | typedef typename boost::range_value |
65 | < |
66 | typename boost::remove_reference<Range>::type |
67 | >::type item_type; |
68 | |
69 | static inline void apply(typename rvalue_type<Range>::type range, |
70 | item_type const& item) |
71 | { |
72 | range.push_back(item); |
73 | } |
74 | }; |
75 | |
76 | |
77 | /*! |
78 | \brief Traits class to append a point to a range (ring, linestring, multi*) |
79 | \ingroup mutable_range |
80 | */ |
81 | template <typename Range> |
82 | struct resize |
83 | { |
84 | static inline void apply(typename rvalue_type<Range>::type range, |
85 | std::size_t new_size) |
86 | { |
87 | range.resize(new_size); |
88 | } |
89 | }; |
90 | |
91 | |
92 | } // namespace traits |
93 | |
94 | |
95 | }} // namespace boost::geometry |
96 | |
97 | |
98 | #endif // BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP |
99 | |