File indexing completed on 2024-11-15 09:10:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_STATIC_HPP
0016 #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_STATIC_HPP
0017
0018 #include <utility>
0019 #include <boost/container/allocator_traits.hpp>
0020 #include <boost/core/invoke_swap.hpp>
0021
0022 #include <boost/geometry/index/detail/rtree/node/weak_dynamic.hpp>
0023 #include <boost/geometry/index/detail/varray.hpp>
0024
0025 namespace boost { namespace geometry { namespace index {
0026
0027 namespace detail { namespace rtree {
0028
0029 template <typename Value, typename Parameters, typename Box, typename Allocators>
0030 struct weak_internal_node<Value, Parameters, Box, Allocators, node_weak_static_tag>
0031 : public weak_node<Value, Parameters, Box, Allocators, node_weak_static_tag>
0032 {
0033 typedef detail::varray<
0034 rtree::ptr_pair<Box, typename Allocators::node_pointer>,
0035 Parameters::max_elements + 1
0036 > elements_type;
0037
0038 template <typename Alloc>
0039 inline weak_internal_node(Alloc const&) {}
0040
0041 elements_type elements;
0042 };
0043
0044 template <typename Value, typename Parameters, typename Box, typename Allocators>
0045 struct weak_leaf<Value, Parameters, Box, Allocators, node_weak_static_tag>
0046 : public weak_node<Value, Parameters, Box, Allocators, node_weak_static_tag>
0047 {
0048 typedef detail::varray<
0049 Value,
0050 Parameters::max_elements + 1
0051 > elements_type;
0052
0053 template <typename Alloc>
0054 inline weak_leaf(Alloc const&) {}
0055
0056 elements_type elements;
0057 };
0058
0059
0060
0061 template <typename Value, typename Parameters, typename Box, typename Allocators>
0062 struct node<Value, Parameters, Box, Allocators, node_weak_static_tag>
0063 {
0064 typedef weak_node<Value, Parameters, Box, Allocators, node_weak_static_tag> type;
0065 };
0066
0067 template <typename Value, typename Parameters, typename Box, typename Allocators>
0068 struct internal_node<Value, Parameters, Box, Allocators, node_weak_static_tag>
0069 {
0070 typedef weak_internal_node<Value, Parameters, Box, Allocators, node_weak_static_tag> type;
0071 };
0072
0073 template <typename Value, typename Parameters, typename Box, typename Allocators>
0074 struct leaf<Value, Parameters, Box, Allocators, node_weak_static_tag>
0075 {
0076 typedef weak_leaf<Value, Parameters, Box, Allocators, node_weak_static_tag> type;
0077 };
0078
0079 template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
0080 struct visitor<Value, Parameters, Box, Allocators, node_weak_static_tag, IsVisitableConst>
0081 {
0082 typedef weak_visitor<Value, Parameters, Box, Allocators, node_weak_static_tag, IsVisitableConst> type;
0083 };
0084
0085
0086
0087 template <typename Allocator, typename Value, typename Parameters, typename Box>
0088 class allocators<Allocator, Value, Parameters, Box, node_weak_static_tag>
0089 : public detail::rtree::internal_node_alloc<Allocator, Value, Parameters, Box, node_weak_static_tag>::type
0090 , public detail::rtree::leaf_alloc<Allocator, Value, Parameters, Box, node_weak_static_tag>::type
0091 {
0092 typedef detail::rtree::internal_node_alloc
0093 <
0094 Allocator, Value, Parameters, Box, node_weak_static_tag
0095 > internal_node_alloc;
0096
0097 typedef detail::rtree::leaf_alloc
0098 <
0099 Allocator, Value, Parameters, Box, node_weak_static_tag
0100 > leaf_alloc;
0101
0102 typedef detail::rtree::node_alloc
0103 <
0104 Allocator, Value, Parameters, Box, node_weak_static_tag
0105 > node_alloc;
0106
0107 public:
0108 typedef typename internal_node_alloc::type internal_node_allocator_type;
0109 typedef typename leaf_alloc::type leaf_allocator_type;
0110 typedef typename node_alloc::traits::pointer node_pointer;
0111
0112 private:
0113 typedef typename boost::container::allocator_traits
0114 <
0115 leaf_allocator_type
0116 >::template rebind_alloc<Value> value_allocator_type;
0117 typedef boost::container::allocator_traits<value_allocator_type> value_allocator_traits;
0118
0119 public:
0120 typedef Allocator allocator_type;
0121
0122 typedef Value value_type;
0123 typedef typename value_allocator_traits::reference reference;
0124 typedef typename value_allocator_traits::const_reference const_reference;
0125 typedef typename value_allocator_traits::size_type size_type;
0126 typedef typename value_allocator_traits::difference_type difference_type;
0127 typedef typename value_allocator_traits::pointer pointer;
0128 typedef typename value_allocator_traits::const_pointer const_pointer;
0129
0130 inline allocators()
0131 : internal_node_allocator_type()
0132 , leaf_allocator_type()
0133 {}
0134
0135 template <typename Alloc>
0136 inline explicit allocators(Alloc const& alloc)
0137 : internal_node_allocator_type(alloc)
0138 , leaf_allocator_type(alloc)
0139 {}
0140
0141 inline allocators(allocators&& a)
0142 : internal_node_allocator_type(std::move(a.internal_node_allocator()))
0143 , leaf_allocator_type(std::move(a.leaf_allocator()))
0144 {}
0145
0146 inline allocators & operator=(allocators&& a)
0147 {
0148 internal_node_allocator() = std::move(a.internal_node_allocator());
0149 leaf_allocator() = std::move(a.leaf_allocator());
0150 return *this;
0151 }
0152
0153 inline allocators & operator=(allocators const& a)
0154 {
0155 internal_node_allocator() = a.internal_node_allocator();
0156 leaf_allocator() = a.leaf_allocator();
0157 return *this;
0158 }
0159
0160 void swap(allocators & a)
0161 {
0162 boost::core::invoke_swap(internal_node_allocator(), a.internal_node_allocator());
0163 boost::core::invoke_swap(leaf_allocator(), a.leaf_allocator());
0164 }
0165
0166 bool operator==(allocators const& a) const { return leaf_allocator() == a.leaf_allocator(); }
0167 template <typename Alloc>
0168 bool operator==(Alloc const& a) const { return leaf_allocator() == leaf_allocator_type(a); }
0169
0170 Allocator allocator() const { return Allocator(leaf_allocator()); }
0171
0172 internal_node_allocator_type & internal_node_allocator() { return *this; }
0173 internal_node_allocator_type const& internal_node_allocator() const { return *this; }
0174 leaf_allocator_type & leaf_allocator() { return *this; }
0175 leaf_allocator_type const& leaf_allocator() const{ return *this; }
0176 };
0177
0178 }}
0179
0180 }}}
0181
0182 #endif