weak_visitor.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Boost.Geometry Index
  2. //
  3. // R-tree nodes weak visitor and nodes base type
  4. //
  5. // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
  6. //
  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)
  10. #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_VISITOR_HPP
  11. #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_VISITOR_HPP
  12. namespace boost { namespace geometry { namespace index {
  13. namespace detail { namespace rtree {
  14. // empty visitor
  15. template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag, bool IsVisitableConst>
  16. struct weak_visitor {};
  17. // node
  18. template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
  19. struct weak_node {};
  20. // nodes variants forward declarations
  21. template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
  22. struct weak_internal_node;
  23. template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
  24. struct weak_leaf;
  25. // nodes conversion
  26. template <typename Derived, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
  27. inline Derived & get(weak_node<Value, Parameters, Box, Allocators, Tag> & n)
  28. {
  29. return static_cast<Derived&>(n);
  30. }
  31. // apply visitor
  32. template <typename Visitor, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
  33. inline void apply_visitor(Visitor & v,
  34. weak_node<Value, Parameters, Box, Allocators, Tag> & n,
  35. bool is_internal_node)
  36. {
  37. BOOST_GEOMETRY_INDEX_ASSERT(&n, "null ptr");
  38. if ( is_internal_node )
  39. {
  40. typedef weak_internal_node<Value, Parameters, Box, Allocators, Tag> internal_node;
  41. v(get<internal_node>(n));
  42. }
  43. else
  44. {
  45. typedef weak_leaf<Value, Parameters, Box, Allocators, Tag> leaf;
  46. v(get<leaf>(n));
  47. }
  48. }
  49. }} // namespace detail::rtree
  50. }}} // namespace boost::geometry::index
  51. #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_DYNAMIC_VISITOR_HPP