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 nodes based on Boost.Variant, storing static-size containers
0004 //
0005 // Copyright (c) 2011-2023 Adam Wulkiewicz, Lodz, Poland.
0006 //
0007 // This file was modified by Oracle on 2021.
0008 // Modifications copyright (c) 2021 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_VARIANT_STATIC_HPP
0016 #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_STATIC_HPP
0017 
0018 #include <utility>
0019 #include <boost/container/allocator_traits.hpp>
0020 #include <boost/core/invoke_swap.hpp>
0021 #include <boost/variant/static_visitor.hpp>
0022 #include <boost/variant/variant.hpp>
0023 
0024 #include <boost/geometry/index/detail/rtree/node/variant_dynamic.hpp>
0025 #include <boost/geometry/index/detail/varray.hpp>
0026 
0027 namespace boost { namespace geometry { namespace index {
0028 
0029 namespace detail { namespace rtree {
0030 
0031 // nodes default types
0032 
0033 template <typename Value, typename Parameters, typename Box, typename Allocators>
0034 struct variant_internal_node<Value, Parameters, Box, Allocators, node_variant_static_tag>
0035 {
0036     typedef detail::varray<
0037         rtree::ptr_pair<Box, typename Allocators::node_pointer>,
0038         Parameters::max_elements + 1
0039     > elements_type;
0040 
0041     template <typename Alloc>
0042     inline variant_internal_node(Alloc const&) {}
0043 
0044     elements_type elements;
0045 };
0046 
0047 template <typename Value, typename Parameters, typename Box, typename Allocators>
0048 struct variant_leaf<Value, Parameters, Box, Allocators, node_variant_static_tag>
0049 {
0050     typedef detail::varray<
0051         Value,
0052         Parameters::max_elements + 1
0053     > elements_type;
0054 
0055     template <typename Alloc>
0056     inline variant_leaf(Alloc const&) {}
0057 
0058     elements_type elements;
0059 };
0060 
0061 // nodes traits
0062 
0063 template <typename Value, typename Parameters, typename Box, typename Allocators>
0064 struct node<Value, Parameters, Box, Allocators, node_variant_static_tag>
0065 {
0066     typedef boost::variant<
0067         variant_leaf<Value, Parameters, Box, Allocators, node_variant_static_tag>,
0068         variant_internal_node<Value, Parameters, Box, Allocators, node_variant_static_tag>
0069     > type;
0070 };
0071 
0072 template <typename Value, typename Parameters, typename Box, typename Allocators>
0073 struct internal_node<Value, Parameters, Box, Allocators, node_variant_static_tag>
0074 {
0075     typedef variant_internal_node<Value, Parameters, Box, Allocators, node_variant_static_tag> type;
0076 };
0077 
0078 template <typename Value, typename Parameters, typename Box, typename Allocators>
0079 struct leaf<Value, Parameters, Box, Allocators, node_variant_static_tag>
0080 {
0081     typedef variant_leaf<Value, Parameters, Box, Allocators, node_variant_static_tag> type;
0082 };
0083 
0084 // visitor traits
0085 
0086 template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
0087 struct visitor<Value, Parameters, Box, Allocators, node_variant_static_tag, IsVisitableConst>
0088 {
0089     typedef static_visitor<> type;
0090 };
0091 
0092 // allocators
0093 
0094 template <typename Allocator, typename Value, typename Parameters, typename Box>
0095 class allocators<Allocator, Value, Parameters, Box, node_variant_static_tag>
0096     : public detail::rtree::node_alloc
0097         <
0098             Allocator, Value, Parameters, Box, node_variant_static_tag
0099         >::type
0100 {
0101     typedef detail::rtree::node_alloc
0102         <
0103             Allocator, Value, Parameters, Box, node_variant_static_tag
0104         > node_alloc;
0105 
0106 public:
0107     typedef typename node_alloc::type node_allocator_type;
0108     typedef typename node_alloc::traits::pointer node_pointer;
0109 
0110 private:
0111     typedef typename boost::container::allocator_traits
0112         <
0113             node_allocator_type
0114         >::template rebind_alloc<Value> value_allocator_type;
0115     typedef boost::container::allocator_traits<value_allocator_type> value_allocator_traits;
0116 
0117 public:
0118     typedef Allocator allocator_type;
0119 
0120     typedef Value value_type;
0121     typedef typename value_allocator_traits::reference reference;
0122     typedef typename value_allocator_traits::const_reference const_reference;
0123     typedef typename value_allocator_traits::size_type size_type;
0124     typedef typename value_allocator_traits::difference_type difference_type;
0125     typedef typename value_allocator_traits::pointer pointer;
0126     typedef typename value_allocator_traits::const_pointer const_pointer;
0127 
0128     inline allocators()
0129         : node_allocator_type()
0130     {}
0131 
0132     template <typename Alloc>
0133     inline explicit allocators(Alloc const& alloc)
0134         : node_allocator_type(alloc)
0135     {}
0136 
0137     inline allocators(allocators&& a)
0138         : node_allocator_type(std::move(a.node_allocator()))
0139     {}
0140 
0141     inline allocators & operator=(allocators&& a)
0142     {
0143         node_allocator() = std::move(a.node_allocator());
0144         return *this;
0145     }
0146 
0147     inline allocators & operator=(allocators const& a)
0148     {
0149         node_allocator() = a.node_allocator();
0150         return *this;
0151     }
0152 
0153     void swap(allocators & a)
0154     {
0155         boost::core::invoke_swap(node_allocator(), a.node_allocator());
0156     }
0157 
0158     bool operator==(allocators const& a) const { return node_allocator() == a.node_allocator(); }
0159     template <typename Alloc>
0160     bool operator==(Alloc const& a) const { return node_allocator() == node_allocator_type(a); }
0161 
0162     Allocator allocator() const { return Allocator(node_allocator()); }
0163 
0164     node_allocator_type & node_allocator() { return *this; }
0165     node_allocator_type const& node_allocator() const { return *this; }
0166 };
0167 
0168 }} // namespace detail::rtree
0169 
0170 }}} // namespace boost::geometry::index
0171 
0172 #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_STATIC_HPP