Added views to release branche

[SVN r70915]
This commit is contained in:
Barend Gehrels
2011-04-02 22:21:47 +00:00
3 changed files with 221 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
#define BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
#include <boost/range.hpp>
#include <boost/geometry/core/closure.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/iterators/closing_iterator.hpp>
#include <boost/geometry/views/identity_view.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
template <typename Range>
struct closing_view
{
// Keep this explicit, important for nested views/ranges
explicit inline closing_view(Range& r)
: m_range(r)
{}
typedef closing_iterator<Range> iterator;
typedef closing_iterator<Range const> const_iterator;
inline const_iterator begin() const { return const_iterator(m_range); }
inline const_iterator end() const { return const_iterator(m_range, true); }
inline iterator begin() { return iterator(m_range); }
inline iterator end() { return iterator(m_range, true); }
private :
Range& m_range;
};
}
#endif // DOXYGEN_NO_DETAIL
/*!
\brief View on a range, either closing or not closing
\tparam Range original range
\tparam Close specifying if it should be closed or not
\ingroup ranges
*/
template <typename Range, closure_selector Close>
struct closeable_view {};
#ifndef DOXYGEN_NO_SPECIALIZATIONS
template <typename Range>
struct closeable_view<Range, closed>
{
typedef identity_view<Range> type;
};
template <typename Range>
struct closeable_view<Range, open>
{
typedef detail::closing_view<Range> type;
};
#endif // DOXYGEN_NO_SPECIALIZATIONS
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP

View File

@@ -0,0 +1,53 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_VIEWS_IDENTITY_VIEW_HPP
#define BOOST_GEOMETRY_VIEWS_IDENTITY_VIEW_HPP
#include <boost/range.hpp>
namespace boost { namespace geometry
{
/*!
\brief View on a range, not modifying anything
\tparam Range original range
\ingroup ranges
*/
template <typename Range>
struct identity_view
{
typedef typename boost::range_iterator<Range const>::type const_iterator;
typedef typename boost::range_iterator<Range>::type iterator;
explicit inline identity_view(Range& r)
: m_range(r)
{}
inline const_iterator begin() const { return boost::begin(m_range); }
inline const_iterator end() const { return boost::end(m_range); }
inline iterator begin() { return boost::begin(m_range); }
inline iterator end() { return boost::end(m_range); }
private :
Range& m_range;
};
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_VIEWS_IDENTITY_VIEW_HPP

View File

@@ -0,0 +1,74 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP
#define BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP
#include <boost/version.hpp>
#include <boost/range.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/views/identity_view.hpp>
namespace boost { namespace geometry
{
/*!
\brief Flag for iterating a reversible_view in forward or reverse direction
\ingroup ranges
*/
enum iterate_direction { iterate_forward, iterate_reverse };
/*!
\brief View on a range, reversing direction if necessary
\tparam Range original range
\tparam Direction direction of iteration
\ingroup ranges
*/
template <typename Range, iterate_direction Direction>
struct reversible_view {};
#ifndef DOXYGEN_NO_SPECIALIZATIONS
template <typename Range>
struct reversible_view<Range, iterate_forward>
{
typedef identity_view<Range> type;
};
template <typename Range>
struct reversible_view<Range, iterate_reverse>
{
#if BOOST_VERSION > 104500
typedef boost::reversed_range<Range> type;
#else
// For older versions of Boost
typedef boost::range_detail::reverse_range<Range> type;
#endif
};
#endif // DOXYGEN_NO_SPECIALIZATIONS
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP