Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:31

0001 // Boost.Geometry Index
0002 //
0003 // R-tree deep copying visitor implementation
0004 //
0005 // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
0006 //
0007 // This file was modified by Oracle on 2019.
0008 // Modifications copyright (c) 2019 Oracle and/or its affiliates.
0009 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0010 //
0011 // Use, modification and distribution is subject to the Boost Software License,
0012 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0013 // http://www.boost.org/LICENSE_1_0.txt)
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);      // MAY THROW, STRONG (N: alloc)
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);                                                   // MAY THROW (V, E: alloc, copy, N: alloc)
0057 
0058             // for exception safety
0059             subtree_destroyer auto_result(result, m_allocators);
0060 
0061             elements_dst.push_back( rtree::make_ptr_pair(it->first, result) );                          // MAY THROW, STRONG (E: alloc, copy)
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);                // MAY THROW, STRONG (N: alloc)
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);                                                                // MAY THROW, STRONG (V: alloc, copy)
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 }}} // namespace detail::rtree::visitors
0097 
0098 }}} // namespace boost::geometry::index
0099 
0100 #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_COPY_HPP