Chris@16: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@16: Chris@16: // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. Chris@16: // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. Chris@16: // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. Chris@16: Chris@16: // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library Chris@16: // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. Chris@16: Chris@16: // Use, modification and distribution is subject to the Boost Software License, Chris@16: // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: Chris@16: #ifndef BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP Chris@16: #define BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: Chris@16: namespace boost { namespace geometry Chris@16: { Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Traits class binding a comparing strategy to a coordinate system Chris@16: \ingroup util Chris@16: \tparam Tag tag of coordinate system of point-type Chris@16: \tparam Direction direction to compare on: 1 for less (-> ascending order) Chris@16: and -1 for greater (-> descending order) Chris@16: \tparam Point point-type Chris@16: \tparam CoordinateSystem coordinate sytem of point Chris@16: \tparam Dimension: the dimension to compare on Chris@16: */ Chris@16: template Chris@16: < Chris@16: typename Tag, Chris@16: int Direction, Chris@16: typename Point, Chris@16: typename CoordinateSystem, Chris@16: std::size_t Dimension Chris@16: > Chris@16: struct strategy_compare Chris@16: { Chris@16: typedef strategy::not_implemented type; Chris@16: }; Chris@16: Chris@16: Chris@16: #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS Chris@16: Chris@16: // For compare we add defaults specializations, Chris@16: // because they defaultly redirect to std::less / greater / equal_to Chris@16: template Chris@16: < Chris@16: typename Tag, Chris@16: typename Point, Chris@16: typename CoordinateSystem, Chris@16: std::size_t Dimension Chris@16: > Chris@16: struct strategy_compare Chris@16: { Chris@16: typedef std::less::type> type; Chris@16: }; Chris@16: Chris@16: Chris@16: template Chris@16: < Chris@16: typename Tag, Chris@16: typename Point, Chris@16: typename CoordinateSystem, Chris@16: std::size_t Dimension Chris@16: > Chris@16: struct strategy_compare Chris@16: { Chris@16: typedef std::greater::type> type; Chris@16: }; Chris@16: Chris@16: Chris@16: template Chris@16: < Chris@16: typename Tag, Chris@16: typename Point, Chris@16: typename CoordinateSystem, Chris@16: std::size_t Dimension Chris@16: > Chris@16: struct strategy_compare Chris@16: { Chris@16: typedef std::equal_to::type> type; Chris@16: }; Chris@16: Chris@16: Chris@16: #endif Chris@16: Chris@16: Chris@16: namespace strategy { namespace compare Chris@16: { Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Default strategy, indicates the default strategy for comparisons Chris@16: \details The default strategy for comparisons defer in most cases Chris@16: to std::less (for ascending) and std::greater (for descending). Chris@16: However, if a spherical coordinate system is used, and comparison Chris@16: is done on longitude, it will take another strategy handling circular Chris@16: */ Chris@16: struct default_strategy {}; Chris@16: Chris@16: Chris@16: #ifndef DOXYGEN_NO_DETAIL Chris@16: namespace detail Chris@16: { Chris@16: Chris@16: template Chris@16: struct is_default : boost::false_type Chris@16: {}; Chris@16: Chris@16: Chris@16: template <> Chris@16: struct is_default : boost::true_type Chris@16: {}; Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Meta-function to select strategy Chris@16: \details If "default_strategy" is specified, it will take the Chris@16: traits-registered class for the specified coordinate system. Chris@16: If another strategy is explicitly specified, it takes that one. Chris@16: */ Chris@16: template Chris@16: < Chris@16: typename Strategy, Chris@16: int Direction, Chris@16: typename Point, Chris@16: std::size_t Dimension Chris@16: > Chris@16: struct select_strategy Chris@16: { Chris@16: typedef typename Chris@16: boost::mpl::if_ Chris@16: < Chris@16: is_default, Chris@16: typename strategy_compare Chris@16: < Chris@16: typename cs_tag::type, Chris@16: Direction, Chris@16: Point, Chris@16: typename coordinate_system::type, Chris@16: Dimension Chris@16: >::type, Chris@16: Strategy Chris@16: >::type type; Chris@16: }; Chris@16: Chris@16: } // namespace detail Chris@16: #endif // DOXYGEN_NO_DETAIL Chris@16: Chris@16: Chris@16: }} // namespace strategy::compare Chris@16: Chris@16: Chris@16: }} // namespace boost::geometry Chris@16: Chris@16: Chris@16: #endif // BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP