$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r84071 - in trunk/boost/geometry/index: . detail detail/rtree/node detail/rtree/visitors
From: adam.wulkiewicz_at_[hidden]
Date: 2013-04-28 13:06:29
Author: awulkiew
Date: 2013-04-28 13:06:28 EDT (Sun, 28 Apr 2013)
New Revision: 84071
URL: http://svn.boost.org/trac/boost/changeset/84071
Log:
geometry.index: added stl container-like typedefs in rtree (reference, pointer, etc.), added type-erased iterator - currently may be enabled by define.
Added:
   trunk/boost/geometry/index/detail/type_erased_iterators.hpp   (contents, props changed)
Text files modified: 
   trunk/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp |    13 ++++++++++++-                           
   trunk/boost/geometry/index/detail/rtree/node/node_d_mem_static.hpp  |    13 ++++++++++++-                           
   trunk/boost/geometry/index/detail/rtree/node/node_s_mem_dynamic.hpp |    13 ++++++++++++-                           
   trunk/boost/geometry/index/detail/rtree/node/node_s_mem_static.hpp  |    13 ++++++++++++-                           
   trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp  |    13 ++++++-------                           
   trunk/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp  |    13 ++++++-------                           
   trunk/boost/geometry/index/rtree.hpp                                |    33 +++++++++++++++++++++++++++++----       
   7 files changed, 89 insertions(+), 22 deletions(-)
Modified: trunk/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp	(original)
+++ trunk/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp	2013-04-28 13:06:28 EDT (Sun, 28 Apr 2013)
@@ -164,9 +164,20 @@
         typename leaf<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_d_mem_dynamic_tag>, node_d_mem_dynamic_tag>::type
     >::other
 {
+    typedef typename Allocator::template rebind<
+        Value
+    >::other value_allocator_type;
+
 public:
     typedef Allocator allocator_type;
-    typedef typename Allocator::size_type size_type;
+    
+    typedef Value value_type;
+    typedef typename value_allocator_type::reference reference;
+    typedef typename value_allocator_type::const_reference const_reference;
+    typedef typename value_allocator_type::size_type size_type;
+    typedef typename value_allocator_type::difference_type difference_type;
+    typedef typename value_allocator_type::pointer pointer;
+    typedef typename value_allocator_type::const_pointer const_pointer;
 
     typedef typename Allocator::template rebind<
         typename node<Value, Parameters, Box, allocators, node_d_mem_dynamic_tag>::type
Modified: trunk/boost/geometry/index/detail/rtree/node/node_d_mem_static.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/node/node_d_mem_static.hpp	(original)
+++ trunk/boost/geometry/index/detail/rtree/node/node_d_mem_static.hpp	2013-04-28 13:06:28 EDT (Sun, 28 Apr 2013)
@@ -113,9 +113,20 @@
         >::type
     >::other
 {
+    typedef typename Allocator::template rebind<
+        Value
+    >::other value_allocator_type;
+
 public:
     typedef Allocator allocator_type;
-    typedef typename Allocator::size_type size_type;
+
+    typedef Value value_type;
+    typedef value_type & reference;
+    typedef const value_type & const_reference;
+    typedef typename value_allocator_type::size_type size_type;
+    typedef typename value_allocator_type::difference_type difference_type;
+    typedef typename value_allocator_type::pointer pointer;
+    typedef typename value_allocator_type::const_pointer const_pointer;
 
     typedef typename Allocator::template rebind<
         typename node<Value, Parameters, Box, allocators, node_d_mem_static_tag>::type
Modified: trunk/boost/geometry/index/detail/rtree/node/node_s_mem_dynamic.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/node/node_s_mem_dynamic.hpp	(original)
+++ trunk/boost/geometry/index/detail/rtree/node/node_s_mem_dynamic.hpp	2013-04-28 13:06:28 EDT (Sun, 28 Apr 2013)
@@ -96,9 +96,20 @@
         typename node<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_s_mem_dynamic_tag>, node_s_mem_dynamic_tag>::type
     >::other
 {
+    typedef typename Allocator::template rebind<
+        Value
+    >::other value_allocator_type;
+
 public:
     typedef Allocator allocator_type;
-    typedef typename Allocator::size_type size_type;
+
+    typedef Value value_type;
+    typedef typename value_allocator_type::reference reference;
+    typedef typename value_allocator_type::const_reference const_reference;
+    typedef typename value_allocator_type::size_type size_type;
+    typedef typename value_allocator_type::difference_type difference_type;
+    typedef typename value_allocator_type::pointer pointer;
+    typedef typename value_allocator_type::const_pointer const_pointer;
 
     typedef typename Allocator::template rebind<
         typename node<Value, Parameters, Box, allocators, node_s_mem_dynamic_tag>::type
Modified: trunk/boost/geometry/index/detail/rtree/node/node_s_mem_static.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/node/node_s_mem_static.hpp	(original)
+++ trunk/boost/geometry/index/detail/rtree/node/node_s_mem_static.hpp	2013-04-28 13:06:28 EDT (Sun, 28 Apr 2013)
@@ -94,9 +94,20 @@
         typename node<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_s_mem_static_tag>, node_s_mem_static_tag>::type
     >::other
 {
+    typedef typename Allocator::template rebind<
+        Value
+    >::other value_allocator_type;
+
 public:
     typedef Allocator allocator_type;
-    typedef typename Allocator::size_type size_type;
+
+    typedef Value value_type;
+    typedef value_type & reference;
+    typedef const value_type & const_reference;
+    typedef typename value_allocator_type::size_type size_type;
+    typedef typename value_allocator_type::difference_type difference_type;
+    typedef typename value_allocator_type::pointer pointer;
+    typedef typename value_allocator_type::const_pointer const_pointer;
 
     typedef typename Allocator::template rebind<
         typename node<Value, Parameters, Box, allocators, node_s_mem_static_tag>::type
Modified: trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp	(original)
+++ trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp	2013-04-28 13:06:28 EDT (Sun, 28 Apr 2013)
@@ -364,6 +364,7 @@
     > value_distances_predicates_check;
 
     typedef typename Allocators::size_type size_type;
+    typedef typename Allocators::const_reference const_reference;
     typedef typename Allocators::node_pointer node_pointer;
 
     static const unsigned predicates_len = index::detail::predicates_length<Predicates>::value;
@@ -390,7 +391,7 @@
         BOOST_ASSERT_MSG(0 < max_count(), "k must be greather than 0");
     }
 
-    Value const& dereference() const
+    const_reference dereference() const
     {
         return *(neighbors[current_neighbor].second);
     }
@@ -622,14 +623,12 @@
     typedef visitors::nearest_query_incremental<Value, Options, Translator, Box, Allocators, Predicates, NearestPredicateIndex> visitor_type;
     typedef typename visitor_type::node_pointer node_pointer;
 
-    typedef typename Allocators::allocator_type::template rebind<Value>::other allocator_type;
-
 public:
     typedef std::input_iterator_tag iterator_category;
-    typedef const Value value_type;
-    typedef Value const& reference;
-    typedef typename allocator_type::difference_type difference_type;
-    typedef typename allocator_type::const_pointer pointer;
+    typedef Value value_type;
+    typedef typename Allocators::const_reference reference;
+    typedef typename Allocators::difference_type difference_type;
+    typedef typename Allocators::const_pointer pointer;
 
     inline nearest_query_iterator(Translator const& t, Predicates const& p)
         : m_visitor(t, p)
Modified: trunk/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp	(original)
+++ trunk/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp	2013-04-28 13:06:28 EDT (Sun, 28 Apr 2013)
@@ -85,6 +85,7 @@
     typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
 
     typedef typename Allocators::size_type size_type;
+    typedef typename Allocators::const_reference const_reference;
     typedef typename Allocators::node_pointer node_pointer;
 
     typedef typename rtree::elements_type<internal_node>::type::const_iterator internal_iterator;
@@ -112,7 +113,7 @@
         m_value_index = 0;
     }
 
-    Value const& dereference() const
+    const_reference dereference() const
     {
         BOOST_ASSERT_MSG(m_values, "not dereferencable");
         return (*m_values)[m_value_index];
@@ -192,14 +193,12 @@
     typedef visitors::spatial_query_incremental<Value, Options, Translator, Box, Allocators, Predicates> visitor_type;
     typedef typename visitor_type::node_pointer node_pointer;
 
-    typedef typename Allocators::allocator_type::template rebind<Value>::other allocator_type;
-
 public:
     typedef std::input_iterator_tag iterator_category;
-    typedef const Value value_type;
-    typedef Value const& reference;
-    typedef typename allocator_type::difference_type difference_type;
-    typedef typename allocator_type::const_pointer pointer;
+    typedef Value value_type;
+    typedef typename Allocators::const_reference reference;
+    typedef typename Allocators::difference_type difference_type;
+    typedef typename Allocators::const_pointer pointer;
 
     inline spatial_query_iterator(Translator const& t, Predicates const& p)
         : m_visitor(t, p)
Added: trunk/boost/geometry/index/detail/type_erased_iterators.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/geometry/index/detail/type_erased_iterators.hpp	2013-04-28 13:06:28 EDT (Sun, 28 Apr 2013)
@@ -0,0 +1,60 @@
+// Boost.Geometry Index
+//
+// Type-erased iterators
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// 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_INDEX_DETAIL_TYPE_ERASED_ITERATORS_HPP
+#define BOOST_GEOMETRY_INDEX_DETAIL_TYPE_ERASED_ITERATORS_HPP
+
+#include <boost/type_erasure/any.hpp>
+#include <boost/type_erasure/operators.hpp>
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+template<typename T, typename ValueType, typename Reference, typename Pointer, typename DifferenceType>
+struct single_pass_iterator_concept :
+    ::boost::mpl::vector<
+        ::boost::type_erasure::copy_constructible<T>,
+        ::boost::type_erasure::equality_comparable<T>,
+        ::boost::type_erasure::dereferenceable<Reference, T>,
+        ::boost::type_erasure::assignable<T>,
+        ::boost::type_erasure::incrementable<T>
+    >
+{};
+
+template <typename ValueType, typename Reference, typename Pointer, typename DifferenceType>
+struct single_pass_iterator_type
+{
+    typedef ::boost::type_erasure::any<
+        single_pass_iterator_concept<
+            ::boost::type_erasure::_self, ValueType, Reference, Pointer, DifferenceType
+        >
+    > type;
+};
+
+}}}} // namespace boost::geometry::index::detail
+
+namespace boost { namespace type_erasure {
+
+template<typename T, typename ValueType, typename Reference, typename Pointer, typename DifferenceType, typename Base>
+struct concept_interface<
+    ::boost::geometry::index::detail::single_pass_iterator_concept<
+        T, ValueType, Reference, Pointer, DifferenceType
+    >, Base, T>
+    : Base
+{
+    typedef ValueType value_type;
+    typedef Reference reference;
+    typedef Pointer pointer;
+    typedef DifferenceType difference_type;
+    typedef ::std::input_iterator_tag iterator_category;
+};
+
+}} // namespace boost::type_erasure
+
+#endif // BOOST_GEOMETRY_INDEX_DETAIL_TYPE_ERASED_ITERATORS_HPP
Modified: trunk/boost/geometry/index/rtree.hpp
==============================================================================
--- trunk/boost/geometry/index/rtree.hpp	(original)
+++ trunk/boost/geometry/index/rtree.hpp	2013-04-28 13:06:28 EDT (Sun, 28 Apr 2013)
@@ -57,6 +57,10 @@
 
 #include <boost/geometry/index/inserter.hpp>
 
+#ifdef BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_TYPE_ERASED_ITERATORS
+#include <boost/geometry/index/detail/type_erased_iterators.hpp>
+#endif
+
 // TODO change the name to bounding_tree
 
 /*!
@@ -117,14 +121,12 @@
     typedef Value value_type;
     /*! \brief R-tree parameters type. */
     typedef Parameters parameters_type;
-    /*! \brief The type of allocator used by the container. */
-    typedef Allocator allocator_type;
-    /*! \brief Unsigned integral type used by the container. */
-    typedef typename allocator_type::size_type size_type;
     /*! \brief The function object extracting Indexable from Value. */
     typedef IndexableGetter indexable_getter;
     /*! \brief The function object comparing objects of type Value. */
     typedef EqualTo value_equal;
+    /*! \brief The type of allocator used by the container. */
+    typedef Allocator allocator_type;
 
     // TODO: SHOULD THIS TYPE BE REMOVED?
     /*! \brief The Indexable type to which Value is translated. */
@@ -154,6 +156,21 @@
 
 public:
 
+    /*! \brief Type of reference to Value. */
+    typedef typename allocators_type::reference reference;
+    /*! \brief Type of reference to const Value. */
+    typedef typename allocators_type::const_reference const_reference;
+    /*! \brief Type of pointer to Value. */
+    typedef typename allocators_type::pointer pointer;
+    /*! \brief Type of pointer to const Value. */
+    typedef typename allocators_type::const_pointer const_pointer;
+    /*! \brief Type of difference type. */
+    typedef typename allocators_type::difference_type difference_type;
+    /*! \brief Unsigned integral type used by the container. */
+    typedef typename allocators_type::size_type size_type;
+
+public:
+
     /*!
     \brief The constructor.
 
@@ -724,6 +741,14 @@
 
 #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
 
+#ifdef BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_TYPE_ERASED_ITERATORS
+
+    typedef typename index::detail::single_pass_iterator_type<
+        value_type, const_reference, const_pointer, difference_type
+    >::type const_query_iterator;
+
+#endif // BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_TYPE_ERASED_ITERATORS
+
     template <typename Predicates>
     typename boost::mpl::if_c<
         detail::predicates_count_nearest<Predicates>::value == 0,