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