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 destroying visitor implementation
0004 //
0005 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
0006 //
0007 // This file was modified by Oracle on 2019-2023.
0008 // Modifications copyright (c) 2019-2023 Oracle and/or its affiliates.
0009 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0010 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0011 //
0012 // Use, modification and distribution is subject to the Boost Software License,
0013 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0014 // http://www.boost.org/LICENSE_1_0.txt)
0015 
0016 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_DELETE_HPP
0017 #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_DELETE_HPP
0018 
0019 #include <boost/geometry/index/detail/rtree/node/concept.hpp>
0020 #include <boost/geometry/index/detail/rtree/node/node_elements.hpp>
0021 #include <boost/geometry/index/detail/rtree/node/weak_visitor.hpp>
0022 
0023 namespace boost { namespace geometry { namespace index {
0024 
0025 namespace detail { namespace rtree { namespace visitors {
0026 
0027 template <typename MembersHolder>
0028 class destroy
0029     : public MembersHolder::visitor
0030 {
0031 public:
0032     typedef typename MembersHolder::node node;
0033     typedef typename MembersHolder::internal_node internal_node;
0034     typedef typename MembersHolder::leaf leaf;
0035 
0036     typedef typename MembersHolder::allocators_type allocators_type;
0037     typedef typename MembersHolder::node_pointer node_pointer;
0038 
0039     inline destroy(node_pointer node, allocators_type & allocators)
0040         : m_current_node(node)
0041         , m_allocators(allocators)
0042     {}
0043 
0044     inline void operator()(internal_node & n)
0045     {
0046         BOOST_GEOMETRY_INDEX_ASSERT(&n == &rtree::get<internal_node>(*m_current_node), "invalid pointers");
0047 
0048         node_pointer node_to_destroy = m_current_node;
0049 
0050         typedef typename rtree::elements_type<internal_node>::type elements_type;
0051         elements_type & elements = rtree::elements(n);
0052 
0053         for (typename elements_type::iterator it = elements.begin();
0054              it != elements.end(); ++it)
0055         {
0056             m_current_node = it->second;
0057             rtree::apply_visitor(*this, *m_current_node);
0058             it->second = 0;
0059         }
0060 
0061         rtree::destroy_node<allocators_type, internal_node>::apply(m_allocators, node_to_destroy);
0062     }
0063 
0064     inline void operator()(leaf & l)
0065     {
0066         boost::ignore_unused(l);
0067         BOOST_GEOMETRY_INDEX_ASSERT(&l == &rtree::get<leaf>(*m_current_node), "invalid pointers");
0068 
0069         rtree::destroy_node<allocators_type, leaf>::apply(m_allocators, m_current_node);
0070     }
0071 
0072     static inline void apply(node_pointer node, allocators_type & allocators)
0073     {
0074         destroy v(node, allocators);
0075         rtree::apply_visitor(v, *node);
0076     }
0077 
0078 private:
0079     node_pointer m_current_node;
0080     allocators_type & m_allocators;
0081 };
0082 
0083 }}} // namespace detail::rtree::visitors
0084 
0085 }}} // namespace boost::geometry::index
0086 
0087 #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_DELETE_HPP