diff --git a/include/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp b/include/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp index a4d142725..92f5d6809 100644 --- a/include/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp +++ b/include/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp @@ -187,6 +187,10 @@ public: typename node::type >::other::pointer node_pointer; + typedef typename allocator_type::template rebind< + typename internal_node::type + >::other::pointer internal_node_pointer; + typedef typename allocator_type::template rebind< typename internal_node::type >::other internal_node_allocator_type; diff --git a/include/boost/geometry/index/detail/rtree/node/node_d_mem_static.hpp b/include/boost/geometry/index/detail/rtree/node/node_d_mem_static.hpp index 21ca4de1c..b6cc23966 100644 --- a/include/boost/geometry/index/detail/rtree/node/node_d_mem_static.hpp +++ b/include/boost/geometry/index/detail/rtree/node/node_d_mem_static.hpp @@ -108,6 +108,10 @@ public: typename node::type >::other::pointer node_pointer; + typedef typename allocator_type::template rebind< + typename internal_node::type + >::other::pointer internal_node_pointer; + typedef typename allocator_type::template rebind< typename internal_node::type >::other internal_node_allocator_type; diff --git a/include/boost/geometry/index/detail/rtree/visitors/copy.hpp b/include/boost/geometry/index/detail/rtree/visitors/copy.hpp index 1819f4a95..29b76326e 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/copy.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/copy.hpp @@ -28,6 +28,7 @@ public: typedef typename rtree::leaf::type leaf; typedef rtree::node_auto_ptr node_auto_ptr; + typedef typename Allocators::node_pointer node_pointer; explicit inline copy(Allocators & allocators) : result(0) @@ -36,7 +37,7 @@ public: inline void operator()(internal_node & n) { - node * raw_new_node = rtree::create_node::apply(m_allocators); // MAY THROW, STRONG (N: alloc) + node_pointer raw_new_node = rtree::create_node::apply(m_allocators); // MAY THROW, STRONG (N: alloc) node_auto_ptr new_node(raw_new_node, m_allocators); typedef typename rtree::elements_type::type elements_type; @@ -63,7 +64,7 @@ public: inline void operator()(leaf & l) { - node * raw_new_node = rtree::create_node::apply(m_allocators); // MAY THROW, STRONG (N: alloc) + node_pointer raw_new_node = rtree::create_node::apply(m_allocators); // MAY THROW, STRONG (N: alloc) node_auto_ptr new_node(raw_new_node, m_allocators); typedef typename rtree::elements_type::type elements_type; @@ -81,7 +82,7 @@ public: new_node.release(); } - node * result; + node_pointer result; private: Allocators & m_allocators; diff --git a/include/boost/geometry/index/detail/rtree/visitors/remove.hpp b/include/boost/geometry/index/detail/rtree/visitors/remove.hpp index 75bdf2718..52df1316c 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/remove.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/remove.hpp @@ -34,9 +34,11 @@ class remove typedef typename rtree::leaf::type leaf; typedef rtree::node_auto_ptr node_auto_ptr; + typedef typename Allocators::node_pointer node_pointer; + typedef typename Allocators::internal_node_pointer internal_node_pointer; public: - inline remove(node* & root, + inline remove(node_pointer & root, size_t & leafs_level, Box & root_box, Value const& value, @@ -121,7 +123,7 @@ public: // shorten the tree if ( rtree::elements(n).size() == 1 ) { - node * root_to_destroy = m_root_node; + node_pointer root_to_destroy = m_root_node; m_root_node = rtree::elements(n)[0].second; --m_leafs_level; @@ -174,12 +176,12 @@ public: private: - typedef std::vector< std::pair > UnderflowNodes; + typedef std::vector< std::pair > UnderflowNodes; void traverse_apply_visitor(internal_node &n, size_t choosen_node_index) { // save previous traverse inputs and set new ones - internal_node * parent_bckup = m_parent; + internal_node_pointer parent_bckup = m_parent; size_t current_child_index_bckup = m_current_child_index; size_t current_level_bckup = m_current_level; @@ -308,7 +310,7 @@ private: Translator const& m_translator; Allocators & m_allocators; - node* & m_root_node; + node_pointer & m_root_node; Box & m_root_box; size_t & m_leafs_level; @@ -316,7 +318,7 @@ private: UnderflowNodes m_underflowed_nodes; // traversing input parameters - internal_node *m_parent; + internal_node_pointer m_parent; size_t m_current_child_index; size_t m_current_level; diff --git a/include/boost/geometry/index/detail/varray.hpp b/include/boost/geometry/index/detail/varray.hpp index 64bc47bde..2d8714a35 100644 --- a/include/boost/geometry/index/detail/varray.hpp +++ b/include/boost/geometry/index/detail/varray.hpp @@ -552,7 +552,7 @@ private: >::type use_memcpy; - this->copy_dispatch(first, last, dst, use_memcpy()); // may throw + this->copy_dispatch(&(*first), &(*last), &(*dst), use_memcpy()); // may throw } void copy_dispatch(const value_type * first, const value_type * last, value_type * dst, @@ -583,7 +583,7 @@ private: >::type use_memcpy; - this->uninitialized_copy_dispatch(first, last, dst, use_memcpy()); // may throw + this->uninitialized_copy_dispatch(&(*first), &(*last), &(*dst), use_memcpy()); // may throw } void uninitialized_copy_dispatch(const value_type * first, const value_type * last, value_type * dst, @@ -607,11 +607,11 @@ private: typedef typename mpl::and_< has_trivial_copy, - is_same + is_same >::type use_memcpy; - uninitialized_fill_dispatch(dst, v, use_memcpy()); // may throw + uninitialized_fill_dispatch(&(*dst), v, use_memcpy()); // may throw } void uninitialized_fill_dispatch(value_type * ptr, value_type const& v, @@ -633,7 +633,7 @@ private: void move(iterator first, iterator last, iterator dst) { - this->move_dispatch(first, last, dst, has_trivial_assign()); // may throw + this->move_dispatch(&(*first), &(*last), &(*dst), has_trivial_assign()); // may throw } void move_dispatch(value_type * first, value_type * last, value_type * dst, @@ -652,7 +652,7 @@ private: void move_backward(iterator first, iterator last, iterator dst) { - this->move_backward_dispatch(first, last, dst, has_trivial_assign()); // may throw + this->move_backward_dispatch(&(*first), &(*last), &(*dst), has_trivial_assign()); // may throw } void move_backward_dispatch(value_type * first, value_type * last, value_type * dst, @@ -673,7 +673,7 @@ private: template void fill(iterator dst, V const& v) { - fill_dispatch(dst, v, has_trivial_assign()); // may throw + fill_dispatch(&(*dst), v, has_trivial_assign()); // may throw } void fill_dispatch(value_type * ptr, value_type const& v, @@ -695,7 +695,7 @@ private: void destroy(iterator first, iterator last) { - this->destroy_dispatch(first, last, has_trivial_destructor()); + this->destroy_dispatch(&(*first), &(*last), has_trivial_destructor()); } void destroy_dispatch(value_type * /*first*/, value_type * /*last*/, @@ -713,7 +713,7 @@ private: void destroy(iterator it) { - this->destroy_dispatch(it, has_trivial_destructor()); + this->destroy_dispatch(&(*it), has_trivial_destructor()); } void destroy_dispatch(value_type * /*ptr*/, @@ -730,7 +730,7 @@ private: void construct(iterator first, iterator last) { - this->construct_dispatch(first, last, has_trivial_constructor()); // may throw + this->construct_dispatch(&(*first), &(*last), has_trivial_constructor()); // may throw } void construct_dispatch(value_type * /*first*/, value_type * /*last*/, diff --git a/test/rtree/Jamfile.v2 b/test/rtree/Jamfile.v2 index 7880902fd..e637ce08a 100644 --- a/test/rtree/Jamfile.v2 +++ b/test/rtree/Jamfile.v2 @@ -13,14 +13,14 @@ test-suite boost-geometry-index-rtree [ run rtree_exceptions.cpp ] ; -#test-suite boost-geometry-index-rtree_interprocess -# : [ run rtree_interprocess.cpp /boost/thread//boost_thread -# : # additional args -# : # test-files -# : # requirements -# acc:-lrt -# acc-pa_risc:-lrt -# gcc-mingw:"-lole32 -loleaut32 -lpsapi -ladvapi32" -# hpux,gcc:"-Wl,+as,mpas" -# ] : multi -# ; \ No newline at end of file +test-suite boost-geometry-index-rtree_interprocess + : [ run rtree_interprocess.cpp /boost/thread//boost_thread + : # additional args + : # test-files + : # requirements + acc:-lrt + acc-pa_risc:-lrt + gcc-mingw:"-lole32 -loleaut32 -lpsapi -ladvapi32" + hpux,gcc:"-Wl,+as,mpas" + ] : multi + ; \ No newline at end of file diff --git a/test/rtree/rtree_interprocess.cpp b/test/rtree/rtree_interprocess.cpp index 9e2af9e95..d7a8d0c16 100644 --- a/test/rtree/rtree_interprocess.cpp +++ b/test/rtree/rtree_interprocess.cpp @@ -16,7 +16,7 @@ #include #include -template +template void test_rtree_interprocess(Parameters const& parameters = Parameters()) { namespace bi = boost::interprocess; @@ -27,58 +27,43 @@ void test_rtree_interprocess(Parameters const& parameters = Parameters()) } remover; bi::managed_shared_memory segment(bi::create_only, "shmem", 65535); - typedef bi::allocator shmem_alloc; + typedef bi::allocator shmem_alloc; - typedef bgi::rtree, shmem_alloc> Tree; + test_rtree_for_box(parameters, shmem_alloc(segment.get_segment_manager())); - Tree * tree = segment.construct("Tree")(parameters, bgi::translator::def(), shmem_alloc(segment.get_segment_manager())); - typedef typename Tree::bounds_type B; - - std::vector input; - B qbox; - - generate_rtree(*tree, input, qbox); + //typedef bgi::rtree, shmem_alloc> Tree; - 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); + //Tree * tree = segment.construct("Tree")(parameters, bgi::translator::def(), shmem_alloc(segment.get_segment_manager())); + //typedef typename Tree::bounds_type B; + // + //std::vector input; + //B qbox; + // + //generate_rtree(*tree, input, qbox); - typedef typename bgi::detail::traits::point_type::type P; - P pt; - bg::centroid(qbox, pt); + //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); - test_nearest_query_k(*tree, input, pt, 10); - test_nearest_query_not_found(*tree, generate_outside_point

::apply()); + //typedef typename bgi::detail::traits::point_type::type P; + //P pt; + //bg::centroid(qbox, pt); - segment.destroy_ptr(tree); + //test_nearest_query_k(*tree, input, pt, 10); + //test_nearest_query_not_found(*tree, generate_outside_point

::apply()); + + //segment.destroy_ptr(tree); } int test_main(int, char* []) { - typedef bg::model::point P2d; - typedef bg::model::box B2d; - typedef std::pair PB2d; - - //test_rtree_interprocess(bgi::linear<32, 8>()); - test_rtree_interprocess(bgi::runtime::linear(32, 8)); - /*test_rtree_interprocess(bgi::quadratic<32, 8>()); - test_rtree_interprocess(bgi::runtime::quadratic(32, 8)); - test_rtree_interprocess(bgi::rstar<32, 8>()); - test_rtree_interprocess(bgi::runtime::rstar(32, 8)); - - typedef bg::model::point P3f; - typedef bg::model::box B3f; - typedef std::pair PB3f; - - test_rtree_interprocess(bgi::linear<32, 8>()); - test_rtree_interprocess(bgi::runtime::linear(32, 8)); - test_rtree_interprocess(bgi::quadratic<32, 8>()); - test_rtree_interprocess(bgi::runtime::quadratic(32, 8)); - test_rtree_interprocess(bgi::rstar<32, 8>()); - test_rtree_interprocess(bgi::runtime::rstar(32, 8));*/ + typedef bg::model::point P2f; + test_rtree_interprocess(bgi::linear<32, 8>()); + test_rtree_interprocess(bgi::runtime::linear(32, 8)); + return 0; } diff --git a/test/rtree/test_rtree.hpp b/test/rtree/test_rtree.hpp index 767788433..8075a44f0 100644 --- a/test/rtree/test_rtree.hpp +++ b/test/rtree/test_rtree.hpp @@ -850,7 +850,7 @@ void test_copy_assignment_swap_move(Rtree const& tree, Box const& qbox) tree.query(qbox, std::back_inserter(expected_output)); // copy constructor - Rtree t1(tree, tree.get_allocator()); + Rtree t1(tree); BOOST_CHECK(tree.empty() == t1.empty()); BOOST_CHECK(tree.size() == t1.size()); @@ -993,10 +993,10 @@ void test_create_insert(Rtree & tree, std::vector const& input, Box const // rtree removing -template -void test_remove(bgi::rtree & tree, Box const& qbox) +template +void test_remove(Rtree & tree, Box const& qbox) { - typedef bgi::rtree T; + typedef typename Rtree::value_type Value; std::vector values_to_remove; tree.query(qbox, std::back_inserter(values_to_remove)); @@ -1008,11 +1008,11 @@ void test_remove(bgi::rtree & tree, Box const& qbox) size_t expected_size_after_remove = tree.size() - values_to_remove.size(); // Add value which is not stored in the Rtree - Value outsider = generate_value_outside(); + Value outsider = generate_value_outside(); values_to_remove.push_back(outsider); { - T t(tree); + Rtree t(tree); size_t r = 0; BOOST_FOREACH(Value const& v, values_to_remove) r += t.remove(v); @@ -1024,7 +1024,7 @@ void test_remove(bgi::rtree & tree, Box const& qbox) test_compare_outputs(t, output, expected_output); } { - T t(tree); + Rtree t(tree); size_t r = t.remove(values_to_remove.begin(), values_to_remove.end()); BOOST_CHECK( r == expected_removed_count ); std::vector output; @@ -1034,7 +1034,7 @@ void test_remove(bgi::rtree & tree, Box const& qbox) test_compare_outputs(t, output, expected_output); } { - T t(tree); + Rtree t(tree); size_t r = t.remove(values_to_remove); BOOST_CHECK( r == expected_removed_count ); std::vector output; @@ -1045,7 +1045,7 @@ void test_remove(bgi::rtree & tree, Box const& qbox) } { - T t(tree); + Rtree t(tree); size_t r = 0; BOOST_FOREACH(Value const& v, values_to_remove) r += bgi::remove(t, v); @@ -1057,7 +1057,7 @@ void test_remove(bgi::rtree & tree, Box const& qbox) test_compare_outputs(t, output, expected_output); } { - T t(tree); + Rtree t(tree); size_t r = bgi::remove(t, values_to_remove.begin(), values_to_remove.end()); BOOST_CHECK( r == expected_removed_count ); std::vector output; @@ -1067,7 +1067,7 @@ void test_remove(bgi::rtree & tree, Box const& qbox) test_compare_outputs(t, output, expected_output); } { - T t(tree); + Rtree t(tree); size_t r = bgi::remove(t, values_to_remove); BOOST_CHECK( r == expected_removed_count ); std::vector output; @@ -1078,18 +1078,16 @@ void test_remove(bgi::rtree & tree, Box const& qbox) } } -template -void test_clear(bgi::rtree & tree, std::vector const& input, Box const& qbox) +template +void test_clear(Rtree & tree, std::vector const& input, Box const& qbox) { - typedef bgi::rtree T; - std::vector values_to_remove; tree.query(qbox, std::back_inserter(values_to_remove)); BOOST_CHECK(0 < values_to_remove.size()); //clear { - T t(tree); + Rtree t(tree); std::vector expected_output; t.query(bgi::intersects(qbox), std::back_inserter(expected_output)); @@ -1108,15 +1106,17 @@ void test_clear(bgi::rtree & tree, std::vector const& input, // run all tests for a single Algorithm and single rtree // defined by Value -template -void test_rtree_by_value(Parameters const& parameters) +template +void test_rtree_by_value(Parameters const& parameters, Allocator const& allocator) { - typedef bgi::rtree Tree; + typedef bgi::translator::def T; + typedef typename Allocator::template rebind::other A; + typedef bgi::rtree Tree; typedef typename Tree::box_type B; // not empty tree test - Tree tree(parameters); + Tree tree(parameters, T(), allocator); std::vector input; B qbox; @@ -1144,7 +1144,7 @@ void test_rtree_by_value(Parameters const& parameters) // empty tree test - Tree empty_tree(parameters); + Tree empty_tree(parameters, T(), allocator); std::vector empty_input; test_intersects(empty_tree, empty_input, qbox); @@ -1160,14 +1160,17 @@ void test_rtree_by_value(Parameters const& parameters) // rtree inserting and removing of counting_value -template -void test_count_rtree_values(Parameters const& parameters) +template +void test_count_rtree_values(Parameters const& parameters, Allocator const& allocator) { typedef counting_value Value; - typedef bgi::rtree Tree; + + typedef bgi::translator::def T; + typedef typename Allocator::template rebind::other A; + typedef bgi::rtree Tree; typedef typename Tree::box_type B; - Tree t(parameters); + Tree t(parameters, T(), allocator); std::vector input; B qbox; @@ -1199,14 +1202,17 @@ void test_count_rtree_values(Parameters const& parameters) // rtree count -template -void test_rtree_count(Parameters const& parameters) +template +void test_rtree_count(Parameters const& parameters, Allocator const& allocator) { typedef std::pair Value; - typedef bgi::rtree Tree; + + typedef bgi::translator::def T; + typedef typename Allocator::template rebind::other A; + typedef bgi::rtree Tree; typedef typename Tree::box_type B; - Tree t(parameters); + Tree t(parameters, T(), allocator); std::vector input; B qbox; @@ -1228,17 +1234,19 @@ void test_rtree_count(Parameters const& parameters) // test rtree box -template -void test_rtree_bounds(Parameters const& parameters) +template +void test_rtree_bounds(Parameters const& parameters, Allocator const& allocator) { - typedef bgi::rtree Tree; + typedef bgi::translator::def T; + typedef typename Allocator::template rebind::other A; + typedef bgi::rtree Tree; typedef typename Tree::box_type B; typedef typename bg::traits::point_type::type P; B b; bg::assign_inverse(b); - Tree t(parameters); + Tree t(parameters, T(), allocator); std::vector input; B qbox; @@ -1283,45 +1291,57 @@ void test_rtree_bounds(Parameters const& parameters) // run all tests for one Algorithm for some number of rtrees // defined by some number of Values constructed from given Point -template -void test_rtree_for_point(Parameters const& parameters = Parameters()) +template +void test_rtree_for_point(Parameters const& parameters, Allocator const& allocator) { typedef std::pair PairP; typedef boost::tuple TupleP; typedef boost::shared_ptr< test_object > SharedPtrP; typedef value_no_dctor VNoDCtor; - test_rtree_by_value(parameters); - test_rtree_by_value(parameters); - test_rtree_by_value(parameters); - - test_rtree_by_value(parameters); - test_rtree_by_value(parameters); + test_rtree_by_value(parameters, allocator); + test_rtree_by_value(parameters, allocator); + test_rtree_by_value(parameters, allocator); - test_count_rtree_values(parameters); + test_rtree_by_value(parameters, allocator); + test_rtree_by_value(parameters, allocator); - test_rtree_count(parameters); - test_rtree_bounds(parameters); + test_count_rtree_values(parameters, allocator); + + test_rtree_count(parameters, allocator); + test_rtree_bounds(parameters, allocator); } -template -void test_rtree_for_box(Parameters const& parameters = Parameters()) +template +void test_rtree_for_box(Parameters const& parameters, Allocator const& allocator) { typedef bg::model::box Box; typedef std::pair PairB; typedef boost::tuple TupleB; typedef value_no_dctor VNoDCtor; - test_rtree_by_value(parameters); - test_rtree_by_value(parameters); - test_rtree_by_value(parameters); + test_rtree_by_value(parameters, allocator); + test_rtree_by_value(parameters, allocator); + test_rtree_by_value(parameters, allocator); - test_rtree_by_value(parameters); + test_rtree_by_value(parameters, allocator); - test_count_rtree_values(parameters); + test_count_rtree_values(parameters, allocator); - test_rtree_count(parameters); - test_rtree_bounds(parameters); + test_rtree_count(parameters, allocator); + test_rtree_bounds(parameters, allocator); +} + +template +void test_rtree_for_point(Parameters const& parameters) +{ + test_rtree_for_point(parameters, std::allocator()); +} + +template +void test_rtree_for_box(Parameters const& parameters) +{ + test_rtree_for_box(parameters, std::allocator()); } #endif diff --git a/test/rtree/test_rtree_exceptions.hpp b/test/rtree/test_rtree_exceptions.hpp index af62ce201..63c4a3c75 100644 --- a/test/rtree/test_rtree_exceptions.hpp +++ b/test/rtree/test_rtree_exceptions.hpp @@ -78,7 +78,7 @@ struct dynamic_internal_node * + typename Allocators::node_pointer >, Parameters::max_elements + 1 > elements_type; @@ -151,6 +151,14 @@ public: typedef Allocator allocator_type; typedef typename allocator_type::size_type size_type; + typedef typename allocator_type::template rebind< + typename node::type + >::other::pointer node_pointer; + + typedef typename allocator_type::template rebind< + typename internal_node::type + >::other::pointer internal_node_pointer; + typedef typename allocator_type::template rebind< typename internal_node::type >::other internal_node_allocator_type; @@ -226,15 +234,14 @@ struct create_node< dynamic_internal_node > { - static inline dynamic_node * + static inline typename Allocators::node_pointer apply(Allocators & allocators) { // throw if counter meets max count throwing_node_settings::throw_if_required(); return create_dynamic_node< - dynamic_node, - dynamic_internal_node + typename Allocators::node_pointer >::template apply(allocators.internal_node_allocator, allocators.internal_node_allocator); } }; @@ -245,15 +252,14 @@ struct create_node< dynamic_leaf > { - static inline typename node::type * + static inline typename Allocators::node_pointer apply(Allocators & allocators) { // throw if counter meets max count throwing_node_settings::throw_if_required(); return create_dynamic_node< - dynamic_node, - dynamic_leaf + typename Allocators::node_pointer >::template apply(allocators.leaf_allocator, allocators.leaf_allocator); } };