Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Boost.Geometry Index
0002 //
0003 // R-tree subtree scoped destroyer
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_NODE_SUBTREE_DESTROYED_HPP
0016 #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SUBTREE_DESTROYED_HPP
0017 
0018 #include <boost/geometry/index/detail/rtree/visitors/destroy.hpp>
0019 
0020 namespace boost { namespace geometry { namespace index {
0021 
0022 namespace detail { namespace rtree {
0023 
0024 template <typename MembersHolder>
0025 class subtree_destroyer
0026 {
0027     typedef typename MembersHolder::node node;
0028 
0029     typedef typename MembersHolder::allocators_type allocators_type;
0030     typedef typename MembersHolder::node_pointer pointer;
0031 
0032     subtree_destroyer(subtree_destroyer const&);
0033     subtree_destroyer & operator=(subtree_destroyer const&);
0034 
0035 public:
0036     subtree_destroyer(pointer ptr, allocators_type & allocators)
0037         : m_ptr(ptr)
0038         , m_allocators(allocators)
0039     {}
0040 
0041     ~subtree_destroyer()
0042     {
0043         reset();
0044     }
0045 
0046     void reset(pointer ptr = 0)
0047     {
0048         if ( m_ptr && m_ptr != ptr )
0049         {
0050             detail::rtree::visitors::destroy<MembersHolder>::apply(m_ptr, m_allocators);
0051         }
0052         m_ptr = ptr;
0053     }
0054 
0055     void release()
0056     {
0057         m_ptr = 0;
0058     }
0059 
0060     pointer get() const
0061     {
0062         return m_ptr;
0063     }
0064 
0065     node & operator*() const
0066     {
0067         return *m_ptr;
0068     }
0069 
0070     pointer operator->() const
0071     {
0072         return m_ptr;
0073     }
0074 
0075 private:
0076     pointer m_ptr;
0077     allocators_type & m_allocators;
0078 };
0079 
0080 }} // namespace detail::rtree
0081 
0082 }}} // namespace boost::geometry::index
0083 
0084 #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SUBTREE_DESTROYED_HPP