1 // Boost.Geometry Index
3 // R-tree nodes based on static conversion, storing static-size containers
5 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_STATIC_HPP
12 #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_STATIC_HPP
14 namespace boost { namespace geometry { namespace index {
16 namespace detail { namespace rtree {
18 template <typename Value, typename Parameters, typename Box, typename Allocators>
19 struct weak_internal_node<Value, Parameters, Box, Allocators, node_weak_static_tag>
20 : public weak_node<Value, Parameters, Box, Allocators, node_weak_static_tag>
22 typedef detail::varray<
23 rtree::ptr_pair<Box, typename Allocators::node_pointer>,
24 Parameters::max_elements + 1
27 template <typename Alloc>
28 inline weak_internal_node(Alloc const&) {}
30 elements_type elements;
33 template <typename Value, typename Parameters, typename Box, typename Allocators>
34 struct weak_leaf<Value, Parameters, Box, Allocators, node_weak_static_tag>
35 : public weak_node<Value, Parameters, Box, Allocators, node_weak_static_tag>
37 typedef detail::varray<
39 Parameters::max_elements + 1
42 template <typename Alloc>
43 inline weak_leaf(Alloc const&) {}
45 elements_type elements;
50 template <typename Value, typename Parameters, typename Box, typename Allocators>
51 struct node<Value, Parameters, Box, Allocators, node_weak_static_tag>
53 typedef weak_node<Value, Parameters, Box, Allocators, node_weak_static_tag> type;
56 template <typename Value, typename Parameters, typename Box, typename Allocators>
57 struct internal_node<Value, Parameters, Box, Allocators, node_weak_static_tag>
59 typedef weak_internal_node<Value, Parameters, Box, Allocators, node_weak_static_tag> type;
62 template <typename Value, typename Parameters, typename Box, typename Allocators>
63 struct leaf<Value, Parameters, Box, Allocators, node_weak_static_tag>
65 typedef weak_leaf<Value, Parameters, Box, Allocators, node_weak_static_tag> type;
68 template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
69 struct visitor<Value, Parameters, Box, Allocators, node_weak_static_tag, IsVisitableConst>
71 typedef weak_visitor<Value, Parameters, Box, Allocators, node_weak_static_tag, IsVisitableConst> type;
76 template <typename Allocator, typename Value, typename Parameters, typename Box>
77 class allocators<Allocator, Value, Parameters, Box, node_weak_static_tag>
78 : public Allocator::template rebind<
79 typename internal_node<
80 Value, Parameters, Box,
81 allocators<Allocator, Value, Parameters, Box, node_weak_static_tag>,
85 , public Allocator::template rebind<
87 Value, Parameters, Box,
88 allocators<Allocator, Value, Parameters, Box, node_weak_static_tag>,
93 typedef typename Allocator::template rebind<
95 >::other value_allocator_type;
98 typedef Allocator allocator_type;
100 typedef Value value_type;
101 typedef value_type & reference;
102 typedef const value_type & const_reference;
103 typedef typename value_allocator_type::size_type size_type;
104 typedef typename value_allocator_type::difference_type difference_type;
105 typedef typename value_allocator_type::pointer pointer;
106 typedef typename value_allocator_type::const_pointer const_pointer;
108 typedef typename Allocator::template rebind<
109 typename node<Value, Parameters, Box, allocators, node_weak_static_tag>::type
110 >::other::pointer node_pointer;
112 typedef typename Allocator::template rebind<
113 typename internal_node<Value, Parameters, Box, allocators, node_weak_static_tag>::type
114 >::other internal_node_allocator_type;
116 typedef typename Allocator::template rebind<
117 typename leaf<Value, Parameters, Box, allocators, node_weak_static_tag>::type
118 >::other leaf_allocator_type;
121 : internal_node_allocator_type()
122 , leaf_allocator_type()
125 template <typename Alloc>
126 inline explicit allocators(Alloc const& alloc)
127 : internal_node_allocator_type(alloc)
128 , leaf_allocator_type(alloc)
131 inline allocators(BOOST_FWD_REF(allocators) a)
132 : internal_node_allocator_type(boost::move(a.internal_node_allocator()))
133 , leaf_allocator_type(boost::move(a.leaf_allocator()))
136 inline allocators & operator=(BOOST_FWD_REF(allocators) a)
138 internal_node_allocator() = ::boost::move(a.internal_node_allocator());
139 leaf_allocator() = ::boost::move(a.leaf_allocator());
143 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
144 inline allocators & operator=(allocators const& a)
146 internal_node_allocator() = a.internal_node_allocator();
147 leaf_allocator() = a.leaf_allocator();
152 void swap(allocators & a)
154 boost::swap(internal_node_allocator(), a.internal_node_allocator());
155 boost::swap(leaf_allocator(), a.leaf_allocator());
158 bool operator==(allocators const& a) const { return leaf_allocator() == a.leaf_allocator(); }
159 template <typename Alloc>
160 bool operator==(Alloc const& a) const { return leaf_allocator() == leaf_allocator_type(a); }
162 Allocator allocator() const { return Allocator(leaf_allocator()); }
164 internal_node_allocator_type & internal_node_allocator() { return *this; }
165 internal_node_allocator_type const& internal_node_allocator() const { return *this; }
166 leaf_allocator_type & leaf_allocator() { return *this; }
167 leaf_allocator_type const& leaf_allocator() const{ return *this; }
170 }} // namespace detail::rtree
172 }}} // namespace boost::geometry::index
174 #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_STATIC_HPP