1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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.
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
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)
14 #ifndef BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
15 #define BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
18 #include <boost/range.hpp>
20 #include <boost/geometry/core/closure.hpp>
21 #include <boost/geometry/core/ring_type.hpp>
22 #include <boost/geometry/core/tag.hpp>
23 #include <boost/geometry/core/tags.hpp>
24 #include <boost/geometry/iterators/closing_iterator.hpp>
26 #include <boost/geometry/views/identity_view.hpp>
28 namespace boost { namespace geometry
31 // Silence warning C4512: assignment operator could not be generated
34 #pragma warning(disable : 4512)
37 #ifndef DOXYGEN_NO_DETAIL
42 template <typename Range>
45 // Keep this explicit, important for nested views/ranges
46 explicit inline closing_view(Range& r)
50 typedef closing_iterator<Range> iterator;
51 typedef closing_iterator<Range const> const_iterator;
53 inline const_iterator begin() const { return const_iterator(m_range); }
54 inline const_iterator end() const { return const_iterator(m_range, true); }
56 inline iterator begin() { return iterator(m_range); }
57 inline iterator end() { return iterator(m_range, true); }
64 #endif // DOXYGEN_NO_DETAIL
68 \brief View on a range, either closing it or leaving it as it is
69 \details The closeable_view is used internally by the library to handle all rings,
70 either closed or open, the same way. The default method is closed, all
71 algorithms process rings as if they are closed. Therefore, if they are opened,
72 a view is created which closes them.
73 The closeable_view might be used by library users, but its main purpose is
75 \tparam Range Original range
76 \tparam Close Specifies if it the range is closed, if so, nothing will happen.
77 If it is open, it will iterate the first point after the last point.
80 template <typename Range, closure_selector Close>
81 struct closeable_view {};
84 #ifndef DOXYGEN_NO_SPECIALIZATIONS
86 template <typename Range>
87 struct closeable_view<Range, closed>
89 typedef identity_view<Range> type;
93 template <typename Range>
94 struct closeable_view<Range, open>
96 typedef detail::closing_view<Range> type;
99 #endif // DOXYGEN_NO_SPECIALIZATIONS
102 #if defined(_MSC_VER)
106 }} // namespace boost::geometry
109 #endif // BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP