mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-11 11:52:11 +00:00
code related to nodes visitation moved to XXX_visitor.hpp
[SVN r80782]
This commit is contained in:
@@ -63,6 +63,30 @@ struct dynamic_visitor<Value, Parameters, Box, Allocators, Tag, false>
|
||||
virtual void operator()(leaf &) = 0;
|
||||
};
|
||||
|
||||
// nodes conversion
|
||||
|
||||
template <typename Derived, typename Parameters, typename Value, typename Box, typename Allocators, typename Tag>
|
||||
inline Derived & get(dynamic_node<Value, Parameters, Box, Allocators, Tag> & n)
|
||||
{
|
||||
assert(dynamic_cast<Derived*>(&n));
|
||||
return static_cast<Derived&>(n);
|
||||
}
|
||||
|
||||
template <typename Derived, typename Parameters, typename Value, typename Box, typename Allocators, typename Tag>
|
||||
inline Derived * get(dynamic_node<Value, Parameters, Box, Allocators, Tag> * n)
|
||||
{
|
||||
assert(dynamic_cast<Derived*>(n));
|
||||
return static_cast<Derived*>(n);
|
||||
}
|
||||
|
||||
// apply visitor
|
||||
|
||||
template <typename Visitor, typename Visitable>
|
||||
inline void apply_visitor(Visitor &v, Visitable & n)
|
||||
{
|
||||
n.apply_visitor(v);
|
||||
}
|
||||
|
||||
}} // namespace detail::rtree
|
||||
|
||||
}}} // namespace boost::geometry::index
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
#include <boost/geometry/extensions/index/rtree/node/concept.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/rtree/node/node_d_mem_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/index/rtree/node/node_s_mem_dynamic.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/rtree/node/node_d_mem_static.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/rtree/node/node_s_mem_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/index/rtree/node/node_s_mem_static.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/expand.hpp>
|
||||
|
||||
@@ -77,22 +77,6 @@ struct leaf<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag>
|
||||
typedef dynamic_leaf<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag> type;
|
||||
};
|
||||
|
||||
// nodes conversion
|
||||
|
||||
template <typename Derived, typename Parameters, typename Value, typename Box, typename Allocators, typename Tag>
|
||||
inline Derived & get(dynamic_node<Value, Parameters, Box, Allocators, Tag> & n)
|
||||
{
|
||||
assert(dynamic_cast<Derived*>(&n));
|
||||
return static_cast<Derived&>(n);
|
||||
}
|
||||
|
||||
template <typename Derived, typename Parameters, typename Value, typename Box, typename Allocators, typename Tag>
|
||||
inline Derived * get(dynamic_node<Value, Parameters, Box, Allocators, Tag> * n)
|
||||
{
|
||||
assert(dynamic_cast<Derived*>(n));
|
||||
return static_cast<Derived*>(n);
|
||||
}
|
||||
|
||||
// visitor traits
|
||||
|
||||
template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
|
||||
@@ -101,12 +85,6 @@ struct visitor<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag, IsVis
|
||||
typedef dynamic_visitor<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag, IsVisitableConst> type;
|
||||
};
|
||||
|
||||
template <typename Visitor, typename Visitable>
|
||||
inline void apply_visitor(Visitor &v, Visitable & n)
|
||||
{
|
||||
n.apply_visitor(v);
|
||||
}
|
||||
|
||||
// element's indexable type
|
||||
|
||||
template <typename Value, typename Translator>
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_NODE_DEFAULT_VARIANT_HPP
|
||||
|
||||
#include <vector>
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/rtree/node/static_visitor.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace index {
|
||||
|
||||
@@ -21,7 +22,7 @@ namespace detail { namespace rtree {
|
||||
// nodes default types
|
||||
|
||||
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
|
||||
struct internal_node_variant
|
||||
struct static_internal_node
|
||||
{
|
||||
typedef std::vector<
|
||||
std::pair<
|
||||
@@ -31,7 +32,7 @@ struct internal_node_variant
|
||||
typename Allocators::internal_node_elements_allocator_type
|
||||
> elements_type;
|
||||
|
||||
inline internal_node_variant(typename Allocators::internal_node_elements_allocator_type & al)
|
||||
inline static_internal_node(typename Allocators::internal_node_elements_allocator_type & al)
|
||||
: elements(al)
|
||||
{}
|
||||
|
||||
@@ -39,14 +40,14 @@ struct internal_node_variant
|
||||
};
|
||||
|
||||
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
|
||||
struct leaf_variant
|
||||
struct static_leaf
|
||||
{
|
||||
typedef std::vector<
|
||||
Value,
|
||||
typename Allocators::leaf_elements_allocator_type
|
||||
> elements_type;
|
||||
|
||||
inline leaf_variant(typename Allocators::leaf_elements_allocator_type & al)
|
||||
inline static_leaf(typename Allocators::leaf_elements_allocator_type & al)
|
||||
: elements(al)
|
||||
{}
|
||||
|
||||
@@ -59,47 +60,23 @@ template <typename Value, typename Parameters, typename Box, typename Allocators
|
||||
struct node<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag>
|
||||
{
|
||||
typedef boost::variant<
|
||||
leaf_variant<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag>,
|
||||
internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag>
|
||||
static_leaf<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag>,
|
||||
static_internal_node<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag>
|
||||
> type;
|
||||
};
|
||||
|
||||
template <typename Value, typename Parameters, typename Box, typename Allocators>
|
||||
struct internal_node<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag>
|
||||
{
|
||||
typedef internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag> type;
|
||||
typedef static_internal_node<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag> type;
|
||||
};
|
||||
|
||||
template <typename Value, typename Parameters, typename Box, typename Allocators>
|
||||
struct leaf<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag>
|
||||
{
|
||||
typedef leaf_variant<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag> type;
|
||||
typedef static_leaf<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag> type;
|
||||
};
|
||||
|
||||
// nodes conversion
|
||||
|
||||
template <typename V, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
|
||||
inline V & get(
|
||||
boost::variant<
|
||||
leaf_variant<Value, Parameters, Box, Allocators, Tag>,
|
||||
internal_node_variant<Value, Parameters, Box, Allocators, Tag>
|
||||
> &v
|
||||
)
|
||||
{
|
||||
return boost::get<V>(v);
|
||||
}
|
||||
|
||||
template <typename V, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
|
||||
inline V * get(
|
||||
boost::variant<
|
||||
leaf_variant<Value, Parameters, Box, Allocators, Tag>,
|
||||
internal_node_variant<Value, Parameters, Box, Allocators, Tag>
|
||||
> *v
|
||||
)
|
||||
{
|
||||
return boost::get<V>(v);
|
||||
}
|
||||
|
||||
// visitor traits
|
||||
|
||||
template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
|
||||
@@ -108,26 +85,6 @@ struct visitor<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag, IsVis
|
||||
typedef static_visitor<> type;
|
||||
};
|
||||
|
||||
template <typename Visitor, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
|
||||
inline void apply_visitor(Visitor & v,
|
||||
boost::variant<
|
||||
leaf_variant<Value, Parameters, Box, Allocators, Tag>,
|
||||
internal_node_variant<Value, Parameters, Box, Allocators, Tag>
|
||||
> & n)
|
||||
{
|
||||
boost::apply_visitor(v, n);
|
||||
}
|
||||
|
||||
template <typename Visitor, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
|
||||
inline void apply_visitor(Visitor & v,
|
||||
boost::variant<
|
||||
leaf_variant<Value, Parameters, Box, Allocators, Tag>,
|
||||
internal_node_variant<Value, Parameters, Box, Allocators, Tag>
|
||||
> const& n)
|
||||
{
|
||||
boost::apply_visitor(v, n);
|
||||
}
|
||||
|
||||
// element's indexable type
|
||||
|
||||
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag, typename Translator>
|
||||
@@ -135,8 +92,8 @@ struct element_indexable_type<
|
||||
std::pair<
|
||||
Box,
|
||||
boost::variant<
|
||||
leaf_variant<Value, Parameters, Box, Allocators, Tag>,
|
||||
internal_node_variant<Value, Parameters, Box, Allocators, Tag>
|
||||
static_leaf<Value, Parameters, Box, Allocators, Tag>,
|
||||
static_internal_node<Value, Parameters, Box, Allocators, Tag>
|
||||
> *
|
||||
>,
|
||||
Translator
|
||||
@@ -152,8 +109,8 @@ inline Box const&
|
||||
element_indexable(std::pair<
|
||||
Box,
|
||||
boost::variant<
|
||||
leaf_variant<Value, Parameters, Box, Allocators, Tag>,
|
||||
internal_node_variant<Value, Parameters, Box, Allocators, Tag>
|
||||
static_leaf<Value, Parameters, Box, Allocators, Tag>,
|
||||
static_internal_node<Value, Parameters, Box, Allocators, Tag>
|
||||
> *
|
||||
> const& el,
|
||||
Translator const&)
|
||||
@@ -239,14 +196,14 @@ struct destroy_node_variant
|
||||
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
|
||||
struct create_node<
|
||||
Allocators,
|
||||
internal_node_variant<Value, Parameters, Box, Allocators, Tag>
|
||||
static_internal_node<Value, Parameters, Box, Allocators, Tag>
|
||||
>
|
||||
{
|
||||
static inline typename node<Value, Parameters, Box, Allocators, Tag>::type *
|
||||
apply(Allocators & allocators)
|
||||
{
|
||||
return create_node_variant<
|
||||
internal_node_variant<Value, Parameters, Box, Allocators, Tag>
|
||||
static_internal_node<Value, Parameters, Box, Allocators, Tag>
|
||||
>::template apply<
|
||||
typename node<Value, Parameters, Box, Allocators, Tag>::type
|
||||
>(allocators.node_allocator, allocators.internal_node_elements_allocator);
|
||||
@@ -256,14 +213,14 @@ struct create_node<
|
||||
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
|
||||
struct create_node<
|
||||
Allocators,
|
||||
leaf_variant<Value, Parameters, Box, Allocators, Tag>
|
||||
static_leaf<Value, Parameters, Box, Allocators, Tag>
|
||||
>
|
||||
{
|
||||
static inline typename node<Value, Parameters, Box, Allocators, Tag>::type *
|
||||
apply(Allocators & allocators)
|
||||
{
|
||||
return create_node_variant<
|
||||
leaf_variant<Value, Parameters, Box, Allocators, Tag>
|
||||
static_leaf<Value, Parameters, Box, Allocators, Tag>
|
||||
>::template apply<
|
||||
typename node<Value, Parameters, Box, Allocators, Tag>::type
|
||||
>(allocators.node_allocator, allocators.leaf_elements_allocator);
|
||||
@@ -275,13 +232,13 @@ struct create_node<
|
||||
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
|
||||
struct destroy_node<
|
||||
Allocators,
|
||||
internal_node_variant<Value, Parameters, Box, Allocators, Tag>
|
||||
static_internal_node<Value, Parameters, Box, Allocators, Tag>
|
||||
>
|
||||
{
|
||||
static inline void apply(Allocators & allocators, typename node<Value, Parameters, Box, Allocators, Tag>::type * n)
|
||||
{
|
||||
destroy_node_variant<
|
||||
internal_node_variant<Value, Parameters, Box, Allocators, Tag>
|
||||
static_internal_node<Value, Parameters, Box, Allocators, Tag>
|
||||
>::apply(allocators.node_allocator, n);
|
||||
}
|
||||
};
|
||||
@@ -289,13 +246,13 @@ struct destroy_node<
|
||||
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
|
||||
struct destroy_node<
|
||||
Allocators,
|
||||
leaf_variant<Value, Parameters, Box, Allocators, Tag>
|
||||
static_leaf<Value, Parameters, Box, Allocators, Tag>
|
||||
>
|
||||
{
|
||||
static inline void apply(Allocators & allocators, typename node<Value, Parameters, Box, Allocators, Tag>::type * n)
|
||||
{
|
||||
destroy_node_variant<
|
||||
leaf_variant<Value, Parameters, Box, Allocators, Tag>
|
||||
static_leaf<Value, Parameters, Box, Allocators, Tag>
|
||||
>::apply(allocators.node_allocator, n);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_NODE_DEFAULT_STATIC_VARIANT_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_NODE_DEFAULT_STATIC_VARIANT_HPP
|
||||
|
||||
#include <vector>
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/geometry/extensions/index/pushable_array.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/rtree/node/static_visitor.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace index {
|
||||
|
||||
@@ -21,7 +22,7 @@ namespace detail { namespace rtree {
|
||||
// nodes default types
|
||||
|
||||
template <typename Value, typename Parameters, typename Box, typename Allocators>
|
||||
struct internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
struct static_internal_node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
{
|
||||
typedef index::pushable_array<
|
||||
std::pair<
|
||||
@@ -32,18 +33,18 @@ struct internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_stat
|
||||
> elements_type;
|
||||
|
||||
template <typename Dummy>
|
||||
inline internal_node_variant(Dummy) {}
|
||||
inline static_internal_node(Dummy) {}
|
||||
|
||||
elements_type elements;
|
||||
};
|
||||
|
||||
template <typename Value, typename Parameters, typename Box, typename Allocators>
|
||||
struct leaf_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
struct static_leaf<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
{
|
||||
typedef index::pushable_array<Value, Parameters::max_elements + 1> elements_type;
|
||||
|
||||
template <typename Dummy>
|
||||
inline leaf_variant(Dummy) {}
|
||||
inline static_leaf(Dummy) {}
|
||||
|
||||
elements_type elements;
|
||||
};
|
||||
@@ -54,21 +55,21 @@ template <typename Value, typename Parameters, typename Box, typename Allocators
|
||||
struct node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
{
|
||||
typedef boost::variant<
|
||||
leaf_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>,
|
||||
internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
static_leaf<Value, Parameters, Box, Allocators, node_s_mem_static_tag>,
|
||||
static_internal_node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
> type;
|
||||
};
|
||||
|
||||
template <typename Value, typename Parameters, typename Box, typename Allocators>
|
||||
struct internal_node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
{
|
||||
typedef internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag> type;
|
||||
typedef static_internal_node<Value, Parameters, Box, Allocators, node_s_mem_static_tag> type;
|
||||
};
|
||||
|
||||
template <typename Value, typename Parameters, typename Box, typename Allocators>
|
||||
struct leaf<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
{
|
||||
typedef leaf_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag> type;
|
||||
typedef static_leaf<Value, Parameters, Box, Allocators, node_s_mem_static_tag> type;
|
||||
};
|
||||
|
||||
// visitor traits
|
||||
@@ -113,14 +114,14 @@ struct allocators<Allocator, Value, Parameters, Box, node_s_mem_static_tag>
|
||||
template <typename Allocators, typename Value, typename Parameters, typename Box>
|
||||
struct create_node<
|
||||
Allocators,
|
||||
internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
static_internal_node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
>
|
||||
{
|
||||
static inline typename node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>::type *
|
||||
apply(Allocators & allocators)
|
||||
{
|
||||
return create_node_variant<
|
||||
internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
static_internal_node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
>::template apply<
|
||||
typename node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>::type
|
||||
>(allocators.node_allocator, allocators.node_allocator);
|
||||
@@ -130,14 +131,14 @@ struct create_node<
|
||||
template <typename Allocators, typename Value, typename Parameters, typename Box>
|
||||
struct create_node<
|
||||
Allocators,
|
||||
leaf_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
static_leaf<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
>
|
||||
{
|
||||
static inline typename node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>::type *
|
||||
apply(Allocators & allocators)
|
||||
{
|
||||
return create_node_variant<
|
||||
leaf_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
static_leaf<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
|
||||
>::template apply<
|
||||
typename node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>::type
|
||||
>(allocators.node_allocator, allocators.node_allocator);
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
// Boost.Geometry Index
|
||||
//
|
||||
// R-tree nodes static visitor related code
|
||||
//
|
||||
// Copyright (c) 2011-2012 Adam Wulkiewicz, Lodz, Poland.
|
||||
//
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_STATIC_VISITOR_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_STATIC_VISITOR_HPP
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace index {
|
||||
|
||||
namespace detail { namespace rtree {
|
||||
|
||||
// nodes variants forward declarations
|
||||
|
||||
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
|
||||
struct static_internal_node;
|
||||
|
||||
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
|
||||
struct static_leaf;
|
||||
|
||||
// nodes conversion
|
||||
|
||||
template <typename V, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
|
||||
inline V & get(
|
||||
boost::variant<
|
||||
static_leaf<Value, Parameters, Box, Allocators, Tag>,
|
||||
static_internal_node<Value, Parameters, Box, Allocators, Tag>
|
||||
> & v)
|
||||
{
|
||||
return boost::get<V>(v);
|
||||
}
|
||||
|
||||
template <typename V, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
|
||||
inline V * get(
|
||||
boost::variant<
|
||||
static_leaf<Value, Parameters, Box, Allocators, Tag>,
|
||||
static_internal_node<Value, Parameters, Box, Allocators, Tag>
|
||||
> *v)
|
||||
{
|
||||
return boost::get<V>(v);
|
||||
}
|
||||
|
||||
// apply visitor
|
||||
|
||||
template <typename Visitor, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
|
||||
inline void apply_visitor(Visitor & v,
|
||||
boost::variant<
|
||||
static_leaf<Value, Parameters, Box, Allocators, Tag>,
|
||||
static_internal_node<Value, Parameters, Box, Allocators, Tag>
|
||||
> & n)
|
||||
{
|
||||
boost::apply_visitor(v, n);
|
||||
}
|
||||
|
||||
template <typename Visitor, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
|
||||
inline void apply_visitor(Visitor & v,
|
||||
boost::variant<
|
||||
static_leaf<Value, Parameters, Box, Allocators, Tag>,
|
||||
static_internal_node<Value, Parameters, Box, Allocators, Tag>
|
||||
> const& n)
|
||||
{
|
||||
boost::apply_visitor(v, n);
|
||||
}
|
||||
|
||||
}} // namespace detail::rtree
|
||||
|
||||
}}} // namespace boost::geometry::index
|
||||
|
||||
#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_STATIC_VISITOR_HPP
|
||||
Reference in New Issue
Block a user