]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/is_simple/interface.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / is_simple / interface.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2014-2020, Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
10
11 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_INTERFACE_HPP
12 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_INTERFACE_HPP
13
14 #include <boost/variant/apply_visitor.hpp>
15 #include <boost/variant/static_visitor.hpp>
16 #include <boost/variant/variant_fwd.hpp>
17
18 #include <boost/geometry/geometries/concepts/check.hpp>
19
20 #include <boost/geometry/algorithms/dispatch/is_simple.hpp>
21 #include <boost/geometry/core/cs.hpp>
22 #include <boost/geometry/strategies/default_strategy.hpp>
23 #include <boost/geometry/strategies/detail.hpp>
24 #include <boost/geometry/strategies/relate/services.hpp>
25
26
27 namespace boost { namespace geometry
28 {
29
30 namespace resolve_strategy
31 {
32
33 template
34 <
35 typename Strategy,
36 bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
37 >
38 struct is_simple
39 {
40 template <typename Geometry>
41 static inline bool apply(Geometry const& geometry,
42 Strategy const& strategy)
43 {
44 return dispatch::is_simple<Geometry>::apply(geometry, strategy);
45 }
46 };
47
48 template <typename Strategy>
49 struct is_simple<Strategy, false>
50 {
51 template <typename Geometry>
52 static inline bool apply(Geometry const& geometry,
53 Strategy const& strategy)
54 {
55 using strategies::relate::services::strategy_converter;
56 return dispatch::is_simple
57 <
58 Geometry
59 >::apply(geometry, strategy_converter<Strategy>::get(strategy));
60 }
61 };
62
63 template <>
64 struct is_simple<default_strategy, false>
65 {
66 template <typename Geometry>
67 static inline bool apply(Geometry const& geometry,
68 default_strategy)
69 {
70 // NOTE: Currently the strategy is only used for Linear geometries
71 typedef typename strategies::relate::services::default_strategy
72 <
73 Geometry, Geometry
74 >::type strategy_type;
75
76 return dispatch::is_simple<Geometry>::apply(geometry, strategy_type());
77 }
78 };
79
80 } // namespace resolve_strategy
81
82 namespace resolve_variant
83 {
84
85 template <typename Geometry>
86 struct is_simple
87 {
88 template <typename Strategy>
89 static inline bool apply(Geometry const& geometry, Strategy const& strategy)
90 {
91 concepts::check<Geometry const>();
92
93 return resolve_strategy::is_simple<Strategy>::apply(geometry, strategy);
94 }
95 };
96
97 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
98 struct is_simple<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
99 {
100 template <typename Strategy>
101 struct visitor : boost::static_visitor<bool>
102 {
103 Strategy const& m_strategy;
104
105 visitor(Strategy const& strategy)
106 : m_strategy(strategy)
107 {}
108
109 template <typename Geometry>
110 bool operator()(Geometry const& geometry) const
111 {
112 return is_simple<Geometry>::apply(geometry, m_strategy);
113 }
114 };
115
116 template <typename Strategy>
117 static inline bool
118 apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry,
119 Strategy const& strategy)
120 {
121 return boost::apply_visitor(visitor<Strategy>(strategy), geometry);
122 }
123 };
124
125 } // namespace resolve_variant
126
127
128 /*!
129 \brief \brief_check{is simple}
130 \ingroup is_simple
131 \tparam Geometry \tparam_geometry
132 \tparam Strategy \tparam_strategy{Is_simple}
133 \param geometry \param_geometry
134 \param strategy \param_strategy{is_simple}
135 \return \return_check{is simple}
136
137 \qbk{distinguish,with strategy}
138 \qbk{[include reference/algorithms/is_simple.qbk]}
139 */
140 template <typename Geometry, typename Strategy>
141 inline bool is_simple(Geometry const& geometry, Strategy const& strategy)
142 {
143 return resolve_variant::is_simple<Geometry>::apply(geometry, strategy);
144 }
145
146
147 /*!
148 \brief \brief_check{is simple}
149 \ingroup is_simple
150 \tparam Geometry \tparam_geometry
151 \param geometry \param_geometry
152 \return \return_check{is simple}
153
154 \qbk{[include reference/algorithms/is_simple.qbk]}
155 */
156 template <typename Geometry>
157 inline bool is_simple(Geometry const& geometry)
158 {
159 return resolve_variant::is_simple<Geometry>::apply(geometry, default_strategy());
160 }
161
162
163 }} // namespace boost::geometry
164
165
166 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_INTERFACE_HPP