1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9
10 #ifndef GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_RING_HPP
11 #define GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_RING_HPP
12
13 #include <cstddef>
14
15 #include <boost/range.hpp>
16
17
18 #include <boost/geometry/core/mutable_range.hpp>
19 #include <boost/geometry/core/tag.hpp>
20 #include <boost/geometry/core/tags.hpp>
21
22 #include <test_geometries/all_custom_container.hpp>
23
24
25 template <typename P>
26 class all_custom_ring : public all_custom_container<P>
27 {};
28
29
30 // Note that the things below are nearly all identical to implementation
31 // in *linestring, but it seems not possible to re-use this (without macro's)
32 // (the only thing DIFFERENT is the tag)
33
34
35 // 1. Adapt to Boost.Geometry
36 namespace boost { namespace geometry
37 {
38
39 namespace traits
40 {
41 template <typename Point>
42 struct tag<all_custom_ring<Point> >
43 {
44 typedef ring_tag type;
45 };
46
47
48 // Implement traits for mutable actions
49 // These are all optional traits (normally / default they are implemented
50 // conforming std:: functionality)
51
52 template <typename Point>
53 struct clear<all_custom_ring<Point> >
54 {
applyboost::geometry::traits::clear55 static inline void apply(all_custom_ring<Point>& acr)
56 {
57 acr.custom_clear();
58 }
59 };
60
61 template <typename Point>
62 struct push_back<all_custom_ring<Point> >
63 {
applyboost::geometry::traits::push_back64 static inline void apply(all_custom_ring<Point>& acr, Point const& point)
65 {
66 acr.custom_push_back(point);
67 }
68 };
69
70 template <typename Point>
71 struct resize<all_custom_ring<Point> >
72 {
applyboost::geometry::traits::resize73 static inline void apply(all_custom_ring<Point>& acr, std::size_t new_size)
74 {
75 acr.custom_resize(new_size);
76 }
77 };
78
79 } // namespace traits
80
81 }} // namespace boost::geometry
82
83
84 // 2a. Adapt to Boost.Range, meta-functions
85 namespace boost
86 {
87 template<typename Point>
88 struct range_mutable_iterator<all_custom_ring<Point> >
89 {
90 typedef typename all_custom_ring<Point>::custom_iterator_type type;
91 };
92
93 template<typename Point>
94 struct range_const_iterator<all_custom_ring<Point> >
95 {
96 typedef typename all_custom_ring<Point>::custom_const_iterator_type type;
97 };
98
99 } // namespace boost
100
101
102 // 2b. Adapt to Boost.Range, part 2, ADP
103
104 template<typename Point>
105 inline typename all_custom_ring<Point>::custom_iterator_type
range_begin(all_custom_ring<Point> & acr)106 range_begin(all_custom_ring<Point>& acr)
107 {
108 return acr.custom_begin();
109 }
110
111 template<typename Point>
112 inline typename all_custom_ring<Point>::custom_const_iterator_type
range_begin(all_custom_ring<Point> const & acr)113 range_begin(all_custom_ring<Point> const& acr)
114 {
115 return acr.custom_begin();
116 }
117
118 template<typename Point>
119 inline typename all_custom_ring<Point>::custom_iterator_type
range_end(all_custom_ring<Point> & acr)120 range_end(all_custom_ring<Point>& acr)
121 {
122 return acr.custom_end();
123 }
124
125 template<typename Point>
126 inline typename all_custom_ring<Point>::custom_const_iterator_type
range_end(all_custom_ring<Point> const & acr)127 range_end(all_custom_ring<Point> const& acr)
128 {
129 return acr.custom_end();
130 }
131
132 // (Optional)
133 template<typename Point>
range_calculate_size(all_custom_ring<Point> const & acr)134 inline std::size_t range_calculate_size(all_custom_ring<Point> const& acr)
135 {
136 return acr.custom_size();
137 }
138
139
140
141
142 #endif // GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_RING_HPP
143