$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r82837 - in sandbox-branches/geometry/index: boost/geometry/index/detail test/rtree
From: adam.wulkiewicz_at_[hidden]
Date: 2013-02-12 13:24:14
Author: awulkiew
Date: 2013-02-12 13:24:13 EST (Tue, 12 Feb 2013)
New Revision: 82837
URL: http://svn.boost.org/trac/boost/changeset/82837
Log:
Added rtree_interprocess test (doesn't executed for now), error fixed in detail::varray
Added:
   sandbox-branches/geometry/index/test/rtree/rtree_interprocess.cpp   (contents, props changed)
Text files modified: 
   sandbox-branches/geometry/index/boost/geometry/index/detail/varray.hpp |     4 +-                                      
   sandbox-branches/geometry/index/test/rtree/Jamfile.v2                  |    11 ++++++++                                
   sandbox-branches/geometry/index/test/rtree/test_rtree.hpp              |    55 ++++++++++++++++++--------------------- 
   3 files changed, 39 insertions(+), 31 deletions(-)
Modified: sandbox-branches/geometry/index/boost/geometry/index/detail/varray.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/index/detail/varray.hpp	(original)
+++ sandbox-branches/geometry/index/boost/geometry/index/detail/varray.hpp	2013-02-12 13:24:13 EST (Tue, 12 Feb 2013)
@@ -798,12 +798,12 @@
 
     pointer ptr()
     {
-        return pointer(m_storage.address());
+        return pointer(static_cast<value_type *>(m_storage.address()));
     }
 
     const_pointer ptr() const
     {
-        return const_pointer(m_storage.address());
+        return const_pointer(static_cast<const value_type *>(m_storage.address()));
     }
 
     boost::aligned_storage<sizeof(Value[Capacity]), boost::alignment_of<Value[Capacity]>::value> m_storage;
Modified: sandbox-branches/geometry/index/test/rtree/Jamfile.v2
==============================================================================
--- sandbox-branches/geometry/index/test/rtree/Jamfile.v2	(original)
+++ sandbox-branches/geometry/index/test/rtree/Jamfile.v2	2013-02-12 13:24:13 EST (Tue, 12 Feb 2013)
@@ -13,3 +13,14 @@
     [ run rtree_exceptions.cpp ]
     ;
     
+#test-suite boost-geometry-index-rtree_interprocess
+#    : [ run rtree_interprocess.cpp /boost/thread//boost_thread
+#        :  # additional args
+#        :  # test-files
+#        :  # requirements
+#        <toolset>acc:<linkflags>-lrt
+#        <toolset>acc-pa_risc:<linkflags>-lrt
+#        <toolset>gcc-mingw:<linkflags>"-lole32 -loleaut32 -lpsapi -ladvapi32"
+#        <host-os>hpux,<toolset>gcc:<linkflags>"-Wl,+as,mpas"
+#    ] : <threading>multi
+#    ;
\ No newline at end of file
Added: sandbox-branches/geometry/index/test/rtree/rtree_interprocess.cpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/test/rtree/rtree_interprocess.cpp	2013-02-12 13:24:13 EST (Tue, 12 Feb 2013)
@@ -0,0 +1,84 @@
+// Boost.Geometry Index
+// Unit Test
+
+// 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)
+
+#include <rtree/test_rtree.hpp>
+
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
+
+#include <boost/interprocess/managed_shared_memory.hpp>
+#include <boost/interprocess/allocators/allocator.hpp>
+
+template <typename Value, typename Parameters>
+void test_rtree_interprocess(Parameters const& parameters = Parameters())
+{
+    namespace bi = boost::interprocess;
+    struct shm_remove
+    {
+        shm_remove() { bi::shared_memory_object::remove("shmem"); }
+        ~shm_remove(){ bi::shared_memory_object::remove("shmem"); }
+    } remover;
+
+    bi::managed_shared_memory segment(bi::create_only, "shmem", 65535);
+    typedef bi::allocator<Value, bi::managed_shared_memory::segment_manager> shmem_alloc;
+
+    typedef bgi::rtree<Value, Parameters, bgi::translator::def<Value>, shmem_alloc> Tree;
+
+    Tree * tree = segment.construct<Tree>("Tree")(parameters, bgi::translator::def<Value>(), shmem_alloc(segment.get_segment_manager()));
+    typedef typename Tree::bounds_type B;
+    
+    std::vector<Value> input;
+    B qbox;
+    
+    generate_rtree(*tree, input, qbox);
+
+    test_intersects(*tree, input, qbox);
+    test_disjoint(*tree, input, qbox);
+    test_covered_by(*tree, input, qbox);
+    test_overlaps(*tree, input, qbox);
+    //test_touches(*tree, input, qbox);
+    test_within(*tree, input, qbox);
+
+    typedef typename bgi::detail::traits::point_type<B>::type P;
+    P pt;
+    bg::centroid(qbox, pt);
+
+    test_nearest_query_k(*tree, input, pt, 10);
+    test_nearest_query_not_found(*tree, generate_outside_point<P>::apply());
+
+    segment.destroy_ptr(tree);
+}
+
+int test_main(int, char* [])
+{
+    typedef bg::model::point<double, 2, bg::cs::cartesian> P2d;
+    typedef bg::model::box<P2d> B2d;
+    typedef std::pair<B2d, int> PB2d;
+
+    test_rtree_interprocess<P2d>(bgi::linear<32, 8>());
+    /*test_rtree_interprocess<P2d>(bgi::runtime::linear(32, 8));
+    test_rtree_interprocess<B2d>(bgi::quadratic<32, 8>());
+    test_rtree_interprocess<B2d>(bgi::runtime::quadratic(32, 8));
+    test_rtree_interprocess<PB2d>(bgi::rstar<32, 8>());
+    test_rtree_interprocess<PB2d>(bgi::runtime::rstar(32, 8));
+
+    typedef bg::model::point<float, 3, bg::cs::cartesian> P3f;
+    typedef bg::model::box<P3f> B3f;
+    typedef std::pair<B3f, int> PB3f;
+
+    test_rtree_interprocess<P3f>(bgi::linear<32, 8>());
+    test_rtree_interprocess<P3f>(bgi::runtime::linear(32, 8));
+    test_rtree_interprocess<B3f>(bgi::quadratic<32, 8>());
+    test_rtree_interprocess<B3f>(bgi::runtime::quadratic(32, 8));
+    test_rtree_interprocess<PB3f>(bgi::rstar<32, 8>());
+    test_rtree_interprocess<PB3f>(bgi::runtime::rstar(32, 8));*/
+
+    return 0;
+}
Modified: sandbox-branches/geometry/index/test/rtree/test_rtree.hpp
==============================================================================
--- sandbox-branches/geometry/index/test/rtree/test_rtree.hpp	(original)
+++ sandbox-branches/geometry/index/test/rtree/test_rtree.hpp	2013-02-12 13:24:13 EST (Tue, 12 Feb 2013)
@@ -480,13 +480,10 @@
     return generate_value_outside_impl<V, bgi::detail::traits::dimension<I>::value>::apply();
 }
 
-template<typename Value, typename Algo, typename Box>
-void generate_rtree(bgi::rtree<Value, Algo> & tree, std::vector<Value> & input, Box & qbox)
+template<typename Rtree, typename Elements, typename Box>
+void generate_rtree(Rtree & tree, Elements & input, Box & qbox)
 {
-    typedef bgi::rtree<Value, Algo> T;
-    typedef typename T::box_type B;
-    typedef typename T::value_type V;
-    typedef typename T::indexable_type I;
+    typedef typename Rtree::indexable_type I;
 
     generate_input<
         bgi::detail::traits::dimension<I>::value
@@ -568,8 +565,8 @@
 
 // rtree specific queries tests
 
-template <typename Value, typename Algo, typename Box>
-void test_intersects(bgi::rtree<Value, Algo> const& tree, std::vector<Value> const& input, Box const& qbox)
+template <typename Value, typename Algo, typename T, typename A, typename Box>
+void test_intersects(bgi::rtree<Value, Algo, T, A> const& tree, std::vector<Value> const& input, Box const& qbox)
 {
     std::vector<Value> expected_output;
 
@@ -592,8 +589,8 @@
     test_spatial_query(tree, !bgi::disjoint(qpoly), expected_output);*/
 }
 
-template <typename Value, typename Algo, typename Box>
-void test_disjoint(bgi::rtree<Value, Algo> const& tree, std::vector<Value> const& input, Box const& qbox)
+template <typename Value, typename Algo, typename T, typename A, typename Box>
+void test_disjoint(bgi::rtree<Value, Algo, T, A> const& tree, std::vector<Value> const& input, Box const& qbox)
 {
     std::vector<Value> expected_output;
 
@@ -614,8 +611,8 @@
 }
 
 
-template <typename Value, typename Algo, typename Box>
-void test_covered_by(bgi::rtree<Value, Algo> const& tree, std::vector<Value> const& input, Box const& qbox)
+template <typename Value, typename Algo, typename T, typename A, typename Box>
+void test_covered_by(bgi::rtree<Value, Algo, T, A> const& tree, std::vector<Value> const& input, Box const& qbox)
 {
     std::vector<Value> expected_output;
 
@@ -637,8 +634,8 @@
 template <typename Tag>
 struct test_overlap_impl
 {
-    template <typename Value, typename Algo, typename Box>
-    static void apply(bgi::rtree<Value, Algo> const& tree, std::vector<Value> const& input, Box const& qbox)
+    template <typename Value, typename Algo, typename T, typename A, typename Box>
+    static void apply(bgi::rtree<Value, Algo, T, A> const& tree, std::vector<Value> const& input, Box const& qbox)
     {
         std::vector<Value> expected_output;
 
@@ -661,13 +658,13 @@
 template <>
 struct test_overlap_impl<bg::point_tag>
 {
-    template <typename Value, typename Algo, typename Box>
-    static void apply(bgi::rtree<Value, Algo> const& /*tree*/, std::vector<Value> const& /*input*/, Box const& /*qbox*/)
+    template <typename Value, typename Algo, typename T, typename A, typename Box>
+    static void apply(bgi::rtree<Value, Algo, T, A> const& /*tree*/, std::vector<Value> const& /*input*/, Box const& /*qbox*/)
     {}
 };
 
-template <typename Value, typename Algo, typename Box>
-void test_overlaps(bgi::rtree<Value, Algo> const& tree, std::vector<Value> const& input, Box const& qbox)
+template <typename Value, typename Algo, typename T, typename A, typename Box>
+void test_overlaps(bgi::rtree<Value, Algo, T, A> const& tree, std::vector<Value> const& input, Box const& qbox)
 {
     test_overlap_impl<
         typename bgi::detail::traits::tag<
@@ -679,16 +676,16 @@
 //template <typename Tag, size_t Dimension>
 //struct test_touches_impl
 //{
-//    template <typename Value, typename Algo, typename Box>
-//    static void apply(bgi::rtree<Value, Algo> const& tree, std::vector<Value> const& input, Box const& qbox)
+//    template <typename Value, typename Algo, typename T, typename A, typename Box>
+//    static void apply(bgi::rtree<Value, Algo, T, A> const& tree, std::vector<Value> const& input, Box const& qbox)
 //    {}
 //};
 //
 //template <>
 //struct test_touches_impl<bg::box_tag, 2>
 //{
-//    template <typename Value, typename Algo, typename Box>
-//    static void apply(bgi::rtree<Value, Algo> const& tree, std::vector<Value> const& input, Box const& qbox)
+//    template <typename Value, typename Algo, typename T, typename A, typename Box>
+//    static void apply(bgi::rtree<Value, Algo, T, A> const& tree, std::vector<Value> const& input, Box const& qbox)
 //    {
 //        std::vector<Value> expected_output;
 //
@@ -700,21 +697,21 @@
 //    }
 //};
 //
-//template <typename Value, typename Algo, typename Box>
-//void test_touches(bgi::rtree<Value, Algo> const& tree, std::vector<Value> const& input, Box const& qbox)
+//template <typename Value, typename Algo, typename T, typename A, typename Box>
+//void test_touches(bgi::rtree<Value, Algo, T, A> const& tree, std::vector<Value> const& input, Box const& qbox)
 //{
 //    test_touches_impl<
 //        bgi::traits::tag<
-//            typename bgi::rtree<Value, Algo>::indexable_type
+//            typename bgi::rtree<Value, Algo, T, A>::indexable_type
 //        >::type,
 //        bgi::traits::dimension<
-//            typename bgi::rtree<Value, Algo>::indexable_type
+//            typename bgi::rtree<Value, Algo, T, A>::indexable_type
 //        >::value
 //    >::apply(tree, input, qbox);
 //}
 
-template <typename Value, typename Algo, typename Box>
-void test_within(bgi::rtree<Value, Algo> const& tree, std::vector<Value> const& input, Box const& qbox)
+template <typename Value, typename Algo, typename T, typename A, typename Box>
+void test_within(bgi::rtree<Value, Algo, T, A> const& tree, std::vector<Value> const& input, Box const& qbox)
 {
     std::vector<Value> expected_output;
 
@@ -830,7 +827,7 @@
 struct AlwaysFalse
 {
     template <typename Value>
-    bool operator()(Value const& v) const { return false; }
+    bool operator()(Value const& ) const { return false; }
 };
 
 template <typename Rtree, typename Point>