with_pointer.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  5. // Use, modification and distribution is subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef GEOMETRY_TEST_COMMON_WITH_POINTER_HPP
  9. #define GEOMETRY_TEST_COMMON_WITH_POINTER_HPP
  10. #include <boost/geometry/core/access.hpp>
  11. #include <boost/geometry/core/coordinate_type.hpp>
  12. #include <boost/geometry/core/coordinate_system.hpp>
  13. #include <boost/geometry/core/coordinate_dimension.hpp>
  14. #include <boost/geometry/core/cs.hpp>
  15. #include <boost/geometry/core/tag.hpp>
  16. // NOTE: since Boost 1.51 the Point type may always be a pointer.
  17. // Therefore the traits class don't need to add a pointer.
  18. // This obsoletes this whole test-point-type
  19. namespace test
  20. {
  21. // Sample point, having x/y
  22. struct test_point_xy
  23. {
  24. float x,y;
  25. };
  26. }
  27. namespace boost { namespace geometry { namespace traits {
  28. template<> struct tag<test::test_point_xy>
  29. { typedef point_tag type; };
  30. template<> struct coordinate_type<test::test_point_xy>
  31. { typedef double type; };
  32. template<> struct coordinate_system<test::test_point_xy>
  33. { typedef cs::cartesian type; };
  34. template<> struct dimension<test::test_point_xy> : boost::mpl::int_<2> {};
  35. template<>
  36. struct access<test::test_point_xy, 0>
  37. {
  38. static double get(test::test_point_xy const& p)
  39. {
  40. return p.x;
  41. }
  42. static void set(test::test_point_xy& p, double const& value)
  43. {
  44. p.x = value;
  45. }
  46. };
  47. template<>
  48. struct access<test::test_point_xy, 1>
  49. {
  50. static double get(test::test_point_xy const& p)
  51. {
  52. return p.y;
  53. }
  54. static void set(test::test_point_xy& p, double const& value)
  55. {
  56. p.y = value;
  57. }
  58. };
  59. }}} // namespace bg::traits
  60. #endif // #ifndef GEOMETRY_TEST_COMMON_WITH_POINTER_HPP