File indexing completed on 2025-01-18 09:35:31
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_COPY_HPP
0016 #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_COPY_HPP
0017
0018 #include <boost/geometry/index/detail/rtree/node/subtree_destroyer.hpp>
0019
0020 namespace boost { namespace geometry { namespace index {
0021
0022 namespace detail { namespace rtree { namespace visitors {
0023
0024 template <typename MembersHolder>
0025 class copy
0026 : public MembersHolder::visitor
0027 {
0028 typedef typename MembersHolder::allocators_type allocators_type;
0029
0030 typedef typename MembersHolder::node node;
0031 typedef typename MembersHolder::internal_node internal_node;
0032 typedef typename MembersHolder::leaf leaf;
0033
0034 typedef rtree::subtree_destroyer<MembersHolder> subtree_destroyer;
0035 typedef typename allocators_type::node_pointer node_pointer;
0036
0037 public:
0038 explicit inline copy(allocators_type & allocators)
0039 : result(0)
0040 , m_allocators(allocators)
0041 {}
0042
0043 inline void operator()(internal_node & n)
0044 {
0045 node_pointer raw_new_node = rtree::create_node<allocators_type, internal_node>::apply(m_allocators);
0046 subtree_destroyer new_node(raw_new_node, m_allocators);
0047
0048 typedef typename rtree::elements_type<internal_node>::type elements_type;
0049 elements_type & elements = rtree::elements(n);
0050
0051 elements_type & elements_dst = rtree::elements(rtree::get<internal_node>(*new_node));
0052
0053 for (typename elements_type::iterator it = elements.begin();
0054 it != elements.end(); ++it)
0055 {
0056 rtree::apply_visitor(*this, *it->second);
0057
0058
0059 subtree_destroyer auto_result(result, m_allocators);
0060
0061 elements_dst.push_back( rtree::make_ptr_pair(it->first, result) );
0062
0063 auto_result.release();
0064 }
0065
0066 result = new_node.get();
0067 new_node.release();
0068 }
0069
0070 inline void operator()(leaf & l)
0071 {
0072 node_pointer raw_new_node = rtree::create_node<allocators_type, leaf>::apply(m_allocators);
0073 subtree_destroyer new_node(raw_new_node, m_allocators);
0074
0075 typedef typename rtree::elements_type<leaf>::type elements_type;
0076 elements_type & elements = rtree::elements(l);
0077
0078 elements_type & elements_dst = rtree::elements(rtree::get<leaf>(*new_node));
0079
0080 for (typename elements_type::iterator it = elements.begin();
0081 it != elements.end(); ++it)
0082 {
0083 elements_dst.push_back(*it);
0084 }
0085
0086 result = new_node.get();
0087 new_node.release();
0088 }
0089
0090 node_pointer result;
0091
0092 private:
0093 allocators_type & m_allocators;
0094 };
0095
0096 }}}
0097
0098 }}}
0099
0100 #endif