weak_visitor.hpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. // This file was modified by Oracle on 2021.
  8. // Modifications copyright (c) 2021 Oracle and/or its affiliates.
  9. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  10. //
  11. // Use, modification and distribution is subject to the Boost Software License,
  12. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_VISITOR_HPP
  15. #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_VISITOR_HPP
  16. #include <boost/geometry/index/detail/assert.hpp>
  17. namespace boost { namespace geometry { namespace index {
  18. namespace detail { namespace rtree {
  19. // empty visitor
  20. template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag, bool IsVisitableConst>
  21. struct weak_visitor {};
  22. // node
  23. template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
  24. struct weak_node {};
  25. // nodes variants forward declarations
  26. template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
  27. struct weak_internal_node;
  28. template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
  29. struct weak_leaf;
  30. // nodes conversion
  31. template <typename Derived, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
  32. inline Derived & get(weak_node<Value, Parameters, Box, Allocators, Tag> & n)
  33. {
  34. return static_cast<Derived&>(n);
  35. }
  36. // apply visitor
  37. template <typename Visitor, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
  38. inline void apply_visitor(Visitor & v,
  39. weak_node<Value, Parameters, Box, Allocators, Tag> & n,
  40. bool is_internal_node)
  41. {
  42. BOOST_GEOMETRY_INDEX_ASSERT(&n, "null ptr");
  43. if ( is_internal_node )
  44. {
  45. typedef weak_internal_node<Value, Parameters, Box, Allocators, Tag> internal_node;
  46. v(get<internal_node>(n));
  47. }
  48. else
  49. {
  50. typedef weak_leaf<Value, Parameters, Box, Allocators, Tag> leaf;
  51. v(get<leaf>(n));
  52. }
  53. }
  54. }} // namespace detail::rtree
  55. }}} // namespace boost::geometry::index
  56. #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_DYNAMIC_VISITOR_HPP