1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | // Unit Test |
3 | |
4 | // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. |
5 | // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. |
6 | |
7 | // This file was modified by Oracle on 2021. |
8 | // Modifications copyright (c) 2021 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 | |
15 | |
16 | #ifndef GEOMETRY_TEST_COMMON_WITH_POINTER_HPP |
17 | #define GEOMETRY_TEST_COMMON_WITH_POINTER_HPP |
18 | |
19 | |
20 | #include <boost/geometry/core/access.hpp> |
21 | #include <boost/geometry/core/coordinate_type.hpp> |
22 | #include <boost/geometry/core/coordinate_system.hpp> |
23 | #include <boost/geometry/core/coordinate_dimension.hpp> |
24 | #include <boost/geometry/core/cs.hpp> |
25 | #include <boost/geometry/core/tag.hpp> |
26 | |
27 | // NOTE: since Boost 1.51 the Point type may always be a pointer. |
28 | // Therefore the traits class don't need to add a pointer. |
29 | // This obsoletes this whole test-point-type |
30 | |
31 | |
32 | |
33 | namespace test |
34 | { |
35 | |
36 | // Sample point, having x/y |
37 | struct test_point_xy |
38 | { |
39 | float x,y; |
40 | }; |
41 | |
42 | } |
43 | |
44 | |
45 | namespace boost { namespace geometry { namespace traits { |
46 | |
47 | template<> struct tag<test::test_point_xy> |
48 | { typedef point_tag type; }; |
49 | |
50 | template<> struct coordinate_type<test::test_point_xy> |
51 | { typedef double type; }; |
52 | |
53 | template<> struct coordinate_system<test::test_point_xy> |
54 | { typedef cs::cartesian type; }; |
55 | |
56 | template<> struct dimension<test::test_point_xy> : std::integral_constant<int, 2> {}; |
57 | |
58 | template<> |
59 | struct access<test::test_point_xy, 0> |
60 | { |
61 | static double get(test::test_point_xy const& p) |
62 | { |
63 | return p.x; |
64 | } |
65 | |
66 | static void set(test::test_point_xy& p, double const& value) |
67 | { |
68 | p.x = value; |
69 | } |
70 | |
71 | }; |
72 | |
73 | |
74 | template<> |
75 | struct access<test::test_point_xy, 1> |
76 | { |
77 | static double get(test::test_point_xy const& p) |
78 | { |
79 | return p.y; |
80 | } |
81 | |
82 | static void set(test::test_point_xy& p, double const& value) |
83 | { |
84 | p.y = value; |
85 | } |
86 | |
87 | }; |
88 | |
89 | }}} // namespace bg::traits |
90 | |
91 | |
92 | #endif // #ifndef GEOMETRY_TEST_COMMON_WITH_POINTER_HPP |
93 | |