query.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Boost.Geometry Index
  2. //
  3. // Query range adaptor
  4. //
  5. // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
  6. //
  7. // This file was modified by Oracle on 2020.
  8. // Modifications copyright (c) 2020 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_ADAPTORS_QUERY_HPP
  15. #define BOOST_GEOMETRY_INDEX_ADAPTORS_QUERY_HPP
  16. #include <boost/geometry/core/static_assert.hpp>
  17. /*!
  18. \defgroup adaptors Adaptors (boost::geometry::index::adaptors::)
  19. */
  20. namespace boost { namespace geometry { namespace index {
  21. namespace adaptors {
  22. namespace detail {
  23. template <typename Index>
  24. class query_range
  25. {
  26. BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
  27. "Not implemented for this Index type.",
  28. Index);
  29. typedef int* iterator;
  30. typedef const int* const_iterator;
  31. template <typename Predicates>
  32. inline query_range(
  33. Index const&,
  34. Predicates const&)
  35. {}
  36. inline iterator begin() { return 0; }
  37. inline iterator end() { return 0; }
  38. inline const_iterator begin() const { return 0; }
  39. inline const_iterator end() const { return 0; }
  40. };
  41. // TODO: awulkiew - consider removing reference from predicates
  42. template<typename Predicates>
  43. struct query
  44. {
  45. inline explicit query(Predicates const& pred)
  46. : predicates(pred)
  47. {}
  48. Predicates const& predicates;
  49. };
  50. template<typename Index, typename Predicates>
  51. index::adaptors::detail::query_range<Index>
  52. operator|(
  53. Index const& si,
  54. index::adaptors::detail::query<Predicates> const& f)
  55. {
  56. return index::adaptors::detail::query_range<Index>(si, f.predicates);
  57. }
  58. } // namespace detail
  59. /*!
  60. \brief The query index adaptor generator.
  61. \ingroup adaptors
  62. \param pred Predicates.
  63. */
  64. template <typename Predicates>
  65. detail::query<Predicates>
  66. queried(Predicates const& pred)
  67. {
  68. return detail::query<Predicates>(pred);
  69. }
  70. } // namespace adaptors
  71. }}} // namespace boost::geometry::index
  72. #endif // BOOST_GEOMETRY_INDEX_ADAPTORS_QUERY_HPP