• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry Index
2 //
3 // Query range adaptor
4 //
5 // Copyright (c) 2011-2013 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 
11 #ifndef BOOST_GEOMETRY_INDEX_ADAPTORS_QUERY_HPP
12 #define BOOST_GEOMETRY_INDEX_ADAPTORS_QUERY_HPP
13 
14 /*!
15 \defgroup adaptors Adaptors (boost::geometry::index::adaptors::)
16 */
17 
18 namespace boost { namespace geometry { namespace index {
19 
20 namespace adaptors {
21 
22 namespace detail {
23 
24 template <typename Index>
25 class query_range
26 {
27     BOOST_MPL_ASSERT_MSG(
28         (false),
29         NOT_IMPLEMENTED_FOR_THIS_INDEX,
30         (query_range));
31 
32     typedef int* iterator;
33     typedef const int* const_iterator;
34 
35     template <typename Predicates>
query_range(Index const &,Predicates const &)36     inline query_range(
37         Index const&,
38         Predicates const&)
39     {}
40 
begin()41     inline iterator begin() { return 0; }
end()42     inline iterator end() { return 0; }
begin() const43     inline const_iterator begin() const { return 0; }
end() const44     inline const_iterator end() const { return 0; }
45 };
46 
47 // TODO: awulkiew - consider removing reference from predicates
48 
49 template<typename Predicates>
50 struct query
51 {
queryboost::geometry::index::adaptors::detail::query52     inline explicit query(Predicates const& pred)
53         : predicates(pred)
54     {}
55 
56     Predicates const& predicates;
57 };
58 
59 template<typename Index, typename Predicates>
60 index::adaptors::detail::query_range<Index>
operator |(Index const & si,index::adaptors::detail::query<Predicates> const & f)61 operator|(
62     Index const& si,
63     index::adaptors::detail::query<Predicates> const& f)
64 {
65     return index::adaptors::detail::query_range<Index>(si, f.predicates);
66 }
67 
68 } // namespace detail
69 
70 /*!
71 \brief The query index adaptor generator.
72 
73 \ingroup adaptors
74 
75 \param pred   Predicates.
76 */
77 template <typename Predicates>
78 detail::query<Predicates>
queried(Predicates const & pred)79 queried(Predicates const& pred)
80 {
81     return detail::query<Predicates>(pred);
82 }
83 
84 } // namespace adaptors
85 
86 }}} // namespace boost::geometry::index
87 
88 #endif // BOOST_GEOMETRY_INDEX_ADAPTORS_QUERY_HPP
89